From 505f4af206017f925ee115311a642876dc039443 Mon Sep 17 00:00:00 2001 From: makejava <1353036300@qq.com> Date: Tue, 17 Aug 2021 14:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=85=BC=E5=AE=B9=E6=97=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E3=80=82=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sjhy/plugin/dto/SettingsStorageDTO.java | 5 ++ .../plugin/ui/GlobalConfigSettingForm.java | 2 +- .../com/sjhy/plugin/ui/SelectSavePath.form | 8 +-- .../sjhy/plugin/ui/TemplateSettingForm.java | 2 +- .../sjhy/plugin/ui/base/ConfigTableModel.java | 7 ++- .../ui/component/ExportImportComponent.java | 18 +++++++ src/main/resources/defaultConfig.json | 2 +- .../template/Default/controller.java.vm | 54 +++++++++++++++++-- .../resources/template/Default/dao.java.vm | 16 +++--- .../resources/template/Default/debug.json.vm | 3 ++ .../resources/template/Default/entity.java.vm | 10 ++-- .../resources/template/Default/mapper.xml.vm | 37 ++++++------- .../template/Default/service.java.vm | 13 ++--- .../template/Default/serviceImpl.java.vm | 17 +++--- .../MybatisPlus-Mixed/controller.java.vm | 4 +- .../template/MybatisPlus-Mixed/dao.java.vm | 2 +- .../template/MybatisPlus-Mixed/entity.java.vm | 4 +- .../template/MybatisPlus-Mixed/mapper.xml.vm | 2 +- .../MybatisPlus-Mixed/service.java.vm | 4 +- .../MybatisPlus-Mixed/serviceImpl.java.vm | 4 +- .../template/MybatisPlus/controller.java.vm | 4 +- .../template/MybatisPlus/dao.java.vm | 4 +- .../template/MybatisPlus/entity.java.vm | 6 +-- .../template/MybatisPlus/service.java.vm | 4 +- .../template/MybatisPlus/serviceImpl.java.vm | 4 +- .../spring-data-mongodb/controller.java.vm | 2 +- .../spring-data-mongodb/entity.java.vm | 31 +++++++++++ .../spring-data-mongodb/repository.java.vm | 4 +- .../spring-data-mongodb/service.java.vm | 6 +-- .../spring-data-mongodb/serviceImpl.java.vm | 4 +- src/main/resources/typeMapper/Default.json | 10 ++++ 31 files changed, 208 insertions(+), 85 deletions(-) create mode 100644 src/main/resources/template/spring-data-mongodb/entity.java.vm diff --git a/src/main/java/com/sjhy/plugin/dto/SettingsStorageDTO.java b/src/main/java/com/sjhy/plugin/dto/SettingsStorageDTO.java index ea255b5..a786e1b 100644 --- a/src/main/java/com/sjhy/plugin/dto/SettingsStorageDTO.java +++ b/src/main/java/com/sjhy/plugin/dto/SettingsStorageDTO.java @@ -1,5 +1,6 @@ package com.sjhy.plugin.dto; +import com.fasterxml.jackson.annotation.JsonProperty; import com.intellij.ide.fileTemplates.impl.UrlUtil; import com.intellij.util.ExceptionUtil; import com.sjhy.plugin.dict.GlobalDict; @@ -130,6 +131,7 @@ public class SettingsStorageDTO { /** * 类型映射组 */ + @JsonProperty("typeMapper") private Map typeMapperGroupMap; /** * 当前模板组名 @@ -138,6 +140,7 @@ public class SettingsStorageDTO { /** * 模板组 */ + @JsonProperty("template") private Map templateGroupMap; /** * 当前配置表组名 @@ -146,6 +149,7 @@ public class SettingsStorageDTO { /** * 配置表组 */ + @JsonProperty("columnConfig") private Map columnConfigGroupMap; /** * 当前全局配置组名 @@ -154,6 +158,7 @@ public class SettingsStorageDTO { /** * 全局配置组 */ + @JsonProperty("globalConfig") private Map globalConfigGroupMap; public void fillDefaultVal() { diff --git a/src/main/java/com/sjhy/plugin/ui/GlobalConfigSettingForm.java b/src/main/java/com/sjhy/plugin/ui/GlobalConfigSettingForm.java index f06343d..ce9dc84 100644 --- a/src/main/java/com/sjhy/plugin/ui/GlobalConfigSettingForm.java +++ b/src/main/java/com/sjhy/plugin/ui/GlobalConfigSettingForm.java @@ -153,7 +153,7 @@ public class GlobalConfigSettingForm implements Configurable, BaseSettings { @Override public void apply() { getSettingsStorage().setGlobalConfigGroupMap(this.globalConfigGroupMap); - getSettingsStorage().setCurrTypeMapperGroupName(this.currGlobalConfigGroup.getName()); + getSettingsStorage().setCurrGlobalConfigGroupName(this.currGlobalConfigGroup.getName()); // 保存包后重新加载配置 this.loadSettingsStore(getSettingsStorage()); } diff --git a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form index 37762c4..da41a41 100644 --- a/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form +++ b/src/main/java/com/sjhy/plugin/ui/SelectSavePath.form @@ -8,7 +8,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -90,7 +90,7 @@ - + diff --git a/src/main/java/com/sjhy/plugin/ui/TemplateSettingForm.java b/src/main/java/com/sjhy/plugin/ui/TemplateSettingForm.java index ce64aff..aec358b 100644 --- a/src/main/java/com/sjhy/plugin/ui/TemplateSettingForm.java +++ b/src/main/java/com/sjhy/plugin/ui/TemplateSettingForm.java @@ -157,7 +157,7 @@ public class TemplateSettingForm implements Configurable, BaseSettings { @Override public void apply() { getSettingsStorage().setTemplateGroupMap(this.templateGroupMap); - getSettingsStorage().setCurrTypeMapperGroupName(this.currTemplateGroup.getName()); + getSettingsStorage().setCurrTemplateGroupName(this.currTemplateGroup.getName()); // 保存包后重新加载配置 this.loadSettingsStore(getSettingsStorage()); } diff --git a/src/main/java/com/sjhy/plugin/ui/base/ConfigTableModel.java b/src/main/java/com/sjhy/plugin/ui/base/ConfigTableModel.java index ba0cb9f..9e3c92b 100644 --- a/src/main/java/com/sjhy/plugin/ui/base/ConfigTableModel.java +++ b/src/main/java/com/sjhy/plugin/ui/base/ConfigTableModel.java @@ -93,8 +93,8 @@ public class ConfigTableModel extends DefaultTableModel implements EditableModel if (columnInfo == null) { return; } - // 非自定义数据不允许修改列名 - if (!columnInfo.getCustom() && column == 0) { + // 非自定义数据不允许修改 + if (!columnInfo.getCustom() && column <= 2) { return; } switch (column) { @@ -125,6 +125,9 @@ public class ConfigTableModel extends DefaultTableModel implements EditableModel break; default: ColumnConfig columnConfig = CurrGroupUtils.getCurrColumnConfigGroup().getElementList().get(column - 3); + if (columnInfo.getExt() == null) { + columnInfo.setExt(new HashMap<>(16)); + } columnInfo.getExt().put(columnConfig.getTitle(), value); break; } diff --git a/src/main/java/com/sjhy/plugin/ui/component/ExportImportComponent.java b/src/main/java/com/sjhy/plugin/ui/component/ExportImportComponent.java index a9c70ef..05c78fa 100644 --- a/src/main/java/com/sjhy/plugin/ui/component/ExportImportComponent.java +++ b/src/main/java/com/sjhy/plugin/ui/component/ExportImportComponent.java @@ -5,6 +5,7 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.ui.ex.MultiLineLabel; +import com.intellij.openapi.ui.popup.JBPopupFactory; import com.sjhy.plugin.dict.GlobalDict; import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.entity.AbstractGroup; @@ -166,6 +167,19 @@ public class ExportImportComponent { mainPanel.add(handler.getRadioComponent()); } } + // 没有需要选择处理的分组则不构建Dialog + boolean anyMatch = allHandlerList.stream().anyMatch(item -> item.getRadioComponent() != null); + if (!anyMatch) { + // 执行每个处理器 + for (Handler handler : allHandlerList) { + handler.execute(); + } + // 执行回调 + if (callback != null) { + callback.run(); + } + return; + } // 构建dialog DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject()); dialogBuilder.setTitle(GlobalDict.TITLE_INFO); @@ -184,6 +198,7 @@ public class ExportImportComponent { } // 关闭并退出 dialogWrapper.close(DialogWrapper.OK_EXIT_CODE); + Messages.showInfoMessage("导入完成", GlobalDict.TITLE_INFO); } }); // 显示窗口 @@ -191,6 +206,9 @@ public class ExportImportComponent { } private void addRadioComponent(List allHandlerList, String groupName, Map localMap, Map remoteMap) { + if (CollectionUtil.isEmpty(remoteMap)) { + return; + } for (String key : remoteMap.keySet()) { if (localMap.containsKey(key)) { ListRadioComponent listRadioComponent = new ListRadioComponent(groupName + "->" + key, Stream.of(Operator.values()).map(item -> StringUtils.capitalize(item.name())).collect(Collectors.toList())); diff --git a/src/main/resources/defaultConfig.json b/src/main/resources/defaultConfig.json index 034e6dd..fb7735c 100644 --- a/src/main/resources/defaultConfig.json +++ b/src/main/resources/defaultConfig.json @@ -1 +1 @@ -{"author":"makejava","version":"1.2.4","userSecure":"","currTypeMapperGroupName":"Default","typeMapperGroupMap":{"Default":{"name":"Default","elementList":[{"matchType":"REGEX","columnType":"varchar(\\(\\d+\\))?","javaType":"java.lang.String"},{"matchType":"REGEX","columnType":"char(\\(\\d+\\))?","javaType":"java.lang.String"},{"matchType":"REGEX","columnType":"(tiny|medium|long)*text","javaType":"java.lang.String"},{"matchType":"REGEX","columnType":"decimal(\\(\\d+,\\d+\\))?","javaType":"java.lang.Double"},{"matchType":"ORDINARY","columnType":"integer","javaType":"java.lang.Integer"},{"matchType":"REGEX","columnType":"(tiny|small|medium)*int(\\(\\d+\\))?","javaType":"java.lang.Integer"},{"matchType":"ORDINARY","columnType":"int4","javaType":"java.lang.Integer"},{"matchType":"ORDINARY","columnType":"int8","javaType":"java.lang.Long"},{"matchType":"REGEX","columnType":"bigint(\\(\\d+\\))?","javaType":"java.lang.Long"},{"matchType":"ORDINARY","columnType":"datetime","javaType":"java.util.Date"},{"matchType":"ORDINARY","columnType":"timestamp","javaType":"java.util.Date"},{"matchType":"ORDINARY","columnType":"boolean","javaType":"java.lang.Boolean"}]}},"currTemplateGroupName":"Default","templateGroupMap":{"spring-data-mongodb":{"name":"spring-data-mongodb","elementList":[{"name":"controller.java.vm","code":"##导入宏定义、设置包名、类名、文件名##导入宏定义\n$!define\n#setPackageSuffix(\"controller\")\n#setTableSuffix(\"Controller\")\n#save(\"/controller\", \"Controller.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##定义服务名\n#set($serviceSortType = $!tool.append($!tableInfo.name, \"Service\"))\n#set($serviceType = $!tool.append($!tableInfo.savePackageName, \".service.\", $serviceSortType))\n#set($serviceVarName = $!tool.firstLowerCase($serviceSortType))\n\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($entityVarName = $!tool.firstLowerCase($!tableInfo.name))\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport $serviceType;\nimport lombok.AllArgsConstructor;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.Pageable;\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.PostMapping;\nimport org.springframework.web.bind.annotation.RequestBody;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\n\n/**\n * $!{tableInfo.comment}控制层\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@RestController\n@RequestMapping(\"/$!tool.firstLowerCase($!tableInfo.name)\")\n@AllArgsConstructor\npublic class $!{tableName} {\n\n\tprivate $serviceSortType $serviceVarName;\n\n\t/**\n\t * 获取$!{tableInfo.comment}列表(分页)\n\t */\n\t@GetMapping(\"/list\")\n\tpublic Page<$entityShortType> list(Pageable page) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * 获取$!{tableInfo.comment}\n\t */\n\t@GetMapping(\"/get\")\n\tpublic $entityShortType get($!pk.shortType id) {\n\t\treturn ${serviceVarName}.findById(id);\n\t}\n\n\t/**\n\t * 添加$!{tableInfo.comment}\n\t */\n\t@PostMapping(\"/add\")\n\tpublic void add(@RequestBody $entityShortType $entityVarName) {\n\t\t${serviceVarName}.save($entityVarName);\n\t}\n\n\n\t/**\n\t * 修改$!{tableInfo.comment}\n\t */\n\t@PostMapping(\"/update\")\n\tpublic void update(@RequestBody $entityShortType $entityVarName) {\n\t\t${serviceVarName}.save($entityVarName);\n\t}\n\n\t/**\n\t * 删除$!{tableInfo.comment}\n\t */\n\t@PostMapping(\"/delete\")\n\tpublic void delete($!pk.shortType id) {\n\t\t${serviceVarName}.deleteById(id);\n\t}\n\n}\n"},{"name":"repository.java.vm","code":"##导入宏定义、设置包名、类名、文件名##导入宏定义\n$!define\n#setPackageSuffix(\"repository\")\n#setTableSuffix(\"Repository\")\n#save(\"/repository\", \"Repository.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##实体类名、主键类名\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($pkShortType = $!pk.shortType)\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport org.springframework.data.mongodb.repository.MongoRepository;\n\n\n/**\n * $!{tableInfo.comment}持久层\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} extends MongoRepository<$entityShortType, $pkShortType> {\n\n}"},{"name":"service.java.vm","code":"##导入宏定义、设置包名、类名、文件名##导入宏定义\n$!define\n#setPackageSuffix(\"service\")\n#setTableSuffix(\"Service\")\n#save(\"/service\", \"Service.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##实体类名、主键类名\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($entityVarName = $!tool.firstLowerCase($!tableInfo.name))\n#set($pkShortType = $!pk.shortType)\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.Pageable;\nimport java.util.Collection;\nimport java.util.List;\n\n\n/**\n * $!{tableInfo.comment}业务层\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} {\n\t\n void save($entityShortType $entityVarName);\n\n void deleteById($pkShortType id);\n\n $entityShortType findById($pkShortType id);\n\n List<$entityShortType> findById(Collection<$pkShortType> ids);\n\n Page<$entityShortType> list(Pageable page);\n\n}"},{"name":"serviceImpl.java.vm","code":"##导入宏定义、设置包名、类名、文件名\n$!define\n#setPackageSuffix(\"service.impl\")\n#setTableSuffix(\"ServiceImpl\")\n#save(\"/service/impl\", \"ServiceImpl.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##业务层类名、持久层类名、实体名\n#set($serviceSortType = $!tool.append($!tableInfo.name, \"Service\"))\n#set($serviceType = $!tool.append($!tableInfo.savePackageName, \".service.\", $serviceSortType))\n#set($repositorySortType = $!tool.append($!tableInfo.name, \"Repository\"))\n#set($repositoryType = $!tool.append($!tableInfo.savePackageName, \".repository.\", $repositorySortType))\n#set($repositoryVarName = $!tool.firstLowerCase($!repositorySortType))\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($entityVarName = $!tool.firstLowerCase($!tableInfo.name))\n#set($pkShortType = $!pk.shortType)\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport $serviceType;\nimport $repositoryType;\nimport org.springframework.stereotype.Service;\nimport javax.annotation.Resource;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.Pageable;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.stream.Collectors;\nimport java.util.stream.StreamSupport;\n\n\n/**\n * $!{tableInfo.comment}业务层\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@Service\npublic class $!{tableName} implements $!serviceSortType {\n\n\t@Resource\n private $repositorySortType $repositoryVarName;\n\n @Override\n public void save($entityShortType $entityVarName) {\n $!{repositoryVarName}.save($entityVarName);\n }\n\n @Override\n public void deleteById($pkShortType id) {\n $!{repositoryVarName}.delete(id);\n }\n\n @Override\n public $entityShortType findById($pkShortType id) {\n return $!{repositoryVarName}.findOne(id);\n }\n\n @Override\n public List<$entityShortType> findById(Collection<$pkShortType> ids) {\n Iterable<$entityShortType> iterable = $!{repositoryVarName}.findAll(ids);\n return StreamSupport.stream(iterable.spliterator(), false)\n .collect(Collectors.toList());\n }\n\n @Override\n public Page<$entityShortType> list(Pageable page) {\n return $!{repositoryVarName}.findAll(page);\n }\n\n}"}]},"MybatisPlus-Mixed":{"name":"MybatisPlus-Mixed","elementList":[{"name":"controller.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Controller\")\n\n##保存文件(宏定义)\n#save(\"/controller\", \"Controller.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"controller\")\n\n##定义服务名\n#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \"Service\"))\n\n##定义实体对象名\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n\nimport com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\nimport com.baomidou.mybatisplus.extension.api.ApiController;\nimport com.baomidou.mybatisplus.extension.api.R;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport java.io.Serializable;\nimport java.util.List;\n\n##表注释(宏定义)\n#tableComment(\"表控制层\")\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($!tableInfo.name)\")\npublic class $!{tableName} extends ApiController {\n /**\n * 服务对象\n */\n @Resource\n private $!{tableInfo.name}Service $!{serviceName};\n\n /**\n * 分页查询所有数据\n *\n * @param page 分页对象\n * @param $!entityName 查询实体\n * @return 所有数据\n */\n @GetMapping\n public R selectAll(Page<$!tableInfo.name> page, $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.page(page, new QueryWrapper<>($!entityName)));\n }\n\n /**\n * 通过主键查询单条数据\n *\n * @param id 主键\n * @return 单条数据\n */\n @GetMapping(\"{id}\")\n public R selectOne(@PathVariable Serializable id) {\n return success(this.$!{serviceName}.getById(id));\n }\n\n /**\n * 新增数据\n *\n * @param $!entityName 实体对象\n * @return 新增结果\n */\n @PostMapping\n public R insert(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.save($!entityName));\n }\n\n /**\n * 修改数据\n *\n * @param $!entityName 实体对象\n * @return 修改结果\n */\n @PutMapping\n public R update(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.updateById($!entityName));\n }\n\n /**\n * 删除数据\n *\n * @param idList 主键结合\n * @return 删除结果\n */\n @DeleteMapping\n public R delete(@RequestParam(\"idList\") List idList) {\n return success(this.$!{serviceName}.removeByIds(idList));\n }\n}"},{"name":"dao.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Dao\")\n\n##保存文件(宏定义)\n#save(\"/dao\", \"Dao.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"dao\")\n\nimport java.util.List;\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport org.apache.ibatis.annotations.Param;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表数据库访问层\")\npublic interface $!{tableName} extends BaseMapper<$!tableInfo.name> {\n\n/**\n* 批量新增数据(MyBatis原生foreach方法)\n*\n* @param entities List<$!{tableInfo.name}> 实例对象列表\n* @return 影响行数\n*/\nint insertBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n/**\n* 批量新增或按主键更新数据(MyBatis原生foreach方法)\n*\n* @param entities List<$!{tableInfo.name}> 实例对象列表\n* @return 影响行数\n* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参\n*/\nint insertOrUpdateBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n}\n"},{"name":"entity.java.vm","code":"##导入宏定义\n$!define\n\n##保存文件(宏定义)\n#save(\"/entity\", \".java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"entity\")\n\n##自动导入包(全局变量)\n$!autoImport\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport java.io.Serializable;\n\n##表注释(宏定义)\n#tableComment(\"表实体类\")\n@SuppressWarnings(\"serial\")\npublic class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})//${column.comment}#end\n\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n#foreach($column in $tableInfo.fullColumn)\n#getSetMethod($column)\n#end\n\n#foreach($column in $tableInfo.pkColumn)\n /**\n * 获取主键值\n *\n * @return 主键值\n */\n @Override\n protected Serializable pkVal() {\n return this.$!column.name;\n }\n #break\n#end\n}"},{"name":"mapper.xml.vm","code":"##引入mybatis支持\n$!mybatisSupport\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \"Dao.xml\"))\n$!callback.setSavePath($tool.append($modulePath, \"/src/main/resources/mapper\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n\n\n\n\n \n#foreach($column in $tableInfo.fullColumn)\n \n#end\n \n\n \n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n \n \n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n on duplicate key update\n #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($velocityHasNext), #end#end\n \n\n\n"},{"name":"service.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Service\")\n\n##保存文件(宏定义)\n#save(\"/service\", \"Service.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service\")\n\nimport com.baomidou.mybatisplus.extension.service.IService;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表服务接口\")\npublic interface $!{tableName} extends IService<$!tableInfo.name> {\n\n}"},{"name":"serviceImpl.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"ServiceImpl\")\n\n##保存文件(宏定义)\n#save(\"/service/impl\", \"ServiceImpl.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service.impl\")\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\n\n##表注释(宏定义)\n#tableComment(\"表服务实现类\")\n@Service(\"$!tool.firstLowerCase($tableInfo.name)Service\")\npublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {\n\n}"}]},"MybatisPlus":{"name":"MybatisPlus","elementList":[{"name":"controller.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Controller\")\n\n##保存文件(宏定义)\n#save(\"/controller\", \"Controller.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"controller\")\n\n##定义服务名\n#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \"Service\"))\n\n##定义实体对象名\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n\nimport com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\nimport com.baomidou.mybatisplus.extension.api.ApiController;\nimport com.baomidou.mybatisplus.extension.api.R;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport java.io.Serializable;\nimport java.util.List;\n\n##表注释(宏定义)\n#tableComment(\"表控制层\")\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($!tableInfo.name)\")\npublic class $!{tableName} extends ApiController {\n /**\n * 服务对象\n */\n @Resource\n private $!{tableInfo.name}Service $!{serviceName};\n\n /**\n * 分页查询所有数据\n *\n * @param page 分页对象\n * @param $!entityName 查询实体\n * @return 所有数据\n */\n @GetMapping\n public R selectAll(Page<$!tableInfo.name> page, $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.page(page, new QueryWrapper<>($!entityName)));\n }\n\n /**\n * 通过主键查询单条数据\n *\n * @param id 主键\n * @return 单条数据\n */\n @GetMapping(\"{id}\")\n public R selectOne(@PathVariable Serializable id) {\n return success(this.$!{serviceName}.getById(id));\n }\n\n /**\n * 新增数据\n *\n * @param $!entityName 实体对象\n * @return 新增结果\n */\n @PostMapping\n public R insert(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.save($!entityName));\n }\n\n /**\n * 修改数据\n *\n * @param $!entityName 实体对象\n * @return 修改结果\n */\n @PutMapping\n public R update(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.updateById($!entityName));\n }\n\n /**\n * 删除数据\n *\n * @param idList 主键结合\n * @return 删除结果\n */\n @DeleteMapping\n public R delete(@RequestParam(\"idList\") List idList) {\n return success(this.$!{serviceName}.removeByIds(idList));\n }\n}"},{"name":"dao.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Dao\")\n\n##保存文件(宏定义)\n#save(\"/dao\", \"Dao.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"dao\")\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表数据库访问层\")\npublic interface $!{tableName} extends BaseMapper<$!tableInfo.name> {\n\n}"},{"name":"entity.java.vm","code":"##导入宏定义\n$!define\n\n##保存文件(宏定义)\n#save(\"/entity\", \".java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"entity\")\n\n##自动导入包(全局变量)\n$!autoImport\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport java.io.Serializable;\n\n##表注释(宏定义)\n#tableComment(\"表实体类\")\n@SuppressWarnings(\"serial\")\npublic class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})//${column.comment}#end\n\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n#foreach($column in $tableInfo.fullColumn)\n#getSetMethod($column)\n#end\n\n#foreach($column in $tableInfo.pkColumn)\n /**\n * 获取主键值\n *\n * @return 主键值\n */\n @Override\n protected Serializable pkVal() {\n return this.$!column.name;\n }\n #break\n#end\n}"},{"name":"service.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Service\")\n\n##保存文件(宏定义)\n#save(\"/service\", \"Service.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service\")\n\nimport com.baomidou.mybatisplus.extension.service.IService;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表服务接口\")\npublic interface $!{tableName} extends IService<$!tableInfo.name> {\n\n}"},{"name":"serviceImpl.java.vm","code":"##导入宏定义\n$!define\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"ServiceImpl\")\n\n##保存文件(宏定义)\n#save(\"/service/impl\", \"ServiceImpl.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service.impl\")\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\n\n##表注释(宏定义)\n#tableComment(\"表服务实现类\")\n@Service(\"$!tool.firstLowerCase($tableInfo.name)Service\")\npublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {\n\n}"}]},"Default":{"name":"Default","elementList":[{"name":"controller.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Controller\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/controller\"))\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表控制层\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($tableInfo.name)\")\npublic class $!{tableName} {\n /**\n * 服务对象\n */\n @Resource\n private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;\n\n /**\n * 通过主键查询单条数据\n *\n * @param id 主键\n * @return 单条数据\n */\n @GetMapping(\"selectOne\")\n public $!{tableInfo.name} selectOne($!pk.shortType id) {\n return this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id);\n }\n\n}"},{"name":"dao.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Dao\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/dao\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport org.apache.ibatis.annotations.Param;\nimport java.util.List;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name} queryById($!pk.shortType $!pk.name);\n\n /**\n * 查询指定行数据\n *\n * @param offset 查询起始位置\n * @param limit 查询条数\n * @return 对象列表\n */\n List<$!{tableInfo.name}> queryAllByLimit(@Param(\"offset\") int offset, @Param(\"limit\") int limit);\n\n\n /**\n * 通过实体作为筛选条件查询\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 对象列表\n */\n List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 批量新增数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n */\n int insertBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 批量新增或按主键更新数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参\n */\n int insertOrUpdateBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 影响行数\n */\n int deleteById($!pk.shortType $!pk.name);\n\n}\n"},{"name":"debug.json.vm","code":"//调试表原始对象\n$!tool.debug($tableInfo.obj)\n\n//调试列原始对象\n$!tool.debug($tableInfo.fullColumn.get(0).obj)\n\n//调试列原始列类型\n$!tool.debug($tableInfo.fullColumn.get(0).obj.dataType)\n\n//获取原始列类型中的字段\nsqlType = $!tool.getField($tableInfo.fullColumn.get(0).obj.dataType, \"typeName\")\n\n//执行原始列类型中的方法\nsqlTypeLen = $!tableInfo.fullColumn.get(0).obj.dataType.getLength()\n"},{"name":"entity.java.vm","code":"##引入宏定义\n$!define\n\n##使用宏定义设置回调(保存位置与文件后缀)\n#save(\"/entity\", \".java\")\n\n##使用宏定义设置包后缀\n#setPackageSuffix(\"entity\")\n\n##使用全局变量实现默认包导入\n$!autoImport\nimport java.io.Serializable;\n\n##使用宏定义实现类注释信息\n#tableComment(\"实体类\")\npublic class $!{tableInfo.name} implements Serializable {\n private static final long serialVersionUID = $!tool.serial();\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})/**\n * ${column.comment}\n */#end\n\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n#foreach($column in $tableInfo.fullColumn)\n##使用宏定义实现get,set方法\n#getSetMethod($column)\n#end\n\n}"},{"name":"mapper.xml.vm","code":"##引入mybatis支持\n$!mybatisSupport\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \"Dao.xml\"))\n$!callback.setSavePath($tool.append($modulePath, \"/src/main/resources/mapper\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n\n\n\n\n \n#foreach($column in $tableInfo.fullColumn)\n \n#end\n \n\n \n \n\n \n \n\n \n \n\n \n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($velocityHasNext), #end#end)\n \n\n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n \n\n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n on duplicate key update\n #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($velocityHasNext), #end#end\n \n\n \n \n update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}\n \n#foreach($column in $tableInfo.otherColumn)\n \n $!column.obj.name = #{$!column.name},\n \n#end\n \n where $!pk.obj.name = #{$!pk.name}\n \n\n \n \n delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}\n \n\n\n"},{"name":"service.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Service\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport java.util.List;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表服务接口\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name} queryById($!pk.shortType $!pk.name);\n\n /**\n * 查询多条数据\n *\n * @param offset 查询起始位置\n * @param limit 查询条数\n * @return 对象列表\n */\n List<$!{tableInfo.name}> queryAllByLimit(int offset, int limit);\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n boolean deleteById($!pk.shortType $!pk.name);\n\n}"},{"name":"serviceImpl.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"ServiceImpl\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service/impl\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\n\nimport javax.annotation.Resource;\nimport java.util.List;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表服务实现类\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@Service(\"$!tool.firstLowerCase($!{tableInfo.name})Service\")\npublic class $!{tableName} implements $!{tableInfo.name}Service {\n @Resource\n private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name} queryById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);\n }\n\n /**\n * 查询多条数据\n *\n * @param offset 查询起始位置\n * @param limit 查询条数\n * @return 对象列表\n */\n @Override\n public List<$!{tableInfo.name}> queryAllByLimit(int offset, int limit) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAllByLimit(offset, limit);\n }\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {\n this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name}));\n return $!tool.firstLowerCase($!{tableInfo.name});\n }\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {\n this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.update($!tool.firstLowerCase($!{tableInfo.name}));\n return this.queryById($!{tool.firstLowerCase($!{tableInfo.name})}.get$!tool.firstUpperCase($pk.name)());\n }\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n @Override\n public boolean deleteById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name) > 0;\n }\n}"}]}},"currColumnConfigGroupName":"Default","columnConfigGroupMap":{"Default":{"name":"Default","elementList":[{"title":"disable","type":"BOOLEAN","selectValue":""},{"title":"support","type":"SELECT","selectValue":"add,edit,query,del,ui"}]}},"currGlobalConfigGroupName":"Default","globalConfigGroupMap":{"Default":{"name":"Default","elementList":[{"name":"autoImport.vm","value":"##自动导入包(仅导入实体属性需要的包,通常用于实体类)\n#foreach($import in $importList)\nimport $!import;\n#end"},{"name":"define.vm","value":"##(Velocity宏定义)\n\n##定义设置表名后缀的宏定义,调用方式:#setTableSuffix(\"Test\")\n#macro(setTableSuffix $suffix)\n #set($tableName = $!tool.append($tableInfo.name, $suffix))\n#end\n\n##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix(\"Test\")\n#macro(setPackageSuffix $suffix)\n#if($suffix!=\"\")package #end#if($tableInfo.savePackageName!=\"\")$!{tableInfo.savePackageName}.#{end}$!suffix;\n#end\n\n##定义直接保存路径与文件名简化的宏定义,调用方式:#save(\"/entity\", \".java\")\n#macro(save $path $fileName)\n $!callback.setSavePath($tool.append($tableInfo.savePath, $path))\n $!callback.setFileName($tool.append($tableInfo.name, $fileName))\n#end\n\n##定义表注释的宏定义,调用方式:#tableComment(\"注释信息\")\n#macro(tableComment $desc)\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})$desc\n *\n * @author $!author\n * @since $!time.currTime()\n */\n#end\n\n##定义GET,SET方法的宏定义,调用方式:#getSetMethod($column)\n#macro(getSetMethod $column)\n\n public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.name)}() {\n return $!{column.name};\n }\n\n public void set$!{tool.firstUpperCase($column.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.name}) {\n this.$!{column.name} = $!{column.name};\n }\n#end"},{"name":"init.vm","value":"##初始化区域\n\n##去掉表的t_前缀\n$!tableInfo.setName($tool.getClassName($tableInfo.obj.name.replaceFirst(\"book_\",\"\")))\n\n##参考阿里巴巴开发手册,POJO 类中布尔类型的变量,都不要加 is 前缀,否则部分框架解析会引起序列化错误\n#foreach($column in $tableInfo.fullColumn)\n#if($column.name.startsWith(\"is\") && $column.type.equals(\"java.lang.Boolean\"))\n $!column.setName($tool.firstLowerCase($column.name.substring(2)))\n#end\n#end\n\n##实现动态排除列\n#set($temp = $tool.newHashSet(\"testCreateTime\", \"otherColumn\"))\n#foreach($item in $temp)\n #set($newList = $tool.newArrayList())\n #foreach($column in $tableInfo.fullColumn)\n #if($column.name!=$item)\n ##带有反回值的方法调用时使用$tool.call来消除返回值\n $tool.call($newList.add($column))\n #end\n #end\n ##重新保存\n $tableInfo.setFullColumn($newList)\n#end\n\n##对importList进行篡改\n#set($temp = $tool.newHashSet())\n#foreach($column in $tableInfo.fullColumn)\n #if(!$column.type.startsWith(\"java.lang.\"))\n ##带有反回值的方法调用时使用$tool.call来消除返回值\n $tool.call($temp.add($column.type))\n #end\n#end\n##覆盖\n#set($importList = $temp)"},{"name":"mybatisSupport.vm","value":"##针对Mybatis 进行支持,主要用于生成xml文件\n#foreach($column in $tableInfo.fullColumn)\n ##储存列类型\n $tool.call($column.ext.put(\"sqlType\", $tool.getField($column.obj.dataType, \"typeName\")))\n #if($tool.newHashSet(\"java.lang.String\").contains($column.type))\n #set($jdbcType=\"VARCHAR\")\n #elseif($tool.newHashSet(\"java.lang.Boolean\", \"boolean\").contains($column.type))\n #set($jdbcType=\"BOOLEAN\")\n #elseif($tool.newHashSet(\"java.lang.Byte\", \"byte\").contains($column.type))\n #set($jdbcType=\"BYTE\")\n #elseif($tool.newHashSet(\"java.lang.Integer\", \"int\", \"java.lang.Short\", \"short\").contains($column.type))\n #set($jdbcType=\"INTEGER\")\n #elseif($tool.newHashSet(\"java.lang.Long\", \"long\").contains($column.type))\n #set($jdbcType=\"INTEGER\")\n #elseif($tool.newHashSet(\"java.lang.Float\", \"float\", \"java.lang.Double\", \"double\").contains($column.type))\n #set($jdbcType=\"NUMERIC\")\n #elseif($tool.newHashSet(\"java.util.Date\", \"java.sql.Timestamp\", \"java.time.Instant\", \"java.time.LocalDateTime\", \"java.time.OffsetDateTime\", \"\tjava.time.ZonedDateTime\").contains($column.type))\n #set($jdbcType=\"TIMESTAMP\")\n #elseif($tool.newHashSet(\"java.sql.Date\", \"java.time.LocalDate\").contains($column.type))\n #set($jdbcType=\"TIMESTAMP\")\n #else\n ##其他类型\n #set($jdbcType=\"VARCHAR\")\n #end\n $tool.call($column.ext.put(\"jdbcType\", $jdbcType))\n#end\n\n##定义宏,查询所有列\n#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($velocityHasNext), #end#end#end\n"}]}}} \ No newline at end of file +{"author":"makejava","version":"1.2.4","userSecure":"","currTypeMapperGroupName":"Default","currTemplateGroupName":"Default","currColumnConfigGroupName":"Default","currGlobalConfigGroupName":"Default","typeMapper":{"Default":{"name":"Default","elementList":[{"matchType":"REGEX","columnType":"varchar(\\(\\d+\\))?","javaType":"java.lang.String"},{"matchType":"REGEX","columnType":"char(\\(\\d+\\))?","javaType":"java.lang.String"},{"matchType":"REGEX","columnType":"(tiny|medium|long)*text","javaType":"java.lang.String"},{"matchType":"REGEX","columnType":"decimal(\\(\\d+,\\d+\\))?","javaType":"java.lang.Double"},{"matchType":"ORDINARY","columnType":"integer","javaType":"java.lang.Integer"},{"matchType":"REGEX","columnType":"(tiny|small|medium)*int(\\(\\d+\\))?","javaType":"java.lang.Integer"},{"matchType":"ORDINARY","columnType":"int4","javaType":"java.lang.Integer"},{"matchType":"ORDINARY","columnType":"int8","javaType":"java.lang.Long"},{"matchType":"REGEX","columnType":"bigint(\\(\\d+\\))?","javaType":"java.lang.Long"},{"matchType":"ORDINARY","columnType":"date","javaType":"java.util.Date"},{"matchType":"ORDINARY","columnType":"datetime","javaType":"java.util.Date"},{"matchType":"ORDINARY","columnType":"timestamp","javaType":"java.util.Date"},{"matchType":"ORDINARY","columnType":"time","javaType":"java.time.LocalTime"},{"matchType":"ORDINARY","columnType":"boolean","javaType":"java.lang.Boolean"}]}},"template":{"spring-data-mongodb":{"name":"spring-data-mongodb","elementList":[{"name":"controller.java.vm","code":"##导入宏定义、设置包名、类名、文件名##导入宏定义\n$!{define.vm}\n#setPackageSuffix(\"controller\")\n#setTableSuffix(\"Controller\")\n#save(\"/controller\", \"Controller.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##定义服务名\n#set($serviceSortType = $!tool.append($!tableInfo.name, \"Service\"))\n#set($serviceType = $!tool.append($!tableInfo.savePackageName, \".service.\", $serviceSortType))\n#set($serviceVarName = $!tool.firstLowerCase($serviceSortType))\n\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($entityVarName = $!tool.firstLowerCase($!tableInfo.name))\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport $serviceType;\nimport lombok.AllArgsConstructor;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.Pageable;\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.PostMapping;\nimport org.springframework.web.bind.annotation.RequestBody;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\n\n/**\n * $!{tableInfo.comment}控制层\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@RestController\n@RequestMapping(\"/$!tool.firstLowerCase($!tableInfo.name)\")\n@AllArgsConstructor\npublic class $!{tableName} {\n\n\tprivate $serviceSortType $serviceVarName;\n\n\t/**\n\t * 获取$!{tableInfo.comment}列表(分页)\n\t */\n\t@GetMapping(\"/list\")\n\tpublic Page<$entityShortType> list(Pageable page) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * 获取$!{tableInfo.comment}\n\t */\n\t@GetMapping(\"/get\")\n\tpublic $entityShortType get($!pk.shortType id) {\n\t\treturn ${serviceVarName}.findById(id);\n\t}\n\n\t/**\n\t * 添加$!{tableInfo.comment}\n\t */\n\t@PostMapping(\"/add\")\n\tpublic void add(@RequestBody $entityShortType $entityVarName) {\n\t\t${serviceVarName}.save($entityVarName);\n\t}\n\n\n\t/**\n\t * 修改$!{tableInfo.comment}\n\t */\n\t@PostMapping(\"/update\")\n\tpublic void update(@RequestBody $entityShortType $entityVarName) {\n\t\t${serviceVarName}.save($entityVarName);\n\t}\n\n\t/**\n\t * 删除$!{tableInfo.comment}\n\t */\n\t@PostMapping(\"/delete\")\n\tpublic void delete($!pk.shortType id) {\n\t\t${serviceVarName}.deleteById(id);\n\t}\n\n}\n"},{"name":"repository.java.vm","code":"##导入宏定义、设置包名、类名、文件名##导入宏定义\n$!{define.vm}\n#setPackageSuffix(\"repository\")\n#setTableSuffix(\"Repository\")\n#save(\"/repository\", \"Repository.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##实体类名、主键类名\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($pkShortType = $!pk.shortType)\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport org.springframework.data.mongodb.repository.MongoRepository;\n\n\n/**\n * $!{tableInfo.comment}持久层\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} extends MongoRepository<$entityShortType, $pkShortType> {\n\n}\n"},{"name":"service.java.vm","code":"##导入宏定义、设置包名、类名、文件名##导入宏定义\n$!{define.vm}\n#setPackageSuffix(\"service\")\n#setTableSuffix(\"Service\")\n#save(\"/service\", \"Service.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##实体类名、主键类名\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($entityVarName = $!tool.firstLowerCase($!tableInfo.name))\n#set($pkShortType = $!pk.shortType)\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.Pageable;\nimport java.util.Collection;\nimport java.util.List;\n\n\n/**\n * $!{tableInfo.comment}业务层\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} {\n\n void save($entityShortType $entityVarName);\n\n void deleteById($pkShortType id);\n\n $entityShortType findById($pkShortType id);\n\n List<$entityShortType> findById(Collection<$pkShortType> ids);\n\n Page<$entityShortType> list(Pageable page);\n\n}\n"},{"name":"serviceImpl.java.vm","code":"##导入宏定义、设置包名、类名、文件名\n$!{define.vm}\n#setPackageSuffix(\"service.impl\")\n#setTableSuffix(\"ServiceImpl\")\n#save(\"/service/impl\", \"ServiceImpl.java\")\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n##业务层类名、持久层类名、实体名\n#set($serviceSortType = $!tool.append($!tableInfo.name, \"Service\"))\n#set($serviceType = $!tool.append($!tableInfo.savePackageName, \".service.\", $serviceSortType))\n#set($repositorySortType = $!tool.append($!tableInfo.name, \"Repository\"))\n#set($repositoryType = $!tool.append($!tableInfo.savePackageName, \".repository.\", $repositorySortType))\n#set($repositoryVarName = $!tool.firstLowerCase($!repositorySortType))\n#set($entityShortType = $!tableInfo.name)\n#set($entityType = $!tableInfo.psiClassObj.getQualifiedName())\n#set($entityVarName = $!tool.firstLowerCase($!tableInfo.name))\n#set($pkShortType = $!pk.shortType)\n#set($pkType = $!pk.type)\n\nimport $pkType;\nimport $entityType;\nimport $serviceType;\nimport $repositoryType;\nimport org.springframework.stereotype.Service;\nimport javax.annotation.Resource;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.Pageable;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.stream.Collectors;\nimport java.util.stream.StreamSupport;\n\n\n/**\n * $!{tableInfo.comment}业务层\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@Service\npublic class $!{tableName} implements $!serviceSortType {\n\n\t@Resource\n private $repositorySortType $repositoryVarName;\n\n @Override\n public void save($entityShortType $entityVarName) {\n $!{repositoryVarName}.save($entityVarName);\n }\n\n @Override\n public void deleteById($pkShortType id) {\n $!{repositoryVarName}.delete(id);\n }\n\n @Override\n public $entityShortType findById($pkShortType id) {\n return $!{repositoryVarName}.findOne(id);\n }\n\n @Override\n public List<$entityShortType> findById(Collection<$pkShortType> ids) {\n Iterable<$entityShortType> iterable = $!{repositoryVarName}.findAll(ids);\n return StreamSupport.stream(iterable.spliterator(), false)\n .collect(Collectors.toList());\n }\n\n @Override\n public Page<$entityShortType> list(Pageable page) {\n return $!{repositoryVarName}.findAll(page);\n }\n\n}\n"}]},"MybatisPlus-Mixed":{"name":"MybatisPlus-Mixed","elementList":[{"name":"controller.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Controller\")\n\n##保存文件(宏定义)\n#save(\"/controller\", \"Controller.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"controller\")\n\n##定义服务名\n#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \"Service\"))\n\n##定义实体对象名\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n\nimport com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\nimport com.baomidou.mybatisplus.extension.api.ApiController;\nimport com.baomidou.mybatisplus.extension.api.R;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport java.io.Serializable;\nimport java.util.List;\n\n##表注释(宏定义)\n#tableComment(\"表控制层\")\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($!tableInfo.name)\")\npublic class $!{tableName} extends ApiController {\n /**\n * 服务对象\n */\n @Resource\n private $!{tableInfo.name}Service $!{serviceName};\n\n /**\n * 分页查询所有数据\n *\n * @param page 分页对象\n * @param $!entityName 查询实体\n * @return 所有数据\n */\n @GetMapping\n public R selectAll(Page<$!tableInfo.name> page, $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.page(page, new QueryWrapper<>($!entityName)));\n }\n\n /**\n * 通过主键查询单条数据\n *\n * @param id 主键\n * @return 单条数据\n */\n @GetMapping(\"{id}\")\n public R selectOne(@PathVariable Serializable id) {\n return success(this.$!{serviceName}.getById(id));\n }\n\n /**\n * 新增数据\n *\n * @param $!entityName 实体对象\n * @return 新增结果\n */\n @PostMapping\n public R insert(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.save($!entityName));\n }\n\n /**\n * 修改数据\n *\n * @param $!entityName 实体对象\n * @return 修改结果\n */\n @PutMapping\n public R update(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.updateById($!entityName));\n }\n\n /**\n * 删除数据\n *\n * @param idList 主键结合\n * @return 删除结果\n */\n @DeleteMapping\n public R delete(@RequestParam(\"idList\") List idList) {\n return success(this.$!{serviceName}.removeByIds(idList));\n }\n}\n"},{"name":"dao.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Dao\")\n\n##保存文件(宏定义)\n#save(\"/dao\", \"Dao.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"dao\")\n\nimport java.util.List;\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport org.apache.ibatis.annotations.Param;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表数据库访问层\")\npublic interface $!{tableName} extends BaseMapper<$!tableInfo.name> {\n\n/**\n* 批量新增数据(MyBatis原生foreach方法)\n*\n* @param entities List<$!{tableInfo.name}> 实例对象列表\n* @return 影响行数\n*/\nint insertBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n/**\n* 批量新增或按主键更新数据(MyBatis原生foreach方法)\n*\n* @param entities List<$!{tableInfo.name}> 实例对象列表\n* @return 影响行数\n* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参\n*/\nint insertOrUpdateBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n}\n"},{"name":"entity.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##保存文件(宏定义)\n#save(\"/entity\", \".java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"entity\")\n\n##自动导入包(全局变量)\n$!autoImport\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport java.io.Serializable;\n\n##表注释(宏定义)\n#tableComment(\"表实体类\")\n@SuppressWarnings(\"serial\")\npublic class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})//${column.comment}#end\n\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n#foreach($column in $tableInfo.fullColumn)\n#getSetMethod($column)\n#end\n\n#foreach($column in $tableInfo.pkColumn)\n /**\n * 获取主键值\n *\n * @return 主键值\n */\n @Override\n protected Serializable pkVal() {\n return this.$!column.name;\n }\n #break\n#end\n}\n"},{"name":"mapper.xml.vm","code":"##引入mybatis支持\n$!{mybatisSupport.vm}\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \"Dao.xml\"))\n$!callback.setSavePath($tool.append($modulePath, \"/src/main/resources/mapper\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n\n\n\n\n \n#foreach($column in $tableInfo.fullColumn)\n \n#end\n \n\n \n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n \n \n \n insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n on duplicate key update\n #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($velocityHasNext), #end#end\n \n\n\n"},{"name":"service.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Service\")\n\n##保存文件(宏定义)\n#save(\"/service\", \"Service.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service\")\n\nimport com.baomidou.mybatisplus.extension.service.IService;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表服务接口\")\npublic interface $!{tableName} extends IService<$!tableInfo.name> {\n\n}\n"},{"name":"serviceImpl.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"ServiceImpl\")\n\n##保存文件(宏定义)\n#save(\"/service/impl\", \"ServiceImpl.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service.impl\")\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\n\n##表注释(宏定义)\n#tableComment(\"表服务实现类\")\n@Service(\"$!tool.firstLowerCase($tableInfo.name)Service\")\npublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {\n\n}\n"}]},"MybatisPlus":{"name":"MybatisPlus","elementList":[{"name":"controller.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Controller\")\n\n##保存文件(宏定义)\n#save(\"/controller\", \"Controller.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"controller\")\n\n##定义服务名\n#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), \"Service\"))\n\n##定义实体对象名\n#set($entityName = $!tool.firstLowerCase($!tableInfo.name))\n\nimport com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;\nimport com.baomidou.mybatisplus.extension.api.ApiController;\nimport com.baomidou.mybatisplus.extension.api.R;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\nimport java.io.Serializable;\nimport java.util.List;\n\n##表注释(宏定义)\n#tableComment(\"表控制层\")\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($!tableInfo.name)\")\npublic class $!{tableName} extends ApiController {\n /**\n * 服务对象\n */\n @Resource\n private $!{tableInfo.name}Service $!{serviceName};\n\n /**\n * 分页查询所有数据\n *\n * @param page 分页对象\n * @param $!entityName 查询实体\n * @return 所有数据\n */\n @GetMapping\n public R selectAll(Page<$!tableInfo.name> page, $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.page(page, new QueryWrapper<>($!entityName)));\n }\n\n /**\n * 通过主键查询单条数据\n *\n * @param id 主键\n * @return 单条数据\n */\n @GetMapping(\"{id}\")\n public R selectOne(@PathVariable Serializable id) {\n return success(this.$!{serviceName}.getById(id));\n }\n\n /**\n * 新增数据\n *\n * @param $!entityName 实体对象\n * @return 新增结果\n */\n @PostMapping\n public R insert(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.save($!entityName));\n }\n\n /**\n * 修改数据\n *\n * @param $!entityName 实体对象\n * @return 修改结果\n */\n @PutMapping\n public R update(@RequestBody $!tableInfo.name $!entityName) {\n return success(this.$!{serviceName}.updateById($!entityName));\n }\n\n /**\n * 删除数据\n *\n * @param idList 主键结合\n * @return 删除结果\n */\n @DeleteMapping\n public R delete(@RequestParam(\"idList\") List idList) {\n return success(this.$!{serviceName}.removeByIds(idList));\n }\n}\n"},{"name":"dao.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Dao\")\n\n##保存文件(宏定义)\n#save(\"/dao\", \"Dao.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"dao\")\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表数据库访问层\")\npublic interface $!{tableName} extends BaseMapper<$!tableInfo.name> {\n\n}\n"},{"name":"entity.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##保存文件(宏定义)\n#save(\"/entity\", \".java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"entity\")\n\n##自动导入包(全局变量)\n$!{autoImport.vm}\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport java.io.Serializable;\n\n##表注释(宏定义)\n#tableComment(\"表实体类\")\n@SuppressWarnings(\"serial\")\npublic class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})//${column.comment}#end\n\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n#foreach($column in $tableInfo.fullColumn)\n#getSetMethod($column)\n#end\n\n#foreach($column in $tableInfo.pkColumn)\n /**\n * 获取主键值\n *\n * @return 主键值\n */\n @Override\n protected Serializable pkVal() {\n return this.$!column.name;\n }\n #break\n#end\n}\n"},{"name":"service.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"Service\")\n\n##保存文件(宏定义)\n#save(\"/service\", \"Service.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service\")\n\nimport com.baomidou.mybatisplus.extension.service.IService;\nimport $!{tableInfo.savePackageName}.entity.$!tableInfo.name;\n\n##表注释(宏定义)\n#tableComment(\"表服务接口\")\npublic interface $!{tableName} extends IService<$!tableInfo.name> {\n\n}\n"},{"name":"serviceImpl.java.vm","code":"##导入宏定义\n$!{define.vm}\n\n##设置表后缀(宏定义)\n#setTableSuffix(\"ServiceImpl\")\n\n##保存文件(宏定义)\n#save(\"/service/impl\", \"ServiceImpl.java\")\n\n##包路径(宏定义)\n#setPackageSuffix(\"service.impl\")\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\n\n##表注释(宏定义)\n#tableComment(\"表服务实现类\")\n@Service(\"$!tool.firstLowerCase($tableInfo.name)Service\")\npublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {\n\n}\n"}]},"Default":{"name":"Default","elementList":[{"name":"controller.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Controller\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/controller\"))\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.PageRequest;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.*;\n\nimport javax.annotation.Resource;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表控制层\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@RestController\n@RequestMapping(\"$!tool.firstLowerCase($tableInfo.name)\")\npublic class $!{tableName} {\n /**\n * 服务对象\n */\n @Resource\n private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;\n\n /**\n * 分页查询\n *\n * @param actualFlightInfo 筛选条件\n * @param pageRequest 分页对象\n * @return 查询结果\n */\n @GetMapping\n public ResponseEntity> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) {\n return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryByPage($!{tool.firstLowerCase($tableInfo.name)}, pageRequest));\n }\n\n /**\n * 通过主键查询单条数据\n *\n * @param id 主键\n * @return 单条数据\n */\n @GetMapping(\"{id}\")\n public ResponseEntity<$!{tableInfo.name}> queryById(@PathVariable(\"id\") $!pk.shortType id) {\n return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id));\n }\n\n /**\n * 新增数据\n *\n * @param $!{tool.firstLowerCase($tableInfo.name)} 实体\n * @return 新增结果\n */\n @PostMapping\n public ResponseEntity<$!{tableInfo.name}> add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {\n return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)}));\n }\n\n /**\n * 编辑数据\n *\n * @param $!{tool.firstLowerCase($tableInfo.name)} 实体\n * @return 编辑结果\n */\n @PutMapping\n public ResponseEntity<$!{tableInfo.name}> edit($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {\n return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.update($!{tool.firstLowerCase($tableInfo.name)}));\n }\n\n /**\n * 删除数据\n *\n * @param id 主键\n * @return 删除是否成功\n */\n @DeleteMapping\n public ResponseEntity deleteById($!pk.shortType id) {\n return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id));\n }\n\n}"},{"name":"dao.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Dao\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/dao\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport org.apache.ibatis.annotations.Param;\nimport org.springframework.data.domain.Pageable;\nimport java.util.List;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name} queryById($!pk.shortType $!pk.name);\n\n /**\n * 查询指定行数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件\n * @param pageable 分页对象\n * @return 对象列表\n */\n List<$!{tableInfo.name}> queryAllByLimit($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), @Param(\"pageable\") Pageable pageable);\n\n /**\n * 统计总行数\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件\n * @return 总行数\n */\n long count($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 批量新增数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n */\n int insertBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 批量新增或按主键更新数据(MyBatis原生foreach方法)\n *\n * @param entities List<$!{tableInfo.name}> 实例对象列表\n * @return 影响行数\n * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参\n */\n int insertOrUpdateBatch(@Param(\"entities\") List<$!{tableInfo.name}> entities);\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 影响行数\n */\n int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 影响行数\n */\n int deleteById($!pk.shortType $!pk.name);\n\n}\n"},{"name":"debug.json.vm","code":"// 禁止将生成结果写入到文件\n$!callback.setWriteFile(false)\n\n//调试表原始对象\n$!tool.debug($tableInfo.obj)\n\n//调试列原始对象\n$!tool.debug($tableInfo.fullColumn.get(0).obj)\n\n//调试列原始列类型\n$!tool.debug($tableInfo.fullColumn.get(0).obj.dataType)\n\n//获取原始列类型中的字段\nsqlType = $!tool.getField($tableInfo.fullColumn.get(0).obj.dataType, \"typeName\")\n\n//执行原始列类型中的方法\nsqlTypeLen = $!tableInfo.fullColumn.get(0).obj.dataType.getLength()\n"},{"name":"entity.java.vm","code":"##引入宏定义\n$!{define.vm}\n\n##使用宏定义设置回调(保存位置与文件后缀)\n#save(\"/entity\", \".java\")\n\n##使用宏定义设置包后缀\n#setPackageSuffix(\"entity\")\n\n##使用全局变量实现默认包导入\n$!{autoImport.vm}\nimport java.io.Serializable;\n\n##使用宏定义实现类注释信息\n#tableComment(\"实体类\")\npublic class $!{tableInfo.name} implements Serializable {\n private static final long serialVersionUID = $!tool.serial();\n#foreach($column in $tableInfo.fullColumn)\n #if(${column.comment})/**\n * ${column.comment}\n */#end\n\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n#end\n\n#foreach($column in $tableInfo.fullColumn)\n##使用宏定义实现get,set方法\n#getSetMethod($column)\n#end\n\n}\n"},{"name":"mapper.xml.vm","code":"##引入mybatis支持\n$!{mybatisSupport.vm}\n\n##设置保存名称与保存位置\n$!callback.setFileName($tool.append($!{tableInfo.name}, \"Dao.xml\"))\n$!callback.setSavePath($tool.append($modulePath, \"/src/main/resources/mapper\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n\n\n\n\n \n#foreach($column in $tableInfo.fullColumn)\n \n#end\n \n\n \n \n\n \n \n\n \n \n\n \n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($velocityHasNext), #end#end)\n \n\n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n \n\n \n insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)\n values\n \n (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)\n \n on duplicate key update\n #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name)#if($velocityHasNext),\n #end#end\n\n \n\n \n \n update $!{tableInfo.obj.name}\n \n#foreach($column in $tableInfo.otherColumn)\n \n $!column.obj.name = #{$!column.name},\n \n#end\n \n where $!pk.obj.name = #{$!pk.name}\n \n\n \n \n delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}\n \n\n\n"},{"name":"service.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Service\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.PageRequest;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表服务接口\n *\n * @author $!author\n * @since $!time.currTime()\n */\npublic interface $!{tableName} {\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n $!{tableInfo.name} queryById($!pk.shortType $!pk.name);\n\n /**\n * 分页查询\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 筛选条件\n * @param pageRequest 分页对象\n * @return 查询结果\n */\n Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), PageRequest pageRequest);\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n boolean deleteById($!pk.shortType $!pk.name);\n\n}"},{"name":"serviceImpl.java.vm","code":"##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"ServiceImpl\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/service/impl\"))\n\n##拿到主键\n#if(!$tableInfo.pkColumn.isEmpty())\n #set($pk = $tableInfo.pkColumn.get(0))\n#end\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\nimport $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport org.springframework.stereotype.Service;\nimport org.springframework.data.domain.Page;\nimport org.springframework.data.domain.PageImpl;\nimport org.springframework.data.domain.PageRequest;\n\nimport javax.annotation.Resource;\n\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表服务实现类\n *\n * @author $!author\n * @since $!time.currTime()\n */\n@Service(\"$!tool.firstLowerCase($!{tableInfo.name})Service\")\npublic class $!{tableName} implements $!{tableInfo.name}Service {\n @Resource\n private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;\n\n /**\n * 通过ID查询单条数据\n *\n * @param $!pk.name 主键\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name} queryById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);\n }\n\n /**\n * 分页查询\n *\n * @param $!{tool.firstLowerCase($tableInfo.name)} 筛选条件\n * @param pageRequest 分页对象\n * @return 查询结果\n */\n @Override\n public Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) {\n long total = this.$!{tool.firstLowerCase($tableInfo.name)}Dao.count($!{tool.firstLowerCase($tableInfo.name)});\n return new PageImpl<>(this.$!{tool.firstLowerCase($tableInfo.name)}Dao.queryAllByLimit($!{tool.firstLowerCase($tableInfo.name)}, pageRequest), pageRequest, total);\n }\n\n /**\n * 新增数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {\n this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name}));\n return $!tool.firstLowerCase($!{tableInfo.name});\n }\n\n /**\n * 修改数据\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象\n * @return 实例对象\n */\n @Override\n public $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {\n this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.update($!tool.firstLowerCase($!{tableInfo.name}));\n return this.queryById($!{tool.firstLowerCase($!{tableInfo.name})}.get$!tool.firstUpperCase($pk.name)());\n }\n\n /**\n * 通过主键删除数据\n *\n * @param $!pk.name 主键\n * @return 是否成功\n */\n @Override\n public boolean deleteById($!pk.shortType $!pk.name) {\n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name) > 0;\n }\n}"}]}},"columnConfig":{"Default":{"name":"Default","elementList":[{"title":"disable","type":"BOOLEAN","selectValue":""},{"title":"support","type":"SELECT","selectValue":"add,edit,query,del,ui"}]}},"globalConfig":{"Default":{"name":"Default","elementList":[{"name":"autoImport.vm","value":"##自动导入包(仅导入实体属性需要的包,通常用于实体类)\n#foreach($import in $importList)\nimport $!import;\n#end"},{"name":"define.vm","value":"##(Velocity宏定义)\n\n##定义设置表名后缀的宏定义,调用方式:#setTableSuffix(\"Test\")\n#macro(setTableSuffix $suffix)\n #set($tableName = $!tool.append($tableInfo.name, $suffix))\n#end\n\n##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix(\"Test\")\n#macro(setPackageSuffix $suffix)\n#if($suffix!=\"\")package #end#if($tableInfo.savePackageName!=\"\")$!{tableInfo.savePackageName}.#{end}$!suffix;\n#end\n\n##定义直接保存路径与文件名简化的宏定义,调用方式:#save(\"/entity\", \".java\")\n#macro(save $path $fileName)\n $!callback.setSavePath($tool.append($tableInfo.savePath, $path))\n $!callback.setFileName($tool.append($tableInfo.name, $fileName))\n#end\n\n##定义表注释的宏定义,调用方式:#tableComment(\"注释信息\")\n#macro(tableComment $desc)\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})$desc\n *\n * @author $!author\n * @since $!time.currTime()\n */\n#end\n\n##定义GET,SET方法的宏定义,调用方式:#getSetMethod($column)\n#macro(getSetMethod $column)\n\n public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.name)}() {\n return $!{column.name};\n }\n\n public void set$!{tool.firstUpperCase($column.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.name}) {\n this.$!{column.name} = $!{column.name};\n }\n#end"},{"name":"init.vm","value":"##初始化区域\n\n##去掉表的t_前缀\n$!tableInfo.setName($tool.getClassName($tableInfo.obj.name.replaceFirst(\"book_\",\"\")))\n\n##参考阿里巴巴开发手册,POJO 类中布尔类型的变量,都不要加 is 前缀,否则部分框架解析会引起序列化错误\n#foreach($column in $tableInfo.fullColumn)\n#if($column.name.startsWith(\"is\") && $column.type.equals(\"java.lang.Boolean\"))\n $!column.setName($tool.firstLowerCase($column.name.substring(2)))\n#end\n#end\n\n##实现动态排除列\n#set($temp = $tool.newHashSet(\"testCreateTime\", \"otherColumn\"))\n#foreach($item in $temp)\n #set($newList = $tool.newArrayList())\n #foreach($column in $tableInfo.fullColumn)\n #if($column.name!=$item)\n ##带有反回值的方法调用时使用$tool.call来消除返回值\n $tool.call($newList.add($column))\n #end\n #end\n ##重新保存\n $tableInfo.setFullColumn($newList)\n#end\n\n##对importList进行篡改\n#set($temp = $tool.newHashSet())\n#foreach($column in $tableInfo.fullColumn)\n #if(!$column.type.startsWith(\"java.lang.\"))\n ##带有反回值的方法调用时使用$tool.call来消除返回值\n $tool.call($temp.add($column.type))\n #end\n#end\n##覆盖\n#set($importList = $temp)"},{"name":"mybatisSupport.vm","value":"##针对Mybatis 进行支持,主要用于生成xml文件\n#foreach($column in $tableInfo.fullColumn)\n ##储存列类型\n $tool.call($column.ext.put(\"sqlType\", $tool.getField($column.obj.dataType, \"typeName\")))\n #if($tool.newHashSet(\"java.lang.String\").contains($column.type))\n #set($jdbcType=\"VARCHAR\")\n #elseif($tool.newHashSet(\"java.lang.Boolean\", \"boolean\").contains($column.type))\n #set($jdbcType=\"BOOLEAN\")\n #elseif($tool.newHashSet(\"java.lang.Byte\", \"byte\").contains($column.type))\n #set($jdbcType=\"BYTE\")\n #elseif($tool.newHashSet(\"java.lang.Integer\", \"int\", \"java.lang.Short\", \"short\").contains($column.type))\n #set($jdbcType=\"INTEGER\")\n #elseif($tool.newHashSet(\"java.lang.Long\", \"long\").contains($column.type))\n #set($jdbcType=\"INTEGER\")\n #elseif($tool.newHashSet(\"java.lang.Float\", \"float\", \"java.lang.Double\", \"double\").contains($column.type))\n #set($jdbcType=\"NUMERIC\")\n #elseif($tool.newHashSet(\"java.util.Date\", \"java.sql.Timestamp\", \"java.time.Instant\", \"java.time.LocalDateTime\", \"java.time.OffsetDateTime\", \"\tjava.time.ZonedDateTime\").contains($column.type))\n #set($jdbcType=\"TIMESTAMP\")\n #elseif($tool.newHashSet(\"java.sql.Date\", \"java.time.LocalDate\").contains($column.type))\n #set($jdbcType=\"TIMESTAMP\")\n #else\n ##其他类型\n #set($jdbcType=\"VARCHAR\")\n #end\n $tool.call($column.ext.put(\"jdbcType\", $jdbcType))\n#end\n\n##定义宏,查询所有列\n#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($velocityHasNext), #end#end#end\n"}]}}} \ No newline at end of file diff --git a/src/main/resources/template/Default/controller.java.vm b/src/main/resources/template/Default/controller.java.vm index 79dcaba..b371f25 100644 --- a/src/main/resources/template/Default/controller.java.vm +++ b/src/main/resources/template/Default/controller.java.vm @@ -12,6 +12,9 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/controller")) import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -31,15 +34,60 @@ public class $!{tableName} { @Resource private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service; + /** + * 分页查询 + * + * @param actualFlightInfo 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 + */ + @GetMapping + public ResponseEntity> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) { + return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryByPage($!{tool.firstLowerCase($tableInfo.name)}, pageRequest)); + } + /** * 通过主键查询单条数据 * * @param id 主键 * @return 单条数据 */ - @GetMapping("selectOne") - public $!{tableInfo.name} selectOne($!pk.shortType id) { - return this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id); + @GetMapping("{id}") + public ResponseEntity<$!{tableInfo.name}> queryById(@PathVariable("id") $!pk.shortType id) { + return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id)); + } + + /** + * 新增数据 + * + * @param $!{tool.firstLowerCase($tableInfo.name)} 实体 + * @return 新增结果 + */ + @PostMapping + public ResponseEntity<$!{tableInfo.name}> add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) { + return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)})); + } + + /** + * 编辑数据 + * + * @param $!{tool.firstLowerCase($tableInfo.name)} 实体 + * @return 编辑结果 + */ + @PutMapping + public ResponseEntity<$!{tableInfo.name}> edit($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) { + return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.update($!{tool.firstLowerCase($tableInfo.name)})); + } + + /** + * 删除数据 + * + * @param id 主键 + * @return 删除是否成功 + */ + @DeleteMapping + public ResponseEntity deleteById($!pk.shortType id) { + return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id)); } } \ No newline at end of file diff --git a/src/main/resources/template/Default/dao.java.vm b/src/main/resources/template/Default/dao.java.vm index fcbbadf..bf14c39 100644 --- a/src/main/resources/template/Default/dao.java.vm +++ b/src/main/resources/template/Default/dao.java.vm @@ -13,6 +13,7 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/dao")) import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; import java.util.List; /** @@ -34,20 +35,19 @@ public interface $!{tableName} { /** * 查询指定行数据 * - * @param offset 查询起始位置 - * @param limit 查询条数 + * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件 + * @param pageable 分页对象 * @return 对象列表 */ - List<$!{tableInfo.name}> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit); - + List<$!{tableInfo.name}> queryAllByLimit($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), @Param("pageable") Pageable pageable); /** - * 通过实体作为筛选条件查询 + * 统计总行数 * - * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象 - * @return 对象列表 + * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件 + * @return 总行数 */ - List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})); + long count($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})); /** * 新增数据 diff --git a/src/main/resources/template/Default/debug.json.vm b/src/main/resources/template/Default/debug.json.vm index 1f59155..9c4361a 100644 --- a/src/main/resources/template/Default/debug.json.vm +++ b/src/main/resources/template/Default/debug.json.vm @@ -1,3 +1,6 @@ +// 禁止将生成结果写入到文件 +$!callback.setWriteFile(false) + //调试表原始对象 $!tool.debug($tableInfo.obj) diff --git a/src/main/resources/template/Default/entity.java.vm b/src/main/resources/template/Default/entity.java.vm index 5866ede..b3d5e3a 100644 --- a/src/main/resources/template/Default/entity.java.vm +++ b/src/main/resources/template/Default/entity.java.vm @@ -1,5 +1,5 @@ ##引入宏定义 -$!define +$!{define.vm} ##使用宏定义设置回调(保存位置与文件后缀) #save("/entity", ".java") @@ -8,7 +8,7 @@ $!define #setPackageSuffix("entity") ##使用全局变量实现默认包导入 -$!autoImport +$!{autoImport.vm} import java.io.Serializable; ##使用宏定义实现类注释信息 @@ -17,8 +17,8 @@ public class $!{tableInfo.name} implements Serializable { private static final long serialVersionUID = $!tool.serial(); #foreach($column in $tableInfo.fullColumn) #if(${column.comment})/** - * ${column.comment} - */#end + * ${column.comment} + */#end private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; #end @@ -28,4 +28,4 @@ public class $!{tableInfo.name} implements Serializable { #getSetMethod($column) #end -} \ No newline at end of file +} diff --git a/src/main/resources/template/Default/mapper.xml.vm b/src/main/resources/template/Default/mapper.xml.vm index 6299d5e..190264b 100644 --- a/src/main/resources/template/Default/mapper.xml.vm +++ b/src/main/resources/template/Default/mapper.xml.vm @@ -1,5 +1,5 @@ ##引入mybatis支持 -$!mybatisSupport +$!{mybatisSupport.vm} ##设置保存名称与保存位置 $!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml")) @@ -25,7 +25,7 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper")) select #allSqlColumn() - from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name + from $!tableInfo.obj.name where $!pk.obj.name = #{$!pk.name} @@ -34,16 +34,7 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper")) select #allSqlColumn() - from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name - limit #{offset}, #{limit} - - - - + + + - insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) + insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($velocityHasNext), #end#end) - insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) + insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) values (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end) @@ -68,18 +67,20 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper")) - insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) + insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) values (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end) on duplicate key update - #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($velocityHasNext), #end#end + #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name)#if($velocityHasNext), + #end#end + - update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} + update $!{tableInfo.obj.name} #foreach($column in $tableInfo.otherColumn) @@ -92,7 +93,7 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper")) - delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name} + delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name} diff --git a/src/main/resources/template/Default/service.java.vm b/src/main/resources/template/Default/service.java.vm index 79b8a79..50a5ecb 100644 --- a/src/main/resources/template/Default/service.java.vm +++ b/src/main/resources/template/Default/service.java.vm @@ -12,7 +12,8 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/service")) #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service; import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; -import java.util.List; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; /** * $!{tableInfo.comment}($!{tableInfo.name})表服务接口 @@ -31,13 +32,13 @@ public interface $!{tableName} { $!{tableInfo.name} queryById($!pk.shortType $!pk.name); /** - * 查询多条数据 + * 分页查询 * - * @param offset 查询起始位置 - * @param limit 查询条数 - * @return 对象列表 + * @param $!tool.firstLowerCase($!{tableInfo.name}) 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 */ - List<$!{tableInfo.name}> queryAllByLimit(int offset, int limit); + Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), PageRequest pageRequest); /** * 新增数据 diff --git a/src/main/resources/template/Default/serviceImpl.java.vm b/src/main/resources/template/Default/serviceImpl.java.vm index c231a63..c6b2c5e 100644 --- a/src/main/resources/template/Default/serviceImpl.java.vm +++ b/src/main/resources/template/Default/serviceImpl.java.vm @@ -15,9 +15,11 @@ import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao; import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; import org.springframework.stereotype.Service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; import javax.annotation.Resource; -import java.util.List; /** * $!{tableInfo.comment}($!{tableInfo.name})表服务实现类 @@ -42,15 +44,16 @@ public class $!{tableName} implements $!{tableInfo.name}Service { } /** - * 查询多条数据 + * 分页查询 * - * @param offset 查询起始位置 - * @param limit 查询条数 - * @return 对象列表 + * @param $!{tool.firstLowerCase($tableInfo.name)} 筛选条件 + * @param pageRequest 分页对象 + * @return 查询结果 */ @Override - public List<$!{tableInfo.name}> queryAllByLimit(int offset, int limit) { - return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAllByLimit(offset, limit); + public Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) { + long total = this.$!{tool.firstLowerCase($tableInfo.name)}Dao.count($!{tool.firstLowerCase($tableInfo.name)}); + return new PageImpl<>(this.$!{tool.firstLowerCase($tableInfo.name)}Dao.queryAllByLimit($!{tool.firstLowerCase($tableInfo.name)}, pageRequest), pageRequest, total); } /** diff --git a/src/main/resources/template/MybatisPlus-Mixed/controller.java.vm b/src/main/resources/template/MybatisPlus-Mixed/controller.java.vm index 4546bba..b941fa6 100644 --- a/src/main/resources/template/MybatisPlus-Mixed/controller.java.vm +++ b/src/main/resources/template/MybatisPlus-Mixed/controller.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("Controller") @@ -94,4 +94,4 @@ public class $!{tableName} extends ApiController { public R delete(@RequestParam("idList") List idList) { return success(this.$!{serviceName}.removeByIds(idList)); } -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus-Mixed/dao.java.vm b/src/main/resources/template/MybatisPlus-Mixed/dao.java.vm index bef511b..68128e7 100644 --- a/src/main/resources/template/MybatisPlus-Mixed/dao.java.vm +++ b/src/main/resources/template/MybatisPlus-Mixed/dao.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("Dao") diff --git a/src/main/resources/template/MybatisPlus-Mixed/entity.java.vm b/src/main/resources/template/MybatisPlus-Mixed/entity.java.vm index 812ad52..fc984f6 100644 --- a/src/main/resources/template/MybatisPlus-Mixed/entity.java.vm +++ b/src/main/resources/template/MybatisPlus-Mixed/entity.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##保存文件(宏定义) #save("/entity", ".java") @@ -38,4 +38,4 @@ public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { } #break #end -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus-Mixed/mapper.xml.vm b/src/main/resources/template/MybatisPlus-Mixed/mapper.xml.vm index 0868c9e..f3e145a 100644 --- a/src/main/resources/template/MybatisPlus-Mixed/mapper.xml.vm +++ b/src/main/resources/template/MybatisPlus-Mixed/mapper.xml.vm @@ -1,5 +1,5 @@ ##引入mybatis支持 -$!mybatisSupport +$!{mybatisSupport.vm} ##设置保存名称与保存位置 $!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml")) diff --git a/src/main/resources/template/MybatisPlus-Mixed/service.java.vm b/src/main/resources/template/MybatisPlus-Mixed/service.java.vm index 7a6b28e..5d730c8 100644 --- a/src/main/resources/template/MybatisPlus-Mixed/service.java.vm +++ b/src/main/resources/template/MybatisPlus-Mixed/service.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("Service") @@ -17,4 +17,4 @@ import $!{tableInfo.savePackageName}.entity.$!tableInfo.name; #tableComment("表服务接口") public interface $!{tableName} extends IService<$!tableInfo.name> { -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus-Mixed/serviceImpl.java.vm b/src/main/resources/template/MybatisPlus-Mixed/serviceImpl.java.vm index fad1b29..1c6d411 100644 --- a/src/main/resources/template/MybatisPlus-Mixed/serviceImpl.java.vm +++ b/src/main/resources/template/MybatisPlus-Mixed/serviceImpl.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("ServiceImpl") @@ -21,4 +21,4 @@ import org.springframework.stereotype.Service; @Service("$!tool.firstLowerCase($tableInfo.name)Service") public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service { -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus/controller.java.vm b/src/main/resources/template/MybatisPlus/controller.java.vm index 4546bba..b941fa6 100644 --- a/src/main/resources/template/MybatisPlus/controller.java.vm +++ b/src/main/resources/template/MybatisPlus/controller.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("Controller") @@ -94,4 +94,4 @@ public class $!{tableName} extends ApiController { public R delete(@RequestParam("idList") List idList) { return success(this.$!{serviceName}.removeByIds(idList)); } -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus/dao.java.vm b/src/main/resources/template/MybatisPlus/dao.java.vm index 83b42a8..cacd102 100644 --- a/src/main/resources/template/MybatisPlus/dao.java.vm +++ b/src/main/resources/template/MybatisPlus/dao.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("Dao") @@ -17,4 +17,4 @@ import $!{tableInfo.savePackageName}.entity.$!tableInfo.name; #tableComment("表数据库访问层") public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus/entity.java.vm b/src/main/resources/template/MybatisPlus/entity.java.vm index 812ad52..0fd23c3 100644 --- a/src/main/resources/template/MybatisPlus/entity.java.vm +++ b/src/main/resources/template/MybatisPlus/entity.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##保存文件(宏定义) #save("/entity", ".java") @@ -8,7 +8,7 @@ $!define #setPackageSuffix("entity") ##自动导入包(全局变量) -$!autoImport +$!{autoImport.vm} import com.baomidou.mybatisplus.extension.activerecord.Model; import java.io.Serializable; @@ -38,4 +38,4 @@ public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { } #break #end -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus/service.java.vm b/src/main/resources/template/MybatisPlus/service.java.vm index 7a6b28e..5d730c8 100644 --- a/src/main/resources/template/MybatisPlus/service.java.vm +++ b/src/main/resources/template/MybatisPlus/service.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("Service") @@ -17,4 +17,4 @@ import $!{tableInfo.savePackageName}.entity.$!tableInfo.name; #tableComment("表服务接口") public interface $!{tableName} extends IService<$!tableInfo.name> { -} \ No newline at end of file +} diff --git a/src/main/resources/template/MybatisPlus/serviceImpl.java.vm b/src/main/resources/template/MybatisPlus/serviceImpl.java.vm index fad1b29..1c6d411 100644 --- a/src/main/resources/template/MybatisPlus/serviceImpl.java.vm +++ b/src/main/resources/template/MybatisPlus/serviceImpl.java.vm @@ -1,5 +1,5 @@ ##导入宏定义 -$!define +$!{define.vm} ##设置表后缀(宏定义) #setTableSuffix("ServiceImpl") @@ -21,4 +21,4 @@ import org.springframework.stereotype.Service; @Service("$!tool.firstLowerCase($tableInfo.name)Service") public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service { -} \ No newline at end of file +} diff --git a/src/main/resources/template/spring-data-mongodb/controller.java.vm b/src/main/resources/template/spring-data-mongodb/controller.java.vm index 3676949..4bde0a2 100644 --- a/src/main/resources/template/spring-data-mongodb/controller.java.vm +++ b/src/main/resources/template/spring-data-mongodb/controller.java.vm @@ -1,5 +1,5 @@ ##导入宏定义、设置包名、类名、文件名##导入宏定义 -$!define +$!{define.vm} #setPackageSuffix("controller") #setTableSuffix("Controller") #save("/controller", "Controller.java") diff --git a/src/main/resources/template/spring-data-mongodb/entity.java.vm b/src/main/resources/template/spring-data-mongodb/entity.java.vm new file mode 100644 index 0000000..b3d5e3a --- /dev/null +++ b/src/main/resources/template/spring-data-mongodb/entity.java.vm @@ -0,0 +1,31 @@ +##引入宏定义 +$!{define.vm} + +##使用宏定义设置回调(保存位置与文件后缀) +#save("/entity", ".java") + +##使用宏定义设置包后缀 +#setPackageSuffix("entity") + +##使用全局变量实现默认包导入 +$!{autoImport.vm} +import java.io.Serializable; + +##使用宏定义实现类注释信息 +#tableComment("实体类") +public class $!{tableInfo.name} implements Serializable { + private static final long serialVersionUID = $!tool.serial(); +#foreach($column in $tableInfo.fullColumn) + #if(${column.comment})/** + * ${column.comment} + */#end + + private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; +#end + +#foreach($column in $tableInfo.fullColumn) +##使用宏定义实现get,set方法 +#getSetMethod($column) +#end + +} diff --git a/src/main/resources/template/spring-data-mongodb/repository.java.vm b/src/main/resources/template/spring-data-mongodb/repository.java.vm index 887e48a..35d28ed 100644 --- a/src/main/resources/template/spring-data-mongodb/repository.java.vm +++ b/src/main/resources/template/spring-data-mongodb/repository.java.vm @@ -1,5 +1,5 @@ ##导入宏定义、设置包名、类名、文件名##导入宏定义 -$!define +$!{define.vm} #setPackageSuffix("repository") #setTableSuffix("Repository") #save("/repository", "Repository.java") @@ -27,4 +27,4 @@ import org.springframework.data.mongodb.repository.MongoRepository; */ public interface $!{tableName} extends MongoRepository<$entityShortType, $pkShortType> { -} \ No newline at end of file +} diff --git a/src/main/resources/template/spring-data-mongodb/service.java.vm b/src/main/resources/template/spring-data-mongodb/service.java.vm index 0d2c283..cfc9040 100644 --- a/src/main/resources/template/spring-data-mongodb/service.java.vm +++ b/src/main/resources/template/spring-data-mongodb/service.java.vm @@ -1,5 +1,5 @@ ##导入宏定义、设置包名、类名、文件名##导入宏定义 -$!define +$!{define.vm} #setPackageSuffix("service") #setTableSuffix("Service") #save("/service", "Service.java") @@ -30,7 +30,7 @@ import java.util.List; * @since $!time.currTime() */ public interface $!{tableName} { - + void save($entityShortType $entityVarName); void deleteById($pkShortType id); @@ -41,4 +41,4 @@ public interface $!{tableName} { Page<$entityShortType> list(Pageable page); -} \ No newline at end of file +} diff --git a/src/main/resources/template/spring-data-mongodb/serviceImpl.java.vm b/src/main/resources/template/spring-data-mongodb/serviceImpl.java.vm index 77a3955..ccdcf9f 100644 --- a/src/main/resources/template/spring-data-mongodb/serviceImpl.java.vm +++ b/src/main/resources/template/spring-data-mongodb/serviceImpl.java.vm @@ -1,5 +1,5 @@ ##导入宏定义、设置包名、类名、文件名 -$!define +$!{define.vm} #setPackageSuffix("service.impl") #setTableSuffix("ServiceImpl") #save("/service/impl", "ServiceImpl.java") @@ -73,4 +73,4 @@ public class $!{tableName} implements $!serviceSortType { return $!{repositoryVarName}.findAll(page); } -} \ No newline at end of file +} diff --git a/src/main/resources/typeMapper/Default.json b/src/main/resources/typeMapper/Default.json index 765529f..0a07174 100644 --- a/src/main/resources/typeMapper/Default.json +++ b/src/main/resources/typeMapper/Default.json @@ -44,6 +44,11 @@ "columnType": "bigint(\\(\\d+\\))?", "javaType": "java.lang.Long" }, + { + "matchType": "ORDINARY", + "columnType": "date", + "javaType": "java.util.Date" + }, { "matchType": "ORDINARY", "columnType": "datetime", @@ -54,6 +59,11 @@ "columnType": "timestamp", "javaType": "java.util.Date" }, + { + "matchType": "ORDINARY", + "columnType": "time", + "javaType": "java.time.LocalTime" + }, { "matchType": "ORDINARY", "columnType": "boolean",