StudentInfoController.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.smart.reader.controller;
  2. import com.smart.reader.common.Page;
  3. import com.smart.reader.common.R;
  4. import com.smart.reader.enums.SuccessResultCode;
  5. import com.smart.reader.exception.CustomException;
  6. import com.smart.reader.model.bo.StudentInfoAddBo;
  7. import com.smart.reader.model.bo.StudentInfoUpdateBo;
  8. import com.smart.reader.model.vo.StudentInfoVo;
  9. import com.smart.reader.model.vo.SysUserInfoVo;
  10. import com.smart.reader.service.StudentInfoService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiImplicitParam;
  13. import io.swagger.annotations.ApiImplicitParams;
  14. import io.swagger.annotations.ApiOperation;
  15. import org.springframework.validation.annotation.Validated;
  16. import org.springframework.web.bind.annotation.*;
  17. import javax.annotation.Resource;
  18. import java.util.List;
  19. @RestController
  20. @RequestMapping("/api/v1/educational/studentInfo")
  21. @Validated
  22. @Api(tags = "学生信息管理")
  23. public class StudentInfoController {
  24. @Resource
  25. private StudentInfoService studentInfoService;
  26. @GetMapping("queryInfo")
  27. @ApiOperation("获取学生列表")
  28. @ApiImplicitParams({
  29. @ApiImplicitParam(name = "pageNum", value = "当前⻚", required = true, dataType = "int", defaultValue = "1"),
  30. @ApiImplicitParam(name = "pageSize", value = "⻚⼤⼩", required = true, dataType = "int", defaultValue = "10"),
  31. })
  32. public R<Page<StudentInfoVo>> queryInfo(int pageNum, int pageSize) throws CustomException {
  33. Page<StudentInfoVo> result = studentInfoService.queryInfo(pageNum, pageSize);
  34. return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), result);
  35. }
  36. @PostMapping("/add")
  37. @ApiOperation("新增学生信息")
  38. public R add(@RequestBody StudentInfoAddBo studentInfo) throws CustomException {
  39. studentInfoService.add(studentInfo);
  40. return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
  41. }
  42. @DeleteMapping("/delete/{id}")
  43. @ApiOperation("删除学生信息")
  44. public R delete(@PathVariable Long id) throws CustomException {
  45. studentInfoService.delete(id);
  46. return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
  47. }
  48. @PutMapping("/edit")
  49. @ApiOperation("修改学生信息")
  50. public R edit(@RequestBody StudentInfoUpdateBo studentInfo) throws CustomException {
  51. studentInfoService.edit(studentInfo);
  52. return R.fail(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg());
  53. }
  54. @GetMapping("/{id}")
  55. @ApiOperation("查询学生详情")
  56. public R detail(@PathVariable Long id) throws CustomException {
  57. StudentInfoVo studentInfoVo = studentInfoService.detail(id);
  58. return R.success(SuccessResultCode.SUCCESS.getCode(), SuccessResultCode.SUCCESS.getMsg(), studentInfoVo);
  59. }
  60. @DeleteMapping("/batchDelete")
  61. @ApiOperation("批量删除学生信息")
  62. public R batchDelete(@RequestBody List<Long> ids) throws CustomException {
  63. studentInfoService.batchDelete(ids);
  64. return R.success(SuccessResultCode.SUCCESS.getCode(), "批量删除成功");
  65. }
  66. }