mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-01 01:50:04 +08:00
完成代码生成器的 sql 生成
This commit is contained in:
parent
b8351f50f2
commit
937c51f4ec
@ -42,14 +42,4 @@ public class GenTable extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String treeName;
|
private String treeName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单ID字段
|
|
||||||
*/
|
|
||||||
private String parentMenuId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级菜单名称字段
|
|
||||||
*/
|
|
||||||
private String parentMenuName;
|
|
||||||
|
|
||||||
}
|
}
|
@ -61,13 +61,6 @@ public class VelocityUtils {
|
|||||||
return velocityContext;
|
return velocityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
|
|
||||||
String options = genTable.getOptions();
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
|
||||||
String parentMenuId = getParentMenuId(paramsObj);
|
|
||||||
context.put("parentMenuId", parentMenuId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
|
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSONObject.parseObject(options);
|
@ -1,114 +0,0 @@
|
|||||||
package ${packageName}.controller;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
|
||||||
import ${packageName}.domain.${ClassName};
|
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
||||||
#if($table.crud)
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
#elseif($table.tree)
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${functionName}Controller
|
|
||||||
*
|
|
||||||
* @author ${author}
|
|
||||||
* @date ${datetime}
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/${moduleName}/${businessName}")
|
|
||||||
public class ${ClassName}Controller extends BaseController
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private I${ClassName}Service ${className}Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询${functionName}列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
#if($table.crud)
|
|
||||||
public TableDataInfo list(${ClassName} ${className})
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
#elseif($table.tree)
|
|
||||||
public AjaxResult list(${ClassName} ${className})
|
|
||||||
{
|
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
||||||
return AjaxResult.success(list);
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出${functionName}列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(${ClassName} ${className})
|
|
||||||
{
|
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
||||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
|
||||||
return util.exportExcel(list, "${businessName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取${functionName}详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
|
||||||
{
|
|
||||||
return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增${functionName}
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
|
||||||
{
|
|
||||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改${functionName}
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
|
||||||
{
|
|
||||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除${functionName}
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
|
||||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
|
||||||
{
|
|
||||||
return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
-- 菜单 SQL
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
|
|
||||||
|
|
||||||
-- 按钮父菜单ID
|
|
||||||
SELECT @parentId := LAST_INSERT_ID();
|
|
||||||
|
|
||||||
-- 按钮 SQL
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
|
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
|
||||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
|
|
@ -33,7 +33,7 @@ public class SysUserSessionDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 用户编号
|
* 用户编号
|
||||||
*
|
*
|
||||||
* 外键 {@link SysUserDO#getId()}
|
* 关联 {@link SysUserDO#getId()}
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ public class SysDeptDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 父部门ID
|
* 父部门ID
|
||||||
*
|
*
|
||||||
* 外键 {@link #id}
|
* 关联 {@link #id}
|
||||||
*/
|
*/
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ public class ToolCodegenColumnDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 表编号
|
* 表编号
|
||||||
*
|
*
|
||||||
* 外键 {@link ToolCodegenTableDO#getId()}
|
* 关联 {@link ToolCodegenTableDO#getId()}
|
||||||
*/
|
*/
|
||||||
private Long tableId;
|
private Long tableId;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen;
|
package cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysMenuDO;
|
||||||
import cn.iocoder.dashboard.modules.tool.enums.codegen.ToolCodegenTemplateTypeEnum;
|
import cn.iocoder.dashboard.modules.tool.enums.codegen.ToolCodegenTemplateTypeEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@ -86,4 +87,11 @@ public class ToolCodegenTableDO extends BaseDO {
|
|||||||
|
|
||||||
// ========== 菜单相关字段 ==========
|
// ========== 菜单相关字段 ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父菜单编号
|
||||||
|
*
|
||||||
|
* 关联 {@link SysMenuDO#getId()}
|
||||||
|
*/
|
||||||
|
private Long parentMenuId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import cn.iocoder.dashboard.common.pojo.PageResult;
|
|||||||
import cn.iocoder.dashboard.framework.codegen.config.CodegenProperties;
|
import cn.iocoder.dashboard.framework.codegen.config.CodegenProperties;
|
||||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
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;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||||
@ -84,6 +86,7 @@ public class ToolCodegenEngine {
|
|||||||
.put(vueTemplatePath("api/api.js"),
|
.put(vueTemplatePath("api/api.js"),
|
||||||
vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
|
vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
|
||||||
// SQL
|
// SQL
|
||||||
|
.put("codegen/sql/sql.vm", "sql/sql.sql")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -124,10 +127,12 @@ public class ToolCodegenEngine {
|
|||||||
globalBindingMap.put("BaseDOClassName", BaseDO.class.getName());
|
globalBindingMap.put("BaseDOClassName", BaseDO.class.getName());
|
||||||
globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName());
|
globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName());
|
||||||
globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName());
|
globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName());
|
||||||
// Util 了诶
|
// Util 工具类
|
||||||
globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName());
|
globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName());
|
||||||
globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName());
|
globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName());
|
||||||
globalBindingMap.put("ExcelUtilsClassName", ExcelUtils.class.getName());
|
globalBindingMap.put("ExcelUtilsClassName", ExcelUtils.class.getName());
|
||||||
|
globalBindingMap.put("OperateLogClassName", OperateLog.class.getName());
|
||||||
|
globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> execute(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) {
|
public Map<String, String> execute(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) {
|
||||||
@ -146,7 +151,10 @@ public class ToolCodegenEngine {
|
|||||||
bindingMap.put("simpleClassName", simpleClassName);
|
bindingMap.put("simpleClassName", simpleClassName);
|
||||||
bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type
|
bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type
|
||||||
bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量
|
bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量
|
||||||
bindingMap.put("simpleClassName_strikeCase", toSymbolCase(simpleClassName, '-')); // 将 DictType 转换成 dict-type
|
String simpleClassNameStrikeCase = toSymbolCase(simpleClassName, '-'); // 将 DictType 转换成 dict-type
|
||||||
|
bindingMap.put("simpleClassName_strikeCase", simpleClassNameStrikeCase);
|
||||||
|
// permission 前缀
|
||||||
|
bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase);
|
||||||
|
|
||||||
// 执行生成
|
// 执行生成
|
||||||
final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序
|
final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序
|
||||||
|
@ -3,6 +3,7 @@ package ${basePackage}.${table.moduleName}.controller.${table.businessName};
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
|
||||||
@ -18,6 +19,9 @@ import static ${CommonResultClassName}.success;
|
|||||||
|
|
||||||
import ${ExcelUtilsClassName};
|
import ${ExcelUtilsClassName};
|
||||||
|
|
||||||
|
import ${OperateLogClassName};
|
||||||
|
import static ${OperateTypeEnumClassName}.*;
|
||||||
|
|
||||||
import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
|
import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||||
import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||||
import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
||||||
@ -33,22 +37,25 @@ public class ${table.className}Controller {
|
|||||||
@Resource
|
@Resource
|
||||||
private ${table.className}Service ${classNameVar}Service;
|
private ${table.className}Service ${classNameVar}Service;
|
||||||
|
|
||||||
@ApiOperation("创建${table.classComment}")
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
|
@ApiOperation("创建${table.classComment}")
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:create')")
|
||||||
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
|
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
|
||||||
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("更新${table.classComment}")
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
|
@ApiOperation("更新${table.classComment}")
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:update')")
|
||||||
public CommonResult<Boolean> update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) {
|
public CommonResult<Boolean> update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) {
|
||||||
${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除${table.classComment}")
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
|
@ApiOperation("删除${table.classComment}")
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:delete')")
|
||||||
public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||||
${classNameVar}Service.delete${simpleClassName}(id);
|
${classNameVar}Service.delete${simpleClassName}(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
@ -57,6 +64,7 @@ public class ${table.className}Controller {
|
|||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@ApiOperation("获得${table.classComment}")
|
@ApiOperation("获得${table.classComment}")
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class)
|
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class)
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||||
public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||||
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
|
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
|
||||||
return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
|
return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
|
||||||
@ -65,13 +73,15 @@ public class ${table.className}Controller {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation("获得${table.classComment}列表")
|
@ApiOperation("获得${table.classComment}列表")
|
||||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
|
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||||
public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
|
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);
|
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);
|
||||||
return success(${table.className}Convert.INSTANCE.convertList(list));
|
return success(${table.className}Convert.INSTANCE.convertList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获得${table.classComment}分页")
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
@ApiOperation("获得${table.classComment}分页")
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||||
public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) {
|
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);
|
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);
|
||||||
return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
|
return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
|
||||||
@ -79,6 +89,8 @@ public class ${table.className}Controller {
|
|||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@ApiOperation("导出${table.classComment} Excel")
|
@ApiOperation("导出${table.classComment} Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
|
public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO);
|
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO);
|
||||||
|
26
src/main/resources/codegen/sql/sql.vm
Normal file
26
src/main/resources/codegen/sql/sql.vm
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
-- 菜单 SQL
|
||||||
|
INSERT INTO `sys_menu`(
|
||||||
|
`name`, `permission`, `menu_type`, `sort`, `parent_id`,
|
||||||
|
`path`, `icon`, `component`, `status`
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'${table.tableComment}管理', '${permissionPrefix}:query', 2, 0, ${table.parentMenuId},
|
||||||
|
'${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 1
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 按钮父菜单ID
|
||||||
|
SELECT @parentId := LAST_INSERT_ID();
|
||||||
|
|
||||||
|
-- 按钮 SQL
|
||||||
|
#set ($functionNames = ['创建', '更新', '删除', '导出'])
|
||||||
|
#set ($functionOps = ['create', 'update', 'delete', 'export'])
|
||||||
|
#foreach ($functionName in $functionNames)
|
||||||
|
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,
|
||||||
|
'', '', '', 1
|
||||||
|
);
|
||||||
|
#end
|
@ -48,11 +48,11 @@
|
|||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:export']">导出</el-button>
|
v-hasPermi="['${permissionPrefix}:export']">导出</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -85,9 +85,9 @@
|
|||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
v-hasPermi="['${permissionPrefix}:update']">修改</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
v-hasPermi="['${permissionPrefix}:delete']">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -211,7 +211,7 @@ export default {
|
|||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// ${table.tableComment}表格数据
|
// ${table.classComment}列表
|
||||||
list: [],
|
list: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
@ -305,7 +305,7 @@ export default {
|
|||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加${table.tableComment}";
|
this.title = "添加${table.classComment}";
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
@ -319,7 +319,7 @@ export default {
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "修改${table.tableComment}";
|
this.title = "修改${table.classComment}";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
@ -353,7 +353,7 @@ export default {
|
|||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||||
this.$confirm('是否确认删除${table.tableComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
|
this.$confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
@ -366,7 +366,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.$confirm('是否确认导出所有${table.tableComment}数据项?', "警告", {
|
this.$confirm('是否确认导出所有${table.classComment}数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
|
Loading…
Reference in New Issue
Block a user