1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| { "author" : "makejava", "version" : "1.2.8", "userSecure" : "", "currTypeMapperGroupName" : "Default", "currTemplateGroupName" : "JPA", "currColumnConfigGroupName" : "Default", "currGlobalConfigGroupName" : "Default", "typeMapper" : { }, "template" : { "JPA" : { "name" : "JPA", "elementList" : [ { "name" : "entity.java", "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/entity\"))\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}entity;\n##使用全局变量实现默认包导入\n#foreach($import in $importList)\nimport $!import;\n#end\nimport java.io.Serializable;\n\nimport io.swagger.annotations.ApiModelProperty;\nimport lombok.Data;\nimport javax.persistence.Column;\nimport javax.persistence.Entity;\nimport javax.persistence.Table;\nimport javax.persistence.Id;\n\n##使用宏定义实现类注释信息\n/**\n * $!{tableInfo.comment}实体类\n *\n * @author $!author\n * @date $!time.currTime(\"yyyy/MM/dd\")\n */\n@Data\n@Entity\n@Table(name = \"$!{tool.hump2Underline($!{tableInfo.name})}\")\npublic class $!{tableInfo.name} implements Serializable {\n\n private static final long serialVersionUID = $!{tool.serial()};\n \n /**\n * ${pk.comment}\n */\n @ApiModelProperty(value = \"${pk.comment}\")\n @Id\n private $!{pk.shortType} $!{pk.name};\n\n#foreach($column in $tableInfo.otherColumn)\n #if(${column.comment})/**\n * ${column.comment}\n */#end\n\n @ApiModelProperty(value = \"${column.comment}\")\n @Column\n private $!{tool.getClsNameByFullName($column.type)} $!{column.name};\n\n#end\n}" }, { "name" : "repository.java", "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Repository\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/repository\"))\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}repository;\n\nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};\n\nimport org.springframework.data.jpa.repository.JpaRepository;\nimport org.springframework.stereotype.Repository;\n/**\n * $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层\n *\n * @author $!author\n * @date $!time.currTime(\"yyyy/MM/dd\")\n */\n@Repository\npublic interface $!{tableName} extends JpaRepository<$!{tableInfo.name} ,$!pk.shortType>{\n\n\n}" }, { "name" : "service.java", "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}服务接口\n *\n * @author $!author\n * @date $!time.currTime(\"yyyy/MM/dd\")\n */\npublic interface $!{tableName} {\n /**\n * 创建$!{tableInfo.comment}\n *\n * @param $!tool.firstLowerCase($!{tableInfo.name}) $!{tableInfo.comment}\n * @return $!{tableInfo.comment}\n */\n $!{tableInfo.name} create$!{tableInfo.name}($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n /**\n * 删除$!{tableInfo.comment}\n *\n * @param $!pk.name $!{tableInfo.comment}的$!{pk.comment}\n */\n void delete$!{tableInfo.name}($!pk.shortType $!pk.name);\n\n /**\n * 获取$!{tableInfo.comment}列表\n *\n * @return $!{tableInfo.comment}列表\n */\n List<$!{tableInfo.name}> list$!{tableInfo.name}s();\n\n /**\n * 获取$!{tableInfo.comment}\n *\n * @param $!pk.name $!{tableInfo.comment}的$!{pk.comment}\n * @return $!{tableInfo.comment}\n */\n $!{tableInfo.name} get$!{tableInfo.name}($!pk.shortType $!pk.name);\n\n /**\n * 更新$!{tableInfo.comment}\n *\n * @param $!pk.name $!{tableInfo.comment}的$!{pk.comment}\n * @param $!tool.firstLowerCase($!{tableInfo.name}) $!{tableInfo.comment}\n * @return $!{tableInfo.comment}\n */\n $!{tableInfo.name} update$!{tableInfo.name}($!pk.shortType $!pk.name, $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));\n\n}" }, { "name" : "serviceImpl.java", "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}.repository.$!{tableInfo.name}Repository;\nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\nimport org.springframework.transaction.annotation.Transactional;\n\nimport java.util.List;\nimport java.util.Optional;\n\n/**\n * $!{tableInfo.comment}服务实现类\n *\n * @author $!author\n * @date $!time.currTime(\"yyyy/MM/dd\")\n */\n@Slf4j\n@Service\npublic class $!{tableName} implements $!{tableInfo.name}Service {\n\n @Autowired\n private $!{tableInfo.name}Repository $!tool.firstLowerCase($!{tableInfo.name})Repository;\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public $!{tableInfo.name} create$!{tableInfo.name}($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})){\n return $!{tool.firstLowerCase($!{tableInfo.name})}Repository.save($!{tool.firstLowerCase($!{tableInfo.name})});\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public void delete$!{tableInfo.name}($!pk.shortType $!pk.name){\n $!{tool.firstLowerCase($!{tableInfo.name})}Repository.deleteBy$!{tool.firstUpperCase($!{pk.name})}($!{pk.name});\n }\n\n @Override\n public List<$!{tableInfo.name}> list$!{tableInfo.name}s(){\n return $!{tool.firstLowerCase($!{tableInfo.name})}Repository.findAll();\n }\n\n @Override\n public $!{tableInfo.name} get$!{tableInfo.name}($!pk.shortType $!pk.name){\n Optional<$!{tableInfo.name}> optional = $!tool.append($!tool.firstLowerCase($!{tableInfo.name}),\"Repository.findBy\",\"$!tool.firstUpperCase($!pk.name)($!pk.name)\");\n if (!optional.isPresent()) {\n throw new RuntimeException();\n }\n return optional.get();\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public $!{tableInfo.name} update$!{tableInfo.name}($!pk.shortType $!pk.name, $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})){\n return $!{tool.firstLowerCase($!{tableInfo.name})}Repository.save($!tool.firstLowerCase($!{tableInfo.name}));\n }\n\n}" }, { "name" : "controller.java", "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 io.swagger.annotations.Api;\nimport io.swagger.annotations.ApiImplicitParam;\nimport io.swagger.annotations.ApiImplicitParams;\nimport io.swagger.annotations.ApiOperation;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\n\n/**\n * $!{tableInfo.comment}控制层\n *\n * @author $!author\n * @date $!time.currTime(\"yyyy/MM/dd\")\n */\n@Api(\"$!{tableInfo.comment}($!{tableInfo.name})服务\")\n@RestController\n@RequestMapping(\"icb/v1/$!tool.firstLowerCase($tableInfo.name)\")\npublic class $!{tableName} {\n\n @Autowired\n private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;\n\n @PostMapping(\"\")\n @ApiOperation(value = \"创建$!{tableInfo.comment}\", notes = \"创建$!{tableInfo.comment}\")\n @ApiImplicitParam(name = \"$!tool.firstLowerCase($!{tableInfo.name})\", value = \"$!{tableInfo.comment}\", dataType = \"$!{tableInfo.name}\", required = true, paramType = \"body\" )\n public $!{tableInfo.name} create$!{tableInfo.name}(@RequestBody $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})){\n return $!{tool.firstLowerCase($tableInfo.name)}Service.create$!{tableInfo.name}($!{tool.firstLowerCase($!{tableInfo.name})});\n }\n\n @DeleteMapping(\"/{$!pk.name}\")\n @ApiOperation(value = \"删除$!{tableInfo.comment}\", notes = \"删除$!{tableInfo.comment}\")\n @ApiImplicitParams(value = {\n @ApiImplicitParam(name = \"$!pk.name\", value = \"$!{tableInfo.comment}$!pk.name\", dataType = \"$!pk.shortType\", required = true, paramType = \"path\")\n })\n public void delete$!{tableInfo.name}(@PathVariable $!pk.shortType $!pk.name){\n $!{tool.firstLowerCase($tableInfo.name)}Service.delete$!{tableInfo.name}($!{pk.name});\n }\n\n @GetMapping(\"\")\n @ApiOperation(value = \"获取$!{tableInfo.comment}列表\", notes = \"获取$!{tableInfo.comment}列表\")\n public List<$!{tableInfo.name}> list$!{tableInfo.name}s(){\n return $!{tool.firstLowerCase($tableInfo.name)}Service.list$!{tableInfo.name}s();\n }\n\n @GetMapping(\"/{$!pk.name}\")\n @ApiOperation(value = \"获取$!{tableInfo.comment}\", notes = \"根据$!{pk.name}获取$!{tableInfo.comment}\")\n @ApiImplicitParams(value = {\n @ApiImplicitParam(name = \"$!pk.name\", value = \"$!{tableInfo.comment}$!pk.name\", dataType = \"$!pk.shortType\", required = true, paramType = \"path\")\n })\n public $!{tableInfo.name} get$!{tableInfo.name}(@PathVariable $!pk.shortType $!pk.name){\n return $!{tool.firstLowerCase($tableInfo.name)}Service.get$!{tableInfo.name}($!pk.name);\n }\n\n @PutMapping(\"/{$!pk.name}\")\n @ApiOperation(value = \"更新$!{tableInfo.comment}\", notes = \"更新$!{tableInfo.comment}\")\n @ApiImplicitParams(value = {\n @ApiImplicitParam(name = \"$!pk.name\", value = \"$!{tableInfo.comment}$!pk.name\", dataType = \"$!pk.shortType\", required = true, paramType = \"path\"),\n @ApiImplicitParam(name = \"$!tool.firstLowerCase($!{tableInfo.name})\", value = \"$!{tableInfo.comment}\", dataType = \"$!{tableInfo.name}\", required = true, paramType = \"body\")\n })\n public $!{tableInfo.name} update$!{tableInfo.name}(@PathVariable $!pk.shortType $!pk.name, @RequestBody $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})){\n return $!{tool.firstLowerCase($tableInfo.name)}Service.update$!{tableInfo.name}($!pk.name, $!tool.firstLowerCase($!{tableInfo.name}));\n }\n\n}" }, { "name" : "error.java", "code" : "##定义初始变量\n#set($tableName = $tool.append($tableInfo.name, \"Error\"))\n##设置回调\n$!callback.setFileName($tool.append($tableName, \".java\"))\n$!callback.setSavePath($tool.append($tableInfo.savePath, \"/error\"))\n\n#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}error;\n\n##使用全局变量实现默认包导入\nimport com.inspur.common.framework.utils.web.MessageSourceUtils;\nimport com.inspur.ipds.common.error.BaseError;\n##使用宏定义实现类注释信息\n/**\n * $!{tableInfo.comment}异常类\n *\n * @author $!author\n * @date $!time.currTime(\"yyyy/MM/dd\")\n */\npublic enum $!{tableInfo.name}Error implements BaseError{\n \n \n ;\n private String code;\n private String message;\n\n private $!{tableInfo.name}Error (String code, String message) {\n this.code = code;\n this.message = message;\n }\n\n\n @Override\n public String message(Object... args) {\n return MessageSourceUtils.getMessage(this.message, args);\n }\n\n @Override\n public String code() {\n return code;\n }\n\n\n}" } ] } }, "columnConfig" : { }, "globalConfig" : { } }
|