mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	feat: 新增生成代码接口(后端代码)
This commit is contained in:
		| @@ -27,9 +27,12 @@ import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import cn.hutool.extra.spring.SpringUtil; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.model.query.PageQuery; | ||||
| import top.charles7c.cnadmin.common.model.vo.PageDataVO; | ||||
| import top.charles7c.cnadmin.common.model.vo.R; | ||||
| import top.charles7c.cnadmin.common.util.validate.ValidationUtils; | ||||
| import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO; | ||||
| import top.charles7c.cnadmin.tool.model.entity.GenConfigDO; | ||||
| import top.charles7c.cnadmin.tool.model.query.TableQuery; | ||||
| @@ -77,4 +80,12 @@ public class GeneratorController { | ||||
|         generatorService.saveConfig(request, tableName); | ||||
|         return R.ok("保存成功"); | ||||
|     } | ||||
|  | ||||
|     @Operation(summary = "生成代码", description = "生成代码") | ||||
|     @PostMapping("/{tableName}") | ||||
|     public R generate(@PathVariable String tableName) { | ||||
|         ValidationUtils.throwIf("prod".equals(SpringUtil.getActiveProfile()), "仅支持在开发环境生成代码"); | ||||
|         generatorService.generate(tableName); | ||||
|         return R.ok("生成成功,请查看生成代码是否正确"); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -45,15 +45,6 @@ logging: | ||||
|       - password | ||||
|       - Authorization | ||||
|  | ||||
| --- ### 代码生成器配置 | ||||
| generator: | ||||
|   # 排除数据表 | ||||
|   excludeTables: | ||||
|     - DATABASECHANGELOG | ||||
|     - DATABASECHANGELOGLOCK | ||||
|     - gen_config | ||||
|     - gen_field_config | ||||
|  | ||||
| --- ### 接口文档配置 | ||||
| springdoc: | ||||
|   # 设置对象型参数的展示形式(设为 true 表示将对象型参数平展开,即对象内的属性直接作为参数展示而不是嵌套在对象内,默认为 false) | ||||
| @@ -214,3 +205,41 @@ thread-pool: | ||||
|   queueCapacity: 128 | ||||
|   # 活跃时间 | ||||
|   keepAliveSeconds: 300 | ||||
|  | ||||
| --- ### 代码生成器配置 | ||||
| generator: | ||||
|   # 排除数据表 | ||||
|   excludeTables: | ||||
|     - DATABASECHANGELOG | ||||
|     - DATABASECHANGELOGLOCK | ||||
|     - gen_config | ||||
|     - gen_field_config | ||||
|   # 模板配置 | ||||
|   templateConfigs: | ||||
|     DO: | ||||
|       templatePath: generator/Entity.ftl | ||||
|       packageName: model.entity | ||||
|     Query: | ||||
|       templatePath: generator/Query.ftl | ||||
|       packageName: model.query | ||||
|     Request: | ||||
|       templatePath: generator/Request.ftl | ||||
|       packageName: model.request | ||||
|     VO: | ||||
|       templatePath: generator/VO.ftl | ||||
|       packageName: model.vo | ||||
|     DetailVO: | ||||
|       templatePath: generator/DetailVO.ftl | ||||
|       packageName: model.vo | ||||
|     Mapper: | ||||
|       templatePath: generator/Mapper.ftl | ||||
|       packageName: mapper | ||||
|     Service: | ||||
|       templatePath: generator/Service.ftl | ||||
|       packageName: service | ||||
|     ServiceImpl: | ||||
|       templatePath: generator/ServiceImpl.ftl | ||||
|       packageName: service.impl | ||||
|     Controller: | ||||
|       templatePath: generator/Controller.ftl | ||||
|       packageName: controller | ||||
		Reference in New Issue
	
	Block a user