完成代码生成器的 sql 生成
parent
b8351f50f2
commit
937c51f4ec
@ -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, '');
|
|
||||||
@ -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
|
||||||
Loading…
Reference in New Issue