BaseStudentInfoController.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.dev33.satoken.stp.StpUtil;
  4. import cn.hutool.core.bean.BeanUtil;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.xjrsoft.common.annotation.XjrLog;
  8. import com.xjrsoft.common.enums.ArchivesStatusEnum;
  9. import com.xjrsoft.common.model.result.RT;
  10. import com.xjrsoft.common.page.ConventPage;
  11. import com.xjrsoft.common.page.PageOutput;
  12. import com.xjrsoft.common.utils.FormatUtil;
  13. import com.xjrsoft.module.base.entity.WhitelistManagement;
  14. import com.xjrsoft.module.base.service.IWhitelistManagementService;
  15. import com.xjrsoft.module.student.dto.BaseStudentInfoDetailDto;
  16. import com.xjrsoft.module.student.dto.BaseStudentInfoPageDto;
  17. import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto;
  18. import com.xjrsoft.module.student.dto.UpdateBaseStudentInfoDto;
  19. import com.xjrsoft.module.student.entity.BaseStudentUser;
  20. import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
  21. import com.xjrsoft.module.student.service.IStudentManagerService;
  22. import com.xjrsoft.module.student.vo.*;
  23. import io.swagger.annotations.Api;
  24. import io.swagger.annotations.ApiOperation;
  25. import lombok.AllArgsConstructor;
  26. import org.springframework.web.bind.annotation.*;
  27. import javax.validation.Valid;
  28. import java.util.List;
  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. private final IWhitelistManagementService whitelistService;
  43. @GetMapping(value = "/mobile-page")
  44. @ApiOperation(value = "学生列表(分页)")
  45. @SaCheckPermission("basestudentinfo:mobilepage")
  46. @XjrLog(value = "学生列表(分页)")
  47. public RT<PageOutput<BaseStudentInfoPageVo>> mobilePage(@Valid BaseStudentInfoPageDto dto) {
  48. Page<BaseStudentInfoPageVo> mobilePage = baseStudentSchoolRollService.getMobilePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  49. for (BaseStudentInfoPageVo record : mobilePage.getRecords()) {
  50. BaseStudentUser user = studentManagerService.getById(record.getId());
  51. record.setAvatar(user.getAvatar());
  52. }
  53. PageOutput<BaseStudentInfoPageVo> pageOutput = ConventPage.getPageOutput(mobilePage, BaseStudentInfoPageVo.class);
  54. return RT.ok(pageOutput);
  55. }
  56. @GetMapping(value = "/mobile-page-statistics")
  57. @ApiOperation(value = "学生列表人数统计")
  58. @SaCheckPermission("basestudentinfo:mobilepagestatistics")
  59. @XjrLog(value = "学生列表人数统计", saveResponseData = true)
  60. public RT<BaseStudentInfoPageDataVo> mobilePageStatistics(@Valid BaseStudentInfoPageDto dto) {
  61. BaseStudentInfoPageDataVo result = baseStudentSchoolRollService.getMobilePageStatistics(dto);
  62. return RT.ok(result);
  63. }
  64. @GetMapping(value = "/mobile-class-statistics")
  65. @ApiOperation(value = "班级统计(移动端)")
  66. @SaCheckPermission("basestudentinfo:mobileclassstatistics")
  67. @XjrLog(value = "班级统计(移动端)", saveResponseData = true)
  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("basestudentinfo:edit")
  75. @XjrLog(value = "修改学生信息", saveResponseData = true)
  76. public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentInfoDto dto) {
  77. return RT.ok(baseStudentSchoolRollService.updateInfo(dto));
  78. }
  79. @GetMapping(value = "/info")
  80. @ApiOperation(value = "根据id查询详情信息")
  81. @SaCheckPermission("basestudentinfo:info")
  82. @XjrLog(value = "根据id查询详情信息", saveResponseData = true)
  83. public RT<BaseStudentInfoDetailVo> info(@RequestParam Long id) {
  84. BaseStudentInfoDetailDto dto = new BaseStudentInfoDetailDto();
  85. dto.setId(id);
  86. BaseStudentInfoDetailVo detailVo = baseStudentSchoolRollService.getInfoById(dto);
  87. BaseStudentUser baseStudentUser = studentManagerService.getByIdDeep(id);
  88. detailVo.setStudentId(baseStudentUser.getBaseStudentList().get(0).getStudentId());
  89. if (detailVo == null) {
  90. return RT.error("找不到此数据!");
  91. }
  92. detailVo.setPhone(FormatUtil.formatPhone(detailVo.getPhone()));
  93. detailVo.setCredentialNumber(FormatUtil.formatIdCard(detailVo.getCredentialNumber()));
  94. detailVo.setStudentId(FormatUtil.formatIdCard(detailVo.getStudentId()));
  95. return RT.ok(BeanUtil.toBean(detailVo, BaseStudentInfoDetailVo.class));
  96. }
  97. @GetMapping(value = "/studentinfoByKeyWord")
  98. @ApiOperation(value = "根据姓名或者身份证号查询详情信息")
  99. @SaCheckPermission("basestudentinfo:studentinfobykeyword")
  100. @XjrLog(value = "根据姓名或者身份证号查询详情信息")
  101. public RT<List<BaseStudentSompleInfoVo>> info(@Valid BaseStudentSimpleInfoDto dto) {
  102. dto.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
  103. List<BaseStudentSompleInfoVo> infos = baseStudentSchoolRollService.getInfosByParam(dto);
  104. return RT.ok(infos);
  105. }
  106. @GetMapping(value = "/studentinfoByKeyWordNotReading")
  107. @ApiOperation(value = "根据姓名或者身份证号查询不在读学生详情信息")
  108. @SaCheckPermission("basestudentinfo:studentinfobykeywordnotreading")
  109. @XjrLog(value = "根据姓名或者身份证号查询不在读学生详情信息")
  110. public RT<List<BaseStudentSompleInfoVo>> studentinfoByKeyWordNotReading(@Valid BaseStudentSimpleInfoDto dto) {
  111. dto.setFindNewStudent(0);
  112. dto.setIsNotReading(1);
  113. List<BaseStudentSompleInfoVo> infos = baseStudentSchoolRollService.getInfosByParam(dto);
  114. return RT.ok(infos);
  115. }
  116. @GetMapping(value = "/getWhitelistInfo")
  117. @ApiOperation(value = "根据userId查询白名单信息(不传默认查询登录者)")
  118. @SaCheckPermission("basestudentinfo:getwhitelistinfo")
  119. @XjrLog(value = "根据userId查询白名单信息(不传默认查询登录者)", saveResponseData = true)
  120. public RT<WhitelistInfoVo> getWhitelistInfo(Long userId) {
  121. if (userId == null) {
  122. userId = StpUtil.getLoginIdAsLong();
  123. }
  124. WhitelistManagement one = whitelistService.getOne(
  125. new QueryWrapper<WhitelistManagement>().lambda()
  126. .eq(WhitelistManagement::getUserId, userId)
  127. );
  128. WhitelistInfoVo whitelistInfoVo = new WhitelistInfoVo();
  129. whitelistInfoVo.setWhitelistStatus(0);
  130. if (one != null) {
  131. whitelistInfoVo.setWhitelistStatus(1);
  132. if (one.getIsTemporary() == 1) {
  133. whitelistInfoVo.setEndTime(one.getEndTime());
  134. }
  135. whitelistInfoVo.setIsTemporary(one.getIsTemporary());
  136. }
  137. return RT.ok(whitelistInfoVo);
  138. }
  139. }