add
This commit is contained in:
@ -70,4 +70,14 @@ public class GeneratorTable implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String parentMenuId;
|
private String parentMenuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档开关
|
||||||
|
*/
|
||||||
|
private String docFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel导出开关
|
||||||
|
*/
|
||||||
|
private String excelFlag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,15 @@ import cn.hutool.core.lang.Snowflake;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.qiaoba.common.base.constants.BaseConstant;
|
import com.qiaoba.common.base.constants.BaseConstant;
|
||||||
import com.qiaoba.common.base.context.BaseContext;
|
import com.qiaoba.common.base.context.BaseContext;
|
||||||
|
import com.qiaoba.common.base.enums.BaseEnum;
|
||||||
import com.qiaoba.module.generator.constant.GenConstants;
|
import com.qiaoba.module.generator.constant.GenConstants;
|
||||||
import com.qiaoba.module.generator.entity.Generator;
|
import com.qiaoba.module.generator.entity.Generator;
|
||||||
import com.qiaoba.module.generator.entity.GeneratorTable;
|
import com.qiaoba.module.generator.entity.GeneratorTable;
|
||||||
|
import com.qiaoba.module.generator.entity.GeneratorTableColumn;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板生成 工具类
|
* 模板生成 工具类
|
||||||
@ -23,28 +24,45 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class VelocityUtil {
|
public class VelocityUtil {
|
||||||
|
|
||||||
private static final String VM_CONTROLLER = "controller.java.vm";
|
private static final List<String> TEMPLATE_JAVA = new ArrayList<>();
|
||||||
private static final String VM_DOMAIN = "entity.java.vm";
|
private static final List<String> TEMPLATE_VUE = new ArrayList<>();
|
||||||
private static final String VM_DTO = "dto.java.vm";
|
private static final List<String> TEMPLATE_SQL = new ArrayList<>();
|
||||||
private static final String VM_PARAM = "param.java.vm";
|
|
||||||
private static final String VM_MAPPER = "mapper.java.vm";
|
private static final String VM_CONTROLLER = "controller.java.qb";
|
||||||
private static final String VM_MAPPER_XML = "mapper.xml.vm";
|
private static final String VM_DOMAIN = "entity.java.qb";
|
||||||
private static final String VM_SERVICE = "service.java.vm";
|
private static final String VM_DTO = "dto.java.qb";
|
||||||
private static final String VM_SERVICE_IMPL = "serviceImpl.java.vm";
|
private static final String VM_PARAM = "param.java.qb";
|
||||||
private static final String VM_SQL = "sql.vm";
|
private static final String VM_EXCEL_EXPORT = "export.java.qb";
|
||||||
private static final String VM_API_JS = "api.js.vm";
|
private static final String VM_MAPPER = "mapper.java.qb";
|
||||||
private static final String VM_INDEX_VUE = "index";
|
private static final String VM_SERVICE = "service.java.qb";
|
||||||
private static final String VM_INDEX_TREE_VUE = "index-tree.vue.vm";
|
private static final String VM_SERVICE_IMPL = "serviceImpl.java.qb";
|
||||||
|
private static final String VM_SQL = "sql.qb";
|
||||||
|
private static final String VM_API_JS = "api.js.qb";
|
||||||
|
private static final String VM_INDEX_VUE = "index.qb";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目空间路径
|
* 项目空间路径
|
||||||
*/
|
*/
|
||||||
private static final String PROJECT_PATH = "main/java";
|
private static final String PROJECT_PATH = "main/java";
|
||||||
|
|
||||||
/**
|
|
||||||
* mybatis空间路径
|
static {
|
||||||
*/
|
// 后端
|
||||||
private static final String MYBATIS_PATH = "main/resources/mapper";
|
TEMPLATE_JAVA.add("vm/java/entity.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/dto.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/param.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/export.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/controller.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/service.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/serviceImpl.java.qb");
|
||||||
|
TEMPLATE_JAVA.add("vm/java/mapper.java.qb");
|
||||||
|
// 前端
|
||||||
|
TEMPLATE_VUE.add("vm/js/api.js.qb");
|
||||||
|
TEMPLATE_VUE.add("vm/vue/index.qb");
|
||||||
|
// SQL
|
||||||
|
TEMPLATE_SQL.add("vm/sql/sql.qb");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载模板
|
* 加载模板
|
||||||
@ -56,38 +74,25 @@ public class VelocityUtil {
|
|||||||
// 全部
|
// 全部
|
||||||
if (GenConstants.TEMPLATE_TYPE_ALL.equals(templateType)) {
|
if (GenConstants.TEMPLATE_TYPE_ALL.equals(templateType)) {
|
||||||
// 后端
|
// 后端
|
||||||
templates.add("vm/java/entity.java.vm");
|
templates.addAll(TEMPLATE_JAVA);
|
||||||
templates.add("vm/java/dto.java.vm");
|
|
||||||
templates.add("vm/java/param.java.vm");
|
|
||||||
templates.add("vm/java/mapper.java.vm");
|
|
||||||
templates.add("vm/java/service.java.vm");
|
|
||||||
templates.add("vm/java/serviceImpl.java.vm");
|
|
||||||
templates.add("vm/java/controller.java.vm");
|
|
||||||
// 前端
|
// 前端
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.addAll(TEMPLATE_VUE);
|
||||||
templates.add("vm/vue/index");
|
|
||||||
// SQL
|
// SQL
|
||||||
templates.add("vm/sql/sql.vm");
|
templates.addAll(TEMPLATE_SQL);
|
||||||
|
|
||||||
}
|
}
|
||||||
// 后端
|
// 后端
|
||||||
else if (GenConstants.TEMPLATE_TYPE_JAVA.equals(templateType)) {
|
else if (GenConstants.TEMPLATE_TYPE_JAVA.equals(templateType)) {
|
||||||
// 后端
|
// 后端
|
||||||
templates.add("vm/java/entity.java.vm");
|
templates.addAll(TEMPLATE_JAVA);
|
||||||
templates.add("vm/java/dto.java.vm");
|
|
||||||
templates.add("vm/java/param.java.vm");
|
|
||||||
templates.add("vm/java/mapper.java.vm");
|
|
||||||
templates.add("vm/java/service.java.vm");
|
|
||||||
templates.add("vm/java/serviceImpl.java.vm");
|
|
||||||
templates.add("vm/java/controller.java.vm");
|
|
||||||
}
|
}
|
||||||
// 前端
|
// 前端
|
||||||
else if (GenConstants.TEMPLATE_TYPE_VUE.equals(templateType)) {
|
else if (GenConstants.TEMPLATE_TYPE_VUE.equals(templateType)) {
|
||||||
// 前端
|
// 前端
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.addAll(TEMPLATE_VUE);
|
||||||
templates.add("vm/vue/index");
|
|
||||||
} else {
|
} else {
|
||||||
// SQL
|
// SQL
|
||||||
templates.add("vm/sql/sql.vm");
|
templates.addAll(TEMPLATE_SQL);
|
||||||
}
|
}
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
@ -100,36 +105,41 @@ public class VelocityUtil {
|
|||||||
String functionName = generator.getTable().getFunctionName();
|
String functionName = generator.getTable().getFunctionName();
|
||||||
|
|
||||||
VelocityContext velocityContext = new VelocityContext();
|
VelocityContext velocityContext = new VelocityContext();
|
||||||
velocityContext.put("tableName", generator.getTable().getTableName());
|
velocityContext.put("tableName" , generator.getTable().getTableName());
|
||||||
velocityContext.put("functionName", StrUtil.isNotBlank(functionName) ? functionName : "【请填写功能名称】");
|
velocityContext.put("functionName" , StrUtil.isNotBlank(functionName) ? functionName : "【请填写功能名称】");
|
||||||
velocityContext.put("ClassName", generator.getTable().getClassName());
|
velocityContext.put("ClassName" , generator.getTable().getClassName());
|
||||||
velocityContext.put("className", StringUtils.uncapitalize(generator.getTable().getClassName()));
|
velocityContext.put("className" , StringUtils.uncapitalize(generator.getTable().getClassName()));
|
||||||
velocityContext.put("moduleName", generator.getTable().getModuleName());
|
velocityContext.put("moduleName" , generator.getTable().getModuleName());
|
||||||
velocityContext.put("BusinessName", StringUtils.capitalize(generator.getTable().getBusinessName()));
|
velocityContext.put("BusinessName" , StringUtils.capitalize(generator.getTable().getBusinessName()));
|
||||||
velocityContext.put("businessName", generator.getTable().getBusinessName());
|
velocityContext.put("businessName" , generator.getTable().getBusinessName());
|
||||||
velocityContext.put("basePackage", getPackagePrefix(packageName));
|
velocityContext.put("basePackage" , getPackagePrefix(packageName));
|
||||||
velocityContext.put("packageName", packageName);
|
velocityContext.put("packageName" , packageName);
|
||||||
velocityContext.put("author", generator.getTable().getAuthor());
|
velocityContext.put("author" , generator.getTable().getAuthor());
|
||||||
velocityContext.put("datetime", DateUtil.now());
|
velocityContext.put("docFlag" , BaseEnum.YES.getCode().equals(generator.getTable().getDocFlag()));
|
||||||
velocityContext.put("pkColumn", generator.getPkColumn());
|
velocityContext.put("excelFlag" , BaseEnum.YES.getCode().equals(generator.getTable().getExcelFlag()));
|
||||||
|
velocityContext.put("datetime" , DateUtil.now());
|
||||||
|
velocityContext.put("pkColumn" , generator.getPkColumn());
|
||||||
|
|
||||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
velocityContext.put("permissionPrefix" , getPermissionPrefix(moduleName, businessName));
|
||||||
velocityContext.put("columns", generator.getColumns());
|
velocityContext.put("columns" , generator.getColumns());
|
||||||
velocityContext.put("queryColumns", generator.getQueryColumns());
|
velocityContext.put("queryColumns" , generator.getQueryColumns());
|
||||||
velocityContext.put("table", generator.getTable());
|
velocityContext.put("table" , generator.getTable());
|
||||||
velocityContext.put("generator", generator);
|
velocityContext.put("generator" , generator);
|
||||||
|
|
||||||
|
velocityContext.put("dicts" , getDict(generator.getColumns()));
|
||||||
|
|
||||||
String parentId = new Snowflake().nextIdStr();
|
String parentId = new Snowflake().nextIdStr();
|
||||||
velocityContext.put("parentId", parentId);
|
velocityContext.put("parentId" , parentId);
|
||||||
velocityContext.put("insertMenuId", new Snowflake().nextIdStr());
|
velocityContext.put("insertMenuId" , new Snowflake().nextIdStr());
|
||||||
velocityContext.put("updateMenuId", new Snowflake().nextIdStr());
|
velocityContext.put("updateMenuId" , new Snowflake().nextIdStr());
|
||||||
velocityContext.put("deleteMenuId", new Snowflake().nextIdStr());
|
velocityContext.put("deleteMenuId" , new Snowflake().nextIdStr());
|
||||||
velocityContext.put("selectMenuId", new Snowflake().nextIdStr());
|
velocityContext.put("selectMenuId" , new Snowflake().nextIdStr());
|
||||||
|
velocityContext.put("exportMenuId" , new Snowflake().nextIdStr());
|
||||||
|
|
||||||
velocityContext.put("tenantId", BaseContext.getTenantId());
|
velocityContext.put("tenantId" , BaseContext.getTenantId());
|
||||||
|
|
||||||
String parentMenuId = generator.getTable().getParentMenuId();
|
String parentMenuId = generator.getTable().getParentMenuId();
|
||||||
velocityContext.put("parentMenuId", StrUtil.isNotBlank(parentMenuId) ? parentMenuId : BaseConstant.DEFAULT_PARENT_ID_VALUE);
|
velocityContext.put("parentMenuId" , StrUtil.isNotBlank(parentMenuId) ? parentMenuId : BaseConstant.DEFAULT_PARENT_ID_VALUE);
|
||||||
|
|
||||||
return velocityContext;
|
return velocityContext;
|
||||||
}
|
}
|
||||||
@ -153,7 +163,36 @@ public class VelocityUtil {
|
|||||||
* @return 返回权限前缀
|
* @return 返回权限前缀
|
||||||
*/
|
*/
|
||||||
private static String getPermissionPrefix(String moduleName, String businessName) {
|
private static String getPermissionPrefix(String moduleName, String businessName) {
|
||||||
return StrUtil.format("{}:{}", moduleName, businessName);
|
return StrUtil.format("{}:{}" , moduleName, businessName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据列类型获取字典组
|
||||||
|
*
|
||||||
|
* @param columns columns
|
||||||
|
* @return 返回字典组
|
||||||
|
*/
|
||||||
|
private static String getDict(List<GeneratorTableColumn> columns) {
|
||||||
|
|
||||||
|
Set<String> dictSet = new HashSet<String>();
|
||||||
|
addDictList(dictSet, columns);
|
||||||
|
return StringUtils.join(dictSet, ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加字典列表
|
||||||
|
*
|
||||||
|
* @param dictSet 字典列表
|
||||||
|
* @param columns 列集合
|
||||||
|
*/
|
||||||
|
private static void addDictList(Set<String> dictSet, List<GeneratorTableColumn> columns) {
|
||||||
|
for (GeneratorTableColumn column : columns) {
|
||||||
|
if (StrUtil.isNotBlank(column.getDictType()) && StringUtils.equalsAny(
|
||||||
|
column.getHtmlType(),
|
||||||
|
new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX})) {
|
||||||
|
dictSet.add("'" + column.getDictType() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,34 +210,31 @@ public class VelocityUtil {
|
|||||||
// 业务名称
|
// 业务名称
|
||||||
String businessName = genTable.getBusinessName();
|
String businessName = genTable.getBusinessName();
|
||||||
|
|
||||||
String javaPath = PROJECT_PATH + "/" + StrUtil.replace(packageName, ".", "/");
|
String javaPath = PROJECT_PATH + "/" + StrUtil.replace(packageName, "." , "/");
|
||||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
|
||||||
String vuePath = "vue";
|
String vuePath = "vue";
|
||||||
|
|
||||||
if (template.contains(VM_DOMAIN)) {
|
if (template.contains(VM_DOMAIN)) {
|
||||||
fileName = StrUtil.format("{}/entity/{}.java", javaPath, className);
|
fileName = StrUtil.format("{}/entity/{}.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_DTO)) {
|
} else if (template.contains(VM_DTO)) {
|
||||||
fileName = StrUtil.format("{}/entity/dto/{}Dto.java", javaPath, className);
|
fileName = StrUtil.format("{}/entity/dto/{}Dto.java" , javaPath, className);
|
||||||
|
} else if (template.contains(VM_EXCEL_EXPORT)) {
|
||||||
|
fileName = StrUtil.format("{}/entity/template/{}Export.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_PARAM)) {
|
} else if (template.contains(VM_PARAM)) {
|
||||||
fileName = StrUtil.format("{}/entity/param/{}Param.java", javaPath, className);
|
fileName = StrUtil.format("{}/entity/param/{}Param.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_MAPPER)) {
|
} else if (template.contains(VM_MAPPER)) {
|
||||||
fileName = StrUtil.format("{}/mapper/{}Mapper.java", javaPath, className);
|
fileName = StrUtil.format("{}/mapper/{}Mapper.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_SERVICE)) {
|
} else if (template.contains(VM_SERVICE)) {
|
||||||
fileName = StrUtil.format("{}/service/{}Service.java", javaPath, className);
|
fileName = StrUtil.format("{}/service/{}Service.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_SERVICE_IMPL)) {
|
} else if (template.contains(VM_SERVICE_IMPL)) {
|
||||||
fileName = StrUtil.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
fileName = StrUtil.format("{}/service/impl/{}ServiceImpl.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_CONTROLLER)) {
|
} else if (template.contains(VM_CONTROLLER)) {
|
||||||
fileName = StrUtil.format("{}/controller/{}Controller.java", javaPath, className);
|
fileName = StrUtil.format("{}/controller/{}Controller.java" , javaPath, className);
|
||||||
} else if (template.contains(VM_MAPPER_XML)) {
|
|
||||||
fileName = StrUtil.format("{}/{}Mapper.xml", mybatisPath, className);
|
|
||||||
} else if (template.contains(VM_SQL)) {
|
} else if (template.contains(VM_SQL)) {
|
||||||
fileName = businessName + "Menu.sql";
|
fileName = businessName + "Menu.sql";
|
||||||
} else if (template.contains(VM_API_JS)) {
|
} else if (template.contains(VM_API_JS)) {
|
||||||
fileName = StrUtil.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
fileName = StrUtil.format("{}/api/{}/{}.js" , vuePath, moduleName, businessName);
|
||||||
} else if (template.contains(VM_INDEX_VUE)) {
|
} else if (template.contains(VM_INDEX_VUE)) {
|
||||||
fileName = StrUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
fileName = StrUtil.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName);
|
||||||
} else if (template.contains(VM_INDEX_TREE_VUE)) {
|
|
||||||
fileName = StrUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
|
||||||
}
|
}
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -3,8 +3,15 @@ package ${packageName}.controller;
|
|||||||
import com.qiaoba.common.base.result.AjaxResult;
|
import com.qiaoba.common.base.result.AjaxResult;
|
||||||
import com.qiaoba.common.database.entity.PageQuery;
|
import com.qiaoba.common.database.entity.PageQuery;
|
||||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||||
|
#if($docFlag)
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
#end
|
||||||
|
#if($excelFlag)
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import com.qiaoba.common.poi.utils.ExcelUtil;
|
||||||
|
import ${packageName}.entity.template.${ClassName}Export;
|
||||||
|
#end
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -27,45 +34,94 @@ import ${packageName}.service.${ClassName}Service;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/${moduleName}/${businessName}")
|
@RequestMapping("/${moduleName}/${businessName}")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
#if($docFlag)
|
||||||
@Tag(name = "${functionName}管理")
|
@Tag(name = "${functionName}管理")
|
||||||
|
#end
|
||||||
public class ${ClassName}Controller {
|
public class ${ClassName}Controller {
|
||||||
|
|
||||||
private final ${ClassName}Service ${className}Service;
|
private final ${ClassName}Service ${className}Service;
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Operation(summary = "获取列表")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 获取列表
|
||||||
|
*/
|
||||||
|
#end
|
||||||
@PreAuthorize("hasAuthority('${permissionPrefix}:list')")
|
@PreAuthorize("hasAuthority('${permissionPrefix}:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获取列表")
|
|
||||||
public TableDataInfo<${ClassName}> list(${ClassName}Param param, PageQuery pageQuery) {
|
public TableDataInfo<${ClassName}> list(${ClassName}Param param, PageQuery pageQuery) {
|
||||||
return ${className}Service.selectPageList(param, pageQuery);
|
return ${className}Service.selectPageList(param, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Operation(summary = "获取详情")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 获取详情
|
||||||
|
*/
|
||||||
|
#end
|
||||||
@PreAuthorize("hasAuthority('${permissionPrefix}:query')")
|
@PreAuthorize("hasAuthority('${permissionPrefix}:query')")
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
@Operation(summary = "获取详情")
|
|
||||||
public AjaxResult getInfo(@PathVariable String ${pkColumn.javaField}) {
|
public AjaxResult getInfo(@PathVariable String ${pkColumn.javaField}) {
|
||||||
return AjaxResult.success(${className}Service.selectById(${pkColumn.javaField}, false));
|
return AjaxResult.success(${className}Service.selectById(${pkColumn.javaField}, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Operation(summary = "新增${functionName}")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 新增${functionName}
|
||||||
|
*/
|
||||||
|
#end
|
||||||
@PreAuthorize("hasAuthority('${permissionPrefix}:add')")
|
@PreAuthorize("hasAuthority('${permissionPrefix}:add')")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "新增${functionName}")
|
|
||||||
public AjaxResult add(@RequestBody ${ClassName}Dto dto) {
|
public AjaxResult add(@RequestBody ${ClassName}Dto dto) {
|
||||||
return AjaxResult.toAjax(${className}Service.insert(dto));
|
return AjaxResult.toAjax(${className}Service.insert(dto));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Operation(summary = "修改${functionName}")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 修改${functionName}
|
||||||
|
*/
|
||||||
|
#end
|
||||||
@PreAuthorize("hasAuthority('${permissionPrefix}:edit')")
|
@PreAuthorize("hasAuthority('${permissionPrefix}:edit')")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@Operation(summary = "修改${functionName}")
|
|
||||||
public AjaxResult edit(@RequestBody ${ClassName}Dto dto) {
|
public AjaxResult edit(@RequestBody ${ClassName}Dto dto) {
|
||||||
return AjaxResult.toAjax(${className}Service.updateById(dto));
|
return AjaxResult.toAjax(${className}Service.updateById(dto));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Operation(summary = "删除${functionName}")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 删除${functionName}
|
||||||
|
*/
|
||||||
|
#end
|
||||||
@PreAuthorize("hasAuthority('${permissionPrefix}:remove')")
|
@PreAuthorize("hasAuthority('${permissionPrefix}:remove')")
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
@Operation(summary = "删除${functionName}")
|
|
||||||
public AjaxResult remove(@PathVariable List<String> ${pkColumn.javaField}s) {
|
public AjaxResult remove(@PathVariable List<String> ${pkColumn.javaField}s) {
|
||||||
return AjaxResult.toAjax(${className}Service.deleteByIds(${pkColumn.javaField}s));
|
return AjaxResult.toAjax(${className}Service.deleteByIds(${pkColumn.javaField}s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($excelFlag)
|
||||||
|
#if($docFlag)
|
||||||
|
@Operation(summary = "导出${functionName}")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 导出${functionName}
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
@PreAuthorize("hasAuthority('${permissionPrefix}:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, ${ClassName}Param param) {
|
||||||
|
List<${ClassName}> list = ${className}Service.selectList(param);
|
||||||
|
ExcelUtil.exportExcel(list, ${ClassName}Export.class, "${functionName}数据", response);
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package ${packageName}.entity;
|
package ${packageName}.entity;
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@ -29,7 +31,13 @@ public class ${ClassName}Dto implements Serializable {
|
|||||||
|
|
||||||
## 不是主键
|
## 不是主键
|
||||||
#else
|
#else
|
||||||
|
#if($docFlag)
|
||||||
@Schema(description = "$column.columnComment")
|
@Schema(description = "$column.columnComment")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
#end
|
||||||
private $column.javaType $column.javaField;
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
#end
|
#end
|
@ -0,0 +1,36 @@
|
|||||||
|
package ${packageName}.entity.template;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${functionName} 导出模板
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @version 1.0
|
||||||
|
* @since ${datetime}
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ${ClassName}Export implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.isList == "1")
|
||||||
|
#if($column.javaType == "Date")
|
||||||
|
@Excel(name = "$column.columnComment", width = 30, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
#else
|
||||||
|
@Excel(name = "$column.columnComment", width = 20)
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package ${packageName}.entity;
|
package ${packageName}.entity;
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@ -25,24 +27,42 @@ public class ${ClassName}Param implements Serializable {
|
|||||||
#if($column.queryType == "BETWEEN")
|
#if($column.queryType == "BETWEEN")
|
||||||
#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($docFlag)
|
||||||
|
@Schema(description = "开始$column.columnComment")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 开始$column.columnComment
|
||||||
|
*/
|
||||||
|
#end
|
||||||
#if($column.javaType == "Date")
|
#if($column.javaType == "Date")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
#end
|
#end
|
||||||
@Schema(description = "开始$column.columnComment")
|
|
||||||
private $column.javaType start$AttrName;
|
private $column.javaType start$AttrName;
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Schema(description = "结束$column.columnComment")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* 结束$column.columnComment
|
||||||
|
*/
|
||||||
|
#end
|
||||||
#if($column.javaType == "Date")
|
#if($column.javaType == "Date")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
#end
|
#end
|
||||||
@Schema(description = "结束$column.columnComment")
|
|
||||||
private $column.javaType end$AttrName;
|
private $column.javaType end$AttrName;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#if($docFlag)
|
||||||
|
@Schema(description = "$column.columnComment")
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
#end
|
||||||
#if($column.javaType == "Date")
|
#if($column.javaType == "Date")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
#end
|
#end
|
||||||
@Schema(description = "$column.columnComment")
|
|
||||||
private $column.javaType $column.javaField;
|
private $column.javaType $column.javaField;
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
@ -41,4 +41,5 @@ export function del${BusinessName}(${pkColumn.javaField}) {
|
|||||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
@ -1,16 +1,21 @@
|
|||||||
-- 菜单 SQL
|
-- 菜单 SQL
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||||
values('${parentId}', '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 0, 0, 'C', '1', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单', '${tenantId}');
|
values('${parentId}', '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 0, 0, 'C', '1', '${permissionPrefix}:list', '#', 'admin', '${datetime}', '', null, '${functionName}菜单', '${tenantId}');
|
||||||
|
|
||||||
-- 按钮 SQL
|
-- 按钮 SQL
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||||
values('${selectMenuId}', '${functionName}查询', '${parentId}', '1', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '', '${tenantId}');
|
values('${selectMenuId}', '${functionName}查询', '${parentId}', '1', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:query', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||||
|
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||||
values('${insertMenuId}', '${functionName}新增', '${parentId}', '2', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '', '${tenantId}');
|
values('${insertMenuId}', '${functionName}新增', '${parentId}', '2', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:add', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||||
|
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||||
values('${updateMenuId}', '${functionName}修改', '${parentId}', '3', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '', '${tenantId}');
|
values('${updateMenuId}', '${functionName}修改', '${parentId}', '3', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:edit', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||||
|
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||||
values('${deleteMenuId}', '${functionName}删除', '${parentId}', '4', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '', '${tenantId}');
|
values('${deleteMenuId}', '${functionName}删除', '${parentId}', '4', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:remove', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||||
|
|
||||||
|
#if($excelFlag)
|
||||||
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, is_visible, perms, icon, create_user, create_time, update_user, update_time, remark, tenant_id)
|
||||||
|
values('${exportMenuId}', '${functionName}导出', '${parentId}', '5', '#', '', 0, 0, 'F', '1', '${permissionPrefix}:export', '#', 'admin', '${datetime}', '', null, '', '${tenantId}');
|
||||||
|
#end
|
@ -96,6 +96,7 @@
|
|||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
#if($excelFlag)
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
@ -105,6 +106,7 @@
|
|||||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||||
>导出</el-button>
|
>导出</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
#end
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@ -465,12 +467,14 @@ function handleDelete(row) {
|
|||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if($excelFlag)
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
proxy.download('${moduleName}/${businessName}/export', {
|
proxy.download('${moduleName}/${businessName}/export', {
|
||||||
...queryParams.value
|
...queryParams.value
|
||||||
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||||
}
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
getList();
|
getList();
|
||||||
</script>
|
</script>
|
Reference in New Issue
Block a user