UserProfileController.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. package com.zhongzheng.controller.base;
  2. import java.io.IOException;
  3. import java.time.LocalDateTime;
  4. import java.time.format.DateTimeFormatter;
  5. import java.util.*;
  6. import cn.afterturn.easypoi.excel.entity.ExportParams;
  7. import cn.hutool.core.lang.Validator;
  8. import com.zhongzheng.common.core.domain.model.LoginUser;
  9. import com.zhongzheng.common.utils.ServletUtils;
  10. import com.zhongzheng.framework.web.service.TokenService;
  11. import com.zhongzheng.modules.base.vo.UserProfileExportGaiVo;
  12. import com.zhongzheng.modules.base.vo.UserProfileExportVo;
  13. import com.zhongzheng.modules.grade.vo.ClassPeriodStudentExportVo;
  14. import com.zhongzheng.modules.user.bo.UserQueryBo;
  15. import com.zhongzheng.modules.user.vo.UserVo;
  16. import lombok.RequiredArgsConstructor;
  17. import org.springframework.security.access.prepost.PreAuthorize;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.GetMapping;
  20. import org.springframework.web.bind.annotation.PostMapping;
  21. import org.springframework.web.bind.annotation.PutMapping;
  22. import org.springframework.web.bind.annotation.DeleteMapping;
  23. import org.springframework.web.bind.annotation.PathVariable;
  24. import org.springframework.web.bind.annotation.RequestBody;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import com.zhongzheng.common.annotation.Log;
  28. import com.zhongzheng.common.core.controller.BaseController;
  29. import com.zhongzheng.common.core.domain.AjaxResult;
  30. import com.zhongzheng.common.enums.BusinessType;
  31. import com.zhongzheng.modules.base.vo.UserProfileVo;
  32. import com.zhongzheng.modules.base.bo.UserProfileQueryBo;
  33. import com.zhongzheng.modules.base.bo.UserProfileAddBo;
  34. import com.zhongzheng.modules.base.bo.UserProfileEditBo;
  35. import com.zhongzheng.modules.base.service.IUserProfileService;
  36. import com.zhongzheng.common.utils.poi.ExcelUtil;
  37. import com.zhongzheng.common.core.page.TableDataInfo;
  38. import io.swagger.annotations.Api;
  39. import io.swagger.annotations.ApiOperation;
  40. /**
  41. * 填写资料审核Controller
  42. *
  43. * @author ruoyi
  44. * @date 2021-12-20
  45. */
  46. @Api(value = "填写资料审核控制器", tags = {"填写资料审核管理"})
  47. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  48. @RestController
  49. @RequestMapping("/base/profile")
  50. public class UserProfileController extends BaseController {
  51. private final IUserProfileService iUserProfileService;
  52. private final TokenService tokenService;
  53. /**
  54. * 查询填写资料审核列表
  55. */
  56. @ApiOperation("查询填写资料审核列表")
  57. @PreAuthorize("@ss.hasPermi('system:profile:list')")
  58. @GetMapping("/list")
  59. public TableDataInfo<UserProfileVo> list(UserProfileQueryBo bo) {
  60. startPage();
  61. //1为资料审核
  62. bo.setTypeStatus(1L);
  63. List<UserProfileVo> list = iUserProfileService.queryList(bo);
  64. return getDataTable(list);
  65. }
  66. /**
  67. * 查询填写资料审核列表
  68. */
  69. @ApiOperation("查询填写资料审记录列表")
  70. @PreAuthorize("@ss.hasPermi('system:profile:list')")
  71. @GetMapping("/listRecord")
  72. public TableDataInfo<UserProfileVo> listRecord(UserProfileQueryBo bo) {
  73. startPage();
  74. //1为资料审核
  75. bo.setTypeStatus(1L);
  76. List<UserProfileVo> list = iUserProfileService.listRecord(bo);
  77. return getDataTable(list);
  78. }
  79. /**
  80. * 获取填写资料审核详细信息
  81. */
  82. @ApiOperation("获取填写资料审核详细信息")
  83. @PreAuthorize("@ss.hasPermi('system:profile:query')")
  84. @GetMapping("/{id}")
  85. public AjaxResult<UserProfileVo> getInfo(@PathVariable("id" ) Long id) {
  86. return AjaxResult.success(iUserProfileService.queryById(id));
  87. }
  88. /**
  89. * 修改填写资料审核
  90. */
  91. @ApiOperation("审核资料")
  92. @PreAuthorize("@ss.hasPermi('system:profile:edit')")
  93. @Log(title = "审核资料", businessType = BusinessType.UPDATE)
  94. @PostMapping()
  95. public AjaxResult<Void> edit(@RequestBody UserProfileEditBo bo) {
  96. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  97. return toAjax(iUserProfileService.updateAuditByEditBo(bo,loginUser) ? 1 : 0);
  98. }
  99. /**
  100. * 导出资料审核列表
  101. */
  102. @ApiOperation("导出资料审核列表")
  103. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  104. @Log(title = "客户端用户", businessType = BusinessType.EXPORT)
  105. @GetMapping("/export")
  106. public AjaxResult<Map<String,Object>> export(UserProfileQueryBo bo) {
  107. String fileName = "";
  108. if(Validator.isEmpty(bo.getStatus())){
  109. bo.setStatus(new ArrayList<Integer>(Arrays.asList(0)));
  110. fileName="全部";
  111. }else {
  112. if(bo.getStatus().get(0)==0){
  113. fileName="全部";
  114. }
  115. if(bo.getStatus().get(0)==1){
  116. fileName="通过";
  117. }
  118. if(bo.getStatus().get(0)==2){
  119. fileName="待审";
  120. }
  121. if(bo.getStatus().get(0)==3){
  122. fileName="不通过";
  123. }
  124. }
  125. startPage();
  126. //1为资料审核
  127. bo.setTypeStatus(1L);
  128. if(bo.getStatus().get(0)==0){
  129. bo.getStatus().remove(0);
  130. bo.setStatus(bo.getStatus());
  131. }
  132. Map<String,Object> map = iUserProfileService.export(bo);
  133. List<UserProfileExportVo> list = (List<UserProfileExportVo>)map.get("list");
  134. ExcelUtil<UserProfileExportVo> util = new ExcelUtil<UserProfileExportVo>(UserProfileExportVo.class);
  135. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  136. ExportParams deptExportParams = new ExportParams();
  137. // 设置sheet得名称
  138. deptExportParams.setSheetName("表1");
  139. Map<String, Object> deptExportMap = new HashMap<>();
  140. deptExportMap.put("title", deptExportParams);
  141. deptExportMap.put("entity", UserProfileExportVo.class);
  142. // sheet中要填充得数据
  143. deptExportMap.put("data", list);
  144. List<Map<String, Object>> sheetsList = new ArrayList<>();
  145. sheetsList.add(deptExportMap);
  146. map.put("excel",util.exportEasyExcel(sheetsList, "填写资料审核-"+fileName+"-学员数据-"+timeStr));
  147. map.remove("list");
  148. return AjaxResult.success(map);
  149. }
  150. @ApiOperation("承诺书下载")
  151. @GetMapping("/querCommitment")
  152. public AjaxResult querCommitment(UserProfileQueryBo bo) {
  153. return AjaxResult.success(iUserProfileService.querCommitment(bo));
  154. }
  155. /*@ApiOperation("审核资料测试")
  156. @PreAuthorize("@ss.hasPermi('system:profile:edit')")
  157. @Log(title = "填写资料审核", businessType = BusinessType.UPDATE)
  158. @PostMapping("/test")
  159. public AjaxResult test(@RequestBody UserProfileAddBo bo) throws IOException {
  160. return AjaxResult.success(iUserProfileService.testWord(bo));
  161. }*/
  162. }