parent
4db991dfb8
commit
d1067d93dd
@ -1,18 +1,56 @@
|
|||||||
package org.opsli.common.base.entity;
|
package org.opsli.common.base.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @BelongsProject: opsli-boot
|
*
|
||||||
* @BelongsPackage: org.opsli.common.base.entity
|
* Entity 基础类
|
||||||
* @Author: Parker
|
*
|
||||||
* @CreateTime: 2020-09-14 17:29
|
* @author Parker
|
||||||
* @Description: Entity 基类
|
* @date 2019-05-11
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class BaseEntity {
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public abstract class BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** ID */
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/** 创建人 */
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/** 更新人 */
|
||||||
|
@ApiModelProperty(value = "修改人")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/** 更新时间 */
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
/** 乐观锁 */
|
/** 乐观锁 版本 */
|
||||||
@Version
|
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.opsli.common.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.common.constants
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-16 17:42
|
||||||
|
* @Description: 缓存 常量
|
||||||
|
*/
|
||||||
|
public interface CacheConstants {
|
||||||
|
|
||||||
|
/** 热点数据 */
|
||||||
|
String HOT_DATA = "hotData";
|
||||||
|
|
||||||
|
/** 系统常量 */
|
||||||
|
String SYSTEM_DATA = "systemData";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.opsli.common.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order
|
||||||
|
* @author parker
|
||||||
|
* @date 2020-09-16
|
||||||
|
*/
|
||||||
|
public interface OrderConstants {
|
||||||
|
|
||||||
|
/** 热点数据加载顺序 */
|
||||||
|
int HOT_DATA_ORDER = 180;
|
||||||
|
|
||||||
|
/** Controller异常拦截顺序 */
|
||||||
|
int EXCEPTION_HANDLER_ORDER = 260;
|
||||||
|
|
||||||
|
/** 参数非法验证顺序 */
|
||||||
|
int PARAM_VALIDATE_AOP_SORT = 500;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
package org.opsli.core.aspect;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.opsli.common.annotation.HotDataDel;
|
||||||
|
import org.opsli.common.annotation.HotDataPut;
|
||||||
|
import org.opsli.common.base.entity.BaseEntity;
|
||||||
|
import org.opsli.common.constants.CacheConstants;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.CacheType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||||
|
import org.opsli.core.cache.pushsub.msgs.CacheDataMsgFactory;
|
||||||
|
import org.opsli.plugins.redis.RedisPlugin;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import static org.opsli.common.constants.OrderConstants.HOT_DATA_ORDER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 热点数据 拦截处理
|
||||||
|
*
|
||||||
|
* @author parker
|
||||||
|
* @date 2020-09-16
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Order(HOT_DATA_ORDER)
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class CacheDataAop {
|
||||||
|
|
||||||
|
/** 热点数据前缀 */
|
||||||
|
public static final String PREFIX_NAME = "opsli:";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisPlugin redisPlugin;
|
||||||
|
|
||||||
|
@Pointcut("@annotation(org.opsli.common.annotation.HotDataPut)")
|
||||||
|
public void hotDataPut() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Pointcut("@annotation(org.opsli.common.annotation.HotDataDel)")
|
||||||
|
public void hotDataDel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Around("hotDataPut()")
|
||||||
|
public Object hotDataPutProcess(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
Object[] args= point.getArgs();
|
||||||
|
Object returnValue = point.proceed(args);
|
||||||
|
// 将
|
||||||
|
if(returnValue != null){
|
||||||
|
String methodName= point.getSignature().getName();
|
||||||
|
Class<?> classTarget= point.getTarget().getClass();
|
||||||
|
Class<?>[] par=((MethodSignature) point.getSignature()).getParameterTypes();
|
||||||
|
Method objMethod = classTarget.getMethod(methodName, par);
|
||||||
|
// 获取注解参数
|
||||||
|
HotDataPut aCache= objMethod.getAnnotation(HotDataPut.class);
|
||||||
|
if(aCache != null){
|
||||||
|
// 类型
|
||||||
|
PushSubType type;
|
||||||
|
// key 前缀
|
||||||
|
StringBuilder keyBuf = new StringBuilder(PREFIX_NAME);
|
||||||
|
// 热点数据
|
||||||
|
if(CacheConstants.HOT_DATA.equals(aCache.name())){
|
||||||
|
keyBuf.append(CacheConstants.HOT_DATA).append(":");
|
||||||
|
type = PushSubType.HOT_DATA;
|
||||||
|
}
|
||||||
|
// 系统数据
|
||||||
|
else if(CacheConstants.SYSTEM_DATA.equals(aCache.name())){
|
||||||
|
keyBuf.append(CacheConstants.SYSTEM_DATA).append(":");
|
||||||
|
type = PushSubType.SYSTEM_DATA;
|
||||||
|
} else {
|
||||||
|
// 如果都不是 则直接退出 不走缓存
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 这里 只对 继承了 BaseEntity 的类做处理
|
||||||
|
BaseEntity baseEntity = (BaseEntity) returnValue;
|
||||||
|
|
||||||
|
// key 存储ID
|
||||||
|
String key = keyBuf.append(baseEntity.getId()).toString();
|
||||||
|
|
||||||
|
// 广播数据
|
||||||
|
redisPlugin.sendMessage(
|
||||||
|
CacheDataMsgFactory.createMsg(type, key, returnValue, CacheType.UPDATE)
|
||||||
|
);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Around("hotDataDel()")
|
||||||
|
public Object hotDataDelProcess(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
Object[] args= point.getArgs();
|
||||||
|
Object returnValue = point.proceed(args);
|
||||||
|
// 将
|
||||||
|
if(returnValue != null){
|
||||||
|
String methodName= point.getSignature().getName();
|
||||||
|
Class<?> classTarget= point.getTarget().getClass();
|
||||||
|
Class<?>[] par=((MethodSignature) point.getSignature()).getParameterTypes();
|
||||||
|
Method objMethod = classTarget.getMethod(methodName, par);
|
||||||
|
// 获取注解参数
|
||||||
|
HotDataDel aCache= objMethod.getAnnotation(HotDataDel.class);
|
||||||
|
if(aCache != null){
|
||||||
|
// 类型
|
||||||
|
PushSubType type;
|
||||||
|
// key 前缀
|
||||||
|
StringBuilder keyBuf = new StringBuilder(PREFIX_NAME);
|
||||||
|
// 热点数据
|
||||||
|
if(CacheConstants.HOT_DATA.equals(aCache.name())){
|
||||||
|
keyBuf.append(CacheConstants.HOT_DATA).append(":");
|
||||||
|
type = PushSubType.HOT_DATA;
|
||||||
|
}
|
||||||
|
// 系统数据
|
||||||
|
else if(CacheConstants.SYSTEM_DATA.equals(aCache.name())){
|
||||||
|
keyBuf.append(CacheConstants.SYSTEM_DATA).append(":");
|
||||||
|
type = PushSubType.SYSTEM_DATA;
|
||||||
|
} else {
|
||||||
|
// 如果都不是 则直接退出 不走缓存
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 这里 只对 继承了 BaseEntity 的类做处理
|
||||||
|
BaseEntity baseEntity = (BaseEntity) returnValue;
|
||||||
|
|
||||||
|
// key 存储ID
|
||||||
|
String key = keyBuf.append(baseEntity.getId()).toString();
|
||||||
|
|
||||||
|
// 广播数据
|
||||||
|
redisPlugin.sendMessage(
|
||||||
|
CacheDataMsgFactory.createMsg(type, key, returnValue, CacheType.DELETE)
|
||||||
|
);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package org.opsli.core.cache.local;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.opsli.common.constants.CacheConstants;
|
||||||
|
import org.opsli.core.aspect.CacheDataAop;
|
||||||
|
import org.opsli.plugins.cache.EhCachePlugin;
|
||||||
|
import org.opsli.plugins.redis.RedisPlugin;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.core.cache.local
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-16 16:20
|
||||||
|
* @Description: 本地 缓存接口
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CacheUtil {
|
||||||
|
|
||||||
|
/** Redis插件 */
|
||||||
|
private static RedisPlugin redisPlugin;
|
||||||
|
/** EhCache插件 */
|
||||||
|
private static EhCachePlugin ehCachePlugin;
|
||||||
|
|
||||||
|
public static <V> V get(String key, Class<V> vClass){
|
||||||
|
return CacheUtil.get(CacheConstants.HOT_DATA,key,vClass,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <V> V getByKeyOriginal(String key, Class<V> vClass){
|
||||||
|
return CacheUtil.get(CacheConstants.HOT_DATA,key,vClass,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static <V> V get(String cacheName, String key, Class<V> vClass,boolean keyFlag){
|
||||||
|
// 自动处理 key
|
||||||
|
if(keyFlag){
|
||||||
|
StringBuilder keyBuf = new StringBuilder(CacheDataAop.PREFIX_NAME);
|
||||||
|
keyBuf.append(cacheName).append(":");
|
||||||
|
keyBuf.append(key);
|
||||||
|
key = keyBuf.toString();
|
||||||
|
}
|
||||||
|
V v = null;
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject;
|
||||||
|
jsonObject = ehCachePlugin.get(cacheName, key, JSONObject.class);
|
||||||
|
// 如果本地缓存为空 则去Redis中 再去取一次
|
||||||
|
if(jsonObject != null){
|
||||||
|
v = jsonObject.toJavaObject(vClass);
|
||||||
|
}else{
|
||||||
|
jsonObject = (JSONObject) redisPlugin.get(key);
|
||||||
|
if(jsonObject != null){
|
||||||
|
v = jsonObject.toJavaObject(vClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ================================
|
||||||
|
@Autowired
|
||||||
|
public void setRedisPlugin(RedisPlugin redisPlugin) {
|
||||||
|
CacheUtil.redisPlugin = redisPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setEhCachePlugin(EhCachePlugin ehCachePlugin) {
|
||||||
|
CacheUtil.ehCachePlugin = ehCachePlugin;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package org.opsli.core.cache.pushsub.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.core.cache.pushsub.enums
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-16 22:28
|
||||||
|
* @Description: 缓存操作类型
|
||||||
|
*/
|
||||||
|
public enum CacheType {
|
||||||
|
|
||||||
|
/** 更新 */
|
||||||
|
UPDATE,
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
DELETE,
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.opsli.core.cache.pushsub.handler;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.opsli.common.constants.CacheConstants;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.CacheType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||||
|
import org.opsli.plugins.cache.EhCachePlugin;
|
||||||
|
import org.opsli.plugins.redis.RedisPlugin;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.core.cache.pushsub.handler
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-15 16:24
|
||||||
|
* @Description: 字典消息处理
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class HotDataHandler implements RedisPushSubHandler{
|
||||||
|
|
||||||
|
/** 热点数据缓存时间 */
|
||||||
|
@Value("${cache.ttl-hot-data}")
|
||||||
|
private int ttlHotData;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisPlugin redisPlugin;
|
||||||
|
@Autowired
|
||||||
|
private EhCachePlugin cachePlugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PushSubType getType() {
|
||||||
|
return PushSubType.HOT_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handler(JSONObject msgJson) {
|
||||||
|
String key = (String) msgJson.get(MsgArgsType.CACHE_DATA_KEY.toString());
|
||||||
|
Object value = msgJson.get(MsgArgsType.CACHE_DATA_VALUE.toString());
|
||||||
|
CacheType type = CacheType.valueOf((String )msgJson.get(MsgArgsType.CACHE_DATA_TYPE.toString()));
|
||||||
|
|
||||||
|
// 缓存更新
|
||||||
|
if(CacheType.UPDATE == type){
|
||||||
|
// 存入EhCache
|
||||||
|
cachePlugin.put(CacheConstants.HOT_DATA,key, value);
|
||||||
|
// 存入Redis
|
||||||
|
redisPlugin.put(key, value, ttlHotData);
|
||||||
|
}
|
||||||
|
// 缓存删除
|
||||||
|
else if(CacheType.DELETE == type){
|
||||||
|
// 存入EhCache
|
||||||
|
cachePlugin.delete(CacheConstants.HOT_DATA,key);
|
||||||
|
// 存入Redis
|
||||||
|
redisPlugin.del(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.opsli.core.cache.pushsub.handler;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.opsli.common.constants.CacheConstants;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.CacheType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||||
|
import org.opsli.plugins.cache.EhCachePlugin;
|
||||||
|
import org.opsli.plugins.redis.RedisPlugin;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.core.cache.pushsub.handler
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-15 16:24
|
||||||
|
* @Description: 字典消息处理
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SystemDataHandler implements RedisPushSubHandler{
|
||||||
|
|
||||||
|
/** 热点数据缓存时间 */
|
||||||
|
@Value("${cache.ttl-system-data}")
|
||||||
|
private int ttlSystemData;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisPlugin redisPlugin;
|
||||||
|
@Autowired
|
||||||
|
private EhCachePlugin cachePlugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PushSubType getType() {
|
||||||
|
return PushSubType.SYSTEM_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handler(JSONObject msgJson) {
|
||||||
|
String key = (String) msgJson.get(MsgArgsType.CACHE_DATA_KEY.toString());
|
||||||
|
Object value = msgJson.get(MsgArgsType.CACHE_DATA_VALUE.toString());
|
||||||
|
CacheType type = CacheType.valueOf((String )msgJson.get(MsgArgsType.CACHE_DATA_TYPE.toString()));
|
||||||
|
|
||||||
|
// 缓存更新
|
||||||
|
if(CacheType.UPDATE == type){
|
||||||
|
// 存入EhCache
|
||||||
|
cachePlugin.put(CacheConstants.SYSTEM_DATA,key, value);
|
||||||
|
// 存入Redis
|
||||||
|
redisPlugin.put(key, value, ttlSystemData);
|
||||||
|
}
|
||||||
|
// 缓存删除
|
||||||
|
else if(CacheType.DELETE == type){
|
||||||
|
// 存入EhCache
|
||||||
|
cachePlugin.delete(CacheConstants.SYSTEM_DATA,key);
|
||||||
|
// 存入Redis
|
||||||
|
redisPlugin.del(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package org.opsli.core.cache.pushsub.msgs;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.CacheType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.MsgArgsType;
|
||||||
|
import org.opsli.core.cache.pushsub.enums.PushSubType;
|
||||||
|
import org.opsli.core.cache.pushsub.receiver.RedisPushSubReceiver;
|
||||||
|
import org.opsli.plugins.redis.pushsub.entity.BaseSubMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.core.cache.pushsub.msgs
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-15 16:50
|
||||||
|
* @Description: 字典消息
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public final class CacheDataMsgFactory extends BaseSubMessage{
|
||||||
|
|
||||||
|
/** 通道 */
|
||||||
|
private static final String CHANNEL = RedisPushSubReceiver.BASE_CHANNEL+RedisPushSubReceiver.CHANNEL;
|
||||||
|
|
||||||
|
private CacheDataMsgFactory(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建消息
|
||||||
|
*/
|
||||||
|
public static BaseSubMessage createMsg(PushSubType py,String key, Object value, CacheType cacheType){
|
||||||
|
BaseSubMessage baseSubMessage = new BaseSubMessage();
|
||||||
|
// 数据
|
||||||
|
JSONObject jsonObj = new JSONObject();
|
||||||
|
jsonObj.put(MsgArgsType.CACHE_DATA_KEY.toString(),key);
|
||||||
|
jsonObj.put(MsgArgsType.CACHE_DATA_VALUE.toString(),value);
|
||||||
|
jsonObj.put(MsgArgsType.CACHE_DATA_TYPE.toString(),cacheType.toString());
|
||||||
|
|
||||||
|
// 热点数据 - 系统数据
|
||||||
|
baseSubMessage.build(CHANNEL,py.toString(),jsonObj);
|
||||||
|
return baseSubMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package org.opsli.modulars.test.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.opsli.common.base.entity.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.modulars.test.entity
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-16 17:33
|
||||||
|
* @Description: 测试类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TestEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package org.opsli.modulars.test.service;
|
||||||
|
|
||||||
|
import org.opsli.common.annotation.HotDataDel;
|
||||||
|
import org.opsli.common.annotation.HotDataPut;
|
||||||
|
import org.opsli.modulars.test.entity.TestEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.modulars.test.service
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-16 17:34
|
||||||
|
* @Description: 测试接口
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TestService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试 存入热点数据
|
||||||
|
* @param testEntity
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@HotDataPut
|
||||||
|
public TestEntity save(TestEntity testEntity){
|
||||||
|
|
||||||
|
|
||||||
|
return testEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试 存入热点数据
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@HotDataDel
|
||||||
|
public TestEntity del(String id){
|
||||||
|
TestEntity t = new TestEntity();
|
||||||
|
t.setId(id);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,2 +0,0 @@
|
|||||||
## 统一异常类
|
|
||||||
02001=请求数据不完整或格式错误!
|
|
Loading…
Reference in new issue