|
@@ -3,6 +3,7 @@ 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.*;
|
|
@@ -19,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 资料模板Controller
|
|
@@ -39,6 +41,8 @@ public class ProfileTpController extends BaseController {
|
|
|
|
|
|
private final IUserProfileService iUserProfileService;
|
|
|
|
|
|
+ private final RedisCache redisCache;
|
|
|
+
|
|
|
/**
|
|
|
* 查询资料模板列表
|
|
|
*/
|
|
@@ -69,7 +73,16 @@ public class ProfileTpController extends BaseController {
|
|
|
public AjaxResult<Void> add(@RequestBody UserProfileAddBo bo) {
|
|
|
ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
bo.setUserId(loginUser.getUser().getUserId());
|
|
|
- return toAjax(iUserProfileService.insertByAddBo(bo) ? 1 : 0);
|
|
|
+ String key = "PROFILE_"+loginUser.getUser().getUserId();
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
+ if(value!=null){
|
|
|
+ return toAjax(1);
|
|
|
+ }
|
|
|
+ if(iUserProfileService.insertByAddBo(bo)){
|
|
|
+ redisCache.setCacheObject(key,1L,10, TimeUnit.SECONDS);//10秒
|
|
|
+ return toAjax(1);
|
|
|
+ }
|
|
|
+ return toAjax(0);
|
|
|
}
|
|
|
|
|
|
/**
|