ProfileTpController.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package com.zhongzheng.controller.base;
  2. import com.zhongzheng.common.core.controller.BaseController;
  3. import com.zhongzheng.common.core.domain.AjaxResult;
  4. import com.zhongzheng.common.core.page.TableDataInfo;
  5. import com.zhongzheng.common.core.redis.RedisCache;
  6. import com.zhongzheng.common.utils.ServletUtils;
  7. import com.zhongzheng.framework.web.service.WxTokenService;
  8. import com.zhongzheng.modules.base.bo.*;
  9. import com.zhongzheng.modules.base.domain.UserProfile;
  10. import com.zhongzheng.modules.base.service.IProfileTpService;
  11. import com.zhongzheng.modules.base.service.IUserProfileService;
  12. import com.zhongzheng.modules.base.vo.ProfileTpVo;
  13. import com.zhongzheng.modules.base.vo.UserProfileVo;
  14. import com.zhongzheng.modules.user.bo.CommitmentSealBo;
  15. import com.zhongzheng.modules.user.entity.ClientLoginUser;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiOperation;
  18. import lombok.RequiredArgsConstructor;
  19. import net.polyv.common.v1.util.StringUtils;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.security.access.prepost.PreAuthorize;
  22. import org.springframework.web.bind.annotation.*;
  23. import org.springframework.web.multipart.MultipartFile;
  24. import java.util.Arrays;
  25. import java.util.List;
  26. import java.util.concurrent.TimeUnit;
  27. import java.util.stream.Collectors;
  28. /**
  29. * 资料模板Controller
  30. *
  31. * @author hjl
  32. * @date 2021-11-19
  33. */
  34. @Api(value = "资料模板控制器", tags = {"资料模板管理"})
  35. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  36. @RestController
  37. @RequestMapping("/base/profile/tp")
  38. public class ProfileTpController extends BaseController {
  39. private final IProfileTpService iProfileTpService;
  40. private final WxTokenService wxTokenService;
  41. private final IUserProfileService iUserProfileService;
  42. private final RedisCache redisCache;
  43. /**
  44. * 查询资料模板列表
  45. */
  46. @ApiOperation("查询资料模板列表")
  47. @GetMapping("/list")
  48. public TableDataInfo<ProfileTpVo> list(ProfileTpQueryBo bo) {
  49. startPage();
  50. if (StringUtils.isNotBlank(bo.getStatus())){
  51. List<Integer> collect = Arrays.asList(bo.getStatus().split(",")).stream().map(x -> Integer.valueOf(x)).collect(Collectors.toList());
  52. bo.setStatusList(collect);
  53. }
  54. List<ProfileTpVo> list = iProfileTpService.selectList(bo);
  55. return getDataTable(list);
  56. }
  57. /**
  58. * 学员上传承诺书
  59. */
  60. @ApiOperation("学员上传承诺书")
  61. @PostMapping("/commitment/upload")
  62. public AjaxResult<Void> commitmentSealUpload(@RequestBody CommitmentSealBo bo) {
  63. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  64. bo.setUserId(loginUser.getUser().getUserId());
  65. return toAjax(iProfileTpService.commitmentSealUpload(bo) ? 1:0 );
  66. }
  67. /**
  68. * 获取资料模板详细信息
  69. */
  70. @ApiOperation("获取资料模板详细信息")
  71. @GetMapping("/{goodsId}")
  72. public AjaxResult<ProfileTpVo> queryByGoodsId(@PathVariable("goodsId" ) Long goodsId) {
  73. return AjaxResult.success(iProfileTpService.queryByGoodsId(goodsId));
  74. }
  75. /**
  76. * 新增填写资料审核
  77. */
  78. @ApiOperation("新增填写资料审核")
  79. @PostMapping()
  80. public AjaxResult<Void> add(@RequestBody UserProfileAddBo bo) {
  81. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  82. bo.setUserId(loginUser.getUser().getUserId());
  83. String key = "PROFILE_"+loginUser.getUser().getUserId();
  84. Long value = redisCache.getCacheObject(key);
  85. if(value!=null){
  86. return toAjax(0);
  87. }
  88. redisCache.setCacheObject(key,1L,5, TimeUnit.SECONDS);//10秒
  89. if(iUserProfileService.insertByAddBo(bo)){
  90. return toAjax(1);
  91. }
  92. return toAjax(0);
  93. }
  94. /**
  95. * 修改填写资料审核
  96. */
  97. @ApiOperation("修改填写资料审核")
  98. @PostMapping("edit")
  99. public AjaxResult<Void> edit(@RequestBody UserProfileEditBo bo) {
  100. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  101. bo.setUserId(loginUser.getUser().getUserId());
  102. return toAjax(iUserProfileService.updateByEditBo(bo) ? 1 : 0);
  103. }
  104. /**
  105. * 获取填写资料审核详细信息
  106. */
  107. @ApiOperation("获取填写资料审核详细信息")
  108. @GetMapping("/getInfo")
  109. public AjaxResult<UserProfileVo> getInfo(UserProfileQueryBo bo) {
  110. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  111. bo.setUserId(loginUser.getUser().getUserId());
  112. bo.setTypeStatus(1L);
  113. return AjaxResult.success(iUserProfileService.getInfo(bo));
  114. }
  115. /**
  116. * 查询填写资料审核列表
  117. */
  118. @ApiOperation("查询填写资料审核列表")
  119. @PreAuthorize("@ss.hasPermi('system:profile:list')")
  120. @GetMapping("/listProfile")
  121. public TableDataInfo<UserProfileVo> list(UserProfileQueryBo bo) {
  122. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  123. bo.setUserId(loginUser.getUser().getUserId());
  124. bo.setTypeStatus(1L);
  125. startPage();
  126. List<UserProfileVo> list = iUserProfileService.queryList(bo);
  127. return getDataTable(list);
  128. }
  129. @ApiOperation("获取最新一次资料审核详细信息")
  130. @GetMapping("/queryLast")
  131. public AjaxResult<UserProfile> queryLast(UserProfileQueryBo bo) {
  132. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  133. bo.setUserId(loginUser.getUser().getUserId());
  134. return AjaxResult.success(iUserProfileService.queryLast(bo));
  135. }
  136. }