Initial commit
This commit is contained in:
@@ -0,0 +1,283 @@
|
||||
<%
|
||||
var serviceIns = strutil.toLowerCase(strutil.subStringTo(table.serviceName, 0, 1)) + strutil.subString(table.serviceName, 1);
|
||||
var authPre = package.ModuleName + ':' + table.entityPath;
|
||||
var idFieldName, idPropertyName;
|
||||
for(field in table.fields) {
|
||||
if(field.keyFlag) {
|
||||
idFieldName = field.name;
|
||||
idPropertyName = field.propertyName;
|
||||
}
|
||||
}
|
||||
%>
|
||||
package ${package.Controller};
|
||||
|
||||
<% if(isNotEmpty(superControllerClassPackage)) { %>
|
||||
import ${superControllerClassPackage};
|
||||
<% } %>
|
||||
import ${cfg.packageName!}.${package.ModuleName}.service.${entity}Service;
|
||||
import ${cfg.packageName!}.${package.ModuleName}.entity.${entity};
|
||||
import ${cfg.packageName!}.${package.ModuleName}.param.${entity}Param;
|
||||
import ${cfg.packageName!}.common.core.web.ApiResult;
|
||||
import ${cfg.packageName!}.common.core.web.PageResult;
|
||||
import ${cfg.packageName!}.common.core.web.PageParam;
|
||||
import ${cfg.packageName!}.common.core.web.BatchParam;
|
||||
import ${cfg.packageName!}.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
<% if(!restControllerStyle) { %>
|
||||
import org.springframework.stereotype.Controller;
|
||||
<% } %>
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!}控制器
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date(), 'yyyy-MM-dd HH:mm:ss'}
|
||||
*/
|
||||
<% if(swagger2) { %>
|
||||
@Api(tags = "${table.comment!}管理")
|
||||
<% } %>
|
||||
<% if(restControllerStyle) { %>
|
||||
@RestController
|
||||
<% } else { %>
|
||||
@Controller
|
||||
<% } %>
|
||||
@RequestMapping("${cfg.controllerMappingPrefix!}<% 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} {
|
||||
<% } %>
|
||||
@Resource
|
||||
private ${table.serviceName} ${serviceIns};
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 分页查询${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:list')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("分页查询${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<${entity}>> page(${entity}Param param) {
|
||||
PageParam<${entity}, ${entity}Param> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(${serviceIns}.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(${serviceIns}.pageRel(param));
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 查询全部${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:list')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("查询全部${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@GetMapping()
|
||||
public ApiResult<List<${entity}>> list(${entity}Param param) {
|
||||
PageParam<${entity}, ${entity}Param> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(${serviceIns}.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(${serviceIns}.listRel(param));
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 根据id查询${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询${table.comment!}")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<${entity}> get(@PathVariable("id") Integer id) {
|
||||
return success(${serviceIns}.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(${serviceIns}.getByIdRel(id));
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 添加${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:save')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("添加${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ${entity} ${table.entityPath}) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
${table.entityPath}.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (${serviceIns}.save(${table.entityPath})) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 修改${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:update')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("修改${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ${entity} ${table.entityPath}) {
|
||||
if (${serviceIns}.updateById(${table.entityPath})) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 删除${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:remove')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("删除${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (${serviceIns}.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 批量添加${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:save')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("批量添加${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<${entity}> list) {
|
||||
if (${serviceIns}.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 批量修改${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:update')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("批量修改${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<${entity}> batchParam) {
|
||||
if (batchParam.update(${serviceIns}, "${idFieldName!}")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
<% if(!swagger2) { %>
|
||||
/**
|
||||
* 批量删除${table.comment!}
|
||||
*/
|
||||
<% } %>
|
||||
<% if(cfg.authAnnotation) { %>
|
||||
@PreAuthorize("hasAuthority('${authPre}:remove')")
|
||||
<% } %>
|
||||
<% if(cfg.logAnnotation) { %>
|
||||
@OperationLog
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiOperation("批量删除${table.comment!}")
|
||||
<% } %>
|
||||
<% if(!restControllerStyle) { %>
|
||||
@ResponseBody
|
||||
<% } %>
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (${serviceIns}.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package ${package.Entity};
|
||||
|
||||
<% for(pkg in table.importPackages) { %>
|
||||
import ${pkg};
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
<% } %>
|
||||
<% if(entityLombokModel) { %>
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
<% if(chainModel) { %>
|
||||
import lombok.experimental.Accessors;
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* ${table.comment!}
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date(), 'yyyy-MM-dd HH:mm:ss'}
|
||||
*/
|
||||
<% if(entityLombokModel) { %>
|
||||
@Data
|
||||
<% if(isNotEmpty(superEntityClass)) { %>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
<% } else { %>
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
<% } %>
|
||||
<% if(chainModel) { %>
|
||||
@Accessors(chain = true)
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiModel(value = "${entity}对象", description = "${table.comment!''}")
|
||||
<% } %>
|
||||
<% if(table.convert) { %>
|
||||
@TableName("${table.name}")
|
||||
<% } %>
|
||||
<% if(isNotEmpty(superEntityClass)) { %>
|
||||
public class ${entity} extends ${superEntityClass}<% if(activeRecord) { %><${entity}><% } %>{
|
||||
<% } else if(activeRecord) { %>
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
<% } else { %>
|
||||
public class ${entity} implements Serializable {
|
||||
<% } %>
|
||||
<% if(entitySerialVersionUID) { %>
|
||||
private static final long serialVersionUID = 1L;
|
||||
<% } %>
|
||||
<% /** -----------BEGIN 字段循环遍历----------- **/ %>
|
||||
<% for(field in table.fields) { %>
|
||||
<%
|
||||
var keyPropertyName;
|
||||
if(field.keyFlag) {
|
||||
keyPropertyName = field.propertyName;
|
||||
}
|
||||
%>
|
||||
|
||||
<% if(isNotEmpty(field.comment)) { %>
|
||||
<% if(swagger2) { %>
|
||||
@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(versionFieldName!'' == field.name) { %>
|
||||
@Version
|
||||
<% } %>
|
||||
<% /* 逻辑删除注解 */ %>
|
||||
<% if(logicDeleteFieldName!'' == field.name) { %>
|
||||
@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
|
||||
protected Serializable pkVal() {
|
||||
<% if(isNotEmpty(keyPropertyName)){ %>
|
||||
return this.${keyPropertyName};
|
||||
<% }else{ %>
|
||||
return null;
|
||||
<% } %>
|
||||
}
|
||||
|
||||
<% } %>
|
||||
<% 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} +
|
||||
<% } %>
|
||||
<% } %>
|
||||
"}";
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import ${superMapperClassPackage};
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${cfg.packageName!}.${package.ModuleName}.param.${entity}Param;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!}Mapper
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date(), 'yyyy-MM-dd HH:mm:ss'}
|
||||
*/
|
||||
<% if(kotlin){ %>
|
||||
interface ${table.mapperName} : ${superMapperClass}<${entity}>
|
||||
<% }else{ %>
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<${entity}>
|
||||
*/
|
||||
List<${entity}> selectPageRel(@Param("page") IPage<${entity}> page,
|
||||
@Param("param") ${entity}Param param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<${entity}> selectListRel(@Param("param") ${entity}Param param);
|
||||
|
||||
}
|
||||
<% } %>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
<% } %>
|
||||
<% 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>
|
||||
<% } %>
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM ${table.name} a
|
||||
<where>
|
||||
<% for(field in table.fields) { %>
|
||||
<% if(field.keyFlag) { %>
|
||||
<% /** 主键字段 **/ %>
|
||||
<if test="param.${field.propertyName} != null">
|
||||
AND a.${field.name} = #{param.${field.propertyName}}
|
||||
</if>
|
||||
<% } else if(field.name == logicDeleteFieldName) { %>
|
||||
<% /** 逻辑删除字段 **/ %>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<% } else if(field.name == 'create_time') { %>
|
||||
<% /** 创建时间字段 **/ %>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<% } else if(array.contain(cfg.paramExcludeFields, field.name)) { %>
|
||||
<% /** 排除的字段 **/ %>
|
||||
<% } else if(array.contain(cfg.paramEqType, field.propertyType)) { %>
|
||||
<% /** 使用EQ的字段 **/ %>
|
||||
<if test="param.${field.propertyName} != null">
|
||||
AND a.${field.name} = #{param.${field.propertyName}}
|
||||
</if>
|
||||
<% } else { %>
|
||||
<% /** 其它类型使用LIKE **/ %>
|
||||
<if test="param.${field.propertyName} != null">
|
||||
AND a.${field.name} LIKE CONCAT('%', #{param.${field.propertyName}}, '%')
|
||||
</if>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="${package.Entity}.${entity}">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="${package.Entity}.${entity}">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,146 @@
|
||||
package ${cfg.packageName!}.${package.ModuleName}.param;
|
||||
|
||||
import ${cfg.packageName!}.common.core.annotation.QueryField;
|
||||
import ${cfg.packageName!}.common.core.annotation.QueryType;
|
||||
import ${cfg.packageName!}.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
<% if(swagger2) { %>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
<% } %>
|
||||
<% if(entityLombokModel) { %>
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
<% if(chainModel) { %>
|
||||
import lombok.experimental.Accessors;
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
/**
|
||||
* ${table.comment!}查询参数
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date(), 'yyyy-MM-dd HH:mm:ss'}
|
||||
*/
|
||||
<% if(entityLombokModel) { %>
|
||||
@Data
|
||||
<% if(isNotEmpty(superEntityClass)) { %>
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
<% } else { %>
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
<% } %>
|
||||
<% if(chainModel) { %>
|
||||
@Accessors(chain = true)
|
||||
<% } %>
|
||||
<% } %>
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
<% if(swagger2) { %>
|
||||
@ApiModel(value = "${entity}Param对象", description = "${table.comment!''}查询参数")
|
||||
<% } %>
|
||||
public class ${entity}Param extends BaseParam {
|
||||
<% if(entitySerialVersionUID) { %>
|
||||
private static final long serialVersionUID = 1L;
|
||||
<% } %>
|
||||
<% /** -----------BEGIN 字段循环遍历----------- **/ %>
|
||||
<% for(field in table.fields) { %>
|
||||
<%
|
||||
var keyPropertyName;
|
||||
if(field.keyFlag) {
|
||||
keyPropertyName = field.propertyName;
|
||||
}
|
||||
// 排除的字段
|
||||
if(array.contain(cfg.paramExcludeFields, field.name)) {
|
||||
continue;
|
||||
}
|
||||
%>
|
||||
|
||||
<% if(isNotEmpty(field.comment)) { %>
|
||||
<% if(swagger2) { %>
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
<% }else{ %>
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% /* 主键 */ %>
|
||||
<% if(field.keyFlag) { %>
|
||||
@QueryField(type = QueryType.EQ)
|
||||
<% /* 使用EQ的字段 */ %>
|
||||
<% } else if(array.contain(cfg.paramEqType, field.propertyType)) { %>
|
||||
@QueryField(type = QueryType.EQ)
|
||||
<% } %>
|
||||
<% /* 使用String类型的字段 */ %>
|
||||
<% if(array.contain(cfg.paramToStringType, field.propertyType)) { %>
|
||||
private String ${field.propertyName};
|
||||
<% } else { %>
|
||||
<% /* 普通字段 */ %>
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% /** -----------END 字段循环遍历----------- **/ %>
|
||||
|
||||
<% if(!entityLombokModel) { %>
|
||||
<% for(field in table.fields) { %>
|
||||
<%
|
||||
var getprefix = '';
|
||||
if(field.propertyType == 'boolean') {
|
||||
getprefix = 'is';
|
||||
} else {
|
||||
getprefix = 'get';
|
||||
}
|
||||
// 排除的字段
|
||||
if(array.contain(cfg.paramExcludeFields, field.name)) {
|
||||
continue;
|
||||
}
|
||||
%>
|
||||
<% if(array.contain(cfg.paramToStringType, field.propertyType)) { %>
|
||||
public String ${getprefix}${field.capitalName}() {
|
||||
<% } else { %>
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
<% } %>
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
<% if(chainModel) { %>
|
||||
<% if(array.contain(cfg.paramToStringType, field.propertyType)) { %>
|
||||
public ${entity} set${field.capitalName}(String ${field.propertyName}) {
|
||||
<% } else { %>
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<% if(array.contain(cfg.paramToStringType, field.propertyType)) { %>
|
||||
public void set${field.capitalName}(String ${field.propertyName}) {
|
||||
<% } else { %>
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
<% } %>
|
||||
<% } %>
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
<% if(chainModel){ %>
|
||||
return this;
|
||||
<% } %>
|
||||
}
|
||||
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(!entityLombokModel) { %>
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
<% for(field in table.fields) { %>
|
||||
<%
|
||||
// 排除的字段
|
||||
if(array.contain(cfg.paramExcludeFields, field.name)) {
|
||||
continue;
|
||||
}
|
||||
%>
|
||||
<% if(fieldLP.index == 0) { %>
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
<% } else { %>
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
<% } %>
|
||||
<% } %>
|
||||
"}";
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<%
|
||||
var idPropertyName, idComment;
|
||||
for(field in table.fields) {
|
||||
if(field.keyFlag) {
|
||||
idPropertyName = field.propertyName;
|
||||
idComment = field.comment;
|
||||
}
|
||||
}
|
||||
%>
|
||||
package ${package.Service};
|
||||
|
||||
import ${superServiceClassPackage};
|
||||
import ${cfg.packageName!}.common.core.web.PageResult;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${cfg.packageName!}.${package.ModuleName}.param.${entity}Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!}Service
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date(), 'yyyy-MM-dd HH:mm:ss'}
|
||||
*/
|
||||
<% if(kotlin){ %>
|
||||
interface ${table.serviceName} : ${superServiceClass}<${entity}>
|
||||
<% }else{ %>
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<${entity}>
|
||||
*/
|
||||
PageResult<${entity}> pageRel(${entity}Param param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<${entity}>
|
||||
*/
|
||||
List<${entity}> listRel(${entity}Param param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param ${idPropertyName!} ${idComment!}
|
||||
* @return ${entity}
|
||||
*/
|
||||
${entity} getByIdRel(Integer ${idPropertyName!});
|
||||
|
||||
}
|
||||
<% } %>
|
||||
@@ -0,0 +1,62 @@
|
||||
<%
|
||||
var idPropertyName, idCapitalName;
|
||||
for(field in table.fields) {
|
||||
if(field.keyFlag) {
|
||||
idPropertyName = field.propertyName;
|
||||
idCapitalName = field.capitalName;
|
||||
}
|
||||
}
|
||||
%>
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import ${superServiceImplClassPackage};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${package.Entity}.${entity};
|
||||
import ${cfg.packageName!}.${package.ModuleName}.param.${entity}Param;
|
||||
import ${cfg.packageName!}.common.core.web.PageParam;
|
||||
import ${cfg.packageName!}.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${table.comment!}Service实现
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date(), 'yyyy-MM-dd HH:mm:ss'}
|
||||
*/
|
||||
@Service
|
||||
<% if(kotlin){ %>
|
||||
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {
|
||||
|
||||
}
|
||||
<% }else{ %>
|
||||
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
|
||||
|
||||
@Override
|
||||
public PageResult<${entity}> pageRel(${entity}Param param) {
|
||||
PageParam<${entity}, ${entity}Param> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<${entity}> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${entity}> listRel(${entity}Param param) {
|
||||
List<${entity}> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<${entity}, ${entity}Param> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${entity} getByIdRel(Integer ${idPropertyName!}) {
|
||||
${entity}Param param = new ${entity}Param();
|
||||
param.set${idCapitalName!}(${idPropertyName!});
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
<% } %>
|
||||
Reference in New Issue
Block a user