BaseStudentInfoController.java 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.hutool.core.bean.BeanUtil;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.xjrsoft.common.model.result.RT;
  6. import com.xjrsoft.common.page.ConventPage;
  7. import com.xjrsoft.common.page.PageOutput;
  8. import com.xjrsoft.module.student.dto.BaseStudentInfoDetailDto;
  9. import com.xjrsoft.module.student.dto.BaseStudentInfoPageDto;
  10. import com.xjrsoft.module.student.dto.UpdateBaseStudentInfoDto;
  11. import com.xjrsoft.module.student.entity.BaseStudentUser;
  12. import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
  13. import com.xjrsoft.module.student.service.IStudentManagerService;
  14. import com.xjrsoft.module.student.vo.BaseStudentInfoDetailVo;
  15. import com.xjrsoft.module.student.vo.BaseStudentInfoPageDataVo;
  16. import com.xjrsoft.module.student.vo.BaseStudentInfoPageVo;
  17. import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
  18. import com.xjrsoft.module.student.vo.MobileClassStatisticsVo;
  19. import io.swagger.annotations.Api;
  20. import io.swagger.annotations.ApiOperation;
  21. import lombok.AllArgsConstructor;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.PutMapping;
  24. import org.springframework.web.bind.annotation.RequestBody;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RequestParam;
  27. import org.springframework.web.bind.annotation.RestController;
  28. import javax.validation.Valid;
  29. /**
  30. * @title: 学生职务设置
  31. * @Author dzx
  32. * @Date: 2023-11-13
  33. * @Version 1.0
  34. */
  35. @RestController
  36. @RequestMapping("/student" + "/basestudentinfo")
  37. @Api(value = "/student" + "/basestudentinfo",tags = "学生信息修改管理")
  38. @AllArgsConstructor
  39. public class BaseStudentInfoController {
  40. private final IStudentManagerService studentManagerService;
  41. private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
  42. @GetMapping(value = "/mobile-page")
  43. @ApiOperation(value="学生列表(分页)")
  44. @SaCheckPermission("basestudentpost:detail")
  45. public RT<PageOutput<BaseStudentInfoPageVo>> mobilePage(@Valid BaseStudentInfoPageDto dto){
  46. Page<BaseStudentInfoPageVo> mobilePage = baseStudentSchoolRollService.getMobilePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  47. for (BaseStudentInfoPageVo record : mobilePage.getRecords()) {
  48. BaseStudentUser user = studentManagerService.getById(record.getId());
  49. record.setAvatar(user.getAvatar());
  50. }
  51. PageOutput<BaseStudentInfoPageVo> pageOutput = ConventPage.getPageOutput(mobilePage, BaseStudentInfoPageVo.class);
  52. return RT.ok(pageOutput);
  53. }
  54. @GetMapping(value = "/mobile-page-statistics")
  55. @ApiOperation(value="学生列表人数统计")
  56. @SaCheckPermission("basestudentpost:detail")
  57. public RT<BaseStudentInfoPageDataVo> mobilePageStatistics(@Valid BaseStudentInfoPageDto dto){
  58. BaseStudentInfoPageDataVo result = baseStudentSchoolRollService.getMobilePageStatistics(dto);
  59. return RT.ok(result);
  60. }
  61. @GetMapping(value = "/mobile-class-statistics")
  62. @ApiOperation(value="班级统计(移动端)")
  63. @SaCheckPermission("basestudentpost:detail")
  64. public RT<MobileClassStatisticsVo> mobileClassStatistics(@Valid BaseStudentInfoPageDto dto){
  65. MobileClassStatisticsVo result = baseStudentSchoolRollService.getMobileClassStatistics(dto);
  66. return RT.ok(result);
  67. }
  68. @PutMapping
  69. @ApiOperation(value = "修改学生信息")
  70. @SaCheckPermission("basestudentpost:edit")
  71. public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentInfoDto dto){
  72. return RT.ok(baseStudentSchoolRollService.updateInfo(dto));
  73. }
  74. @GetMapping(value = "/info")
  75. @ApiOperation(value="根据id查询详情信息")
  76. @SaCheckPermission("room:detail")
  77. public RT<BaseStudentInfoDetailVo> info(@RequestParam Long id){
  78. BaseStudentInfoDetailDto dto = new BaseStudentInfoDetailDto();
  79. dto.setId(id);
  80. BaseStudentInfoDetailVo detailVo = baseStudentSchoolRollService.getInfoById(dto);
  81. if (detailVo == null) {
  82. return RT.error("找不到此数据!");
  83. }
  84. return RT.ok(BeanUtil.toBean(detailVo, BaseStudentInfoDetailVo.class));
  85. }
  86. }