零、火人在球 感谢同事昊工!在线教学
一、IDEA安装插件
从 setting 里面安装easycode,然后导入这个配置
二、配置内容
配置内容:EasyCodeConfig.json
{"author":"wuhao8","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"},{"matchType":"REGEX","columnType":"decimal(\(\d+\))?","javaType":"java.lang.Double"}]}},"template":{"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#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;nnimport $!{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.*;nnimport javax.annotation.Resource;nnn@RestControllern@RequestMapping("$!tool.firstLowerCase($tableInfo.name)")npublic class $!{tableName} {n n @Resourcen private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;nn n @GetMappingn 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 }nn 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 }nn n @PostMappingn 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 }nn n @PutMappingn 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 }nn n @DeleteMappingn public ResponseEntity deleteById($!pk.shortType id) {n return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id));n }nn}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"))nn##拿到主键n#if(!$tableInfo.pkColumn.isEmpty())n #set($pk = $tableInfo.pkColumn.get(0))n#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;nnimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};nimport org.apache.ibatis.annotations.Param;nimport org.springframework.data.domain.Pageable;nimport java.util.List;nnnpublic interface $!{tableName} {nn n $!{tableInfo.name} queryById($!pk.shortType $!pk.name);nn n List<$!{tableInfo.name}> queryAllByLimit($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), @Param("pageable") Pageable pageable);nn n long count($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n int insertBatch(@Param("entities") List<$!{tableInfo.name}> entities);nn n int insertOrUpdateBatch(@Param("entities") List<$!{tableInfo.name}> entities);nn n int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n int deleteById($!pk.shortType $!pk.name);nn}n"},{"name":"debug.json.vm","code":"// 禁止将生成结果写入到文件n##$!callback.setWriteFile(false)nn//调试表原始对象n##$!tool.debug($tableInfo.obj)nn//调试列原始对象n##$!tool.debug($tableInfo.fullColumn.get(0).obj)nn//调试列原始列类型n##$!tool.debug($tableInfo.fullColumn.get(0).obj)nn//获取原始列类型中的字段n##sqlType = $!tool.getField($tableInfo.fullColumn.get(0).obj.dataType, "typeName")nn//执行原始列类型中的方法nsqlTypeLen = $!tableInfo.fullColumn.get(1).obj.namen"},{"name":"entity.java.vm","code":"##引入宏定义n$!{define.vm}nn##使用宏定义设置回调(保存位置与文件后缀)n#save("/entity", ".java")nn##使用宏定义设置包后缀n#setPackageSuffix("entity")nn##使用全局变量实现默认包导入n$!{autoimport.vm}nimport java.io.Serializable;nn##使用宏定义实现类注释信息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})#endnn private $!{tool.getClsNameByFullName($column.type)} $!{column.obj.name};n#endnn#foreach($column in $tableInfo.fullColumn)n##使用宏定义实现get,set方法n#getSetMethod($column)n#endn}n"},{"name":"mapper.xml.vm","code":"##引入mybatis支持n$!{mybatisSupport.vm}nn##设置保存名称与保存位置n$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))n$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))nn##拿到主键n#if(!$tableInfo.pkColumn.isEmpty())n #set($pk = $tableInfo.pkColumn.get(0))n#endnnnn nn 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"))nn##拿到主键n#if(!$tableInfo.pkColumn.isEmpty())n #set($pk = $tableInfo.pkColumn.get(0))n#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;nnimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};nimport org.springframework.data.domain.Page;nimport org.springframework.data.domain.PageRequest;nnnpublic interface $!{tableName} {nn n $!{tableInfo.name} queryById($!pk.shortType $!pk.name);nn n Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), PageRequest pageRequest);nn n $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n boolean deleteById($!pk.shortType $!pk.name);nn}"},{"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"))nn##拿到主键n#if(!$tableInfo.pkColumn.isEmpty())n #set($pk = $tableInfo.pkColumn.get(0))n#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;nnimport $!{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;nimport org.slf4j.Logger;nimport org.slf4j.LoggerFactory;nimport javax.annotation.Resource;nnn@Service("$!tool.firstLowerCase($!{tableInfo.name})Service")npublic class $!{tableName} implements $!{tableInfo.name}Service {n public static final Logger logger = LoggerFactory.getLogger($!{tableName}.class);n @Resourcen private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;nn n @Overriden public $!{tableInfo.name} queryById($!pk.shortType $!pk.name) {n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);n }nn n @Overriden 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 }nn n @Overriden 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 }nn n @Overriden 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 }nn n @Overriden public boolean deleteById($!pk.shortType $!pk.name) {n return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name) > 0;n }n}"},{"name":"demo.java.vm","code":"##引入宏定义n$!{define.vm}nn##使用宏定义设置回调(保存位置与文件后缀)n#save("/entity", ".java")nn##使用宏定义设置包后缀n#setPackageSuffix("entity")nn##使用全局变量实现默认包导入n$!{autoimport.vm}nimport java.io.Serializable;nn##使用宏定义实现类注释信息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})#endn private $!{tool.getClsNameByFullName($column.type)} $!{column.name};n#endnn}n"},{"name":"serviceImpl-warroom.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"))nn##拿到主键n#if(!$tableInfo.pkColumn.isEmpty())n #set($pk = $tableInfo.pkColumn.get(0))n#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;nnimport $!{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.slf4j.Logger;nimport org.slf4j.LoggerFactory;nimport javax.annotation.Resource;nimport com.cicccrm.webapp.bussiness.system.model.CurrentUser;nimport com.cicccrm.webapp.common.util.SessionHelper;nimport com.github.pagehelper.PageHelper;nimport com.github.pagehelper.PageInfo;nimport com.cicccrm.webapp.common.util.IdUtil;nimport org.springframework.beans.factory.annotation.Autowired;nimport java.util.*;nn@Service("$!tool.firstLowerCase($!{tableInfo.name})Service")npublic class $!{tableName} implements $!{tableInfo.name}Service {n public static final Logger logger = LoggerFactory.getLogger($!{tableName}.class);n //private static final String PLAN_TYPE_SRMB = "0";n @Autowiredn SqlSession sqlSession;nn n @Overriden public $!{tableInfo.name} queryById($!pk.shortType $!pk.obj.name) {n //return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);nttreturn sqlSession.selectone("$!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao.queryById",$!pk.obj.name);n }nn n @Overriden public PageInfo<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, Integer pageSize, Integer pageNumber) {n CurrentUser currentUser = SessionHelper.getCurrentUser();n HashMapn#foreach($column in $tableInfo.fullColumn)n nn nn#endn params = new HashMap<>();n //TODOn PageHelper.startPage(pageNumber, pageSize);n PageInfo<$!{tableInfo.name}> businessList = new PageInfo<>(sqlSession.selectList("$!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao.queryAllByLimit", params));n }nn n @Overriden public $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {n String $!pk.obj.name = IdUtil.getGuid32();n $!tool.append($!tool.firstLowerCase($!{tableInfo.name}),".set",$!tool.firstUpperCase($!pk.obj.name),"(",$!pk.obj.name,")",";")nsqlSession.selectone("$!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao.insert",$!tool.firstLowerCase($!{tableInfo.name}));n return $!tool.firstLowerCase($!{tableInfo.name});n }nn n @Overriden public $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {n //TODOn sqlSession.update("$!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao.update",$!tool.firstLowerCase($!{tableInfo.name}));n return null;n }nn n @Overriden public boolean deleteById($!pk.shortType $!pk.obj.name) {n //TODOn return sqlSession.delete("$!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao.deleteById",$!pk.obj.name);n }n}"},{"name":"service-warroom.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"))nn##拿到主键n#if(!$tableInfo.pkColumn.isEmpty())n #set($pk = $tableInfo.pkColumn.get(0))n#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;nnimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};nimport com.github.pagehelper.PageInfo;nnnpublic interface $!{tableName} {nn n $!{tableInfo.name} queryById($!pk.shortType $!pk.obj.name);nn n PageInfo<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}),Integer pageSize, Integer pageNumber );nn n $!{tableInfo.name} insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));nn n boolean deleteById($!pk.shortType $!pk.obj.name);nn}"},{"name":"controller-warroom.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#endnn#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;nimport com.cicccrm.webapp.annotation.ApiVersion;nimport com.cicccrm.webapp.annotation.NeedLog;nimport $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};nimport $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;nimport com.cicccrm.webapp.common.model.ApibaseMessage;nimport com.github.pagehelper.PageInfo;nimport io.swagger.annotations.Api;nimport io.swagger.annotations.ApiOperation;nimport org.springframework.beans.factory.annotation.Autowired;nimport org.springframework.http.ResponseEntity;nimport org.springframework.web.bind.annotation.*;nnnn@RestControllern@RequestMapping("/$!tool.firstLowerCase($tableInfo.name)")n@Api(value = "/$!tool.firstLowerCase($tableInfo.name)", description = "")npublic class $!{tableName} {n n @Autowiredn private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;nn n @ApiVersion({ApiVersionConstant.ONE_CRM_SPRINT_16})n @ApiOperation(value = "")n @NeedLog(value = "")n @GetMappingn public ApibaseMessage queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)},Integer pageSize, Integer pageNumber) {n return ApibaseMessage.getOperationSucceedInstance(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryByPage($!{tool.firstLowerCase($tableInfo.name)}, pageSize,pageNumber));n }nn n @GetMapping("{$!pk.obj.name}")n public ApibaseMessage queryById(@PathVariable("$!pk.obj.name") $!pk.shortType $!pk.obj.name) {n return ApibaseMessage.getOperationSucceedInstance(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById($!pk.obj.name));n }nn n @PostMappingn public ApibaseMessage add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {n return ApibaseMessage.getOperationSucceedInstance(this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)}));n }nn n @PostMappingn public ApibaseMessage edit($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {n return ApibaseMessage.getOperationSucceedInstance(this.$!{tool.firstLowerCase($tableInfo.name)}Service.update($!{tool.firstLowerCase($tableInfo.name)}));n }nn n @PostMappingn public ApibaseMessage deleteById($!pk.shortType $!pk.obj.name) {n return ApibaseMessage.getOperationSucceedInstance(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById($!pk.obj.name));n }nn}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宏定义)nn##定义设置表名后缀的宏定义,调用方式:#setTableSuffix("Test")n#macro(setTableSuffix $suffix)n #set($tableName = $!tool.append($tableInfo.name, $suffix))n#endnn##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix("Test")n#macro(setPackageSuffix $suffix)n#if($suffix!="")package #end#if($tableInfo.savePackageName!="")$!{tableInfo.savePackageName}.#{end}$!suffix;n#endnn##定义直接保存路径与文件名简化的宏定义,调用方式:#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#endnn##定义表注释的宏定义,调用方式:#tableComment("注释信息")n#macro(tableComment $desc)nn#endnn##定义GET,SET方法的宏定义,调用方式:#getSetMethod($column)n#macro(getSetMethod $column)nn public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.obj.name)}() {n return $!{column.obj.name};n }nn public void set$!{tool.firstUpperCase($column.obj.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.obj.name}) {n this.$!{column.obj.name} = $!{column.obj.name};n }n#end"},{"name":"init.vm","value":"##初始化区域nn##去掉表的t_前缀n$!tableInfo.setName($tool.getClassName($tableInfo.obj.name.replaceFirst("book_","")))nn##参考阿里巴巴开发手册,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#endn#endnn##实现动态排除列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 #endn #endn ##重新保存n $tableInfo.setFullColumn($newList)n#endnn##对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 #endn#endn##覆盖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 #elsen ##其他类型n #set($jdbcType="VARCHAR")n #endn $tool.call($column.ext.put("jdbcType", $jdbcType))n#endnn##定义宏,查询所有列n#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($velocityHasNext), #end#end#endn"}]}}}
三、使用
选择生成代码路径
生成文件即可。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)