123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- package com.zhongzheng.controller.base;
- import com.zhongzheng.common.core.controller.BaseController;
- import com.zhongzheng.common.core.domain.AjaxResult;
- import com.zhongzheng.common.core.page.TableDataInfo;
- import com.zhongzheng.common.core.redis.RedisCache;
- import com.zhongzheng.common.utils.ServletUtils;
- import com.zhongzheng.framework.web.service.WxTokenService;
- import com.zhongzheng.modules.base.bo.*;
- import com.zhongzheng.modules.base.domain.UserProfile;
- import com.zhongzheng.modules.base.service.IProfileTpService;
- import com.zhongzheng.modules.base.service.IUserProfileService;
- import com.zhongzheng.modules.base.vo.ProfileTpVo;
- import com.zhongzheng.modules.base.vo.UserProfileVo;
- import com.zhongzheng.modules.user.bo.CommitmentSealBo;
- import com.zhongzheng.modules.user.entity.ClientLoginUser;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import net.polyv.common.v1.util.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import java.util.Arrays;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- import java.util.stream.Collectors;
- /**
- * 资料模板Controller
- *
- * @author hjl
- * @date 2021-11-19
- */
- @Api(value = "资料模板控制器", tags = {"资料模板管理"})
- @RequiredArgsConstructor(onConstructor_ = @Autowired)
- @RestController
- @RequestMapping("/base/profile/tp")
- public class ProfileTpController extends BaseController {
- private final IProfileTpService iProfileTpService;
- private final WxTokenService wxTokenService;
- private final IUserProfileService iUserProfileService;
- private final RedisCache redisCache;
- /**
- * 查询资料模板列表
- */
- @ApiOperation("查询资料模板列表")
- @GetMapping("/list")
- public TableDataInfo<ProfileTpVo> list(ProfileTpQueryBo bo) {
- startPage();
- if (StringUtils.isNotBlank(bo.getStatus())){
- List<Integer> collect = Arrays.asList(bo.getStatus().split(",")).stream().map(x -> Integer.valueOf(x)).collect(Collectors.toList());
- bo.setStatusList(collect);
- }
- List<ProfileTpVo> list = iProfileTpService.selectList(bo);
- return getDataTable(list);
- }
- /**
- * 学员上传承诺书
- */
- @ApiOperation("学员上传承诺书")
- @PostMapping("/commitment/upload")
- public AjaxResult<Void> commitmentSealUpload(@RequestBody CommitmentSealBo bo) {
- ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
- bo.setUserId(loginUser.getUser().getUserId());
- return toAjax(iProfileTpService.commitmentSealUpload(bo) ? 1:0 );
- }
- /**
- * 获取资料模板详细信息
- */
- @ApiOperation("获取资料模板详细信息")
- @GetMapping("/{goodsId}")
- public AjaxResult<ProfileTpVo> queryByGoodsId(@PathVariable("goodsId" ) Long goodsId) {
- return AjaxResult.success(iProfileTpService.queryByGoodsId(goodsId));
- }
- /**
- * 新增填写资料审核
- */
- @ApiOperation("新增填写资料审核")
- @PostMapping()
- public AjaxResult<Void> add(@RequestBody UserProfileAddBo bo) {
- ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
- bo.setUserId(loginUser.getUser().getUserId());
- String key = "PROFILE_"+loginUser.getUser().getUserId();
- Long value = redisCache.getCacheObject(key);
- if(value!=null){
- return toAjax(0);
- }
- redisCache.setCacheObject(key,1L,5, TimeUnit.SECONDS);//10秒
- if(iUserProfileService.insertByAddBo(bo)){
- return toAjax(1);
- }
- return toAjax(0);
- }
- /**
- * 修改填写资料审核
- */
- @ApiOperation("修改填写资料审核")
- @PostMapping("edit")
- public AjaxResult<Void> edit(@RequestBody UserProfileEditBo bo) {
- ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
- bo.setUserId(loginUser.getUser().getUserId());
- return toAjax(iUserProfileService.updateByEditBo(bo) ? 1 : 0);
- }
- /**
- * 获取填写资料审核详细信息
- */
- @ApiOperation("获取填写资料审核详细信息")
- @GetMapping("/getInfo")
- public AjaxResult<UserProfileVo> getInfo(UserProfileQueryBo bo) {
- ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
- bo.setUserId(loginUser.getUser().getUserId());
- bo.setTypeStatus(1L);
- return AjaxResult.success(iUserProfileService.getInfo(bo));
- }
- /**
- * 查询填写资料审核列表
- */
- @ApiOperation("查询填写资料审核列表")
- @PreAuthorize("@ss.hasPermi('system:profile:list')")
- @GetMapping("/listProfile")
- public TableDataInfo<UserProfileVo> list(UserProfileQueryBo bo) {
- ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
- bo.setUserId(loginUser.getUser().getUserId());
- bo.setTypeStatus(1L);
- startPage();
- List<UserProfileVo> list = iUserProfileService.queryList(bo);
- return getDataTable(list);
- }
- @ApiOperation("获取最新一次资料审核详细信息")
- @GetMapping("/queryLast")
- public AjaxResult<UserProfile> queryLast(UserProfileQueryBo bo) {
- ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
- bo.setUserId(loginUser.getUser().getUserId());
- return AjaxResult.success(iUserProfileService.queryLast(bo));
- }
- }
|