mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-23 15:35:06 +08:00
基本完成代码生成器
This commit is contained in:
@ -44,14 +44,19 @@ public class DictConvert implements Converter<Object> {
|
||||
|
||||
@Override
|
||||
public CellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
// 空时,返回空
|
||||
if (object == null) {
|
||||
return new CellData<>("");
|
||||
}
|
||||
|
||||
// 使用字典格式化
|
||||
SysDictTypeEnum type = getType(contentProperty);
|
||||
String value = String.valueOf(object);
|
||||
SysDictDataDO dictData = DictUtils.getDictDataFromCache(type.getValue(), value);
|
||||
if (dictData == null) {
|
||||
log.error("[convertToExcelData][type({}) 转换不了 label({})]", type, value);
|
||||
return null;
|
||||
return new CellData<>("");
|
||||
}
|
||||
// 生成 Excel 小表格
|
||||
return new CellData<>(dictData.getLabel());
|
||||
|
@ -1 +0,0 @@
|
||||
package cn.iocoder.dashboard.framework.excel.core;
|
@ -42,11 +42,12 @@ public class SysMenuBaseVO {
|
||||
@ApiModelProperty(value = "菜单图标", example = "/menu/list", notes = "仅菜单类型为菜单或者目录时,才需要传")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
@ApiModelProperty(value = "组件路径", example = "system/post/index", notes = "仅菜单类型为菜单时,才需要传")
|
||||
@Size(max = 200, message = "组件路径不能超过255个字符")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ public class ToolCodegenController {
|
||||
@ApiImplicitParam(name = "tableName", required = true, example = "yudao", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "tableComment", required = true, example = "芋道", dataTypeClass = String.class)
|
||||
})
|
||||
// @PreAuthorize("@ss.hasPermi('tool:gen:list')") TODO 权限
|
||||
public CommonResult<List<ToolSchemaTableRespVO>> getSchemaTableList(
|
||||
@RequestParam(value = "tableName", required = false) String tableName,
|
||||
@RequestParam(value = "tableComment", required = false) String tableComment) {
|
||||
|
@ -31,10 +31,6 @@ public class ToolCodegenTableBaseVO {
|
||||
@NotNull(message = "业务名不能为空")
|
||||
private String businessName;
|
||||
|
||||
@ApiModelProperty(value = "业务包", required = true, example = "codegen")
|
||||
@NotNull(message = "业务包不能为空")
|
||||
private String businessPackage;
|
||||
|
||||
@ApiModelProperty(value = "类名称", required = true, example = "ToolCodegenTable")
|
||||
@NotNull(message = "类名称不能为空")
|
||||
private String className;
|
||||
@ -51,4 +47,7 @@ public class ToolCodegenTableBaseVO {
|
||||
@NotNull(message = "模板类型不能为空")
|
||||
private Integer templateType;
|
||||
|
||||
@ApiModelProperty(value = "父菜单编号", example = "1024")
|
||||
private Long parentMenuId;
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.tool.controller.test;
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.dashboard.modules.tool.controller.test.vo.*;
|
||||
import cn.iocoder.dashboard.modules.tool.convert.test.ToolTestDemoConvert;
|
||||
import cn.iocoder.dashboard.modules.tool.dal.dataobject.test.ToolTestDemoDO;
|
||||
@ -10,6 +11,7 @@ import cn.iocoder.dashboard.modules.tool.service.test.ToolTestDemoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -21,8 +23,9 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "字典类型")
|
||||
@Api(tags = "测试示例")
|
||||
@RestController
|
||||
@RequestMapping("/tool/test-demo")
|
||||
@Validated
|
||||
@ -31,58 +34,66 @@ public class ToolTestDemoController {
|
||||
@Resource
|
||||
private ToolTestDemoService testDemoService;
|
||||
|
||||
@ApiOperation("创建字典类型")
|
||||
@PostMapping("/create")
|
||||
public CommonResult<Long> createTestDemo(@Valid ToolTestDemoCreateReqVO createReqVO) {
|
||||
@ApiOperation("创建测试示例")
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:create')")
|
||||
public CommonResult<Long> createTestDemo(@Valid @RequestBody ToolTestDemoCreateReqVO createReqVO) {
|
||||
return success(testDemoService.createTestDemo(createReqVO));
|
||||
}
|
||||
|
||||
@ApiOperation("更新字典类型")
|
||||
@PutMapping("/update")
|
||||
public CommonResult<Boolean> updateTestDemo(@Valid ToolTestDemoUpdateReqVO updateReqVO) {
|
||||
@ApiOperation("更新测试示例")
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:update')")
|
||||
public CommonResult<Boolean> updateTestDemo(@Valid @RequestBody ToolTestDemoUpdateReqVO updateReqVO) {
|
||||
testDemoService.updateTestDemo(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ApiOperation("删除字典类型")
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除测试示例")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:delete')")
|
||||
public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) {
|
||||
testDemoService.deleteTestDemo(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得字典类型")
|
||||
@ApiOperation("获得测试示例")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:query')")
|
||||
public CommonResult<ToolTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) {
|
||||
ToolTestDemoDO testDemo = testDemoService.getTestDemo(id);
|
||||
return success(ToolTestDemoConvert.INSTANCE.convert(testDemo));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得字典类型列表")
|
||||
@ApiOperation("获得测试示例列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:query')")
|
||||
public CommonResult<List<ToolTestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ToolTestDemoDO> list = testDemoService.getTestDemoList(ids);
|
||||
return success(ToolTestDemoConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@ApiOperation("获得字典类型分页")
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得测试示例分页")
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:query')")
|
||||
public CommonResult<PageResult<ToolTestDemoRespVO>> getTestDemoPage(@Valid ToolTestDemoPageReqVO pageVO) {
|
||||
PageResult<ToolTestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO);
|
||||
return success(ToolTestDemoConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出字典类型 Excel")
|
||||
@ApiOperation("导出测试示例 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('tool:test-demo:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportTestDemoExcel(@Valid ToolTestDemoExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ToolTestDemoDO> list = testDemoService.getTestDemoList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ToolTestDemoExcelVO> datas = ToolTestDemoConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "字典类型.xls", "数据", ToolTestDemoExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "测试示例.xls", "数据", ToolTestDemoExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.dashboard.modules.tool.controller.test.vo;
|
||||
|
||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -9,7 +10,7 @@ import java.util.Date;
|
||||
import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.*;
|
||||
|
||||
/**
|
||||
* 字典类型 Excel VO
|
||||
* 测试示例 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@ -22,15 +23,15 @@ public class ToolTestDemoExcelVO {
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("状态")
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(SYS_COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("类型")
|
||||
@ExcelProperty(value = "类型", converter = DictConvert.class)
|
||||
@DictFormat(SYS_OPERATE_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty("分类")
|
||||
@ExcelProperty(value = "分类", converter = DictConvert.class)
|
||||
@DictFormat(INF_REDIS_TIMEOUT_TYPE)
|
||||
private Integer category;
|
||||
|
||||
|
@ -53,14 +53,6 @@ public class ToolCodegenTableDO extends BaseDO {
|
||||
* 例如说,user、permission、dict 等等
|
||||
*/
|
||||
private String businessName;
|
||||
/**
|
||||
* 业务包,自定义二级目录
|
||||
*
|
||||
* 例如说,我们希望将 dictType 和 dictData 归类成 dict 业务
|
||||
*
|
||||
* 如果不需要的情况下,businessName 和 businessPackage 是等价的
|
||||
*/
|
||||
private String businessPackage;
|
||||
/**
|
||||
* 类名称(首字母大写)
|
||||
*
|
||||
|
@ -128,7 +128,6 @@ public class ToolCodegenBuilder {
|
||||
'_', false))); // 第一个 _ 前缀的前面,作为 module 名字
|
||||
table.setBusinessName(toCamelCase(subAfter(table.getTableName(),
|
||||
'_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰
|
||||
table.setBusinessPackage(table.getBusinessPackage());
|
||||
table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写
|
||||
table.setClassComment(subBefore(table.getTableComment(), // 去除结尾的表,作为类描述
|
||||
'表', true));
|
||||
|
@ -11,6 +11,7 @@ import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.codegen.config.CodegenProperties;
|
||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum;
|
||||
@ -27,11 +28,9 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.hutool.core.map.MapUtil.getStr;
|
||||
import static cn.hutool.core.text.CharSequenceUtil.*;
|
||||
|
||||
/**
|
||||
@ -82,7 +81,7 @@ public class ToolCodegenEngine {
|
||||
javaFilePath("service/${table.businessName}/impl/${table.className}ServiceImpl"))
|
||||
// Vue
|
||||
.put(vueTemplatePath("views/index.vue"),
|
||||
vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
|
||||
vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue"))
|
||||
.put(vueTemplatePath("api/api.js"),
|
||||
vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
|
||||
// SQL
|
||||
@ -131,6 +130,7 @@ public class ToolCodegenEngine {
|
||||
globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName());
|
||||
globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName());
|
||||
globalBindingMap.put("ExcelUtilsClassName", ExcelUtils.class.getName());
|
||||
globalBindingMap.put("DictConvertClassName", DictConvert.class.getName());
|
||||
globalBindingMap.put("OperateLogClassName", OperateLog.class.getName());
|
||||
globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName());
|
||||
}
|
||||
@ -167,13 +167,18 @@ public class ToolCodegenEngine {
|
||||
}
|
||||
|
||||
private String formatFilePath(String filePath, Map<String, Object> bindingMap) {
|
||||
filePath = StrUtil.replace(filePath, "${basePackage}", ((String) bindingMap.get("basePackage")).replaceAll("\\.", "/"));
|
||||
filePath = StrUtil.replace(filePath, "${basePackage}",
|
||||
getStr(bindingMap, "basePackage").replaceAll("\\.", "/"));
|
||||
filePath = StrUtil.replace(filePath, "${simpleModuleName_upperFirst}",
|
||||
getStr(bindingMap, "simpleModuleName_upperFirst"));
|
||||
filePath = StrUtil.replace(filePath, "${classNameVar}",
|
||||
getStr(bindingMap, "classNameVar"));
|
||||
|
||||
// table 包含的字段
|
||||
ToolCodegenTableDO table = (ToolCodegenTableDO) bindingMap.get("table");
|
||||
filePath = StrUtil.replace(filePath, "${simpleModuleName_upperFirst}", (String) bindingMap.get("simpleModuleName_upperFirst"));
|
||||
filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName());
|
||||
filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName());
|
||||
filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName());
|
||||
filePath = StrUtil.replace(filePath, "${classNameVar}", (String) bindingMap.get("classNameVar"));
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
@ -39,15 +39,15 @@ public class ${table.className}Controller {
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建${table.classComment}")
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:create')")
|
||||
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
|
||||
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${table.className}CreateReqVO createReqVO) {
|
||||
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新${table.classComment}")
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:update')")
|
||||
public CommonResult<Boolean> update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) {
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
|
||||
public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${table.className}UpdateReqVO updateReqVO) {
|
||||
${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class ${table.className}Controller {
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除${table.classComment}")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
||||
public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||
${classNameVar}Service.delete${simpleClassName}(id);
|
||||
return success(true);
|
||||
@ -64,7 +64,7 @@ public class ${table.className}Controller {
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得${table.classComment}")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class)
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
|
||||
return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
|
||||
@ -73,7 +73,7 @@ public class ${table.className}Controller {
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得${table.classComment}列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
|
||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);
|
||||
return success(${table.className}Convert.INSTANCE.convertList(list));
|
||||
@ -81,7 +81,7 @@ public class ${table.className}Controller {
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得${table.classComment}分页")
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) {
|
||||
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);
|
||||
return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
|
||||
@ -89,7 +89,7 @@ public class ${table.className}Controller {
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出${table.classComment} Excel")
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
@ -8,6 +8,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
#foreach ($column in $columns)
|
||||
#if ("$!column.dictType" != "")## 有设置数据字典
|
||||
import ${DictFormatClassName};
|
||||
import ${DictConvertClassName};
|
||||
|
||||
import static ${SysDictTypeEnumClassName}.*;
|
||||
#break
|
||||
@ -24,9 +25,11 @@ public class ${table.className}ExcelVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperationResult})##返回字段
|
||||
@ExcelProperty("${column.columnComment}")
|
||||
#if ("$!column.dictType" != "")##处理枚举值
|
||||
@ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class)
|
||||
@DictFormat(${column.dictType.toUpperCase()})
|
||||
#else
|
||||
@ExcelProperty("${column.columnComment}")
|
||||
#end
|
||||
private ${column.javaType} ${column.javaField};
|
||||
|
||||
|
@ -4,8 +4,8 @@ INSERT INTO `sys_menu`(
|
||||
`path`, `icon`, `component`, `status`
|
||||
)
|
||||
VALUES (
|
||||
'${table.tableComment}管理', '${permissionPrefix}:query', 2, 0, ${table.parentMenuId},
|
||||
'${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 1
|
||||
'${table.classComment}管理', '${permissionPrefix}:query', 2, 0, ${table.parentMenuId},
|
||||
'${simpleClassName_strikeCase}', '', '${table.moduleName}/${classNameVar}/index', 1
|
||||
);
|
||||
|
||||
-- 按钮父菜单ID
|
||||
@ -15,12 +15,13 @@ SELECT @parentId := LAST_INSERT_ID();
|
||||
#set ($functionNames = ['创建', '更新', '删除', '导出'])
|
||||
#set ($functionOps = ['create', 'update', 'delete', 'export'])
|
||||
#foreach ($functionName in $functionNames)
|
||||
#set ($index = $foreach.count - 1)
|
||||
INSERT INTO `sys_menu`(
|
||||
`name`, `permission`, `menu_type`, `sort`, `parent_id`,
|
||||
`path`, `icon`, `component`, `status`
|
||||
)
|
||||
VALUES (
|
||||
'${table.tableComment}${functionName}', '${permissionPrefix}:${functionOps[$velocityCount]}', 3, 0, @parentId,
|
||||
'${table.tableComment}${functionName}', '${permissionPrefix}:${functionOps.get($index)}', 3, $foreach.count, @parentId,
|
||||
'', '', '', 1
|
||||
);
|
||||
#end
|
||||
|
@ -23,7 +23,7 @@ export function update${simpleClassName}(data) {
|
||||
// 删除${table.classComment}
|
||||
export function delete${simpleClassName}(id) {
|
||||
return request({
|
||||
url: '${baseURL}/delelte?id=' + id,
|
||||
url: '${baseURL}/delete?id=' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@ -51,6 +51,6 @@ export function export${simpleClassName}Excel(query) {
|
||||
url: '${baseURL}/export-excel',
|
||||
method: 'get',
|
||||
params: query,
|
||||
reponseBody: 'blob'
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
@ -18,14 +18,14 @@
|
||||
<el-select v-model="queryParams.${javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
|
||||
:key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"/>
|
||||
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
#else## 未设置 dictType 数据字典的情况
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
#end
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
#if ($column.queryType != "BETWEEN")## 非范围
|
||||
#if ($column.listOperationCondition != "BETWEEN")## 非范围
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-date-picker clearable size="small" v-model="queryParams.${javaField}" type="date" value-format="yyyy-MM-dd" placeholder="选择${comment}" />
|
||||
</el-form-item>
|
||||
@ -74,7 +74,7 @@
|
||||
#elseif("" != $column.dictType)## 数据字典
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getDictDataLabel(DICT_TYPE.$dictType.toUpperCase(), scope.row.javaField) }}</span>
|
||||
<span>{{ getDictDataLabel(DICT_TYPE.$dictType.toUpperCase(), scope.row.${column.javaField}) }}</span>
|
||||
</template>
|
||||
</el-table-column>>
|
||||
#else
|
||||
@ -253,11 +253,12 @@ export default {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField});
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, '${column.javaField}');
|
||||
#end
|
||||
#end
|
||||
// 执行查询
|
||||
@ -279,7 +280,7 @@ export default {
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: [],
|
||||
#else
|
||||
$column.javaField: null,
|
||||
$column.javaField: undefined,
|
||||
#end
|
||||
#end
|
||||
};
|
||||
@ -325,7 +326,7 @@ export default {
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.#[[$]]#refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
#foreach ($column in $columns)
|
||||
@ -366,19 +367,23 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
params.pageNo = undefined;
|
||||
params.pageSize = undefined;
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, '${column.javaField}');
|
||||
#end
|
||||
#end
|
||||
// 执行导出
|
||||
this.$confirm('是否确认导出所有${table.classComment}数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
let params = {...this.queryParams};
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, ${column.javaField});
|
||||
#end
|
||||
#end
|
||||
return export${simpleClassName}(params);
|
||||
return export${simpleClassName}Excel(params);
|
||||
}).then(response => {
|
||||
this.downloadExcel(response, '${table.classComment}.xls');
|
||||
})
|
||||
|
Reference in New Issue
Block a user