feat():缓存各个模块对象

dev.operation
86191 2024-10-02 10:33:14 +08:00
parent 476d6ae0b7
commit 370a91773e
13 changed files with 271 additions and 2 deletions

View File

@ -8,6 +8,9 @@ package com.muyu.cache;/**
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import static cn.hutool.core.lang.ansi.AnsiEncoder.encode; import static cn.hutool.core.lang.ansi.AnsiEncoder.encode;
/** /**

View File

@ -1,5 +1,7 @@
package com.muyu.cache; package com.muyu.cache;
import java.util.List;
/** /**
* @author yuping * @author yuping
* @package com.muyu.cache * @package com.muyu.cache

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.CarType;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 16:31:44
*/
@Component
public class CarTypeCacheService extends CacheAbsBasic<String, CarType> {
/**
* key
* @return
*/
@Override
public String keyPre() {
return "carType:";
}
/**
* key
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -0,0 +1,33 @@
package com.muyu.cache;
import com.muyu.common.domain.DataType;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 10:57:24
*/
@Component
public class DataTypeCacheService extends CacheAbsBasic<String, DataType> {
/**
* key
* @return
*/
@Override
public String keyPre() {
return "DataType";
}
/**
*
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -3,6 +3,8 @@ package com.muyu.cache;
import com.muyu.common.domain.database.ElectronicFence; import com.muyu.common.domain.database.ElectronicFence;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* @Author YuPing * @Author YuPing
* @Description * @Description

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.MessageTemplate;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 11:01:13
*/
@Component
public class MessageTemplateCacheService extends CacheAbsBasic<String, MessageTemplate>{
/**
* key
* @return
*/
@Override
public String keyPre() {
return "message_template";
}
/**
*
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.MessageTemplateType;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 11:04:43
*/
@Component
public class MessageTemplateTypeCacheService extends CacheAbsBasic<String, MessageTemplateType>{
/**
* key
* @return
*/
@Override
public String keyPre() {
return "messageTemplateType";
}
/**
*
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.SysCar;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 16:35:14
*/
@Component
public class SysCarCacheService extends CacheAbsBasic<String, SysCar>{
/**
* key
* @return
*/
@Override
public String keyPre() {
return "car:";
}
/**
*
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.Template;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 18:21:46
*/
@Component
public class TemplateCacheService extends CacheAbsBasic<String, Template>{
/**
* key
* @return
*/
@Override
public String keyPre() {
return "template";
}
/**
*
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.WarnRule;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 16:37:09
*/
@Component
public class WarnRuleCacheService extends CacheAbsBasic<String, WarnRule>{
/**
* key
* @return
*/
@Override
public String keyPre() {
return "warnRule";
}
/**
*
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -0,0 +1,32 @@
package com.muyu.cache;
import com.muyu.common.domain.WarnStrategy;
import org.springframework.stereotype.Component;
/**
* @Author YuPing
* @Description
* @Version 1.0
* @Data 2024-09-30 16:38:35
*/
@Component
public class WarnStrategyCacheService extends CacheAbsBasic<String, WarnStrategy> {
/**
* key
* @return
*/
@Override
public String keyPre() {
return "warnStrategy";
}
/**
* key
* @param key key
* @return
*/
@Override
public String decode(String key) {
return key.replace(keyPre(), "");
}
}

View File

@ -2,6 +2,7 @@ package com.muyu.server.mapper;
import com.muyu.common.domain.Enterprise; import com.muyu.common.domain.Enterprise;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -26,5 +27,5 @@ public interface EnterpriseDao {
//删除企业信息 //删除企业信息
public int deleteByIds(Integer[] ids); public int deleteByIds(@Param("ids") Integer[] ids);
} }

View File

@ -16,6 +16,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -53,9 +54,12 @@ public class ElectronicFenceServiceImpl extends ServiceImpl<ElectronicFenceMappe
List<ElectronicFence> list = this.list(queryWrapper); List<ElectronicFence> list = this.list(queryWrapper);
list.forEach(electronicFence -> { list.forEach(electronicFence -> {
electronicFenceCacheService.put(electronicFence.getId().toString(),electronicFence); electronicFenceCacheService.put(electronicFence.getId().toString(), electronicFence);
}); });
ElectronicFence electronicFence = electronicFenceCacheService.get("electronicFence");
log.info("electronicFenceCacheService.get(electronicFence) = {}",electronicFence);
return list.stream().map(ElectronicFence::bullerResp).toList(); return list.stream().map(ElectronicFence::bullerResp).toList();
} }