作者 若依

!209 导出 Excel 工作表的名称 由 ${businessName} 更改为 ${functionName}

Merge pull request !209 from lihy2021/N/A
1 -package ${packageName}.controller;  
2 -  
3 -import java.util.List;  
4 -import org.springframework.security.access.prepost.PreAuthorize;  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.web.bind.annotation.GetMapping;  
7 -import org.springframework.web.bind.annotation.PostMapping;  
8 -import org.springframework.web.bind.annotation.PutMapping;  
9 -import org.springframework.web.bind.annotation.DeleteMapping;  
10 -import org.springframework.web.bind.annotation.PathVariable;  
11 -import org.springframework.web.bind.annotation.RequestBody;  
12 -import org.springframework.web.bind.annotation.RequestMapping;  
13 -import org.springframework.web.bind.annotation.RestController;  
14 -import com.ruoyi.common.annotation.Log;  
15 -import com.ruoyi.common.core.controller.BaseController;  
16 -import com.ruoyi.common.core.domain.AjaxResult;  
17 -import com.ruoyi.common.enums.BusinessType;  
18 -import ${packageName}.domain.${ClassName};  
19 -import ${packageName}.service.I${ClassName}Service;  
20 -import com.ruoyi.common.utils.poi.ExcelUtil;  
21 -#if($table.crud || $table.sub)  
22 -import com.ruoyi.common.core.page.TableDataInfo;  
23 -#elseif($table.tree)  
24 -#end  
25 -  
26 -/**  
27 - * ${functionName}Controller  
28 - *  
29 - * @author ${author}  
30 - * @date ${datetime}  
31 - */  
32 -@RestController  
33 -@RequestMapping("/${moduleName}/${businessName}")  
34 -public class ${ClassName}Controller extends BaseController  
35 -{  
36 - @Autowired  
37 - private I${ClassName}Service ${className}Service;  
38 -  
39 - /**  
40 - * 查询${functionName}列表  
41 - */  
42 - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")  
43 - @GetMapping("/list")  
44 -#if($table.crud || $table.sub)  
45 - public TableDataInfo list(${ClassName} ${className})  
46 - {  
47 - startPage();  
48 - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});  
49 - return getDataTable(list);  
50 - }  
51 -#elseif($table.tree)  
52 - public AjaxResult list(${ClassName} ${className})  
53 - {  
54 - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});  
55 - return AjaxResult.success(list);  
56 - }  
57 -#end  
58 -  
59 - /**  
60 - * 导出${functionName}列表  
61 - */  
62 - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")  
63 - @Log(title = "${functionName}", businessType = BusinessType.EXPORT)  
64 - @GetMapping("/export")  
65 - public AjaxResult export(${ClassName} ${className})  
66 - {  
67 - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});  
68 - ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);  
69 - return util.exportExcel(list, "${businessName}");  
70 - }  
71 -  
72 - /**  
73 - * 获取${functionName}详细信息  
74 - */  
75 - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")  
76 - @GetMapping(value = "/{${pkColumn.javaField}}")  
77 - public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})  
78 - {  
79 - return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));  
80 - }  
81 -  
82 - /**  
83 - * 新增${functionName}  
84 - */  
85 - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")  
86 - @Log(title = "${functionName}", businessType = BusinessType.INSERT)  
87 - @PostMapping  
88 - public AjaxResult add(@RequestBody ${ClassName} ${className})  
89 - {  
90 - return toAjax(${className}Service.insert${ClassName}(${className}));  
91 - }  
92 -  
93 - /**  
94 - * 修改${functionName}  
95 - */  
96 - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")  
97 - @Log(title = "${functionName}", businessType = BusinessType.UPDATE)  
98 - @PutMapping  
99 - public AjaxResult edit(@RequestBody ${ClassName} ${className})  
100 - {  
101 - return toAjax(${className}Service.update${ClassName}(${className}));  
102 - }  
103 -  
104 - /**  
105 - * 删除${functionName}  
106 - */  
107 - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")  
108 - @Log(title = "${functionName}", businessType = BusinessType.DELETE)  
109 - @DeleteMapping("/{${pkColumn.javaField}s}")  
110 - public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)  
111 - {  
112 - return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));  
113 - }  
114 -} 1 +package ${packageName}.controller;
  2 +
  3 +import java.util.List;
  4 +import org.springframework.security.access.prepost.PreAuthorize;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.GetMapping;
  7 +import org.springframework.web.bind.annotation.PostMapping;
  8 +import org.springframework.web.bind.annotation.PutMapping;
  9 +import org.springframework.web.bind.annotation.DeleteMapping;
  10 +import org.springframework.web.bind.annotation.PathVariable;
  11 +import org.springframework.web.bind.annotation.RequestBody;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +import com.ruoyi.common.annotation.Log;
  15 +import com.ruoyi.common.core.controller.BaseController;
  16 +import com.ruoyi.common.core.domain.AjaxResult;
  17 +import com.ruoyi.common.enums.BusinessType;
  18 +import ${packageName}.domain.${ClassName};
  19 +import ${packageName}.service.I${ClassName}Service;
  20 +import com.ruoyi.common.utils.poi.ExcelUtil;
  21 +#if($table.crud || $table.sub)
  22 +import com.ruoyi.common.core.page.TableDataInfo;
  23 +#elseif($table.tree)
  24 +#end
  25 +
  26 +/**
  27 + * ${functionName}Controller
  28 + *
  29 + * @author ${author}
  30 + * @date ${datetime}
  31 + */
  32 +@RestController
  33 +@RequestMapping("/${moduleName}/${businessName}")
  34 +public class ${ClassName}Controller extends BaseController
  35 +{
  36 + @Autowired
  37 + private I${ClassName}Service ${className}Service;
  38 +
  39 + /**
  40 + * 查询${functionName}列表
  41 + */
  42 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
  43 + @GetMapping("/list")
  44 +#if($table.crud || $table.sub)
  45 + public TableDataInfo list(${ClassName} ${className})
  46 + {
  47 + startPage();
  48 + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
  49 + return getDataTable(list);
  50 + }
  51 +#elseif($table.tree)
  52 + public AjaxResult list(${ClassName} ${className})
  53 + {
  54 + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
  55 + return AjaxResult.success(list);
  56 + }
  57 +#end
  58 +
  59 + /**
  60 + * 导出${functionName}列表
  61 + */
  62 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
  63 + @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
  64 + @GetMapping("/export")
  65 + public AjaxResult export(${ClassName} ${className})
  66 + {
  67 + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
  68 + ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
  69 + return util.exportExcel(list, "${functionName}");
  70 + }
  71 +
  72 + /**
  73 + * 获取${functionName}详细信息
  74 + */
  75 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
  76 + @GetMapping(value = "/{${pkColumn.javaField}}")
  77 + public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
  78 + {
  79 + return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
  80 + }
  81 +
  82 + /**
  83 + * 新增${functionName}
  84 + */
  85 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
  86 + @Log(title = "${functionName}", businessType = BusinessType.INSERT)
  87 + @PostMapping
  88 + public AjaxResult add(@RequestBody ${ClassName} ${className})
  89 + {
  90 + return toAjax(${className}Service.insert${ClassName}(${className}));
  91 + }
  92 +
  93 + /**
  94 + * 修改${functionName}
  95 + */
  96 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
  97 + @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
  98 + @PutMapping
  99 + public AjaxResult edit(@RequestBody ${ClassName} ${className})
  100 + {
  101 + return toAjax(${className}Service.update${ClassName}(${className}));
  102 + }
  103 +
  104 + /**
  105 + * 删除${functionName}
  106 + */
  107 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
  108 + @Log(title = "${functionName}", businessType = BusinessType.DELETE)
  109 + @DeleteMapping("/{${pkColumn.javaField}s}")
  110 + public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
  111 + {
  112 + return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
  113 + }
  114 +}