BaseStudentScholarshipApplicantController.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.hutool.core.bean.BeanUtil;
  4. import cn.hutool.core.util.ObjectUtil;
  5. import cn.hutool.core.util.StrUtil;
  6. import com.baomidou.mybatisplus.core.metadata.IPage;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import com.github.yulichang.toolkit.MPJWrappers;
  9. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  10. import com.xjrsoft.common.model.result.RT;
  11. import com.xjrsoft.common.page.ConventPage;
  12. import com.xjrsoft.common.page.PageOutput;
  13. import com.xjrsoft.common.utils.VoToColumnUtil;
  14. import com.xjrsoft.module.base.entity.BaseSemester;
  15. import com.xjrsoft.module.organization.entity.User;
  16. import com.xjrsoft.module.student.dto.AddBaseStudentScholarshipApplicantDto;
  17. import com.xjrsoft.module.student.dto.BaseStudentScholarshipApplicantCategoryPageDto;
  18. import com.xjrsoft.module.student.dto.BaseStudentScholarshipApplicantPageDto;
  19. import com.xjrsoft.module.student.dto.UpdateBaseStudentScholarshipApplicantDto;
  20. import com.xjrsoft.module.student.entity.BaseStudentScholarshipApplicant;
  21. import com.xjrsoft.module.student.entity.BaseStudentScholarshipCategory;
  22. import com.xjrsoft.module.student.service.IBaseStudentScholarshipApplicantService;
  23. import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantCategoryPageVo;
  24. import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantPageVo;
  25. import com.xjrsoft.module.student.vo.BaseStudentScholarshipApplicantVo;
  26. import com.xjrsoft.module.student.vo.ScholarshipApplicantOptionVo;
  27. import com.xjrsoft.module.system.entity.DictionaryDetail;
  28. import io.swagger.annotations.Api;
  29. import io.swagger.annotations.ApiOperation;
  30. import lombok.AllArgsConstructor;
  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.util.List;
  41. /**
  42. * @title: 奖学金申请
  43. * @Author dzx
  44. * @Date: 2023-11-23
  45. * @Version 1.0
  46. */
  47. @RestController
  48. @RequestMapping("/student" + "/baseStudentScholarshipApplicant")
  49. @Api(value = "/student" + "/baseStudentScholarshipApplicant",tags = "奖学金申请代码")
  50. @AllArgsConstructor
  51. public class BaseStudentScholarshipApplicantController {
  52. private final IBaseStudentScholarshipApplicantService applicantService;
  53. @GetMapping(value = "/page")
  54. @ApiOperation(value="奖学金申请列表(分页)")
  55. @SaCheckPermission("basestudentscholarshipapplicant:detail")
  56. public RT<PageOutput<BaseStudentScholarshipApplicantPageVo>> page(@Valid BaseStudentScholarshipApplicantPageDto dto){
  57. IPage<BaseStudentScholarshipApplicantPageVo> page = applicantService.selectJoinListPage(ConventPage.getPage(dto), BaseStudentScholarshipApplicantPageVo.class,
  58. MPJWrappers.<BaseStudentScholarshipApplicant>lambdaJoin()
  59. .like(StrUtil.isNotEmpty(dto.getName()), BaseStudentScholarshipApplicant::getName, dto.getName())
  60. .eq(ObjectUtil.isNotNull(dto.getSemesterId()), BaseStudentScholarshipCategory::getBaseSemesterId, dto.getSemesterId())
  61. .eq(ObjectUtil.isNotNull(dto.getReleaseStatus()), BaseStudentScholarshipApplicant::getReleaseStatus, dto.getReleaseStatus())
  62. .eq(BaseStudentScholarshipApplicant::getStatus, 1)
  63. .between(ObjectUtil.isNotNull(dto.getStartDate()) && ObjectUtil.isNotNull(dto.getEndDate()), BaseStudentScholarshipApplicant::getAwardDate,dto.getStartDate(),dto.getEndDate())
  64. .eq(BaseStudentScholarshipApplicant::getBaseStudentScholarshipCategoryId,dto.getBaseStudentScholarshipCategoryId())
  65. .orderByAsc(BaseStudentScholarshipApplicant::getSortCode)
  66. .selectAs(BaseStudentScholarshipApplicant::getId, BaseStudentScholarshipApplicantPageVo::getId)
  67. .select(" t4.name as bank_type_cn")
  68. .selectAs(BaseSemester::getName, BaseStudentScholarshipApplicantPageVo::getSemesterName)
  69. .select(" t5.name as category_cn")
  70. .select(BaseStudentScholarshipApplicant.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentScholarshipApplicantPageVo.class).contains(x.getProperty()))
  71. .innerJoin(BaseStudentScholarshipCategory.class, BaseStudentScholarshipCategory::getId, BaseStudentScholarshipApplicant::getBaseStudentScholarshipCategoryId)
  72. .leftJoin(BaseSemester.class, BaseSemester::getId, BaseStudentScholarshipApplicant::getBaseSemesterId)
  73. .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, BaseStudentScholarshipApplicant::getBankType)
  74. .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, BaseStudentScholarshipCategory::getCategory)
  75. );
  76. PageOutput<BaseStudentScholarshipApplicantPageVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentScholarshipApplicantPageVo.class);
  77. return RT.ok(pageOutput);
  78. }
  79. @GetMapping(value = "/scholarship-page")
  80. @ApiOperation(value="奖学金名称表(分页)")
  81. @SaCheckPermission("basestudentscholarshipapplicant:detail")
  82. public RT<PageOutput<BaseStudentScholarshipApplicantCategoryPageVo>> scholarshiPage(@Valid BaseStudentScholarshipApplicantCategoryPageDto dto){
  83. IPage<BaseStudentScholarshipApplicantCategoryPageVo> page = applicantService.getScholarshiPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  84. PageOutput<BaseStudentScholarshipApplicantCategoryPageVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentScholarshipApplicantCategoryPageVo.class);
  85. return RT.ok(pageOutput);
  86. }
  87. @GetMapping(value = "/info")
  88. @ApiOperation(value="根据id查询奖学金申请信息")
  89. @SaCheckPermission("basestudentscholarshipapplicant:detail")
  90. public RT<BaseStudentScholarshipApplicantVo> info(@RequestParam Long id){
  91. BaseStudentScholarshipApplicant baseStudentScholarshipApplicant = applicantService.getById(id);
  92. if (baseStudentScholarshipApplicant == null) {
  93. return RT.error("找不到此数据!");
  94. }
  95. return RT.ok(BeanUtil.toBean(baseStudentScholarshipApplicant, BaseStudentScholarshipApplicantVo.class));
  96. }
  97. @PostMapping
  98. @ApiOperation(value = "新增奖学金申请")
  99. @SaCheckPermission("basestudentscholarshipapplicant:add")
  100. public RT<Boolean> add(@Valid @RequestBody AddBaseStudentScholarshipApplicantDto dto){
  101. BaseStudentScholarshipApplicant baseStudentScholarshipApplicant = BeanUtil.toBean(dto, BaseStudentScholarshipApplicant.class);
  102. boolean isSuccess = applicantService.save(baseStudentScholarshipApplicant);
  103. return RT.ok(isSuccess);
  104. }
  105. @PutMapping
  106. @ApiOperation(value = "修改奖学金申请")
  107. @SaCheckPermission("basestudentscholarshipapplicant:edit")
  108. public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentScholarshipApplicantDto dto){
  109. BaseStudentScholarshipApplicant baseStudentScholarshipApplicant = BeanUtil.toBean(dto, BaseStudentScholarshipApplicant.class);
  110. return RT.ok(applicantService.updateById(baseStudentScholarshipApplicant));
  111. }
  112. @DeleteMapping
  113. @ApiOperation(value = "删除奖学金申请")
  114. @SaCheckPermission("basestudentscholarshipapplicant:delete")
  115. public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
  116. return RT.ok(applicantService.removeBatchByIds(ids));
  117. }
  118. @GetMapping(value = "/option-select")
  119. @ApiOperation(value="申请人下拉列表")
  120. @SaCheckPermission("basestudentscholarshipapplicant:detail")
  121. public RT<List<ScholarshipApplicantOptionVo>> optionSelect(@Valid BaseStudentScholarshipApplicantPageDto dto){
  122. List<BaseStudentScholarshipApplicant> applicantList = applicantService.list(
  123. new MPJLambdaWrapper<BaseStudentScholarshipApplicant>()
  124. .select(BaseStudentScholarshipApplicant::getId)
  125. .selectAs(User::getName, BaseStudentScholarshipApplicant::getName)
  126. .select(BaseStudentScholarshipApplicant.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentScholarshipApplicantPageVo.class).contains(x.getProperty()))
  127. .leftJoin(User.class, User::getId, BaseStudentScholarshipApplicant::getApplicantUserId)
  128. .eq(ObjectUtil.isNotNull(dto.getBaseStudentScholarshipCategoryId()),BaseStudentScholarshipApplicant::getBaseStudentScholarshipCategoryId, dto.getBaseStudentScholarshipCategoryId())
  129. .eq(ObjectUtil.isNotNull(dto.getSemesterId()), BaseStudentScholarshipApplicant::getBaseSemesterId, dto.getSemesterId())
  130. .eq(BaseStudentScholarshipApplicant::getStatus, 1)
  131. .ne(BaseStudentScholarshipApplicant::getReviewStatus, 1)
  132. );
  133. List<ScholarshipApplicantOptionVo> voList = BeanUtil.copyToList(applicantList, ScholarshipApplicantOptionVo.class);
  134. return RT.ok(voList);
  135. }
  136. }