提交 | 用户 | 时间
|
722af2
|
1 |
package ${packageName}.controller; |
X |
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.concurrent.TimeUnit; |
|
6 |
|
|
7 |
import lombok.RequiredArgsConstructor; |
|
8 |
import javax.servlet.http.HttpServletResponse; |
|
9 |
import javax.validation.constraints.*; |
|
10 |
import cn.dev33.satoken.annotation.SaCheckPermission; |
|
11 |
import org.springframework.web.bind.annotation.*; |
|
12 |
import org.springframework.validation.annotation.Validated; |
|
13 |
import com.dl.common.annotation.RepeatSubmit; |
|
14 |
import com.dl.common.annotation.Log; |
|
15 |
import com.dl.common.core.controller.BaseController; |
|
16 |
import com.dl.common.core.domain.PageQuery; |
|
17 |
import com.dl.common.core.domain.R; |
|
18 |
import com.dl.common.core.validate.AddGroup; |
|
19 |
import com.dl.common.core.validate.EditGroup; |
|
20 |
import com.dl.common.core.validate.QueryGroup; |
|
21 |
import com.dl.common.enums.BusinessType; |
|
22 |
import com.dl.common.utils.poi.ExcelUtil; |
|
23 |
import ${packageName}.domain.vo.${ClassName}Vo; |
|
24 |
import ${packageName}.domain.bo.${ClassName}Bo; |
|
25 |
import ${packageName}.service.I${ClassName}Service; |
|
26 |
#if($table.crud || $table.sub) |
|
27 |
import com.dl.common.core.page.TableDataInfo; |
|
28 |
#elseif($table.tree) |
|
29 |
#end |
|
30 |
|
|
31 |
/** |
|
32 |
* ${functionName} |
|
33 |
* |
|
34 |
* @author ${author} |
|
35 |
* @date ${datetime} |
|
36 |
*/ |
|
37 |
@Validated |
|
38 |
@RequiredArgsConstructor |
|
39 |
@RestController |
|
40 |
@RequestMapping("/${moduleName}/${businessName}") |
|
41 |
public class ${ClassName}Controller extends BaseController { |
|
42 |
|
|
43 |
private final I${ClassName}Service i${ClassName}Service; |
|
44 |
|
|
45 |
/** |
|
46 |
* 查询${functionName}列表 |
|
47 |
*/ |
|
48 |
@SaCheckPermission("${permissionPrefix}:list") |
|
49 |
@GetMapping("/list") |
|
50 |
#if($table.crud || $table.sub) |
|
51 |
public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo bo, PageQuery pageQuery) { |
|
52 |
return i${ClassName}Service.queryPageList(bo, pageQuery); |
|
53 |
} |
|
54 |
#elseif($table.tree) |
|
55 |
public R<List<${ClassName}Vo>> list(${ClassName}Bo bo) { |
|
56 |
List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); |
|
57 |
return R.ok(list); |
|
58 |
} |
|
59 |
#end |
|
60 |
|
|
61 |
/** |
|
62 |
* 导出${functionName}列表 |
|
63 |
*/ |
|
64 |
@SaCheckPermission("${permissionPrefix}:export") |
|
65 |
@Log(title = "${functionName}", businessType = BusinessType.EXPORT) |
|
66 |
@PostMapping("/export") |
|
67 |
public void export(${ClassName}Bo bo, HttpServletResponse response) { |
|
68 |
List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); |
|
69 |
ExcelUtil.exportExcel(list, "${functionName}", ${ClassName}Vo.class, response); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* 获取${functionName}详细信息 |
|
74 |
* |
|
75 |
* @param ${pkColumn.javaField} 主键 |
|
76 |
*/ |
|
77 |
@SaCheckPermission("${permissionPrefix}:query") |
|
78 |
@GetMapping("/{${pkColumn.javaField}}") |
|
79 |
public R<${ClassName}Vo> getInfo(@NotNull(message = "主键不能为空") |
|
80 |
@PathVariable ${pkColumn.javaType} ${pkColumn.javaField}) { |
|
81 |
return R.ok(i${ClassName}Service.queryById(${pkColumn.javaField})); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* 新增${functionName} |
|
86 |
*/ |
|
87 |
@SaCheckPermission("${permissionPrefix}:add") |
|
88 |
@Log(title = "${functionName}", businessType = BusinessType.INSERT) |
|
89 |
@RepeatSubmit() |
|
90 |
@PostMapping() |
|
91 |
public R<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { |
|
92 |
return toAjax(i${ClassName}Service.insertByBo(bo)); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* 修改${functionName} |
|
97 |
*/ |
|
98 |
@SaCheckPermission("${permissionPrefix}:edit") |
|
99 |
@Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
|
100 |
@RepeatSubmit() |
|
101 |
@PutMapping() |
|
102 |
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { |
|
103 |
return toAjax(i${ClassName}Service.updateByBo(bo)); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* 删除${functionName} |
|
108 |
* |
|
109 |
* @param ${pkColumn.javaField}s 主键串 |
|
110 |
*/ |
|
111 |
@SaCheckPermission("${permissionPrefix}:remove") |
|
112 |
@Log(title = "${functionName}", businessType = BusinessType.DELETE) |
|
113 |
@DeleteMapping("/{${pkColumn.javaField}s}") |
|
114 |
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|
115 |
@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
|
116 |
return toAjax(i${ClassName}Service.deleteWithValidByIds(Arrays.asList(${pkColumn.javaField}s), true)); |
|
117 |
} |
|
118 |
} |