mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 18:45:06 +08:00
基本完成代码生成器
This commit is contained in:
@ -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