BaseStudentInfoController.java 6.2 KB

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