按项目分模块,避免配置冲突
This commit is contained in:
12
cemis/pom.xml
Normal file
12
cemis/pom.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.hncy.generator</groupId>
|
||||
<artifactId>code-generator</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cemis</artifactId>
|
||||
<name>cemis-code-generator</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
</project>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.optima.cemis.base.bean;
|
||||
package com.hncy.generator.zgf.base.bean;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.optima.cemis.base.bean;
|
||||
package com.hncy.generator.zgf.base.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.optima.cemis.base.entity.BaseEntity;
|
||||
import com.hncy.generator.zgf.base.entity.BaseEntity;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.optima.cemis.base.entity;
|
||||
package com.hncy.generator.zgf.base.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
@@ -2,7 +2,7 @@
|
||||
<% var serviceInstanceName = @cn.hutool.core.util.StrUtil.lowerFirst(table.serviceName); %>
|
||||
package ${package.Controller};
|
||||
|
||||
import com.optima.cemis.base.bean.CommonResult;
|
||||
import bean.com.hncy.generator.zgf.base.CommonResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
<% if(!restControllerStyle){ %>
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Controller;
|
||||
import ${superControllerClassPackage};
|
||||
<% } %>
|
||||
<% if(isNotEmpty(controllerMethods.list)){ %>
|
||||
import com.optima.cemis.base.bean.Page;
|
||||
import bean.com.hncy.generator.zgf.base.Page;
|
||||
<% } %>
|
||||
<% if(isNotEmpty(controllerMethods.hasMethod)){ %>
|
||||
import ${package.Service}.${table.serviceName};
|
||||
12
hncy4cloud-zgf/pom.xml
Normal file
12
hncy4cloud-zgf/pom.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.hncy.generator</groupId>
|
||||
<artifactId>code-generator</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hncy4cloud-zgf</artifactId>
|
||||
<name>hncy4cloud-zgf-code-generator</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.hncy4cloud.hncy.common.core.constant;
|
||||
|
||||
public interface CommonConstants {
|
||||
String STATUS_DEL = "1";
|
||||
String STATUS_NORMAL = "0";
|
||||
String STATUS_LOCK = "9";
|
||||
Long MENU_TREE_ROOT_ID = -1L;
|
||||
String MENU = "0";
|
||||
String UTF8 = "UTF-8";
|
||||
String CONTENT_TYPE = "application/json; charset=utf-8";
|
||||
String FRONT_END_PROJECT = "hncy-ui";
|
||||
String BACK_END_PROJECT = "hncy";
|
||||
Integer SUCCESS = 200;
|
||||
Integer FAIL = 500;
|
||||
String CURRENT = "current";
|
||||
String SIZE = "size";
|
||||
String REQUEST_START_TIME = "REQUEST-START-TIME";
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.hncy4cloud.hncy.common.core.util;
|
||||
|
||||
import com.hncy4cloud.hncy.common.core.constant.CommonConstants;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class R<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult((T) null, CommonConstants.SUCCESS, (String) null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, CommonConstants.SUCCESS, (String) null);
|
||||
}
|
||||
|
||||
public static <T> R<T> okMsg(String message) {
|
||||
return restResult((T) null, CommonConstants.SUCCESS, message);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, CommonConstants.SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed() {
|
||||
return restResult((T) null, CommonConstants.FAIL, (String) null);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(String msg) {
|
||||
return restResult((T) null, CommonConstants.FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data) {
|
||||
return restResult(data, CommonConstants.FAIL, (String) null);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data, String msg) {
|
||||
return restResult(data, CommonConstants.FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> result(T data, int code, String msg) {
|
||||
return restResult(data, code, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> apiResult = new R();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public Boolean isSuccess() {
|
||||
return this.code == CommonConstants.SUCCESS;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "R(code=" + this.getCode() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ")";
|
||||
}
|
||||
|
||||
public R() {
|
||||
}
|
||||
|
||||
public R(int code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public R<T> setCode(int code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
public R<T> setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public R<T> setData(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
55
hncy4cloud-zgf/src/test/java/GeberatorUIServer.java
Normal file
55
hncy4cloud-zgf/src/test/java/GeberatorUIServer.java
Normal file
@@ -0,0 +1,55 @@
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.github.davidfantasy.mybatisplus.generatorui.GeneratorConfig;
|
||||
import com.github.davidfantasy.mybatisplus.generatorui.MybatisPlusToolsApplication;
|
||||
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GeberatorUIServer {
|
||||
/**
|
||||
* 数据库相关配置
|
||||
*/
|
||||
private static final String dbName = "cgtf";
|
||||
private static final String url = "jdbc:mysql://38.147.185.130:3306/" + dbName + "?useUnicode=true&useSSL=false&characterEncoding=utf8";
|
||||
private static final String username = "root";
|
||||
private static final String password = "hncy@123";
|
||||
private static final String driverClassName = "com.mysql.cj.jdbc.Driver";
|
||||
|
||||
//项目父包名,service、controller等包会建在这个包下
|
||||
private static final String parent = "com.hncy.zgf.rota";
|
||||
//表名前缀,生成表时会删除
|
||||
private static final String tablePrefix = "rota_";
|
||||
|
||||
public static void main(String[] args) {
|
||||
GeneratorConfig config = GeneratorConfig.builder()
|
||||
.jdbcUrl(url)
|
||||
.userName(username)
|
||||
.password(password)
|
||||
.driverClassName(driverClassName)
|
||||
.dateType(DateType.TIME_PACK)
|
||||
//数据库schema,MSSQL,PGSQL,ORACLE,DB2类型的数据库需要指定
|
||||
//.schemaName("myBusiness")
|
||||
//数据库表前缀,生成entity名称时会去掉(v2.0.3新增)
|
||||
.tablePrefix(tablePrefix)
|
||||
.nameConverter(new NameConverter() {
|
||||
/**
|
||||
* 自定义Service类文件的名称规则
|
||||
*/
|
||||
@Override
|
||||
public String serviceNameConvert(String entityName) {
|
||||
return entityName + "Service";
|
||||
}
|
||||
})
|
||||
.templateVaribleInjecter(tableInfo -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("mapperAnnotationClass", org.apache.ibatis.annotations.Mapper.class);
|
||||
return map;
|
||||
})
|
||||
//所有生成的java文件的父包名,后续也可单独在界面上设置
|
||||
.basePackage(parent)
|
||||
.port(8068)
|
||||
.build();
|
||||
MybatisPlusToolsApplication.run(config);
|
||||
}
|
||||
}
|
||||
3
hncy4cloud-zgf/src/test/resources/application.yml
Normal file
3
hncy4cloud-zgf/src/test/resources/application.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
spring:
|
||||
mvc:
|
||||
static-path-pattern: /**
|
||||
111
hncy4cloud-zgf/src/test/resources/codetpls/controller.java.btl
Normal file
111
hncy4cloud-zgf/src/test/resources/codetpls/controller.java.btl
Normal file
@@ -0,0 +1,111 @@
|
||||
<% var entityInstanceName = @cn.hutool.core.util.StrUtil.lowerFirst(table.entityName); %>
|
||||
<% var serviceInstanceName = @cn.hutool.core.util.StrUtil.lowerFirst(table.serviceName); %>
|
||||
package ${package.Controller};
|
||||
|
||||
import com.hncy4cloud.hncy.common.core.util.R;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
<% if(!restControllerStyle){ %>
|
||||
import org.springframework.stereotype.Controller;
|
||||
<% } %>
|
||||
<% if(isNotEmpty(superControllerClassPackage)){ %>
|
||||
import ${superControllerClassPackage};
|
||||
<% } %>
|
||||
<% if(isNotEmpty(controllerMethods.list)){ %>
|
||||
|
||||
<% } %>
|
||||
<% if(isNotEmpty(controllerMethods.hasMethod)){ %>
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${package.Entity}.${table.entityName};
|
||||
|
||||
import javax.annotation.Resource;
|
||||
<% } %>
|
||||
import java.util.List;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ${table.comment!} 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
<% if(restControllerStyle){ %>
|
||||
@RestController
|
||||
<% }else{ %>
|
||||
@Controller
|
||||
<% } %>
|
||||
@RequestMapping("<% if(isNotEmpty(package.ModuleName)){ %>/${package.ModuleName}<% } %>/<% if(isNotEmpty(controllerMappingHyphenStyle)){ %>${controllerMappingHyphen}<% }else{ %>${table.entityPath}<% } %>")
|
||||
<% if(kotlin){ %>
|
||||
class ${table.controllerName}<% if(isNotEmpty(superControllerClass)){ %> : ${superControllerClass}()<% } %>
|
||||
<% }else{ %>
|
||||
<% if(isNotEmpty(superControllerClass)){ %>
|
||||
public class ${table.controllerName} extends ${superControllerClass} {
|
||||
<% }else{ %>
|
||||
public class ${table.controllerName} {
|
||||
<% } %>
|
||||
|
||||
<% if(isNotEmpty(controllerMethods.hasMethod)){ %>
|
||||
@Resource
|
||||
private ${table.serviceName} ${serviceInstanceName};
|
||||
<% } %>
|
||||
|
||||
<% if(isNotEmpty(controllerMethods.list)){ %>
|
||||
@GetMapping(value = "/list")
|
||||
<% if(!restControllerStyle){ %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
public R<List<${table.entityName}>> list(${table.entityName} ${entityInstanceName}) {
|
||||
R<List<${table.entityName}>> result = R.ok();
|
||||
return result.setData(${serviceInstanceName}.list(${entityInstanceName})).setMsg("查询成功");
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if(isNotEmpty(controllerMethods.getById)){ %>
|
||||
@GetMapping(value = "/{id}")
|
||||
<% if(!restControllerStyle){ %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
public R<${table.entityName}> detail(@PathVariable("id") Serializable id) {
|
||||
R<${table.entityName}> result = R.ok();
|
||||
return result.setData(${serviceInstanceName}.getById(id)).setMsg("查询成功");
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if(isNotEmpty(controllerMethods.create)){ %>
|
||||
<% if(!restControllerStyle){ %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@PostMapping(value = "/insert")
|
||||
public R<${table.entityName}> insert(${table.entityName} ${entityInstanceName}) {
|
||||
R<${table.entityName}> result = R.ok();
|
||||
${serviceInstanceName}.save(${entityInstanceName});
|
||||
return result.setData(${entityInstanceName}).setMsg("保存成功");
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if(isNotEmpty(controllerMethods.delete)){ %>
|
||||
@GetMapping(value = "/delete/{id}")
|
||||
<% if(!restControllerStyle){ %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
public R<Serializable> delete(@PathVariable("id") Serializable id) {
|
||||
R<Serializable> result = R.ok();
|
||||
${serviceInstanceName}.removeById(id);
|
||||
return result.setData(id).setMsg("删除成功");
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% if(isNotEmpty(controllerMethods.update)){ %>
|
||||
@PostMapping(value = "/update")
|
||||
<% if(!restControllerStyle){ %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
public R<${table.entityName}> update(${table.entityName} ${entityInstanceName}) {
|
||||
R<${table.entityName}> result = R.ok();
|
||||
${serviceInstanceName}.updateById(${entityInstanceName});
|
||||
return result.setData(${serviceInstanceName}.getById(${entityInstanceName}.getId())).setMsg("更新成功");
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
<% } %>
|
||||
53
hncy4cloud-zgf/src/test/resources/codetpls/dto.btl
Normal file
53
hncy4cloud-zgf/src/test/resources/codetpls/dto.btl
Normal file
@@ -0,0 +1,53 @@
|
||||
package ${config.pkg};
|
||||
<% for(pkg in config.importPackages){ %>
|
||||
import ${pkg};
|
||||
<% } %>
|
||||
<% if(config.enableLombok){ %>
|
||||
import lombok.Data;
|
||||
<% } %>
|
||||
/**
|
||||
* ${config.comment!}
|
||||
*
|
||||
* @author ${config.author}
|
||||
* @since ${config.createDate}
|
||||
*/
|
||||
<% if(config.enableLombok){ %>
|
||||
@Data
|
||||
<% } %>
|
||||
public class ${config.dtoName} {
|
||||
|
||||
<% /** -----------BEGIN 字段循环遍历----------- **/ %>
|
||||
<% for(field in config.fields){ %>
|
||||
<%/*字段定义*/%>
|
||||
private ${field.shortJavaType} ${field.propertyName};
|
||||
|
||||
<% } %>
|
||||
<% /** -----------END 字段循环遍历----------- **/ %>
|
||||
<% if(!config.enableLombok){ %>
|
||||
<% for(field in config.fields){ %>
|
||||
public ${field.shortJavaType} ${field.getMethodName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
public void ${field.setMethodName}(${field.shortJavaType} ${field.propertyName}) {
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
}
|
||||
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(!config.enableLombok){ %>
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${config.dtoName}{" +
|
||||
<% for(field in config.fields){ %>
|
||||
<% if(fieldLP.index==0){ %>
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
<% }else{ %>
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
<% } %>
|
||||
<% } %>
|
||||
"}";
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
173
hncy4cloud-zgf/src/test/resources/codetpls/entity.java.btl
Normal file
173
hncy4cloud-zgf/src/test/resources/codetpls/entity.java.btl
Normal file
@@ -0,0 +1,173 @@
|
||||
package ${package.Entity};
|
||||
|
||||
<% for(pkg in table.importPackages){ %>
|
||||
import ${pkg};
|
||||
<% } %>
|
||||
<% if(springdoc){ %>
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
<% }else if(swagger){ %>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
<% } %>
|
||||
<% if(entityLombokModel){ %>
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
<% if(chainModel){ %>
|
||||
import lombok.experimental.Accessors;
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ${table.comment!}
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
<% if(entityLombokModel){ %>
|
||||
@Getter
|
||||
@Setter
|
||||
<% if(chainModel){ %>
|
||||
@Accessors(chain = true)
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(table.convert){ %>
|
||||
@TableName("${schemaName}${table.name}")
|
||||
<% } %>
|
||||
<% if(springdoc){ %>
|
||||
@Schema(name = "${entity}", description = "$!{table.comment}")
|
||||
<% }else if(swagger){ %>
|
||||
@ApiModel(value = "${entity}对象", description = "${table.comment!''}")
|
||||
<% } %>
|
||||
<% if(isNotEmpty(superEntityClass)){ %>
|
||||
public class ${entity} extends ${superEntityClass}<% if(activeRecord){ %><${entity}><%}%> {
|
||||
<% }else if(activeRecord){ %>
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
<% }else if(entitySerialVersionUID){ %>
|
||||
public class ${entity} implements Serializable {
|
||||
<% }else{ %>
|
||||
public class ${entity} {
|
||||
<% } %>
|
||||
<% if(entitySerialVersionUID){ %>
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<% } %>
|
||||
<% var keyPropertyName; %>
|
||||
<% /** -----------BEGIN 字段循环遍历----------- **/ %>
|
||||
<% for(field in table.fields){ %>
|
||||
<%
|
||||
if(field.keyFlag){
|
||||
keyPropertyName = field.propertyName;
|
||||
}
|
||||
%>
|
||||
<% if(isNotEmpty(field.comment)){ %>
|
||||
|
||||
<% if(springdoc){ %>
|
||||
@Schema(description = "${field.comment}")
|
||||
<% }else if(swagger){ %>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<% }else{ %>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(field.keyFlag){ %>
|
||||
<%
|
||||
/*主键*/
|
||||
%>
|
||||
<% if(field.keyIdentityFlag){ %>
|
||||
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
||||
<% }else if(isNotEmpty(idType)){ %>
|
||||
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
||||
<% }else if(field.convert){ %>
|
||||
@TableId("${field.annotationColumnName}")
|
||||
<% } %>
|
||||
<%
|
||||
/*普通字段*/
|
||||
%>
|
||||
<% }else if(isNotEmpty(field.fill)){ %>
|
||||
<% if(field.convert){ %>
|
||||
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
||||
<% }else{ %>
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
<% } %>
|
||||
<% }else if(field.convert){ %>
|
||||
@TableField("${field.annotationColumnName}")
|
||||
<% } %>
|
||||
<%
|
||||
/*乐观锁注解*/
|
||||
%>
|
||||
<% if(field.versionField){ %>
|
||||
@Version
|
||||
<% } %>
|
||||
<%
|
||||
/*逻辑删除注解*/
|
||||
%>
|
||||
<% if(field.logicDeleteField){ %>
|
||||
@TableLogic
|
||||
<% } %>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
<% } %>
|
||||
<% /** -----------END 字段循环遍历----------- **/ %>
|
||||
<% if(!entityLombokModel){ %>
|
||||
<% for(field in table.fields){ %>
|
||||
<%
|
||||
var getprefix ='';
|
||||
if(field.propertyType=='boolean'){
|
||||
getprefix='is';
|
||||
}else{
|
||||
getprefix='get';
|
||||
}
|
||||
%>
|
||||
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<% if(chainModel){ %>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<% }else{ %>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<% } %>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<% if(chainModel){ %>
|
||||
return this;
|
||||
<% } %>
|
||||
}
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(entityColumnConstant){ %>
|
||||
<% for(field in table.fields){ %>
|
||||
|
||||
public static final String ${strutil.toUpperCase(field.name)} = "${field.name}";
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(activeRecord){ %>
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
<% if(isNotEmpty(keyPropertyName)){ %>
|
||||
return this.${keyPropertyName};
|
||||
<% }else{ %>
|
||||
return super.pkVal();
|
||||
<% } %>
|
||||
}
|
||||
<% } %>
|
||||
<% if(!entityLombokModel){ %>
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
<% for(field in table.fields){ %>
|
||||
<% if(fieldLP.index==0){ %>
|
||||
"${field.propertyName} = " + ${field.propertyName} +
|
||||
<% }else{ %>
|
||||
", ${field.propertyName} = " + ${field.propertyName} +
|
||||
<% } %>
|
||||
<% } %>
|
||||
"}";
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
26
hncy4cloud-zgf/src/test/resources/codetpls/mapper.java.btl
Normal file
26
hncy4cloud-zgf/src/test/resources/codetpls/mapper.java.btl
Normal file
@@ -0,0 +1,26 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superMapperClassPackage};
|
||||
<% if(mapperAnnotationClass!=null){ %>
|
||||
import ${mapperAnnotationClass.name};
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ${table.comment!} Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
<% if(mapperAnnotationClass!=null){ %>
|
||||
@${mapperAnnotationClass.simpleName}
|
||||
<% } %>
|
||||
<% if(kotlin){ %>
|
||||
interface ${table.mapperName} : ${superMapperClass}<${entity}>
|
||||
<% }else{ %>
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
|
||||
}
|
||||
<% } %>
|
||||
41
hncy4cloud-zgf/src/test/resources/codetpls/mapper.xml.btl
Normal file
41
hncy4cloud-zgf/src/test/resources/codetpls/mapper.xml.btl
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
||||
|
||||
<% if(enableCache){ %>
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="${cacheClassName}"/>
|
||||
|
||||
<% } %>
|
||||
<% if(baseResultMap){ %>
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
||||
<% for(field in table.fields){ %>
|
||||
<% /** 生成主键排在第一位 **/ %>
|
||||
<% if(field.keyFlag){ %>
|
||||
<id column="${field.name}" property="${field.propertyName}" />
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% for(field in table.commonFields){ %>
|
||||
<% /** 生成公共字段 **/ %>
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
<% } %>
|
||||
<% for(field in table.fields){ %>
|
||||
<% /** 生成普通字段 **/ %>
|
||||
<% if(!field.keyFlag){ %>
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
<% } %>
|
||||
<% } %>
|
||||
</resultMap>
|
||||
<% } %>
|
||||
<% if(baseColumnList){ %>
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
<% for(field in table.commonFields){ %>
|
||||
${field.columnName},
|
||||
<% } %>
|
||||
${table.fieldNames}
|
||||
</sql>
|
||||
|
||||
<% } %>
|
||||
</mapper>
|
||||
10
hncy4cloud-zgf/src/test/resources/codetpls/mapperMethods.btl
Normal file
10
hncy4cloud-zgf/src/test/resources/codetpls/mapperMethods.btl
Normal file
@@ -0,0 +1,10 @@
|
||||
<% if(elementType == 'select'){ %>
|
||||
<% if(config.resultMap != null){ %>
|
||||
<select id="${config.mapperElementId}" resultMap="${config.resultMap}">
|
||||
<% }%>
|
||||
<% if(config.resultMap == null){ %>
|
||||
<select id="${config.mapperElementId}" resultType="${config.resultType}">
|
||||
<% }%>
|
||||
${sql}
|
||||
</select>
|
||||
<% } %>
|
||||
3
hncy4cloud-zgf/src/test/resources/codetpls/resultMap.btl
Normal file
3
hncy4cloud-zgf/src/test/resources/codetpls/resultMap.btl
Normal file
@@ -0,0 +1,3 @@
|
||||
<resultMap id="${config.dtoName}Map" type="${config.fullPackage}">
|
||||
<% for(field in config.fields){ %><result column="${field.columnName}" property="${field.propertyName}" /><% } %>
|
||||
</resultMap>
|
||||
22
hncy4cloud-zgf/src/test/resources/codetpls/service.java.btl
Normal file
22
hncy4cloud-zgf/src/test/resources/codetpls/service.java.btl
Normal file
@@ -0,0 +1,22 @@
|
||||
package ${package.Service};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superServiceClassPackage};
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ${table.comment!} 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
<% if(kotlin){ %>
|
||||
interface ${table.serviceName} : ${superServiceClass}<${entity}>
|
||||
<% }else{ %>
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
||||
List<${table.entityName}> list(${table.entityName} ${table.entityPath});
|
||||
}
|
||||
<% } %>
|
||||
@@ -0,0 +1,35 @@
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
<% if(table.serviceInterface){ %>
|
||||
import ${package.Service}.${table.serviceName};
|
||||
<% } %>
|
||||
import ${superServiceImplClassPackage};
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ${table.comment!} 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
<% if(kotlin){ %>
|
||||
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>()<% if(table.serviceInterface){ %>, ${table.serviceName}<% } %> {
|
||||
|
||||
}
|
||||
<% }else{ %>
|
||||
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}><% if(table.serviceInterface){ %> implements ${table.serviceName}<% } %> {
|
||||
@Override
|
||||
public List<${table.entityName}> list(${table.entityName} ${table.entityPath}) {
|
||||
LambdaQueryWrapper<${table.entityName}> wrapper = new LambdaQueryWrapper<>();
|
||||
return this.list(wrapper);
|
||||
}
|
||||
}
|
||||
<% } %>
|
||||
36
pom.xml
36
pom.xml
@@ -2,11 +2,16 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.optima.cemis</groupId>
|
||||
<artifactId>cemis-code-generator</artifactId>
|
||||
<groupId>com.hncy.generator</groupId>
|
||||
<artifactId>code-generator</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>cemis-code-generator</name>
|
||||
<description>cemis-code-generator</description>
|
||||
<modules>
|
||||
<module>cemis</module>
|
||||
<module>hncy4cloud-zgf</module>
|
||||
</modules>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-boot.version>2.7.18</spring-boot.version>
|
||||
@@ -92,4 +97,31 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>hncy-release</id>
|
||||
<name>Release Repository</name>
|
||||
<url>http://hncy.info/nexus/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>osgeo</id>
|
||||
<name>OSGeo Release Repository</name>
|
||||
<url>https://repo.osgeo.org/repository/release/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user