BaseStudentInfoController.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.module.base.entity.WhitelistManagement;
  13. import com.xjrsoft.module.base.service.IWhitelistManagementService;
  14. import com.xjrsoft.module.student.dto.BaseStudentInfoDetailDto;
  15. import com.xjrsoft.module.student.dto.BaseStudentInfoPageDto;
  16. import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto;
  17. import com.xjrsoft.module.student.dto.UpdateBaseStudentInfoDto;
  18. import com.xjrsoft.module.student.entity.BaseStudentUser;
  19. import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
  20. import com.xjrsoft.module.student.service.IStudentManagerService;
  21. import com.xjrsoft.module.student.vo.*;
  22. import io.swagger.annotations.Api;
  23. import io.swagger.annotations.ApiOperation;
  24. import lombok.AllArgsConstructor;
  25. import org.springframework.web.bind.annotation.*;
  26. import javax.validation.Valid;
  27. import java.util.List;
  28. /**
  29. * @title: 学生职务设置
  30. * @Author dzx
  31. * @Date: 2023-11-13
  32. * @Version 1.0
  33. */
  34. @RestController
  35. @RequestMapping("/student" + "/basestudentinfo")
  36. @Api(value = "/student" + "/basestudentinfo", tags = "学生信息修改管理")
  37. @AllArgsConstructor
  38. public class BaseStudentInfoController {
  39. private final IStudentManagerService studentManagerService;
  40. private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
  41. private final IWhitelistManagementService whitelistService;
  42. @GetMapping(value = "/mobile-page")
  43. @ApiOperation(value = "学生列表(分页)")
  44. @SaCheckPermission("basestudentpost:detail")
  45. @XjrLog(value = "学生列表(分页)")
  46. public RT<PageOutput<BaseStudentInfoPageVo>> mobilePage(@Valid BaseStudentInfoPageDto dto) {
  47. Page<BaseStudentInfoPageVo> mobilePage = baseStudentSchoolRollService.getMobilePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  48. for (BaseStudentInfoPageVo record : mobilePage.getRecords()) {
  49. BaseStudentUser user = studentManagerService.getById(record.getId());
  50. record.setAvatar(user.getAvatar());
  51. }
  52. PageOutput<BaseStudentInfoPageVo> pageOutput = ConventPage.getPageOutput(mobilePage, BaseStudentInfoPageVo.class);
  53. return RT.ok(pageOutput);
  54. }
  55. @GetMapping(value = "/mobile-page-statistics")
  56. @ApiOperation(value = "学生列表人数统计")
  57. @SaCheckPermission("basestudentpost:detail")
  58. @XjrLog(value = "学生列表人数统计", saveResponseData = true)
  59. public RT<BaseStudentInfoPageDataVo> mobilePageStatistics(@Valid BaseStudentInfoPageDto dto) {
  60. BaseStudentInfoPageDataVo result = baseStudentSchoolRollService.getMobilePageStatistics(dto);
  61. return RT.ok(result);
  62. }
  63. @GetMapping(value = "/mobile-class-statistics")
  64. @ApiOperation(value = "班级统计(移动端)")
  65. @SaCheckPermission("basestudentpost:detail")
  66. @XjrLog(value = "班级统计(移动端)", saveResponseData = true)
  67. public RT<MobileClassStatisticsVo> mobileClassStatistics(@Valid BaseStudentInfoPageDto dto) {
  68. MobileClassStatisticsVo result = baseStudentSchoolRollService.getMobileClassStatistics(dto);
  69. return RT.ok(result);
  70. }
  71. @PutMapping
  72. @ApiOperation(value = "修改学生信息")
  73. @SaCheckPermission("basestudentpost:edit")
  74. @XjrLog(value = "修改学生信息", saveResponseData = true)
  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("basestudentpost:detail")
  81. @XjrLog(value = "根据id查询详情信息", saveResponseData = true)
  82. public RT<BaseStudentInfoDetailVo> info(@RequestParam Long id) {
  83. BaseStudentInfoDetailDto dto = new BaseStudentInfoDetailDto();
  84. dto.setId(id);
  85. BaseStudentInfoDetailVo detailVo = baseStudentSchoolRollService.getInfoById(dto);
  86. BaseStudentUser baseStudentUser = studentManagerService.getByIdDeep(id);
  87. detailVo.setStudentId(baseStudentUser.getBaseStudentList().get(0).getStudentId());
  88. if (detailVo == null) {
  89. return RT.error("找不到此数据!");
  90. }
  91. return RT.ok(BeanUtil.toBean(detailVo, BaseStudentInfoDetailVo.class));
  92. }
  93. @GetMapping(value = "/studentinfoByKeyWord")
  94. @ApiOperation(value = "根据姓名或者身份证号查询详情信息")
  95. @SaCheckPermission("basestudentpost:detail")
  96. @XjrLog(value = "根据姓名或者身份证号查询详情信息")
  97. public RT<List<BaseStudentSompleInfoVo>> info(@Valid BaseStudentSimpleInfoDto dto) {
  98. dto.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
  99. List<BaseStudentSompleInfoVo> infos = baseStudentSchoolRollService.getInfosByParam(dto);
  100. return RT.ok(infos);
  101. }
  102. @GetMapping(value = "/studentinfoByKeyWordNotReading")
  103. @ApiOperation(value = "根据姓名或者身份证号查询不在读学生详情信息")
  104. @SaCheckPermission("basestudentpost:detail")
  105. @XjrLog(value = "根据姓名或者身份证号查询不在读学生详情信息")
  106. public RT<List<BaseStudentSompleInfoVo>> studentinfoByKeyWordNotReading(@Valid BaseStudentSimpleInfoDto dto) {
  107. dto.setFindNewStudent(0);
  108. dto.setIsNotReading(1);
  109. List<BaseStudentSompleInfoVo> infos = baseStudentSchoolRollService.getInfosByParam(dto);
  110. return RT.ok(infos);
  111. }
  112. @GetMapping(value = "/getWhitelistInfo")
  113. @ApiOperation(value = "根据userId查询白名单信息(不传默认查询登录者)")
  114. @SaCheckPermission("basestudentpost:detail")
  115. @XjrLog(value = "根据userId查询白名单信息(不传默认查询登录者)", saveResponseData = true)
  116. public RT<WhitelistInfoVo> getWhitelistInfo(Long userId) {
  117. if (userId == null) {
  118. userId = StpUtil.getLoginIdAsLong();
  119. }
  120. WhitelistManagement one = whitelistService.getOne(
  121. new QueryWrapper<WhitelistManagement>().lambda()
  122. .eq(WhitelistManagement::getUserId, userId)
  123. );
  124. WhitelistInfoVo whitelistInfoVo = new WhitelistInfoVo();
  125. whitelistInfoVo.setWhitelistStatus(0);
  126. if (one != null) {
  127. whitelistInfoVo.setWhitelistStatus(1);
  128. if (one.getIsTemporary() == 1) {
  129. whitelistInfoVo.setEndTime(one.getEndTime());
  130. }
  131. whitelistInfoVo.setIsTemporary(one.getIsTemporary());
  132. }
  133. return RT.ok(whitelistInfoVo);
  134. }
  135. }