浏览代码

调整返回值类型与格式与用户

mcbaiyun 5 月之前
父节点
当前提交
e4a20bb9fc

+ 15 - 10
src/main/java/com/smart/reader/controller/ClassInfoController.java

@@ -41,31 +41,36 @@ public class ClassInfoController {
 
     @PostMapping("/add")
     @ApiOperation("新增班级信息")
-    public Boolean add(@RequestBody ClassInfoAddBo classInfo) throws CustomException {
-        return classInfoService.add(classInfo);
+    public R add(@RequestBody ClassInfoAddBo classInfo) throws CustomException {
+        classInfoService.add(classInfo);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
     }
 
     @DeleteMapping("/delete/{id}")
     @ApiOperation("删除班级信息")
-    public Boolean delete(@PathVariable Long id) throws CustomException {
-        return classInfoService.delete(id);
+    public R delete(@PathVariable Long id) throws CustomException {
+        classInfoService.delete(id);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
     }
 
     @PutMapping("/edit")
     @ApiOperation("修改班级信息")
-    public Boolean edit(@RequestBody ClassInfoUpdateBo classInfo) throws CustomException {
-        return classInfoService.edit(classInfo);
+    public R edit(@RequestBody ClassInfoUpdateBo classInfo) throws CustomException {
+        classInfoService.edit(classInfo);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
     }
 
     @GetMapping("/{id}")
     @ApiOperation("查询班级详情")
-    public ClassInfoVo detail(@PathVariable Long id) throws CustomException {
-        return classInfoService.detail(id);
+    public R detail(@PathVariable Long id) throws CustomException {
+        ClassInfoVo classInfoVo = classInfoService.detail(id);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), classInfoVo);
     }
 
     @DeleteMapping("/batchDelete")
     @ApiOperation("批量删除班级信息")
-    public Boolean batchDelete(@RequestBody List<Long> ids) throws CustomException {
-        return classInfoService.batchDelete(ids);
+    public R batchDelete(@RequestBody List<Long> ids) throws CustomException {
+        classInfoService.batchDelete(ids);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), "批量删除成功");
     }
 }

+ 15 - 10
src/main/java/com/smart/reader/controller/StudentInfoController.java

@@ -41,31 +41,36 @@ public class StudentInfoController {
 
     @PostMapping("/add")
     @ApiOperation("新增学生信息")
-    public Boolean add(@RequestBody StudentInfoAddBo studentInfo) throws CustomException {
-        return studentInfoService.add(studentInfo);
+    public R add(@RequestBody StudentInfoAddBo studentInfo) throws CustomException {
+        studentInfoService.add(studentInfo);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
     }
 
     @DeleteMapping("/delete/{id}")
     @ApiOperation("删除学生信息")
-    public Boolean delete(@PathVariable Long id) throws CustomException {
-        return studentInfoService.delete(id);
+    public R delete(@PathVariable Long id) throws CustomException {
+        studentInfoService.delete(id);
+        return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
     }
 
     @PutMapping("/edit")
     @ApiOperation("修改学生信息")
-    public Boolean edit(@RequestBody StudentInfoUpdateBo studentInfo) throws CustomException {
-        return studentInfoService.edit(studentInfo);
+    public R edit(@RequestBody StudentInfoUpdateBo studentInfo) throws CustomException {
+        studentInfoService.edit(studentInfo);
+        return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
     }
 
     @GetMapping("/{id}")
     @ApiOperation("查询学生详情")
-    public StudentInfoVo detail(@PathVariable Long id) throws CustomException {
-        return studentInfoService.detail(id);
+    public R detail(@PathVariable Long id) throws CustomException {
+        StudentInfoVo studentInfoVo = studentInfoService.detail(id);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), studentInfoVo);
     }
 
     @DeleteMapping("/batchDelete")
     @ApiOperation("批量删除学生信息")
-    public Boolean batchDelete(@RequestBody List<Long> ids) throws CustomException {
-        return studentInfoService.batchDelete(ids);
+    public R batchDelete(@RequestBody List<Long> ids) throws CustomException {
+        studentInfoService.batchDelete(ids);
+        return R.success(SuccessResultCode.SUCCESS.getCode(), "批量删除成功");
     }
 }