代码生成器模板调整
This commit is contained in:
parent
4467008849
commit
526bff448d
|
|
@ -17,6 +17,9 @@ public class GlobalConfig {
|
||||||
// 系统加密字符
|
// 系统加密字符
|
||||||
public static String secret = "UVTIyzCy";
|
public static String secret = "UVTIyzCy";
|
||||||
|
|
||||||
|
// Mysql表前缀
|
||||||
|
public static String tablePrefix = "ls_";
|
||||||
|
|
||||||
// Redis键前缀
|
// Redis键前缀
|
||||||
public static String redisPrefix = "Like:";
|
public static String redisPrefix = "Like:";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,7 @@ public class GenTable implements Serializable {
|
||||||
private String subTableFk;
|
private String subTableFk;
|
||||||
private String authorName;
|
private String authorName;
|
||||||
private String entityName;
|
private String entityName;
|
||||||
private String packageName;
|
|
||||||
private String moduleName;
|
private String moduleName;
|
||||||
private String businessName;
|
|
||||||
private String functionName;
|
private String functionName;
|
||||||
private String treePrimary;
|
private String treePrimary;
|
||||||
private String treeParent;
|
private String treeParent;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public class GenTableColumn implements Serializable {
|
||||||
private Integer isInsert;
|
private Integer isInsert;
|
||||||
private Integer isEdit;
|
private Integer isEdit;
|
||||||
private Integer isList;
|
private Integer isList;
|
||||||
|
private Integer isDetail;
|
||||||
private Integer isQuery;
|
private Integer isQuery;
|
||||||
private String queryType;
|
private String queryType;
|
||||||
private String htmlType;
|
private String htmlType;
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,6 @@ public class GenerateServiceImpl implements IGenerateService {
|
||||||
gen.put("genType", genTable.getGenType());
|
gen.put("genType", genTable.getGenType());
|
||||||
gen.put("genPath", genTable.getGenPath());
|
gen.put("genPath", genTable.getGenPath());
|
||||||
gen.put("moduleName", genTable.getModuleName());
|
gen.put("moduleName", genTable.getModuleName());
|
||||||
gen.put("packageName", genTable.getPackageName());
|
|
||||||
gen.put("businessName", genTable.getBusinessName());
|
|
||||||
gen.put("functionName", genTable.getFunctionName());
|
gen.put("functionName", genTable.getFunctionName());
|
||||||
maps.put("gen", gen);
|
maps.put("gen", gen);
|
||||||
|
|
||||||
|
|
@ -227,8 +225,6 @@ public class GenerateServiceImpl implements IGenerateService {
|
||||||
model.setAuthorName(genParam.getAuthorName());
|
model.setAuthorName(genParam.getAuthorName());
|
||||||
model.setEntityName(genParam.getEntityName());
|
model.setEntityName(genParam.getEntityName());
|
||||||
model.setModuleName(genParam.getModuleName());
|
model.setModuleName(genParam.getModuleName());
|
||||||
model.setPackageName(genParam.getPackageName());
|
|
||||||
model.setBusinessName(genParam.getBusinessName());
|
|
||||||
model.setFunctionName(genParam.getFunctionName());
|
model.setFunctionName(genParam.getFunctionName());
|
||||||
model.setTreePrimary(genParam.getTreePrimary());
|
model.setTreePrimary(genParam.getTreePrimary());
|
||||||
model.setTreeParent(genParam.getTreeParent());
|
model.setTreeParent(genParam.getTreeParent());
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,7 @@ public class GenUtil {
|
||||||
table.setTableComment(tableDesc);
|
table.setTableComment(tableDesc);
|
||||||
table.setAuthorName(map.getOrDefault("author_name", ""));
|
table.setAuthorName(map.getOrDefault("author_name", ""));
|
||||||
table.setEntityName(GenUtil.toClassName(tableName));
|
table.setEntityName(GenUtil.toClassName(tableName));
|
||||||
table.setModuleName(GenUtil.toBusinessName(tableName));
|
table.setModuleName(GenUtil.toModuleName(tableName));
|
||||||
table.setPackageName(GenConfig.packageName);
|
|
||||||
table.setBusinessName(GenUtil.toBusinessName(tableName));
|
|
||||||
table.setFunctionName(GenUtil.replaceText(tableDesc));
|
table.setFunctionName(GenUtil.replaceText(tableDesc));
|
||||||
table.setCreateTime(System.currentTimeMillis() / 1000);
|
table.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
table.setUpdateTime(System.currentTimeMillis() / 1000);
|
table.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
@ -142,19 +140,6 @@ public class GenUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 转模块名
|
|
||||||
*
|
|
||||||
* @author fzr
|
|
||||||
* @param packageName 包名
|
|
||||||
* @return 模块名
|
|
||||||
*/
|
|
||||||
public static String toModuleName(String packageName) {
|
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
|
||||||
int nameLength = packageName.length();
|
|
||||||
return StringUtil.substring(packageName, lastIndex + 1, nameLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转业务名
|
* 转业务名
|
||||||
*
|
*
|
||||||
|
|
@ -162,7 +147,7 @@ public class GenUtil {
|
||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @return 业务名
|
* @return 业务名
|
||||||
*/
|
*/
|
||||||
public static String toBusinessName(String tableName) {
|
public static String toModuleName(String tableName) {
|
||||||
int lastIndex = tableName.lastIndexOf("_");
|
int lastIndex = tableName.lastIndexOf("_");
|
||||||
int nameLength = tableName.length();
|
int nameLength = tableName.length();
|
||||||
return StringUtil.substring(tableName, lastIndex + 1, nameLength);
|
return StringUtil.substring(tableName, lastIndex + 1, nameLength);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.hxkj.generator.util;
|
||||||
|
|
||||||
import com.hxkj.common.utils.StringUtil;
|
import com.hxkj.common.utils.StringUtil;
|
||||||
import com.hxkj.generator.config.GenConfig;
|
import com.hxkj.generator.config.GenConfig;
|
||||||
|
import com.hxkj.generator.constant.SqlConstants;
|
||||||
import com.hxkj.generator.entity.GenTable;
|
import com.hxkj.generator.entity.GenTable;
|
||||||
import com.hxkj.generator.entity.GenTableColumn;
|
import com.hxkj.generator.entity.GenTableColumn;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
|
|
@ -38,12 +39,19 @@ public class VelocityUtil {
|
||||||
* @return VelocityContext
|
* @return VelocityContext
|
||||||
*/
|
*/
|
||||||
public static VelocityContext prepareContext(GenTable table, List<GenTableColumn> columns) {
|
public static VelocityContext prepareContext(GenTable table, List<GenTableColumn> columns) {
|
||||||
// 处理变量字段
|
boolean isSearch = false; // 是否需要搜索
|
||||||
boolean isSearch = false;
|
List<String> allFields = new LinkedList<>(); // 所有字段
|
||||||
List<String> fields = new LinkedList<>();
|
List<String> listFields = new LinkedList<>(); // 列表字段
|
||||||
|
List<String> detailFields = new LinkedList<>(); // 详情字段
|
||||||
for (GenTableColumn column : columns) {
|
for (GenTableColumn column : columns) {
|
||||||
|
allFields.add(column.getColumnName());
|
||||||
|
if (column.getIsList() == 1) {
|
||||||
|
listFields.add(column.getColumnName());
|
||||||
|
}
|
||||||
|
if (column.getIsDetail() == 1) {
|
||||||
|
detailFields.add(column.getColumnName());
|
||||||
|
}
|
||||||
if (column.getIsQuery() == 1) {
|
if (column.getIsQuery() == 1) {
|
||||||
fields.add(column.getColumnName());
|
|
||||||
isSearch = true;
|
isSearch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +68,10 @@ public class VelocityUtil {
|
||||||
velocityContext.put("functionName", StringUtil.isNotEmpty(table.getFunctionName()) ? table.getFunctionName() : "【请填写功能名称】");
|
velocityContext.put("functionName", StringUtil.isNotEmpty(table.getFunctionName()) ? table.getFunctionName() : "【请填写功能名称】");
|
||||||
velocityContext.put("table", table);
|
velocityContext.put("table", table);
|
||||||
velocityContext.put("columns", columns);
|
velocityContext.put("columns", columns);
|
||||||
velocityContext.put("fields", fields);
|
velocityContext.put("dateFields", SqlConstants.COLUMN_TIME_NAME);
|
||||||
|
velocityContext.put("allFields", allFields);
|
||||||
|
velocityContext.put("listFields", listFields);
|
||||||
|
velocityContext.put("detailFields", detailFields);
|
||||||
velocityContext.put("isSearch", isSearch);
|
velocityContext.put("isSearch", isSearch);
|
||||||
return velocityContext;
|
return velocityContext;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.yulichang.query.MPJQueryWrapper;
|
import com.github.yulichang.query.MPJQueryWrapper;
|
||||||
import ${packageName}.admin.service.${moduleName}.IArticleService;
|
import ${packageName}.admin.service.${moduleName}.I${EntityName}Service;
|
||||||
import ${packageName}.admin.validate.common.PageParam;
|
import ${packageName}.admin.validate.common.PageParam;
|
||||||
import ${packageName}.admin.validate.${moduleName}.ArticleParam;
|
import ${packageName}.admin.validate.${moduleName}.${EntityName}Param;
|
||||||
import ${packageName}.admin.vo.${moduleName}.${EntityName}ListVo;
|
import ${packageName}.admin.vo.${moduleName}.${EntityName}ListVo;
|
||||||
import ${packageName}.admin.vo.${moduleName}.${EntityName}DetailVo;
|
import ${packageName}.admin.vo.${moduleName}.${EntityName}DetailVo;
|
||||||
import ${packageName}.common.core.PageResult;
|
import ${packageName}.common.core.PageResult;
|
||||||
import ${packageName}.common.entity.${moduleName}.Article;
|
import ${packageName}.common.entity.${moduleName}.${EntityName};
|
||||||
import ${packageName}.common.mapper.${moduleName}.ArticleMapper;
|
import ${packageName}.common.mapper.${moduleName}.${EntityName}Mapper;
|
||||||
import ${packageName}.common.utils.TimeUtil;
|
import ${packageName}.common.utils.TimeUtil;
|
||||||
import ${packageName}.common.utils.UrlUtil;
|
import ${packageName}.common.utils.UrlUtil;
|
||||||
|
import com.hxkj.common.config.GlobalConfig;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
|
@ -25,29 +26,59 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
|
## 设置模板方式的变量
|
||||||
|
#if($table.genTpl.equals("curd"))
|
||||||
|
#set($genTpl = "PageResult<${EntityName}ListVo>")
|
||||||
|
#if($isSearch)
|
||||||
|
#set($isSearchParam = true)
|
||||||
|
#set($genParam = "PageParam pageParam, Map<String, String> params")
|
||||||
|
#else
|
||||||
|
#set($isSearchParam = false)
|
||||||
|
#set($genParam = "PageParam pageParam")
|
||||||
|
#end
|
||||||
|
#else
|
||||||
|
#set($genTpl = "JSONArray")
|
||||||
|
#if($isSearch)
|
||||||
|
#set($isSearchParam = true)
|
||||||
|
#set($genParam = "Map<String, String> params")
|
||||||
|
#else
|
||||||
|
#set($isSearchParam = false)
|
||||||
|
#set($genParam = "")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
## 设置基本的参数变量
|
||||||
|
#set($isAuthor = !$authorName.equals(""))
|
||||||
|
#set($pageParam = "@param pageParam 分页参数")
|
||||||
|
#set($searchparams = "@param params 搜索参数")
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
${EntityName}Mapper ${entityName}Mapper;
|
${EntityName}Mapper ${entityName}Mapper;
|
||||||
|
|
||||||
#if($table.sub_table_name.equals(""))
|
|
||||||
#if($table.genTpl=="curd")
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}列表
|
* ${functionName}列表
|
||||||
*
|
*
|
||||||
#if(!$authorName.equals(""))
|
#if($isAuthor)
|
||||||
* @author ${authorName}
|
* @author ${authorName}
|
||||||
#end
|
#end
|
||||||
* @param pageParam 分页参数
|
* ${pageParam}
|
||||||
* @param params 搜索参数
|
#if($isSearchParam)
|
||||||
* @return PageResult<${EntityName}Vo>
|
* ${searchparams}
|
||||||
|
#end
|
||||||
|
* @return $genTpl
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<${EntityName}ListVo> list(PageParam pageParam, Map<String, String> params) {
|
public $genTpl list($genParam) {
|
||||||
Integer page = pageParam.getPageNo();
|
#if($table.genTpl.equals("curd"))
|
||||||
Integer limit = pageParam.getPageSize();
|
Integer pageNo = pageParam.getPageNo();
|
||||||
|
Integer pageSize = pageParam.getPageSize();
|
||||||
|
#end
|
||||||
|
|
||||||
|
#if(!$table.subTableName.equals("") && !$table.subTableFk.equals(""))
|
||||||
|
MPJQueryWrapper<${EntityName}> queryWrapper = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.innerJoin("?_$table.subTableName f ON f.$table.SubTableFk=t.id".replace("?_", GlobalConfig.tablePrefix));
|
||||||
|
#else
|
||||||
QueryWrapper<${EntityName}> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<${EntityName}> queryWrapper = new QueryWrapper<>();
|
||||||
#if($isSearch)
|
#end
|
||||||
#if($fields.contains("is_delete"))
|
#if($fields.contains("is_delete"))
|
||||||
queryWrapper.eq("is_delete", 0);
|
queryWrapper.eq("is_delete", 0);
|
||||||
#end
|
#end
|
||||||
|
|
@ -55,370 +86,182 @@ public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
#else
|
#else
|
||||||
queryWrapper.orderByDesc("id");
|
queryWrapper.orderByDesc("id");
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#if($isSearch)
|
|
||||||
${entityName}Mapper.setSearch(queryWrapper, params, new String[]{
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.isQuery)
|
|
||||||
#if($column.queryType=="datetime")
|
|
||||||
"datetime:startTime-endTime@${column.columnName}:str"
|
|
||||||
#else
|
|
||||||
#if($column.javaType=="Integer")
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
|
||||||
"${column.queryType}:${column.javaField}:int",
|
|
||||||
#else
|
|
||||||
"${column.queryType}:${column.javaField}@${column.columnName}:int",
|
|
||||||
#end
|
|
||||||
#elseif($column.javaType=="Long")
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
|
||||||
"${column.queryType}:${column.javaField}:long",
|
|
||||||
#else
|
|
||||||
"${column.queryType}:${column.javaField}@${column.columnName}:long",
|
|
||||||
#end
|
|
||||||
#else
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
|
||||||
"${column.queryType}:${column.javaField}:str",
|
|
||||||
#else
|
|
||||||
"${column.queryType.toLowerCase()}:${column.javaField}@${column.columnName}:str",
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
});
|
|
||||||
#end
|
|
||||||
|
|
||||||
IPage<${EntityName}ListVo> iPage = ${entityName}Mapper.selectPage(new Page<>(page, limit), queryWrapper);
|
|
||||||
|
|
||||||
#if($fields.contains("create_time") || $fields.contains("update_time"))
|
|
||||||
List<${EntityName}ListVo> list = new ArrayList<>();
|
|
||||||
#end
|
|
||||||
for (${EntityName}ListVo item : iPage.getRecords()) {
|
|
||||||
${EntityName}ListVo vo = new ${EntityName}ListVo();
|
|
||||||
BeanUtils.copyProperties(item, vo);
|
|
||||||
#if($fields.contains("image"))
|
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()));
|
|
||||||
#end
|
|
||||||
#if($fields.contains("avatar"))
|
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("logo"))
|
|
||||||
vo.setLogo(UrlUtil.toAbsoluteUrl(vo.getLogo()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("create_time"))
|
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
|
||||||
#end
|
|
||||||
#if($fields.contains("update_time"))
|
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(item.getUpdateTime()));
|
|
||||||
#end
|
|
||||||
list.add(vo);
|
|
||||||
}
|
|
||||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
|
||||||
#else
|
|
||||||
return PageResult.iPageHandle(iPage);
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#elseif($table.genTpl=="tree")
|
|
||||||
/**
|
|
||||||
* ${functionName}列表
|
|
||||||
*
|
|
||||||
#if(!$authorName.equals(""))
|
|
||||||
* @author ${authorName}
|
|
||||||
#end
|
|
||||||
* @param params 搜索参数
|
|
||||||
* @return PageResult<${EntityName}Vo>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public JSONArray list(Map<String, String> params) {
|
|
||||||
QueryWrapper<${EntityName}> queryWrapper = new QueryWrapper<>();
|
|
||||||
#if($isSearch)
|
|
||||||
#if($fields.contains("is_delete"))
|
|
||||||
queryWrapper.eq("is_delete", 0);
|
|
||||||
#end
|
|
||||||
#if($fields.contains("sort"))
|
|
||||||
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
|
||||||
#else
|
|
||||||
queryWrapper.orderByDesc("id");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#if($isSearch)
|
|
||||||
${entityName}Mapper.setSearch(queryWrapper, params, new String[]{
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.isQuery)
|
|
||||||
#if($column.queryType=="datetime")
|
|
||||||
"datetime:startTime-endTime@${column.columnName}:str"
|
|
||||||
#else
|
|
||||||
#if($column.javaType=="Integer")
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
|
||||||
"${column.queryType}:${column.javaField}:int",
|
|
||||||
#else
|
|
||||||
"${column.queryType}:${column.javaField}@${column.columnName}:int",
|
|
||||||
#end
|
|
||||||
#elseif($column.javaType=="Long")
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
|
||||||
"${column.queryType}:${column.javaField}:long",
|
|
||||||
#else
|
|
||||||
"${column.queryType}:${column.javaField}@${column.columnName}:long",
|
|
||||||
#end
|
|
||||||
#else
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
|
||||||
"${column.queryType}:${column.javaField}:str",
|
|
||||||
#else
|
|
||||||
"${column.queryType.toLowerCase()}:${column.javaField}@${column.columnName}:str",
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
});
|
|
||||||
#end
|
|
||||||
|
|
||||||
List<${EntityName}> arrayData = ${entityName}Mapper.selectList(queryWrapper);
|
|
||||||
|
|
||||||
#if($fields.contains("create_time") || $fields.contains("update_time"))
|
|
||||||
List<${EntityName}ListVo> list = new ArrayList<>();
|
|
||||||
for (${EntityName} item : arrayData) {
|
|
||||||
${EntityName}ListVo vo = new ${EntityName}ListVo();
|
|
||||||
BeanUtils.copyProperties(item, vo);
|
|
||||||
#if($fields.contains("image"))
|
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("avatar"))
|
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("logo"))
|
|
||||||
vo.setLogo(UrlUtil.toAbsoluteUrl(vo.getLogo()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("create_time"))
|
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
|
||||||
#end
|
|
||||||
#if($fields.contains("update_time"))
|
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(item.getUpdateTime()));
|
|
||||||
#end
|
|
||||||
list.add(vo);
|
|
||||||
}
|
|
||||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(list));
|
|
||||||
return ArrayUtil.listToTree(jsonArray, "${table.treePrimary}", "${table.treeParent}", "children");
|
|
||||||
#else
|
|
||||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(arrayData));
|
|
||||||
return ArrayUtil.listToTree(jsonArray, "${table.treePrimary}", "${table.treeParent}", "children");
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#else
|
|
||||||
#if($table.genTpl=="curd")
|
|
||||||
/**
|
|
||||||
* ${functionName}列表
|
|
||||||
*
|
|
||||||
#if(!$authorName.equals(""))
|
|
||||||
* @author ${authorName}
|
|
||||||
#end
|
|
||||||
* @param pageParam 分页参数
|
|
||||||
* @param params 搜索参数
|
|
||||||
* @return PageResult<${EntityName}Vo>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public#if($isEqually) PageResult<${EntityName}Vo>#else PageResult<${EntityName}ListVo>#end list(PageParam pageParam, Map<String, String> params) {
|
|
||||||
Integer page = pageParam.getPageNo();
|
|
||||||
Integer limit = pageParam.getPageSize();
|
|
||||||
|
|
||||||
MPJQueryWrapper<${EntityName}> mpjQueryWrapper = new MPJQueryWrapper<>();
|
|
||||||
mpjQueryWrapper.leftJoin("{$table.sub_table_name} f ON f.{$table.sub_table_fk}=t.id");
|
|
||||||
#if($isSearch)
|
|
||||||
#if($fields.contains("is_delete"))
|
|
||||||
mpjQueryWrapper.eq("is_delete", 0);
|
|
||||||
#end
|
|
||||||
#if($fields.contains("sort"))
|
|
||||||
mpjQueryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
|
||||||
#else
|
|
||||||
mpjQueryWrapper.orderByDesc("id");
|
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if($isSearch)
|
#if($isSearch)
|
||||||
${entityName}Mapper.setSearch(mpjQueryWrapper, params, new String[]{
|
${entityName}Mapper.setSearch(mpjQueryWrapper, params, new String[]{
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.isQuery)
|
#if($column.isQuery)
|
||||||
#if($column.queryType=="datetime")
|
#if($dateFields.contains($column.columnName))
|
||||||
"datetime:startTime-endTime@${column.columnName}:str"
|
"datetime:startTime-endTime@${column.columnName}:str"
|
||||||
#else
|
#elseif($column.javaType=="Integer")
|
||||||
#if($column.javaType=="Integer")
|
|
||||||
#if($column.javaField.equals($column.columnName))
|
#if($column.javaField.equals($column.columnName))
|
||||||
"${column.queryType}:${column.javaField}:int",
|
"${column.queryType.toLowerCase()}:${column.javaField}:int",
|
||||||
#else
|
#else
|
||||||
"${column.queryType}:${column.javaField}@${column.columnName}:int",
|
"${column.queryType.toLowerCase()}:${column.javaField}@${column.columnName}:int",
|
||||||
#end
|
#end
|
||||||
#elseif($column.javaType=="Long")
|
#elseif($column.javaType=="Long")
|
||||||
#if($column.javaField.equals($column.columnName))
|
#if($column.javaField.equals($column.columnName))
|
||||||
"${column.queryType}:${column.javaField}:long",
|
"${column.queryType.toLowerCase()}:${column.javaField}:long",
|
||||||
#else
|
#else
|
||||||
"${column.queryType}:${column.javaField}@${column.columnName}:long",
|
"${column.queryType.toLowerCase()}:${column.javaField}@${column.columnName}:long",
|
||||||
#end
|
#end
|
||||||
#else
|
#else
|
||||||
#if($column.javaField.equals($column.columnName))
|
#if($column.javaField.equals($column.columnName))
|
||||||
"${column.queryType}:${column.javaField}:str",
|
"${column.queryType.toLowerCase()}:${column.javaField}:str",
|
||||||
#else
|
#else
|
||||||
"${column.queryType.toLowerCase()}:${column.javaField}@${column.columnName}:str",
|
"${column.queryType.toLowerCase()}:${column.javaField}@${column.columnName}:str",
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
}
|
||||||
});
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#if(!$table.subTableName.equals("") && !$table.subTableFk.equals(""))
|
||||||
|
#set($isJoin = true)
|
||||||
|
#set($joinCurdList = "${EntityName}ListVo")
|
||||||
|
#set($joinCurdName = "iPage.getRecords()")
|
||||||
|
#if($table.genTpl.equals("curd"))
|
||||||
IPage<${EntityName}ListVo> iPage = ${entityName}Mapper.selectJoinPage(
|
IPage<${EntityName}ListVo> iPage = ${entityName}Mapper.selectJoinPage(
|
||||||
new Page<>(page, limit),
|
new Page<>(page, limit),
|
||||||
${EntityName}ListVo.class,
|
${EntityName}ListVo.class,
|
||||||
mpjQueryWrapper);
|
mpjQueryWrapper);
|
||||||
|
|
||||||
for (${EntityName}ListVo vo : iPage.getRecords()) {
|
|
||||||
#if($fields.contains("image"))
|
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()));
|
|
||||||
#end
|
|
||||||
#if($fields.contains("avatar"))
|
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("logo"))
|
|
||||||
vo.setLogo(UrlUtil.toAbsoluteUrl(vo.getLogo()))
|
|
||||||
#end
|
|
||||||
#if($fields.contains("create_time"))
|
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(vo.getCreateTime()));
|
|
||||||
#end
|
|
||||||
#if($fields.contains("update_time"))
|
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(vo.getUpdateTime()));
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
return PageResult.iPageHandle(iPage);
|
|
||||||
}
|
|
||||||
#elseif($table.genTpl=="tree")
|
|
||||||
/**
|
|
||||||
* ${functionName}列表
|
|
||||||
*
|
|
||||||
#if(!$authorName.equals(""))
|
|
||||||
* @author ${authorName}
|
|
||||||
#end
|
|
||||||
* @param params 搜索参数
|
|
||||||
* @return PageResult<${EntityName}Vo>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public JSONArray list(Map<String, String> params) {
|
|
||||||
MPJQueryWrapper<${EntityName}> mpjQueryWrapper = new MPJQueryWrapper<>();
|
|
||||||
#if($isSearch)
|
|
||||||
#if($fields.contains("is_delete"))
|
|
||||||
mpjQueryWrapper.eq("t.is_delete", 0);
|
|
||||||
#end
|
|
||||||
#if($fields.contains("sort"))
|
|
||||||
mpjQueryWrapper.orderByDesc(Arrays.asList("t.sort", "t.id"));
|
|
||||||
#else
|
#else
|
||||||
mpjQueryWrapper.orderByDesc("t.id");
|
List<${EntityName}ListVo> iPage = ${entityName}Mapper.selectJoinList(
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
#if($isSearch)
|
|
||||||
${entityName}Mapper.setSearch(mpjQueryWrapper, params, new String[]{
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.isQuery)
|
|
||||||
#if($column.queryType=="datetime")
|
|
||||||
"datetime:startTime-endTime@t.${column.columnName}:str"
|
|
||||||
#else
|
|
||||||
#if($column.javaType=="Integer")
|
|
||||||
"${column.queryType}:${column.javaField}@t.${column.columnName}:int",
|
|
||||||
#elseif($column.javaType=="Long")
|
|
||||||
"${column.queryType}:${column.javaField}@t.${column.columnName}:long",
|
|
||||||
#else
|
|
||||||
"${column.queryType}:${column.javaField}@t.${column.columnName}:str",
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
});
|
|
||||||
#end
|
|
||||||
|
|
||||||
List<${EntityNameList}> arrayData = ${entityName}Mapper.selectJoinList(
|
|
||||||
${EntityName}ListVo.class,
|
${EntityName}ListVo.class,
|
||||||
mpjQueryWrapper);
|
mpjQueryWrapper);
|
||||||
|
#end
|
||||||
#if($fields.contains("create_time") || $fields.contains("update_time"))
|
|
||||||
for (${EntityName} item : arrayData) {
|
|
||||||
#if($isEqually)
|
|
||||||
${EntityName}Vo vo = new ${EntityName}Vo();
|
|
||||||
#else
|
#else
|
||||||
|
#set($isJoin = false)
|
||||||
|
#set($joinCurdList = "${EntityName}")
|
||||||
|
#if($table.genTpl.equals("curd"))
|
||||||
|
#set($joinCurdName = "iPage.getRecords()")
|
||||||
|
IPage<${EntityName}> iPage = ${entityName}Mapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
#else
|
||||||
|
#set($joinCurdName = "array")
|
||||||
|
List<${EntityName}> array = ${entityName}Mapper.selectList(queryWrapper);
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
#set($filter = false)
|
||||||
|
#if($listFields.contains("create_time") || $listFields.contains("update_time") ||
|
||||||
|
$listFields.contains("delete_time") || $listFields.contains("start_time") ||
|
||||||
|
$listFields.contains("end_time") || $listFields.contains("image") ||
|
||||||
|
$listFields.contains("avatar") || $listFields.contains("logo") ||
|
||||||
|
$listFields.contains("img"))
|
||||||
|
#set($filter = true)
|
||||||
|
#if(!$isJoin)
|
||||||
|
List<${EntityName}ListVo> list = new LinkedList<>();
|
||||||
|
#end
|
||||||
|
for($joinCurdList item : $joinCurdName) {
|
||||||
|
#if(!$isJoin)
|
||||||
${EntityName}ListVo vo = new ${EntityName}Vo();
|
${EntityName}ListVo vo = new ${EntityName}Vo();
|
||||||
#end
|
|
||||||
BeanUtils.copyProperties(item, vo);
|
BeanUtils.copyProperties(item, vo);
|
||||||
#if($fields.contains("image"))
|
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(vo.getImage()))
|
|
||||||
#end
|
#end
|
||||||
#if($fields.contains("avatar"))
|
#if($listFields.contains("image"))
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(vo.getAvatar()))
|
vo.setImage(UrlUtil.toAbsoluteUrl(item.getImage()))
|
||||||
#end
|
#end
|
||||||
#if($fields.contains("logo"))
|
#if($listFields.contains("avatar"))
|
||||||
vo.setLogo(UrlUtil.toAbsoluteUrl(vo.getLogo()))
|
vo.setAvatar(UrlUtil.toAbsoluteUrl(item.getAvatar()))
|
||||||
#end
|
#end
|
||||||
#if($fields.contains("create_time"))
|
#if($listFields.contains("logo"))
|
||||||
|
vo.setLogo(UrlUtil.toAbsoluteUrl(item.getLogo()))
|
||||||
|
#end
|
||||||
|
#if($listFields.contains("img"))
|
||||||
|
vo.setImg(UrlUtil.toAbsoluteUrl(item.getImg()))
|
||||||
|
#end
|
||||||
|
#if($listFields.contains("create_time"))
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(item.getCreateTime()));
|
||||||
#end
|
#end
|
||||||
#if($fields.contains("update_time"))
|
#if($listFields.contains("update_time"))
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(item.getUpdateTime()));
|
vo.setUpdateTime(TimeUtil.timestampToDate(item.getUpdateTime()));
|
||||||
#end
|
#end
|
||||||
list.add(vo);
|
#if($listFields.contains("delete_time"))
|
||||||
|
vo.setDeleteTime(TimeUtil.timestampToDate(item.getDeleteTime()));
|
||||||
|
#end
|
||||||
|
#if($listFields.contains("start_time"))
|
||||||
|
vo.setStartTime(TimeUtil.timestampToDate(item.getStartTime()));
|
||||||
|
#end
|
||||||
|
#if($listFields.contains("end_time"))
|
||||||
|
vo.setEndTime(TimeUtil.timestampToDate(item.getEndTime()));
|
||||||
|
#end
|
||||||
|
#if(!$isJoin)
|
||||||
|
list.add(vo)
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#if($table.genTpl.equals("curd"))
|
||||||
|
#if($isJoin)
|
||||||
|
return PageResult.iPageHandle(iPage);
|
||||||
|
#else
|
||||||
|
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||||
|
#end
|
||||||
|
#else
|
||||||
|
#if($filter)
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(list));
|
||||||
|
#else
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(array));
|
||||||
#end
|
#end
|
||||||
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(arrayData));
|
|
||||||
return ArrayUtil.listToTree(jsonArray, "${table.treePrimary}", "${table.treeParent}", "children");
|
return ArrayUtil.listToTree(jsonArray, "${table.treePrimary}", "${table.treeParent}", "children");
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}详情
|
* ${functionName}详情
|
||||||
*
|
*
|
||||||
#if(!$authorName.equals(""))
|
#if($isAuthor)
|
||||||
* @author ${authorName}
|
* @author ${authorName}
|
||||||
#end
|
#end
|
||||||
* @param id 主键参数
|
* @param id 主键参数
|
||||||
* @return ${EntityName}
|
* @return ${EntityName}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public#if($isEqually) ${EntityName}Vo#else ${EntityName}DetailVo#end detail(Integer id) {
|
public ${EntityName}DetailVo detail(Integer id) {
|
||||||
Article model = ${entityName}Mapper.selectOne(
|
${EntityName} model = new QueryWrapper<${EntityName}>()
|
||||||
#if($field.contains("is_delete"))
|
|
||||||
new QueryWrapper<${EntityName}>()
|
|
||||||
.eq("id", id)
|
.eq("id", id)
|
||||||
|
#if($allFields.contains("is_delete"))
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
|
#end
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
#else
|
|
||||||
new QueryWrapper<${EntityName}>()
|
|
||||||
.eq("id", id)
|
|
||||||
.last("limit 1"));
|
|
||||||
#end
|
|
||||||
|
|
||||||
Assert.notNull(model, "${functionName}不存在}");
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
ArticleDetailVo vo = new ArticleDetailVo();
|
${EntityName}DetailVo vo = new ${EntityName}DetailVo();
|
||||||
#if($field.contains("image"))
|
BeanUtils.copyProperties(model, vo);
|
||||||
vo.setImage(UrlUtil.toAbsoluteUrl(model.getImage()));
|
#if($detailFields.contains("create_time") || $detailFields.contains("update_time") ||
|
||||||
|
$detailFields.contains("delete_time") || $detailFields.contains("start_time") ||
|
||||||
|
$detailFields.contains("end_time") || $detailFields.contains("image") ||
|
||||||
|
$detailFields.contains("avatar") || $detailFields.contains("logo") ||
|
||||||
|
$detailFields.contains("img"))
|
||||||
|
#if($detailFields.contains("image"))
|
||||||
|
vo.setImage(UrlUtil.toAbsoluteUrl(model.getImage()))
|
||||||
#end
|
#end
|
||||||
#if($field.contains("avatar"))
|
#if($detailFields.contains("avatar"))
|
||||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(model.getAvatar()));
|
vo.setAvatar(UrlUtil.toAbsoluteUrl(model.getAvatar()))
|
||||||
#end
|
#end
|
||||||
#if($field.contains("logo"))
|
#if($detailFields.contains("logo"))
|
||||||
vo.setLogo(UrlUtil.toAbsoluteUrl(model.getLogo()));
|
vo.setLogo(UrlUtil.toAbsoluteUrl(model.getLogo()))
|
||||||
#end
|
#end
|
||||||
#if($field.contains("create_time"))
|
#if($detailFields.contains("img"))
|
||||||
|
vo.setImg(UrlUtil.toAbsoluteUrl(model.getImg()))
|
||||||
|
#end
|
||||||
|
#if($detailFields.contains("create_time"))
|
||||||
vo.setCreateTime(TimeUtil.timestampToDate(model.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(model.getCreateTime()));
|
||||||
#end
|
#end
|
||||||
#if($field.contains("update_time"))
|
#if($detailFields.contains("update_time"))
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(model.getUpdateTime()));
|
vo.setUpdateTime(TimeUtil.timestampToDate(model.getUpdateTime()));
|
||||||
#end
|
#end
|
||||||
#if($field.contains("delete_time"))
|
#if($detailFields.contains("delete_time"))
|
||||||
vo.setUpdateTime(TimeUtil.timestampToDate(model.getUpdateTime()));
|
vo.setDeleteTime(TimeUtil.timestampToDate(model.getDeleteTime()));
|
||||||
|
#end
|
||||||
|
#if($detailFields.contains("start_time"))
|
||||||
|
vo.setStartTime(TimeUtil.timestampToDate(model.getStartTime()));
|
||||||
|
#end
|
||||||
|
#if($detailFields.contains("end_time"))
|
||||||
|
vo.setEndTime(TimeUtil.timestampToDate(model.getEndTime()));
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
@ -426,7 +269,7 @@ public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
/**
|
/**
|
||||||
* ${functionName}新增
|
* ${functionName}新增
|
||||||
*
|
*
|
||||||
#if(!$authorName.equals(""))
|
#if($isAuthor)
|
||||||
* @author ${authorName}
|
* @author ${authorName}
|
||||||
#end
|
#end
|
||||||
* @param ${entityName}Param 参数
|
* @param ${entityName}Param 参数
|
||||||
|
|
@ -435,13 +278,13 @@ public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
public void add(${EntityName}Param ${entityName}Param) {
|
public void add(${EntityName}Param ${entityName}Param) {
|
||||||
${EntityName} model = new ${EntityName}();
|
${EntityName} model = new ${EntityName}();
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$column.isIncrement)
|
#if($column.isInsert)
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#if($column.javaField.equals("image") || $colum.javaField.equals("avatar") || $colum.javaField.equals("logo"))
|
#if($column.javaField.equals("image") || $column.javaField.equals("avatar") || $column.javaField.equals("logo") || $column.javaField.equals("img"))
|
||||||
model.set${AttrName}(UrlUtil.toRelativeUrl(${entityName}Param.get${AttrName}()));
|
model.set${AttrName}(UrlUtil.toRelativeUrl(${entityName}Param.get${AttrName}()));
|
||||||
#elseif(!$column.javaField.equals("createTime") and !$column.javaField.equals("deleteTime") and !$column.javaField.equals("updateTime") and !$column.javaField.equals("isDelete"))
|
#elseif(!$dateFields.contains($column.columnName) and !$column.javaField.equals("isDelete"))
|
||||||
model.set${AttrName}(${entityName}Param.get${AttrName}());
|
model.set${AttrName}(${entityName}Param.get${AttrName}());
|
||||||
#elseif($column.javaField.equals("createTime") || $column.javaField.equals("updateTime"))
|
#elseif($dateFields.contains($column.columnName))
|
||||||
model.set${AttrName}(System.currentTimeMillis() / 1000);
|
model.set${AttrName}(System.currentTimeMillis() / 1000);
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
@ -452,35 +295,30 @@ public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
/**
|
/**
|
||||||
* ${functionName}编辑
|
* ${functionName}编辑
|
||||||
*
|
*
|
||||||
#if(!$authorName.equals(""))
|
#if($isAuthor)
|
||||||
* @author ${authorName}
|
* @author ${authorName}
|
||||||
#end
|
#end
|
||||||
* @param ${entityName}Param 参数
|
* @param ${entityName}Param 参数
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void edit(${EntityName}Param ${entityName}Param) {
|
public void edit(${EntityName}Param ${entityName}Param) {
|
||||||
${EntityName} model = ${entityName}Mapper.selectOne(
|
${EntityName} model = new QueryWrapper<${EntityName}>()
|
||||||
#if($field.contains("is_delete"))
|
.eq("id", id)
|
||||||
new QueryWrapper<${EntityName}>()
|
#if($allFields.contains("is_delete"))
|
||||||
.eq("id", ${entityName}Param.getId())
|
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.last("limit 1"));
|
|
||||||
#else
|
|
||||||
new QueryWrapper<${EntityName}>()
|
|
||||||
.eq("id", ${entityName}Param.getId())
|
|
||||||
.last("limit 1"));
|
|
||||||
#end
|
#end
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
Assert.notNull(model, "${functionName}不存在!");
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$column.isIncrement)
|
#if($column.isEdit==1)
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#if($column.javaField.equals("image") || $colum.javaField.equals("avatar") || $colum.javaField.equals("logo"))
|
#if($column.javaField.equals("image") || $column.javaField.equals("avatar") || $column.javaField.equals("logo") || $column.javaField.equals("img"))
|
||||||
model.set${AttrName}(UrlUtil.toRelativeUrl(${entityName}Param.get${AttrName}()));
|
model.set${AttrName}(UrlUtil.toRelativeUrl(${entityName}Param.get${AttrName}()));
|
||||||
#elseif(!$column.javaField.equals("createTime") and !$column.javaField.equals("deleteTime") and !$column.javaField.equals("updateTime") and !$column.javaField.equals("isDelete"))
|
#elseif(!$dateFields.contains($column.columnName) and !$column.javaField.equals("isDelete"))
|
||||||
model.set${AttrName}(${entityName}Param.get${AttrName}());
|
model.set${AttrName}(${entityName}Param.get${AttrName}());
|
||||||
#elseif($column.javaField.equals("updateTime"))
|
#elseif($dateFields.contains($column.columnName))
|
||||||
model.set${AttrName}(System.currentTimeMillis() / 1000);
|
model.set${AttrName}(System.currentTimeMillis() / 1000);
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
@ -491,32 +329,25 @@ public class ${EntityName}ServiceImpl implements I${EntityName}Service {
|
||||||
/**
|
/**
|
||||||
* ${functionName}删除
|
* ${functionName}删除
|
||||||
*
|
*
|
||||||
#if(!$authorName.equals(""))
|
#if($isAuthor)
|
||||||
* @author ${authorName}
|
* @author ${authorName}
|
||||||
#end
|
#end
|
||||||
* @param id 主键ID
|
* @param id 主键ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void del(Integer id) {
|
public void del(Integer id) {
|
||||||
${EntityName} model = ${entityName}Mapper.selectOne(
|
${EntityName} model = new QueryWrapper<${EntityName}>()
|
||||||
#if($fields.contains("is_delete"))
|
|
||||||
new QueryWrapper<${EntityName}>()
|
|
||||||
.select("id")
|
|
||||||
.eq("id", id)
|
.eq("id", id)
|
||||||
|
#if($allFields.contains("is_delete"))
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.last("limit 1"));
|
|
||||||
#else
|
|
||||||
new QueryWrapper<${EntityName}>()
|
|
||||||
.select("id")
|
|
||||||
.eq("id", id)
|
|
||||||
.last("limit 1"));
|
|
||||||
#end
|
#end
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
Assert.notNull(model, "${functionName}不存在!");
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
#if($fields.contains("is_delete"))
|
#if($allFields.contains("is_delete"))
|
||||||
model.setIsDelete(1);
|
model.setIsDelete(1);
|
||||||
#if($fields.contains("delete_time"))
|
#if($allFields.contains("delete_time"))
|
||||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||||
#end
|
#end
|
||||||
${entityName}Mapper.updateById(model);
|
${entityName}Mapper.updateById(model);
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
package ${packageName}.admin.vo.${moduleName};
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${EntityName}Vo
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ${EntityName}Vo implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.isList==1 || $column.isQuery==1)
|
|
||||||
#if($column.javaField.equals("createTime") || $column.javaField.equals("updateTime") || $column.javaField.equals("deleteTime"))
|
|
||||||
private String ${column.javaField};
|
|
||||||
#else
|
|
||||||
private ${column.javaType} ${column.javaField};
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -13,10 +13,12 @@ public class ${EntityName}DetailVo implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.javaField.equals("createTime") || $column.javaField.equals("updateTime") || $column.javaField.equals("deleteTime"))
|
#if($column.isDetail==1)
|
||||||
private String ${column.javaField};
|
#if($dateFields.contains($column.columnName))
|
||||||
|
private String ${column.javaField}; // ${column.columnComment}
|
||||||
#else
|
#else
|
||||||
private ${column.javaType} ${column.javaField};
|
private ${column.javaType} ${column.javaField}; // ${column.columnComment}
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ public class ${EntityName}ListVo implements Serializable {
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.isList==1)
|
#if($column.isList==1)
|
||||||
#if($column.javaField.equals("createTime") || $column.javaField.equals("updateTime") || $column.javaField.equals("deleteTime"))
|
#if($dateFields.contains($column.columnName))
|
||||||
private String ${column.javaField};
|
private String ${column.javaField}; // ${column.columnComment}
|
||||||
#else
|
#else
|
||||||
private ${column.javaType} ${column.javaField};
|
private ${column.javaType} ${column.javaField}; // ${column.columnComment}
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue