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

View File

@@ -84,7 +84,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
@Resource
private StringRedisTemplate redisTemplate;
private StringRedisTemplate stringRedisTemplate;
@Override
@@ -148,7 +148,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
boolean acquired = false;
try {
//10s过期
acquired = redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
acquired = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
if (Boolean.TRUE.equals(acquired)) {
SignFranchiseDO signFranchiseDO = request.toSignFranchiseDO();
if (Objects.isNull(request.getId())) {
@@ -174,9 +174,9 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
}finally {
if (Boolean.TRUE.equals(acquired)) {
String currentValue = redisTemplate.opsForValue().get(lockKey);
String currentValue = stringRedisTemplate.opsForValue().get(lockKey);
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.constant.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -87,7 +88,7 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
PointDetailInfoMapper pointDetailInfoMapper;
@Resource
private StringRedisTemplate redisTemplate;
private StringRedisTemplate stringRedisTemplate;
@Resource
RedisUtilPool redisUtilPool;
@@ -103,7 +104,7 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
String lockValue = UUID.randomUUID().toString();
boolean acquired = false;
try {
acquired = redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
acquired = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
if (Boolean.TRUE.equals(acquired)) {
//1.操作数据库
SystemBuildingShopDO systemBuildingShopDO = SystemBuildingShopDO.convertToSystemBuildingShopDO(request);
@@ -125,9 +126,9 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
}
}finally {
if (Boolean.TRUE.equals(acquired)) {
String currentValue = redisTemplate.opsForValue().get(lockKey);
String currentValue = stringRedisTemplate.opsForValue().get(lockKey);
if (lockValue.equals(currentValue)) {
redisTemplate.delete(lockKey);
stringRedisTemplate.delete(lockKey);
}
}
}