ProfileTpController.java 4.3 KB

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