|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.smcic.api.operate.entity.EnrollInfo;
|
|
|
+import com.smcic.api.operate.entity.KeysConst;
|
|
|
import com.smcic.api.operate.entity.VoteInfo;
|
|
|
import com.smcic.api.operate.mapper.VoteInfoMapper;
|
|
|
import com.smcic.api.operate.service.IVoteInfoService;
|
|
@@ -68,13 +69,13 @@ public class VoteInfoServiceImpl extends ServiceImpl<VoteInfoMapper, VoteInfo> i
|
|
|
if(null == one){
|
|
|
throw new APIException(400, "不存在的目标");
|
|
|
}*/
|
|
|
- String one = redisTemplate.opsForValue().get("OPERATE_TARGET_" + operateId + "_" + target);
|
|
|
+ String one = redisTemplate.opsForValue().get(KeysConst.TARGET + operateId + "_" + target);
|
|
|
|
|
|
if (null == one){
|
|
|
throw new APIException(400, "不存在的目标");
|
|
|
}
|
|
|
|
|
|
- String vds = redisTemplate.opsForValue().get("OPERATE_DT_SOURCE_" + operateId + "_"+ dt + "_" + source);
|
|
|
+ String vds = redisTemplate.opsForValue().get(KeysConst.SOURCE + operateId + "_"+ dt + "_" + source);
|
|
|
long vd;
|
|
|
if(TextUtils.isEmpty(vds)){
|
|
|
vd = 0L;
|
|
@@ -94,12 +95,12 @@ public class VoteInfoServiceImpl extends ServiceImpl<VoteInfoMapper, VoteInfo> i
|
|
|
|
|
|
long id = snowflakeGenerator.next();
|
|
|
|
|
|
- String lockKey = "OPERATE_SOURCE_LOCK_" + operateId + "_" + source;
|
|
|
+ String lockKey = KeysConst.VOTE_LOCK + operateId + "_" + source;
|
|
|
while (true){
|
|
|
Boolean success = redisTemplate.opsForValue().setIfAbsent(lockKey, String.valueOf(id), Duration.ofSeconds(3));
|
|
|
|
|
|
if (Boolean.TRUE.equals(success)){
|
|
|
- vds = redisTemplate.opsForValue().get("OPERATE_DT_SOURCE_" + operateId + "_"+ dt + "_" + source);
|
|
|
+ vds = redisTemplate.opsForValue().get(KeysConst.SOURCE + operateId + "_"+ dt + "_" + source);
|
|
|
if(TextUtils.isEmpty(vds)){
|
|
|
vd = 0L;
|
|
|
}else{
|
|
@@ -116,15 +117,15 @@ public class VoteInfoServiceImpl extends ServiceImpl<VoteInfoMapper, VoteInfo> i
|
|
|
|
|
|
|
|
|
try {
|
|
|
- kafkaTemplate.send("operate_vote_queue",
|
|
|
+ kafkaTemplate.send(KeysConst.KAFKA_QUEUE,
|
|
|
objectMapper.writeValueAsString(
|
|
|
new VoteInfo(target, source, client, LocalDateTime.now(), LocalDate.now())
|
|
|
));
|
|
|
} catch (JsonProcessingException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
- redisTemplate.opsForValue().increment("OPERATE_DT_SOURCE_" + operateId + "_"+ dt + "_" + source);
|
|
|
- redisTemplate.expire("OPERATE_DT_SOURCE_" + operateId + "_"+ dt + "_" + source, Duration.ofDays(1));
|
|
|
+ redisTemplate.opsForValue().increment(KeysConst.SOURCE + operateId + "_"+ dt + "_" + source);
|
|
|
+ redisTemplate.expire(KeysConst.SOURCE + operateId + "_"+ dt + "_" + source, Duration.ofDays(1));
|
|
|
redisTemplate.delete(lockKey);
|
|
|
break;
|
|
|
}
|