TextbookStudentClaimController.java 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. package com.xjrsoft.module.textbook.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.LambdaQueryWrapper;
  6. import com.baomidou.mybatisplus.core.metadata.IPage;
  7. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  8. import com.xjrsoft.common.model.result.RT;
  9. import com.xjrsoft.common.page.ConventPage;
  10. import com.xjrsoft.common.page.PageOutput;
  11. import com.xjrsoft.common.utils.VoToColumnUtil;
  12. import com.xjrsoft.module.textbook.dto.*;
  13. import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
  14. import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
  15. import com.xjrsoft.module.textbook.vo.*;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiOperation;
  18. import lombok.AllArgsConstructor;
  19. import org.springframework.web.bind.annotation.DeleteMapping;
  20. import org.springframework.web.bind.annotation.GetMapping;
  21. import org.springframework.web.bind.annotation.PostMapping;
  22. import org.springframework.web.bind.annotation.PutMapping;
  23. import org.springframework.web.bind.annotation.RequestBody;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RequestParam;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import javax.validation.Valid;
  28. import java.util.Date;
  29. import java.util.List;
  30. /**
  31. * @title: 学生教材认领记录
  32. * @Author szs
  33. * @Date: 2023-12-26
  34. * @Version 1.0
  35. */
  36. @RestController
  37. @RequestMapping("/textbook" + "/textbookStudentClaim")
  38. @Api(value = "/textbook" + "/textbookStudentClaim",tags = "学生教材认领记录代码")
  39. @AllArgsConstructor
  40. public class TextbookStudentClaimController {
  41. private final ITextbookStudentClaimService textbookStudentClaimService;
  42. @GetMapping(value = "/head-tea-look-class-book-semester")
  43. @ApiOperation(value="班主任查看班级教材学期页面")
  44. @SaCheckPermission("textbookstudentclaim:detail")
  45. public RT<List<HeadTeaLookClassBookSemesterVo>> headTeaLookClassBookSemester(){
  46. return RT.ok(textbookStudentClaimService.headTeaLookClassBookSemester());
  47. }
  48. @GetMapping(value = "/head-tea-look-class-book")
  49. @ApiOperation(value="班主任查看班级教材页面")
  50. @SaCheckPermission("textbookstudentclaim:detail")
  51. public RT<HeadTeaLookClassBookVo> headTeaLookClassBook(@Valid HeadTeaLookClassBookDto dto){
  52. return RT.ok(textbookStudentClaimService.headTeaLookClassBook(dto));
  53. }
  54. @GetMapping(value = "/page")
  55. @ApiOperation(value="学生教材认领记录列表(分页)")
  56. @SaCheckPermission("textbookstudentclaim:detail")
  57. public RT<PageOutput<TextbookStudentClaimPageVo>> page(@Valid TextbookStudentClaimPageDto dto){
  58. LambdaQueryWrapper<TextbookStudentClaim> queryWrapper = new LambdaQueryWrapper<>();
  59. queryWrapper
  60. .orderByDesc(TextbookStudentClaim::getId)
  61. .select(TextbookStudentClaim.class,x -> VoToColumnUtil.fieldsToColumns(TextbookStudentClaimPageVo.class).contains(x.getProperty()))
  62. .eq(dto.getStudentUserId() != null, TextbookStudentClaim::getStudentUserId, dto.getStudentUserId())
  63. .eq(TextbookStudentClaim::getIsClaim, 1)
  64. ;
  65. IPage<TextbookStudentClaim> page = textbookStudentClaimService.page(ConventPage.getPage(dto), queryWrapper);
  66. PageOutput<TextbookStudentClaimPageVo> pageOutput = ConventPage.getPageOutput(page, TextbookStudentClaimPageVo.class);
  67. return RT.ok(pageOutput);
  68. }
  69. @GetMapping(value = "/student-confirm-list")
  70. @ApiOperation(value="学生教材领取确定页面")
  71. @SaCheckPermission("textbookstudentclaim:detail")
  72. public RT<TextbookClaimStudentConfirmVo> studentConfirmList(@Valid TextbookClaimStudentConfirmDto dto){
  73. TextbookClaimStudentConfirmVo textbookClaimStudentConfirmVo = textbookStudentClaimService.getStudentConfirmList(dto);
  74. return RT.ok(textbookClaimStudentConfirmVo);
  75. }
  76. @GetMapping(value = "/student-semester-list")
  77. @ApiOperation(value="学生教材领取学期页面")
  78. @SaCheckPermission("textbookstudentclaim:detail")
  79. public RT<List<TextbookStudentSemesterVo>> studentSemesterList(){
  80. List<TextbookStudentSemesterVo> textbookStudentSemesterVoList = textbookStudentClaimService.getStudentSemesterList();
  81. return RT.ok(textbookStudentSemesterVoList);
  82. }
  83. @GetMapping(value = "/teacher-check-byClass-list")
  84. @ApiOperation(value="教师教材领取按班级查看页面")
  85. @SaCheckPermission("textbookstudentclaim:detail")
  86. public RT<PageOutput<TeacherCheckByclassVo>> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){
  87. IPage<TeacherCheckByclassVo> page = textbookStudentClaimService.getTeacherCheckByclassList(dto);
  88. PageOutput<TeacherCheckByclassVo> pageOutput = ConventPage.getPageOutput(page, TeacherCheckByclassVo.class);
  89. return RT.ok(pageOutput);
  90. }
  91. // @GetMapping(value = "/teacher-check-byClass-list")
  92. // @ApiOperation(value="班主任为学生教材领取按班级查看页面")
  93. // @SaCheckPermission("textbookstudentclaim:detail")
  94. // public RT<PageOutput<TeacherCheckByclassVo>> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){
  95. // IPage<TeacherCheckByclassVo> page = textbookStudentClaimService.getTeacherCheckByclassList(dto);
  96. // PageOutput<TeacherCheckByclassVo> pageOutput = ConventPage.getPageOutput(page, TeacherCheckByclassVo.class);
  97. // return RT.ok(pageOutput);
  98. // }
  99. @GetMapping(value = "/teacher-check-byStu-list")
  100. @ApiOperation(value="教师教材领取按学生查看页面")
  101. @SaCheckPermission("textbookstudentclaim:detail")
  102. public RT<PageOutput<TeacherCheckByStuVo>> teacherCheckByStuList(@Valid TeacherCheckByStuDto dto){
  103. IPage<TeacherCheckByStuVo> page = textbookStudentClaimService.getTeacherCheckByStuList(dto);
  104. PageOutput<TeacherCheckByStuVo> pageOutput = ConventPage.getPageOutput(page, TeacherCheckByStuVo.class);
  105. return RT.ok(pageOutput);
  106. }
  107. @GetMapping(value = "/teacher-check-stu-claim-list")
  108. @ApiOperation(value="教师查看一本教材的学生领取情况页面")
  109. @SaCheckPermission("textbookstudentclaim:detail")
  110. public RT<List<TeacherCheckStuClaimVo>> teacherCheckStuClaimList(@Valid TeacherCheckStuClaimDto dto){
  111. List<TeacherCheckStuClaimVo> teacherCheckStuClaimList = textbookStudentClaimService.getTeacherCheckStuClaimList(dto);
  112. return RT.ok(teacherCheckStuClaimList);
  113. }
  114. @GetMapping(value = "/teacher-get-stu-noClaim-list")
  115. @ApiOperation(value="班主任获取班上某个学生没有认领的教材记录")
  116. @SaCheckPermission("textbookstudentclaim:detail")
  117. public RT<List<TextbookClaimVO>> teacherGetStuNoClaimList(@RequestParam Long studentUserId){
  118. List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimService.getTeacherGetStuNoClaimList(studentUserId);
  119. return RT.ok(textbookClaimVOList);
  120. }
  121. @GetMapping(value = "/info")
  122. @ApiOperation(value="根据id查询学生教材认领记录信息")
  123. @SaCheckPermission("textbookstudentclaim:detail")
  124. public RT<TextbookStudentClaimVo> info(@RequestParam Long id){
  125. TextbookStudentClaim textbookStudentClaim = textbookStudentClaimService.getById(id);
  126. if (textbookStudentClaim == null) {
  127. return RT.error("找不到此数据!");
  128. }
  129. return RT.ok(BeanUtil.toBean(textbookStudentClaim, TextbookStudentClaimVo.class));
  130. }
  131. @PostMapping
  132. @ApiOperation(value = "新增学生教材认领记录")
  133. @SaCheckPermission("textbookstudentclaim:add")
  134. public RT<Boolean> add(@Valid @RequestBody AddTextbookStudentClaimDto dto){
  135. TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class);
  136. boolean isSuccess = textbookStudentClaimService.save(textbookStudentClaim);
  137. return RT.ok(isSuccess);
  138. }
  139. @PutMapping
  140. @ApiOperation(value = "修改学生教材认领记录")
  141. @SaCheckPermission("textbookstudentclaim:edit")
  142. public RT<Boolean> update(@Valid @RequestBody UpdateTextbookStudentClaimDto dto){
  143. TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class);
  144. return RT.ok(textbookStudentClaimService.updateById(textbookStudentClaim));
  145. }
  146. @PutMapping("/confirm")
  147. @ApiOperation(value = "学生自己确认已经领取")
  148. @SaCheckPermission("textbookstudentclaim:edit")
  149. public RT<Boolean> confirm(@Valid @RequestBody List<Long> textbookStudentClaimIds){
  150. return RT.ok(textbookStudentClaimService.updateByIds(textbookStudentClaimIds));
  151. }
  152. @PutMapping("/teacher-confirm")
  153. @ApiOperation(value = "教师帮助学生确认已经领取")
  154. @SaCheckPermission("textbookstudentclaim:edit")
  155. public RT<Boolean> teacherConfirm(@Valid @RequestBody List<TeacherConfirmDto> teacherConfirmDtoList){
  156. for (TeacherConfirmDto dto : teacherConfirmDtoList) {
  157. TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class);
  158. textbookStudentClaim.setId(dto.getTextbookStudentClaimId());
  159. textbookStudentClaim.setIsClaim(1);
  160. textbookStudentClaim.setRemark(dto.getRemark());
  161. textbookStudentClaim.setModifyUserId(StpUtil.getLoginIdAsLong());
  162. textbookStudentClaim.setModifyDate(new Date());
  163. textbookStudentClaimService.updateById(textbookStudentClaim);
  164. }
  165. return RT.ok(true);
  166. }
  167. @DeleteMapping
  168. @ApiOperation(value = "删除学生教材认领记录")
  169. @SaCheckPermission("textbookstudentclaim:delete")
  170. public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
  171. return RT.ok(textbookStudentClaimService.removeBatchByIds(ids));
  172. }
  173. }