6666
This commit is contained in:
parent
9f861bf6ec
commit
348c08c495
@ -0,0 +1,124 @@
|
||||
package net.lab1024.sa.admin.extend.fangxinqian;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.common.common.exception.BusinessException;
|
||||
import net.lab1024.sa.common.module.support.redis.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class Base {
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Value("${fxq.client-id}")
|
||||
private static String clientId;
|
||||
|
||||
@Value("${fxq.client-secret}")
|
||||
private static String clientSecret;
|
||||
|
||||
@Value("${fxq.client-url}")
|
||||
private static String clientUrl;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 发送 POST JSON 请求
|
||||
* @param url 请求地址
|
||||
* @param jsonData JSON 字符串
|
||||
* @param headers 请求头
|
||||
* @return 响应字符串
|
||||
*/
|
||||
public String postJson(String url, String jsonData, Map<String, String> headers) {
|
||||
// 获取token
|
||||
String tokenKey = "fangxinqian:" + clientId;
|
||||
String token = redisService.get(tokenKey);
|
||||
if (token == null) {
|
||||
token = getAccessToken();
|
||||
}
|
||||
|
||||
// 刷新token
|
||||
HttpRequest request = HttpRequest.post(url)
|
||||
.body(jsonData)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", "Bearer " + token);
|
||||
|
||||
if (headers != null) {
|
||||
headers.forEach(request::header);
|
||||
}
|
||||
|
||||
try (HttpResponse response = request.execute()) {
|
||||
JSONObject json = JSONUtil.parseObj(response.body());
|
||||
|
||||
log.info("获取app数据返回:{}",json);
|
||||
|
||||
int code = json.getInt("code", -1);
|
||||
if (code == 10000) {
|
||||
return response.body();
|
||||
} else if (code == 10005) {
|
||||
// token 失效,重新获取
|
||||
getAccessToken();
|
||||
|
||||
return postJson(url,jsonData,headers);
|
||||
}else{
|
||||
throw new BusinessException(json.getStr("message", "操作失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAccessToken(){
|
||||
String url = String.format("%s?grant_type=client_credentials&client_id=%s&client_secret=%s",
|
||||
"https://saasapi.fangxinqian.cn/oauth/token", clientId, clientSecret);
|
||||
|
||||
HttpRequest request = HttpRequest.post(url);
|
||||
|
||||
try (HttpResponse response = request.execute()) {
|
||||
if (response.getStatus() != 200) {
|
||||
throw new BusinessException("操作失败");
|
||||
}
|
||||
|
||||
JSONObject json = JSONUtil.parseObj(response.body());
|
||||
|
||||
log.info("获取app数据返回:{}",json);
|
||||
|
||||
String accessToken = json.getStr("access_token");
|
||||
if (accessToken == null || accessToken.isEmpty()) {
|
||||
throw new BusinessException("操作失败");
|
||||
}
|
||||
|
||||
Integer expiresIn = json.getInt("expires_in");
|
||||
if (expiresIn == null || expiresIn <= 0) {
|
||||
throw new BusinessException("操作失败");
|
||||
}
|
||||
|
||||
String tokenKey = "fangxinqian:" + clientId;
|
||||
redisService.set(tokenKey,accessToken,(expiresIn - 120));
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
public class R
|
||||
{
|
||||
/** 接口调用状态。200:正常;其它值:调用出错 */
|
||||
private int code;
|
||||
|
||||
/** 结果说明。如果接口调用出错,那么返回错误描述。成功则返回 ok */
|
||||
private String msg;
|
||||
|
||||
/** 接口是否调用成功 */
|
||||
private boolean success;
|
||||
|
||||
/** 错误信息或提示信息 */
|
||||
private String message;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package net.lab1024.sa.admin.extend.fangxinqian;
|
||||
|
||||
/**
|
||||
* 企业账号
|
||||
*/
|
||||
public class Company {
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package net.lab1024.sa.admin.extend.fangxinqian;
|
||||
|
||||
/**
|
||||
* 个人账号
|
||||
*/
|
||||
public class Personal {
|
||||
}
|
||||
@ -229,8 +229,7 @@ public class ExpertController {
|
||||
// 获取白名单用户-姓名、医院名称
|
||||
ExpertWhiteEntity expertWhiteEntity = expertWhiteEntityService.getExpertWhiteEntityByNameAndHospitalName(name,hospital_name);
|
||||
if (expertWhiteEntity == null) {
|
||||
responseDTO.setMsg("暂无登录权限");
|
||||
return responseDTO;
|
||||
return ResponseDTO.error(NO_AUTH);
|
||||
}
|
||||
|
||||
ExpertEntity expert = new ExpertEntity();
|
||||
@ -472,8 +471,7 @@ public class ExpertController {
|
||||
// 获取白名单用户-姓名、医院名称
|
||||
ExpertWhiteEntity expertWhiteEntity = expertWhiteEntityService.getExpertWhiteEntityByNameAndHospitalName(name,hospital_name);
|
||||
if (expertWhiteEntity == null) {
|
||||
responseDTO.setMsg("暂无登录权限");
|
||||
return responseDTO;
|
||||
return ResponseDTO.error(NO_AUTH);
|
||||
}
|
||||
|
||||
ExpertEntity expert = new ExpertEntity();
|
||||
|
||||
@ -9,7 +9,6 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class DpmsAddForm {
|
||||
|
||||
@ApiModelProperty(value = "治疗时间", required = true)
|
||||
@NotNull(message = "治疗时间 不能为空")
|
||||
private LocalDateTime treatTime;
|
||||
|
||||
@ -12,6 +12,13 @@ server:
|
||||
spring:
|
||||
profiles:
|
||||
active: '@profiles.active@'
|
||||
data:
|
||||
redis:
|
||||
host: '139.155.127.177'
|
||||
port: 30002
|
||||
password: gdxz2022&dj.
|
||||
database: 11
|
||||
timeout: 3000
|
||||
|
||||
# 项目配置
|
||||
project:
|
||||
@ -40,4 +47,9 @@ igandan:
|
||||
token: XUUHml5iQ9mlFsa8QqOwyBrLI2nGGGxJ
|
||||
platform: case
|
||||
doc:
|
||||
host: https://dev-doc.igandan.com/app/
|
||||
host: https://dev-doc.igandan.com/app/
|
||||
|
||||
fxq:
|
||||
client-id: Md7w4eaZih
|
||||
client-secret: 97acf8ebb09641cbb90accf06e74ccf5
|
||||
client-url: https://saasapi.fangxinqian.cn/openapi/v2/
|
||||
@ -260,7 +260,6 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,9 @@ public enum UserErrorCode implements ErrorCode {
|
||||
NO_PERMISSION_EDIT(30010, "该状态不允许修改"),
|
||||
NO_MODIFY(30011, "该账号无需补充资料"),
|
||||
PROJECT_CLOSE(30012, "本年度人工肝病例登记项目已结束,谢谢您的关注!"),
|
||||
ExpertBankVerifyFail(30013, "银行卡认证失败");
|
||||
ExpertBankVerifyFail(30013, "银行卡认证失败"),
|
||||
|
||||
NO_AUTH(30014, "对不起,您暂无权限访问该项目~");
|
||||
|
||||
private final int code;
|
||||
|
||||
|
||||
@ -1,222 +1,223 @@
|
||||
//package net.lab1024.sa.common.module.support.redis;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import net.lab1024.sa.common.common.domain.SystemEnvironment;
|
||||
//import net.lab1024.sa.common.common.enumeration.SystemEnvironmentEnum;
|
||||
//import net.lab1024.sa.common.common.util.SmartStringUtil;
|
||||
//import net.lab1024.sa.common.constant.RedisKeyConst;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.*;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.util.CollectionUtils;
|
||||
//
|
||||
//import java.time.LocalDate;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.time.LocalTime;
|
||||
//import java.time.temporal.ChronoUnit;
|
||||
//import java.util.Collection;
|
||||
//import java.util.List;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
///**
|
||||
// * redis 一顿操作
|
||||
// *
|
||||
// * @Author 1024创新实验室: 罗伊
|
||||
// * @Date 2020/8/25 21:57
|
||||
// * @Wechat zhuoda1024
|
||||
// * @Email lab1024@163.com
|
||||
// * @Copyright 1024创新实验室 ( https://1024lab.net )
|
||||
// */
|
||||
////@Component
|
||||
//public class RedisService {
|
||||
//
|
||||
// private static final Logger log = org.slf4j.LoggerFactory.getLogger(RedisService.class);
|
||||
//
|
||||
// @Autowired
|
||||
// private StringRedisTemplate stringRedisTemplate;
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisTemplate<String, Object> redisTemplate;
|
||||
//
|
||||
// @Autowired
|
||||
// private ValueOperations<String, String> redisValueOperations;
|
||||
//
|
||||
// @Autowired
|
||||
// private HashOperations<String, String, Object> redisHashOperations;
|
||||
//
|
||||
// @Autowired
|
||||
// private ListOperations<String, Object> redisListOperations;
|
||||
//
|
||||
// @Autowired
|
||||
// private SetOperations<String, Object> redisSetOperations;
|
||||
//
|
||||
// @Autowired
|
||||
// private SystemEnvironment systemEnvironment;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 生成redis key
|
||||
// * @param prefix
|
||||
// * @param key
|
||||
// * @return
|
||||
// */
|
||||
// public String generateRedisKey(String prefix, String key) {
|
||||
// SystemEnvironmentEnum currentEnvironment = systemEnvironment.getCurrentEnvironment();
|
||||
// return systemEnvironment.getProjectName() + RedisKeyConst.SEPARATOR + currentEnvironment.getValue() + RedisKeyConst.SEPARATOR + prefix + key;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * redis key 解析成真实的内容
|
||||
// * @param redisKey
|
||||
// * @return
|
||||
// */
|
||||
// public static String redisKeyParse(String redisKey) {
|
||||
// if(SmartStringUtil.isBlank(redisKey)){
|
||||
// return "";
|
||||
// }
|
||||
// int index = redisKey.lastIndexOf(RedisKeyConst.SEPARATOR);
|
||||
// if(index < 1){
|
||||
// return redisKey;
|
||||
// }
|
||||
// return redisKey.substring(index);
|
||||
// }
|
||||
//
|
||||
// public boolean getLock(String key, long expire) {
|
||||
// return redisValueOperations.setIfAbsent(key, String.valueOf(System.currentTimeMillis()), expire, TimeUnit.MILLISECONDS);
|
||||
// }
|
||||
//
|
||||
// public void unLock(String key) {
|
||||
// redisValueOperations.getOperations().delete(key);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 指定缓存失效时间
|
||||
// *
|
||||
// * @param key 键
|
||||
// * @param time 时间(秒)
|
||||
// * @return
|
||||
// */
|
||||
// public boolean expire(String key, long time) {
|
||||
// return redisTemplate.expire(key, time, TimeUnit.SECONDS);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取当天剩余的秒数
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public static long currentDaySecond() {
|
||||
// return ChronoUnit.SECONDS.between(LocalDateTime.now(), LocalDateTime.of(LocalDate.now(), LocalTime.MAX));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据key 获取过期时间
|
||||
// *
|
||||
// * @param key 键 不能为null
|
||||
// * @return 时间(秒) 返回0代表为永久有效
|
||||
// */
|
||||
// public long getExpire(String key) {
|
||||
// return redisTemplate.getExpire(key, TimeUnit.SECONDS);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 判断key是否存在
|
||||
// *
|
||||
// * @param key 键
|
||||
// * @return true 存在 false不存在
|
||||
// */
|
||||
// public boolean hasKey(String key) {
|
||||
// return redisTemplate.hasKey(key);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除缓存
|
||||
// *
|
||||
// * @param key 可以传一个值 或多个
|
||||
// */
|
||||
// @SuppressWarnings("unchecked")
|
||||
// public void delete(String... key) {
|
||||
// if (key != null && key.length > 0) {
|
||||
// if (key.length == 1) {
|
||||
// redisTemplate.delete(key[0]);
|
||||
// } else {
|
||||
// redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除缓存
|
||||
// *
|
||||
// * @param keyList
|
||||
// */
|
||||
// public void delete(List<String> keyList) {
|
||||
// if (CollectionUtils.isEmpty(keyList)) {
|
||||
// return;
|
||||
// }
|
||||
// redisTemplate.delete(keyList);
|
||||
// }
|
||||
//
|
||||
// //============================String=============================
|
||||
//
|
||||
// /**
|
||||
// * 普通缓存获取
|
||||
// *
|
||||
// * @param key 键
|
||||
// * @return 值
|
||||
// */
|
||||
// public String get(String key) {
|
||||
// return key == null ? null : redisValueOperations.get(key);
|
||||
// }
|
||||
//
|
||||
// public <T> T getObject(String key, Class<T> clazz) {
|
||||
// Object json = this.get(key);
|
||||
// if (json == null) {
|
||||
// return null;
|
||||
// }
|
||||
// T obj = JSON.parseObject(json.toString(), clazz);
|
||||
// return obj;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 普通缓存放入
|
||||
// */
|
||||
// public void set(String key, String value) {
|
||||
// redisValueOperations.set(key, value);
|
||||
// }
|
||||
// public void set(Object key, Object value) {
|
||||
// String jsonString = JSON.toJSONString(value);
|
||||
// redisValueOperations.set(key.toString(), jsonString);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 普通缓存放入
|
||||
// */
|
||||
// public void set(String key, String value, long second) {
|
||||
// redisValueOperations.set(key, value, second, TimeUnit.SECONDS);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 普通缓存放入并设置时间
|
||||
// */
|
||||
// public void set(Object key, Object value, long time) {
|
||||
// String jsonString = JSON.toJSONString(value);
|
||||
// if (time > 0) {
|
||||
// redisValueOperations.set(key.toString(), jsonString, time, TimeUnit.SECONDS);
|
||||
// } else {
|
||||
// set(key.toString(), jsonString);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //============================ map =============================
|
||||
// public void mset(String key, String hashKey, Object value) {
|
||||
// redisHashOperations.put(key, hashKey, value);
|
||||
// }
|
||||
//
|
||||
// public Object mget(String key, String hashKey) {
|
||||
// return redisHashOperations.get(key, hashKey);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package net.lab1024.sa.common.module.support.redis;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import net.lab1024.sa.common.common.domain.SystemEnvironment;
|
||||
import net.lab1024.sa.common.common.enumeration.SystemEnvironmentEnum;
|
||||
import net.lab1024.sa.common.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.common.constant.RedisKeyConst;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* redis 一顿操作
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2020/8/25 21:57
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net )
|
||||
*/
|
||||
//@Component
|
||||
public class RedisService {
|
||||
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(RedisService.class);
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Resource
|
||||
private ValueOperations<String, String> redisValueOperations;
|
||||
|
||||
@Resource
|
||||
private HashOperations<String, String, Object> redisHashOperations;
|
||||
|
||||
@Resource
|
||||
private ListOperations<String, Object> redisListOperations;
|
||||
|
||||
@Resource
|
||||
private SetOperations<String, Object> redisSetOperations;
|
||||
|
||||
@Resource
|
||||
private SystemEnvironment systemEnvironment;
|
||||
|
||||
|
||||
/**
|
||||
* 生成redis key
|
||||
* @param prefix
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public String generateRedisKey(String prefix, String key) {
|
||||
SystemEnvironmentEnum currentEnvironment = systemEnvironment.getCurrentEnvironment();
|
||||
return systemEnvironment.getProjectName() + RedisKeyConst.SEPARATOR + currentEnvironment.getValue() + RedisKeyConst.SEPARATOR + prefix + key;
|
||||
}
|
||||
|
||||
/**
|
||||
* redis key 解析成真实的内容
|
||||
* @param redisKey
|
||||
* @return
|
||||
*/
|
||||
public static String redisKeyParse(String redisKey) {
|
||||
if(SmartStringUtil.isBlank(redisKey)){
|
||||
return "";
|
||||
}
|
||||
int index = redisKey.lastIndexOf(RedisKeyConst.SEPARATOR);
|
||||
if(index < 1){
|
||||
return redisKey;
|
||||
}
|
||||
return redisKey.substring(index);
|
||||
}
|
||||
|
||||
public boolean getLock(String key, long expire) {
|
||||
return redisValueOperations.setIfAbsent(key, String.valueOf(System.currentTimeMillis()), expire, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void unLock(String key) {
|
||||
redisValueOperations.getOperations().delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定缓存失效时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param time 时间(秒)
|
||||
* @return
|
||||
*/
|
||||
public boolean expire(String key, long time) {
|
||||
return redisTemplate.expire(key, time, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当天剩余的秒数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long currentDaySecond() {
|
||||
return ChronoUnit.SECONDS.between(LocalDateTime.now(), LocalDateTime.of(LocalDate.now(), LocalTime.MAX));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 获取过期时间
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @return 时间(秒) 返回0代表为永久有效
|
||||
*/
|
||||
public long getExpire(String key) {
|
||||
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断key是否存在
|
||||
*
|
||||
* @param key 键
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
public boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param key 可以传一个值 或多个
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void delete(String... key) {
|
||||
if (key != null && key.length > 0) {
|
||||
if (key.length == 1) {
|
||||
redisTemplate.delete(key[0]);
|
||||
} else {
|
||||
redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param keyList
|
||||
*/
|
||||
public void delete(List<String> keyList) {
|
||||
if (CollectionUtils.isEmpty(keyList)) {
|
||||
return;
|
||||
}
|
||||
redisTemplate.delete(keyList);
|
||||
}
|
||||
|
||||
//============================String=============================
|
||||
|
||||
/**
|
||||
* 普通缓存获取
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public String get(String key) {
|
||||
return key == null ? null : redisValueOperations.get(key);
|
||||
}
|
||||
|
||||
public <T> T getObject(String key, Class<T> clazz) {
|
||||
Object json = this.get(key);
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
T obj = JSON.parseObject(json.toString(), clazz);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 普通缓存放入
|
||||
*/
|
||||
public void set(String key, String value) {
|
||||
redisValueOperations.set(key, value);
|
||||
}
|
||||
public void set(Object key, Object value) {
|
||||
String jsonString = JSON.toJSONString(value);
|
||||
redisValueOperations.set(key.toString(), jsonString);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通缓存放入
|
||||
*/
|
||||
public void set(String key, String value, long second) {
|
||||
redisValueOperations.set(key, value, second, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通缓存放入并设置时间
|
||||
*/
|
||||
public void set(Object key, Object value, long time) {
|
||||
String jsonString = JSON.toJSONString(value);
|
||||
if (time > 0) {
|
||||
redisValueOperations.set(key.toString(), jsonString, time, TimeUnit.SECONDS);
|
||||
} else {
|
||||
set(key.toString(), jsonString);
|
||||
}
|
||||
}
|
||||
|
||||
//============================ map =============================
|
||||
public void mset(String key, String hashKey, Object value) {
|
||||
redisHashOperations.put(key, hashKey, value);
|
||||
}
|
||||
|
||||
public Object mget(String key, String hashKey) {
|
||||
return redisHashOperations.get(key, hashKey);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user