ProfileTpController.java 5.0 KB

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