CGradeController.java
7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
package cn.bronet.admin.demo.controller;
import java.util.List;
import java.util.Arrays;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import cn.bronet.admin.common.annotation.RepeatSubmit;
import cn.bronet.admin.common.annotation.Log;
import cn.bronet.admin.common.core.controller.BaseController;
import cn.bronet.admin.common.core.domain.AjaxResult;
import cn.bronet.admin.common.core.validate.AddGroup;
import cn.bronet.admin.common.core.validate.EditGroup;
import cn.bronet.admin.common.enums.BusinessType;
import cn.bronet.admin.demo.domain.vo.CGradeVo;
import cn.bronet.admin.demo.domain.bo.CGradeBo;
import cn.bronet.admin.demo.service.ICGradeService;
import cn.bronet.admin.common.utils.poi.ExcelUtil;
import cn.bronet.admin.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 学校年级Controller
*
* @author ruoyi
* @date 2021-09-09
*/
@Slf4j
@Validated
@Api(value = "学校年级控制器", tags = {"学校年级管理"})
@RequiredArgsConstructor()
@RestController
@RequestMapping("/demo/grade")
public class CGradeController extends BaseController {
private final ICGradeService iCGradeService;
/**
* 查询学校年级列表
*/
@ApiOperation("查询学校年级列表")
@PreAuthorize("@ss.hasPermi('demo:grade:list')")
@GetMapping("/list")
public TableDataInfo<CGradeVo> list(@Validated CGradeBo bo) {
log.info("<<<接收的参数<<<::"+bo);
return iCGradeService.queryPageList(bo);
}
/**
* 导出学校年级列表
*/
@ApiOperation("导出学校年级列表")
@PreAuthorize("@ss.hasPermi('demo:grade:export')")
@Log(title = "学校年级", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult<CGradeVo> export(@Validated CGradeBo bo) {
List<CGradeVo> list = iCGradeService.queryList(bo);
ExcelUtil<CGradeVo> util = new ExcelUtil<CGradeVo>(CGradeVo.class);
return util.exportExcel(list, "学校年级");
}
/**
* 获取需要修改的年级信息
*/
@ApiOperation("获取需要修改的年级信息")
@PreAuthorize("@ss.hasPermi('demo:grade:query')")
@GetMapping("/{id}")
public AjaxResult<CGradeVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
return AjaxResult.success(iCGradeService.queryById(id));
}
/**
* 新增学校年级
*/
@ApiOperation("新增学校年级")
@PreAuthorize("@ss.hasPermi('demo:grade:add')")
@Log(title = "学校年级", businessType = BusinessType.INSERT)
@RepeatSubmit
@PostMapping()
public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody CGradeBo bo) {
return toAjax(iCGradeService.insertByBo(bo) ? 1 : 0);
}
/**
* 修改学校年级和班级
*/
@ApiOperation("修改学校年级和班级")
@PreAuthorize("@ss.hasPermi('demo:grade:edit')")
@Log(title = "学校年级", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping()
public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody CGradeBo bo) {
return toAjax(iCGradeService.updateByBo(bo) ? 1 : 0);
}
/**
* 删除学校班级
*/
@ApiOperation("删除学校班级")
@PreAuthorize("@ss.hasPermi('demo:grade:remove')")
@Log(title = "学校班级" , businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(iCGradeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
}
/**
* 查询此学校下所有的年级
*//*
@ApiOperation("查询此年级下的所有年级")
@GetMapping("/getAllGrades")
public AjaxResult myAllGrades(@RequestBody CGradeBo bo){
return iCGradeService.getAllGrades(bo);
}*/
/**
* 添加年级
*/
@ApiOperation("添加年级")
@PostMapping("/saveGrade")
public AjaxResult mySaveGrade(@RequestBody CGradeBo bo){
log.info("<<<接收的参数<<<::"+bo);
return iCGradeService.saveGrade(bo);
}
/**
* 查询此学校下正常状态的年级
*/
@ApiOperation("查询此学校下正常状态的年级")
@GetMapping("/getGrades")
public AjaxResult myGrades(){
return iCGradeService.getGrades();
}
/**
* 添加班级
*/
@ApiOperation("添加班级")
@PostMapping("/saveClasses")
public AjaxResult myClasses(@RequestBody CGradeBo bo){
log.info("<<<接收的参数<<<::"+bo);
return iCGradeService.saveClasses(bo);
}
/**
* 查询此学校下所有班级
*//*
@ApiOperation("查询此学校下所有班级")
@PostMapping("/getAllClasses")
public AjaxResult myAllClasses(@RequestBody CGradeBo bo){
log.info("<<<接收的参数<<<::"+bo);
return iCGradeService.getAllClasses(bo);
}*/
/**
* 查询此学校下正常状态的班级
*/
@ApiImplicitParam(name = "gradeParentId",value = "年级ID",dataType = "Long",required = true,paramType = "query")
@ApiOperation("查询此学校下正常状态的班级")
@GetMapping("/getClasses")
public AjaxResult myClasses( Long gradeParentId){
return iCGradeService.getClasses(gradeParentId);
}
/**
* 查看年级的详细信息
*/
@ApiImplicitParam(name = "gradeId",value ="年级ID",dataType = "Long",required = true,paramType = "query")
@ApiOperation("查看年级的详细信息")
@PostMapping("/getGradeInfo")
public AjaxResult myGradeInfo(Long gradeId){
log.info("<<<接收的参数<<<::"+gradeId);
return iCGradeService.getGradeInfo(gradeId);
}
/**
* 查看班级的详细信息
*/
@ApiImplicitParam(name = "gradeId",value = "班级ID",dataType = "Long",required = true,paramType = "query")
@ApiOperation("查看班级的详细信息")
@PostMapping("/getClassInfo")
public AjaxResult myClassInfo(Long gradeId){
log.info("<<<接收的参数<<<::"+gradeId);
return iCGradeService.getClassInfo(gradeId);
}
/**
* 获取需要修改的班级信息
*/
@ApiImplicitParam(name = "gradeId",value = "班级ID",dataType = "Long",required = true,paramType = "query")
@ApiOperation("获取需要修改的班级信息")
@GetMapping("/getClassInfo")
public AjaxResult myClassEdit(Long gradeId){
log.info("<<<接收的参数<<<::"+gradeId);
return iCGradeService.getUpdateClassInfo(gradeId);
}
/**
* 删除学校年级
*/
@ApiOperation("删除学校年级")
@DeleteMapping("/deleteGrade/{ids}")
public AjaxResult myDeleteGrade(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
List<@NotEmpty(message = "主键不能为空") Long> gradeIds = Arrays.asList(ids);
return iCGradeService.deleteGrade(gradeIds);
}
/**
* 删除学校班级(备选)
*/
@ApiOperation("删除学校班级(备选)")
@DeleteMapping("/deleteClasses/{ids}")
public AjaxResult myDeleteClasses(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
List<@NotEmpty(message = "主键不能为空") Long> gradeIds = Arrays.asList(ids);
return iCGradeService.deleteClasses(gradeIds);
}
}