update 聊天室误删客服bug修改
This commit is contained in:
@@ -7,6 +7,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -117,6 +118,31 @@ public class RedisService {
|
||||
return operation.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有数字类型转换为BigDecimal
|
||||
* @param key 缓存键值
|
||||
* @return 缓存键值对应数据
|
||||
*/
|
||||
public BigDecimal getCacheBigDecimal(final String key) {
|
||||
ValueOperations<String, Object> operation = redisTemplate.opsForValue();
|
||||
Object value = operation.get(key);
|
||||
if (value != null) {
|
||||
if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
} else if (value instanceof String) {
|
||||
try {
|
||||
return new BigDecimal((String) value);
|
||||
} catch (NumberFormatException e) {
|
||||
// 处理字符串无法转换为 BigDecimal 的情况
|
||||
return null;
|
||||
}
|
||||
} else if (value instanceof Number) {
|
||||
return new BigDecimal(value.toString());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user