@Resource

This commit is contained in:
苏竹红
2024-06-03 09:59:07 +08:00
parent 4ed67b93b4
commit 68c209d0ca
3 changed files with 13 additions and 12 deletions

View File

@@ -76,7 +76,7 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
AliyunService aliyunService; AliyunService aliyunService;
@Resource @Resource
private StringRedisTemplate redisTemplate; private StringRedisTemplate stringRedisTemplate;
@Override @Override
@@ -209,7 +209,7 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
String lockValue = UUID.randomUUID().toString(); String lockValue = UUID.randomUUID().toString();
boolean acquired = false; boolean acquired = false;
try { try {
acquired = redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS); acquired = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
if (Boolean.TRUE.equals(acquired)) { if (Boolean.TRUE.equals(acquired)) {
Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> requestMap = new HashMap<>();
fillSignatureInfo(requestMap); fillSignatureInfo(requestMap);
@@ -236,9 +236,9 @@ public class IntentAgreementServiceImpl extends LineFlowService implements Inten
} }
}finally { }finally {
if (Boolean.TRUE.equals(acquired)) { if (Boolean.TRUE.equals(acquired)) {
String currentValue = redisTemplate.opsForValue().get(lockKey); String currentValue = stringRedisTemplate.opsForValue().get(lockKey);
if (lockValue.equals(currentValue)) { if (lockValue.equals(currentValue)) {
redisTemplate.delete(lockKey); stringRedisTemplate.delete(lockKey);
} }
} }
} }

View File

@@ -84,7 +84,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
@Resource @Resource
private StringRedisTemplate redisTemplate; private StringRedisTemplate stringRedisTemplate;
@Override @Override
@@ -148,7 +148,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
boolean acquired = false; boolean acquired = false;
try { try {
//10s过期 //10s过期
acquired = redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS); acquired = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
if (Boolean.TRUE.equals(acquired)) { if (Boolean.TRUE.equals(acquired)) {
SignFranchiseDO signFranchiseDO = request.toSignFranchiseDO(); SignFranchiseDO signFranchiseDO = request.toSignFranchiseDO();
if (Objects.isNull(request.getId())) { if (Objects.isNull(request.getId())) {
@@ -174,9 +174,9 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
}finally { }finally {
if (Boolean.TRUE.equals(acquired)) { if (Boolean.TRUE.equals(acquired)) {
String currentValue = redisTemplate.opsForValue().get(lockKey); String currentValue = stringRedisTemplate.opsForValue().get(lockKey);
if (lockValue.equals(currentValue)) { if (lockValue.equals(currentValue)) {
redisTemplate.delete(lockKey); stringRedisTemplate.delete(lockKey);
} }
} }
} }

View File

@@ -27,6 +27,7 @@ import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.poi.StringUtils; import com.cool.store.utils.poi.StringUtils;
import com.cool.store.utils.poi.constant.Constants; import com.cool.store.utils.poi.constant.Constants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -87,7 +88,7 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
PointDetailInfoMapper pointDetailInfoMapper; PointDetailInfoMapper pointDetailInfoMapper;
@Resource @Resource
private StringRedisTemplate redisTemplate; private StringRedisTemplate stringRedisTemplate;
@Resource @Resource
RedisUtilPool redisUtilPool; RedisUtilPool redisUtilPool;
@@ -103,7 +104,7 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
String lockValue = UUID.randomUUID().toString(); String lockValue = UUID.randomUUID().toString();
boolean acquired = false; boolean acquired = false;
try { try {
acquired = redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS); acquired = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
if (Boolean.TRUE.equals(acquired)) { if (Boolean.TRUE.equals(acquired)) {
//1.操作数据库 //1.操作数据库
SystemBuildingShopDO systemBuildingShopDO = SystemBuildingShopDO.convertToSystemBuildingShopDO(request); SystemBuildingShopDO systemBuildingShopDO = SystemBuildingShopDO.convertToSystemBuildingShopDO(request);
@@ -125,9 +126,9 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
} }
}finally { }finally {
if (Boolean.TRUE.equals(acquired)) { if (Boolean.TRUE.equals(acquired)) {
String currentValue = redisTemplate.opsForValue().get(lockKey); String currentValue = stringRedisTemplate.opsForValue().get(lockKey);
if (lockValue.equals(currentValue)) { if (lockValue.equals(currentValue)) {
redisTemplate.delete(lockKey); stringRedisTemplate.delete(lockKey);
} }
} }
} }