BaseStudentInfoController.java 4.8 KB

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