BaseStudentAssessmentInspectionController.java 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.alibaba.excel.support.ExcelTypeEnum;
  6. import com.baomidou.mybatisplus.core.metadata.IPage;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import com.xjrsoft.common.enums.EnabledMark;
  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.student.dto.AddBaseStudentAssessmentInspectionDto;
  13. import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionMobilePageDto;
  14. import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto;
  15. import com.xjrsoft.module.student.dto.CalssQuantitativeAssessmentPageDto;
  16. import com.xjrsoft.module.student.dto.CancelStudentDto;
  17. import com.xjrsoft.module.student.dto.UpdateBaseStudentAssessmentInspectionDto;
  18. import com.xjrsoft.module.student.entity.BaseStudentAssessmentInspection;
  19. import com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation;
  20. import com.xjrsoft.module.student.service.IBaseStudentAssessmentInspectionService;
  21. import com.xjrsoft.module.student.service.IBaseStudentAssessmentStudentRelationService;
  22. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobilePageVo;
  23. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobileVo;
  24. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionPageVo;
  25. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionVo;
  26. import com.xjrsoft.module.student.vo.CalssQuantitativeAssessmentPageVo;
  27. import io.swagger.annotations.Api;
  28. import io.swagger.annotations.ApiOperation;
  29. import lombok.AllArgsConstructor;
  30. import org.springframework.http.ResponseEntity;
  31. import org.springframework.web.bind.annotation.DeleteMapping;
  32. import org.springframework.web.bind.annotation.GetMapping;
  33. import org.springframework.web.bind.annotation.PostMapping;
  34. import org.springframework.web.bind.annotation.PutMapping;
  35. import org.springframework.web.bind.annotation.RequestBody;
  36. import org.springframework.web.bind.annotation.RequestMapping;
  37. import org.springframework.web.bind.annotation.RequestParam;
  38. import org.springframework.web.bind.annotation.RestController;
  39. import javax.validation.Valid;
  40. import java.io.IOException;
  41. import java.util.Date;
  42. import java.util.List;
  43. import static com.alibaba.fastjson.JSONPatch.OperationType.remove;
  44. /**
  45. * @title: 学生班级巡查考核
  46. * @Author dzx
  47. * @Date: 2023-11-16
  48. * @Version 1.0
  49. */
  50. @RestController
  51. @RequestMapping("/student" + "/basestudentassessmentinspection")
  52. @Api(value = "/student" + "/basestudentassessmentinspection", tags = "学生班级巡查考核代码")
  53. @AllArgsConstructor
  54. public class BaseStudentAssessmentInspectionController {
  55. private final IBaseStudentAssessmentInspectionService inspectionService;
  56. private final IBaseStudentAssessmentStudentRelationService studentRelationService;
  57. @GetMapping(value = "/page")
  58. @ApiOperation(value = "学生班级巡查考核列表(分页)")
  59. @SaCheckPermission("basestudentassessmentinspection:detail")
  60. public RT<PageOutput<BaseStudentAssessmentInspectionPageVo>> page(@Valid BaseStudentAssessmentInspectionPageDto dto) {
  61. List<String> roleList = StpUtil.getRoleList();
  62. if(roleList.size() == 2 && roleList.contains("TEACHER") && roleList.contains("CLASSTE")){
  63. dto.setTeacherId(StpUtil.getLoginIdAsLong());
  64. }
  65. Page<BaseStudentAssessmentInspectionPageVo> page = inspectionService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  66. return RT.ok(ConventPage.getPageOutput(page, BaseStudentAssessmentInspectionPageVo.class));
  67. }
  68. @GetMapping(value = "/info")
  69. @ApiOperation(value = "根据id查询学生班级巡查考核信息")
  70. @SaCheckPermission("basestudentassessmentinspection:detail")
  71. public RT<BaseStudentAssessmentInspectionVo> info(@RequestParam Long id) {
  72. BaseStudentAssessmentInspectionVo result = inspectionService.getInfo(id);
  73. return RT.ok(result);
  74. }
  75. @GetMapping(value = "/mobile-page")
  76. @ApiOperation(value = "学生操行分记录管理列表(移动端)")
  77. @SaCheckPermission("basestudentbehaviormanage:detail")
  78. public RT<PageOutput<BaseStudentAssessmentInspectionMobilePageVo>> mobilePage(@Valid BaseStudentAssessmentInspectionMobilePageDto dto) {
  79. Page<BaseStudentAssessmentInspectionMobilePageVo> page = inspectionService.getMobilePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  80. if (page == null) {
  81. return RT.ok(ConventPage.getPageOutputNull(BaseStudentAssessmentInspectionMobilePageVo.class));
  82. }
  83. return RT.ok(ConventPage.getPageOutput(page, BaseStudentAssessmentInspectionMobilePageVo.class));
  84. }
  85. @GetMapping(value = "/mobile-info")
  86. @ApiOperation(value = "根据id查询学生班级巡查考核信息(移动端)")
  87. @SaCheckPermission("basestudentassessmentinspection:detail")
  88. public RT<BaseStudentAssessmentInspectionMobileVo> mobileInfo(@Valid Long id) {
  89. BaseStudentAssessmentInspectionMobileVo result = inspectionService.getMobileInfo(id);
  90. return RT.ok(result);
  91. }
  92. @PostMapping
  93. @ApiOperation(value = "新增学生班级巡查考核")
  94. @SaCheckPermission("basestudentassessmentinspection:add")
  95. public RT<Boolean> add(@Valid @RequestBody AddBaseStudentAssessmentInspectionDto dto) {
  96. BaseStudentAssessmentInspection inspection = BeanUtil.toBean(dto, BaseStudentAssessmentInspection.class);
  97. inspection.setCreateDate(new Date());
  98. inspection.setPersonalStudentUserIds(dto.getStudentUserIds());
  99. boolean isSuccess = inspectionService.save(inspection);
  100. inspectionService.dataHandle(inspection.getId());
  101. inspectionService.noticeTeacher(inspection.getId());
  102. return RT.ok(isSuccess);
  103. }
  104. @PutMapping
  105. @ApiOperation(value = "修改学生班级巡查考核")
  106. @SaCheckPermission("basestudentassessmentinspection:edit")
  107. public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentAssessmentInspectionDto dto) {
  108. BaseStudentAssessmentInspection baseStudentAssessmentInspection = BeanUtil.toBean(dto, BaseStudentAssessmentInspection.class);
  109. return RT.ok(inspectionService.updateById(baseStudentAssessmentInspection));
  110. }
  111. @DeleteMapping
  112. @ApiOperation(value = "删除学生班级巡查考核")
  113. @SaCheckPermission("basestudentassessmentinspection:delete")
  114. public RT<Boolean> delete(@Valid @RequestBody List<Long> ids) {
  115. return RT.ok(inspectionService.removeBatchByIds(ids));
  116. }
  117. @GetMapping(value = "/calss-quantitative-assessment-page")
  118. @ApiOperation(value = "班级量化考核列表(分页)")
  119. @SaCheckPermission("basestudentassessmentinspection:detail")
  120. public RT<PageOutput<CalssQuantitativeAssessmentPageVo>> calssQuantitativeAssessmentPage(@Valid CalssQuantitativeAssessmentPageDto dto) {
  121. IPage<CalssQuantitativeAssessmentPageVo> page = inspectionService.getCalssQuantitativeAssessmentPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  122. return RT.ok(ConventPage.getPageOutput(page, CalssQuantitativeAssessmentPageVo.class));
  123. }
  124. // @PostMapping("/export-query")
  125. // @ApiOperation(value = "入参导出")
  126. // public ResponseEntity<byte[]> exportDataQuery(@Valid @RequestBody QuantitativeAssessmentExcelDto dto) {
  127. @PostMapping("/export-query")
  128. @ApiOperation(value = "导出")
  129. public ResponseEntity<byte[]> exportDataQuery(@Valid @RequestBody CalssQuantitativeAssessmentPageDto dto) throws IOException {
  130. byte[] bytes = inspectionService.getExcelByte(dto);
  131. String fileName = "recordExport" + ExcelTypeEnum.XLSX.getValue();
  132. return RT.fileStream(bytes, fileName);
  133. }
  134. @PostMapping("/cancel-student")
  135. @ApiOperation(value = "作废学生")
  136. public RT<Boolean> cancelStudent(@RequestBody CancelStudentDto dto){
  137. BaseStudentAssessmentStudentRelation relation = studentRelationService.getById(dto.getId());
  138. relation.setEnabledMark(EnabledMark.DISABLED.getCode());
  139. boolean update = studentRelationService.updateById(relation);
  140. return RT.ok(update);
  141. }
  142. }