Commit 868d0407 authored by fangxinjiang's avatar fangxinjiang

工资查询优化-fxj

parent 9b6098c3
......@@ -19,11 +19,17 @@ package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.redis.RedisDistributedLock;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TMobileChangeInfo;
import com.yifu.cloud.plus.v1.yifu.salary.service.TMobileChangeInfoService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TMobileChangeInfoSearchVo;
......@@ -97,10 +103,21 @@ public class TMobileChangeInfoController {
* @param tMobileChangeInfo
* @return R
*/
@Operation(summary = "新增", description = "新增:hasPermission('demo_tmobilechangeinfo_add')")
@Operation(summary = "新增", description = "新增")
@SysLog("新增")
@PostMapping("/add")
public R<Boolean> save(@RequestBody TMobileChangeInfo tMobileChangeInfo) {
// 获取redis分布式事务锁
String key = CacheConstants.MOBILE_CHANGE_LIMIT + CommonConstants.DOWN_LINE_STRING + "mobileChangeFlag";
String requestId;
try {
requestId = RedisDistributedLock.getLock(key,"10");
} catch (Exception e) {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
}
try {
if (Common.isNotNull(requestId)) {
//主动释放锁
tMobileChangeInfo.setHandleStatus(CommonConstants.ZERO_STRING);
if (null != redisUtil.get(CommonConstants.C_PREFIX.concat(tMobileChangeInfo.getMobileNew()))) {
String code = (String) redisUtil.get(CommonConstants.C_PREFIX.concat(tMobileChangeInfo.getMobileNew()));
......@@ -111,6 +128,15 @@ public class TMobileChangeInfoController {
return R.failed("未找到手机号对应的验证码或验证码已超时,请重新获取");
}
return R.ok(tMobileChangeInfoService.save(tMobileChangeInfo));
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
}
}
/**
......
......@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.redis.RedisDistributedLock;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
......@@ -95,11 +100,32 @@ public class TQuestionFeedbackInfoController {
* @param tQuestionFeedbackInfo
* @return R
*/
@Operation(summary = "新增", description = "新增:hasPermission('demo_tquestionfeedbackinfo_add')")
@Operation(summary = "新增", description = "新增")
@SysLog("新增")
@PostMapping("/add")
public R<Boolean> save(@RequestBody TQuestionFeedbackInfo tQuestionFeedbackInfo) {
String key = CacheConstants.QUESTION_FEEDBACK_LIMIT + CommonConstants.DOWN_LINE_STRING + "questionFeedBackFlag";
String requestId;
try {
requestId = RedisDistributedLock.getLock(key,"10");
} catch (Exception e) {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
}
try {
if (Common.isNotNull(requestId)) {
if (Common.isNotNull(tQuestionFeedbackInfo.getQuestion()) && tQuestionFeedbackInfo.getQuestion().length() > 200){
return R.failed("你遇到的问题请控制在200字以内!");
}
return tQuestionFeedbackInfoService.saveAsso(tQuestionFeedbackInfo);
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment