diff --git a/beacon-api/src/main/java/com/mashibing/api/feignClient/CacheClient.java b/beacon-api/src/main/java/com/mashibing/api/feignclient/CacheClient.java similarity index 68% rename from beacon-api/src/main/java/com/mashibing/api/feignClient/CacheClient.java rename to beacon-api/src/main/java/com/mashibing/api/feignclient/CacheClient.java index 18d43a5..661e19b 100644 --- a/beacon-api/src/main/java/com/mashibing/api/feignClient/CacheClient.java +++ b/beacon-api/src/main/java/com/mashibing/api/feignclient/CacheClient.java @@ -1,4 +1,4 @@ -package com.mashibing.api.feignClient; +package com.mashibing.api.feignclient; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; @@ -14,29 +14,30 @@ import java.util.Set; */ @FeignClient("beacon-cache") -@RequestMapping("cache") +//@RequestMapping("cache") public interface CacheClient { - @GetMapping("get/{key}") + @GetMapping("/cache/get/{key}") String get(@PathVariable String key); - @GetMapping("set/{key}/{value}") + @GetMapping("/cache/set/{key}/{value}") void set(@PathVariable String key, @PathVariable String value); - @GetMapping("hget/{key}") + @GetMapping("/cache/hget/{key}") Map hget(@PathVariable String key); - @GetMapping("/hget/{key}/{field}") + @GetMapping("/cache/hget/{key}/{field}") Object hget(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field); - @GetMapping("/hgetString/{key}/{field}") + // 这是弄成了两个接口先处理了一下是吧。 + @GetMapping("/cache/hget/{key}/{field}") String hgetString(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field); - @PostMapping("hset/{key}") + @PostMapping("/cache/hset/{key}") void hset(@PathVariable String key, @RequestBody Map hash); - @PostMapping("/sadd/{key}") + @PostMapping("/cache/sadd/{key}") void sadd(@PathVariable(value = "key") String key, @RequestBody Map... maps); - @PostMapping("/smember/{key}") + @PostMapping("/cache/smember/{key}") Set smember(@PathVariable(value = "key") String key); } diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java index 7c1ac11..aca96e5 100644 --- a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/ApikeySendCheckServiceImpl.java @@ -2,7 +2,7 @@ package com.mashibing.api.service.sendCheck.impl; import com.alibaba.nacos.common.utils.MapUtils; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mashibing.api.feignClient.CacheClient; +import com.mashibing.api.feignclient.CacheClient; import com.mashibing.api.service.sendCheck.SendCheckService; import com.mashibing.common.constant.CacheConstant; import com.mashibing.common.entity.ClientBusiness; diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java index 0efc5c1..c3e4c59 100644 --- a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/FeeSendCheckServiceImpl.java @@ -1,7 +1,6 @@ package com.mashibing.api.service.sendCheck.impl; -import com.mashibing.api.feignClient.CacheClient; -import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.feignclient.CacheClient; import com.mashibing.api.service.sendCheck.SendCheckService; import com.mashibing.common.constant.CacheConstant; import com.mashibing.common.constant.SMSConstant; diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java index b9d6f32..3a2da1e 100644 --- a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/IpSendCheckServiceImpl.java @@ -1,6 +1,6 @@ package com.mashibing.api.service.sendCheck.impl; -import com.mashibing.api.feignClient.CacheClient; +import com.mashibing.api.feignclient.CacheClient; import com.mashibing.api.service.sendCheck.SendCheckService; import com.mashibing.common.constant.CacheConstant; import com.mashibing.common.enums.ExceptionEnums; diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java index 1812f9f..fe38d59 100644 --- a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/SignSendCheckServiceImpl.java @@ -1,7 +1,6 @@ package com.mashibing.api.service.sendCheck.impl; -import com.mashibing.api.feignClient.CacheClient; -import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.feignclient.CacheClient; import com.mashibing.api.service.sendCheck.SendCheckService; import com.mashibing.common.constant.CacheConstant; import com.mashibing.common.constant.SMSConstant; diff --git a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java index 0084a7b..53628d1 100644 --- a/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java +++ b/beacon-api/src/main/java/com/mashibing/api/service/sendCheck/impl/TemplateSendCheckServiceImpl.java @@ -1,7 +1,6 @@ package com.mashibing.api.service.sendCheck.impl; -import com.mashibing.api.feignClient.CacheClient; -import com.mashibing.api.pojo.SingleSendRequest; +import com.mashibing.api.feignclient.CacheClient; import com.mashibing.api.service.sendCheck.SendCheckService; import com.mashibing.common.constant.CacheConstant; import com.mashibing.common.constant.SMSConstant; diff --git a/beacon-cache/src/main/java/com/mashibing/cache/controller/CacheController.java b/beacon-cache/src/main/java/com/mashibing/cache/controller/CacheController.java index 6e469d9..00ea1e7 100644 --- a/beacon-cache/src/main/java/com/mashibing/cache/controller/CacheController.java +++ b/beacon-cache/src/main/java/com/mashibing/cache/controller/CacheController.java @@ -78,4 +78,22 @@ public class CacheController { return value; } + /** + * 大批量写入String数据 + * + * @param map key是key,value是value + */ + @PostMapping("/pipeline/string") + public void pipelineString(@RequestBody Map map) { + log.info("【缓存模块】pipelineString: 数量 = {},", map.size()); + long start = System.currentTimeMillis(); + redisClient.pipelined(consumer -> { + for (Map.Entry entry : map.entrySet()) { + consumer.opsForValue().set(entry.getKey(), entry.getValue()); + } + }); + long end = System.currentTimeMillis(); + log.info("【缓存模块】pipelineString: 耗时 = {},", end - start); + } + } diff --git a/beacon-strategy/pom.xml b/beacon-strategy/pom.xml index b43ff79..cdbef7e 100644 --- a/beacon-strategy/pom.xml +++ b/beacon-strategy/pom.xml @@ -29,6 +29,10 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config + + org.springframework.cloud + spring-cloud-starter-openfeign + org.springframework.boot diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/feignclient/CacheClient.java b/beacon-strategy/src/main/java/com/mashibing/strategy/feignclient/CacheClient.java new file mode 100644 index 0000000..ad87879 --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/feignclient/CacheClient.java @@ -0,0 +1,44 @@ +package com.mashibing.strategy.feignclient; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.Map; +import java.util.Set; + +/** + * @author heqijun + * @ClassName: BeaconCacheClient + * @Description: 缓存模块openFeignClient接口 + * @date 2025/6/7 20:16 + */ + +@FeignClient("beacon-cache") +public interface CacheClient { + @GetMapping("/cache/get/{key}") + String get(@PathVariable String key); + + @GetMapping("/cache/set/{key}/{value}") + void set(@PathVariable String key, @PathVariable String value); + + @GetMapping("/cache/hget/{key}") + Map hget(@PathVariable String key); + + @GetMapping("/cache/hget/{key}/{field}") + Object hget(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field); + + @GetMapping("/cache/hget/{key}/{field}") + String hgetString(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field); + + @PostMapping("/cache/hset/{key}") + void hset(@PathVariable String key, @RequestBody Map hash); + + @PostMapping("/cache/sadd/{key}") + void sadd(@PathVariable(value = "key") String key, @RequestBody Map... maps); + + @PostMapping("/cache/smember/{key}") + Set smember(@PathVariable(value = "key") String key); +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/mq/PreSendListener.java b/beacon-strategy/src/main/java/com/mashibing/strategy/mq/PreSendListener.java new file mode 100644 index 0000000..85f46d5 --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/mq/PreSendListener.java @@ -0,0 +1,42 @@ +package com.mashibing.strategy.mq; + +import com.mashibing.common.constant.RabbitMQConstant; +import com.mashibing.common.pojo.StandardSubmit; +import com.mashibing.strategy.service.strategyfilter.StrategyFilterContext; +import com.rabbitmq.client.Channel; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * @author heqijun + * @ClassName: PreSendListener + * @Description: TODO(这里用一句话描述这个类的作用) + * @date 2025/6/7 19:36 + */ + +@Slf4j +@Component +public class PreSendListener { + + @Autowired + StrategyFilterContext strategyFilterContext; + + @RabbitListener(queues = {RabbitMQConstant.SMS_PRE_SEND}) + public void listen(StandardSubmit standardSubmit, Message message, Channel channel) throws Exception { + log.info("【策略模块-接收消息】接收到接口模块发送的消息:{}", standardSubmit); + + try { + strategyFilterContext.strategy(standardSubmit); + log.info("【策略模块-接收消息】消息消费完毕,手动ack"); + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } catch (IOException e) { + e.printStackTrace(); + log.info("【策略模块-接收消息】消息消费失败!!!!!!!"); + } + } +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/StrategyFilter.java b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/StrategyFilter.java new file mode 100644 index 0000000..ca3456e --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/StrategyFilter.java @@ -0,0 +1,19 @@ +package com.mashibing.strategy.service.strategyfilter; + +import com.mashibing.common.pojo.StandardSubmit; + +/** + * @author heqijun + * @ClassName: StrategyFilter + * @Description: 策略校验父接口 + * @date 2025/6/7 20:24 + */ + +public interface StrategyFilter { + + /** + * 策略校验 + */ + void strategy(StandardSubmit standardSubmit); + +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/StrategyFilterContext.java b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/StrategyFilterContext.java new file mode 100644 index 0000000..6cb58f8 --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/StrategyFilterContext.java @@ -0,0 +1,47 @@ +package com.mashibing.strategy.service.strategyfilter; + +import com.mashibing.common.constant.CacheConstant; +import com.mashibing.common.pojo.StandardSubmit; +import com.mashibing.strategy.feignclient.CacheClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * @author heqijun + * @ClassName: StrategyFilterContext + * @Description: 策略模块校验链的执行 + * @date 2025/6/7 20:32 + */ + +@Slf4j +@Service +public class StrategyFilterContext { + + @Autowired + private Map strategyFilters; + + @Autowired + CacheClient cacheClient; + + private final String CLIENT_FILTERS = "clientFilters"; + + public void strategy(StandardSubmit standardSubmit) { + String s = cacheClient.hgetString(CacheConstant.CLIENT_BUSINESS + standardSubmit.getApikey(), CLIENT_FILTERS); + if (StringUtils.isBlank(s)) { + log.info("【策略模块-策略为空】没有校验。。。"); + return; + } + String[] strategyFilterArr = s.split(","); + for (String strategyFilter : strategyFilterArr) { + StrategyFilter check = strategyFilters.get(strategyFilter); + if (check != null) { + check.strategy(standardSubmit); + } + } + } + +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/BlackStrategyFilter.java b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/BlackStrategyFilter.java new file mode 100644 index 0000000..5e5098f --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/BlackStrategyFilter.java @@ -0,0 +1,23 @@ +package com.mashibing.strategy.service.strategyfilter.impl; + +import com.mashibing.common.pojo.StandardSubmit; +import com.mashibing.strategy.service.strategyfilter.StrategyFilter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: BlackStrategyFilter + * @Description: 黑名单校验 + * @date 2025/6/7 20:26 + */ + +@Slf4j +@Service(value = "black") +public class BlackStrategyFilter implements StrategyFilter { + + @Override + public void strategy(StandardSubmit standardSubmit) { + log.info("【策略模块-黑名单校验】。。。"); + } +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/DirtyWordStrategyFilter.java b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/DirtyWordStrategyFilter.java new file mode 100644 index 0000000..d6ed21d --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/DirtyWordStrategyFilter.java @@ -0,0 +1,23 @@ +package com.mashibing.strategy.service.strategyfilter.impl; + +import com.mashibing.common.pojo.StandardSubmit; +import com.mashibing.strategy.service.strategyfilter.StrategyFilter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: DirtyWordStrategyFilter + * @Description: 敏感词校验 + * @date 2025/6/7 20:26 + */ + +@Slf4j +@Service(value = "dirtyword") +public class DirtyWordStrategyFilter implements StrategyFilter { + + @Override + public void strategy(StandardSubmit standardSubmit) { + log.info("【策略模块-敏感词校验】。。。"); + } +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/PhaseStrategyFilter.java b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/PhaseStrategyFilter.java new file mode 100644 index 0000000..14512d2 --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/PhaseStrategyFilter.java @@ -0,0 +1,26 @@ +package com.mashibing.strategy.service.strategyfilter.impl; + +import com.mashibing.common.pojo.StandardSubmit; +import com.mashibing.strategy.service.strategyfilter.StrategyFilter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: PhaseStrategyFilter + * @Description: 号段补全 + * @date 2025/6/7 20:26 + */ + +@Slf4j +@Service(value = "phase") +public class PhaseStrategyFilter implements StrategyFilter { + + + + @Override + public void strategy(StandardSubmit standardSubmit) { + log.info("【策略模块-号段补全】。。。"); + + } +} diff --git a/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/RouteStrategyFilter.java b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/RouteStrategyFilter.java new file mode 100644 index 0000000..5181343 --- /dev/null +++ b/beacon-strategy/src/main/java/com/mashibing/strategy/service/strategyfilter/impl/RouteStrategyFilter.java @@ -0,0 +1,23 @@ +package com.mashibing.strategy.service.strategyfilter.impl; + +import com.mashibing.common.pojo.StandardSubmit; +import com.mashibing.strategy.service.strategyfilter.StrategyFilter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author heqijun + * @ClassName: RouteStrategyFilter + * @Description: 路由校验 + * @date 2025/6/7 20:26 + */ + +@Slf4j +@Service(value = "route") +public class RouteStrategyFilter implements StrategyFilter { + + @Override + public void strategy(StandardSubmit standardSubmit) { + log.info("【策略模块-路由校验】。。。"); + } +} diff --git a/beacon-test/src/main/java/com/mashibing/test/entity/MobileArea.java b/beacon-test/src/main/java/com/mashibing/test/entity/MobileArea.java new file mode 100644 index 0000000..e3714f9 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/entity/MobileArea.java @@ -0,0 +1,165 @@ +package com.mashibing.test.entity; + +public class MobileArea { + + private long id; + + private String mobileNumber; + + private String mobileArea; + + private String mobileType; + + private String areaCode; + + private String postCode; + + private String provinceCode; + + private java.sql.Timestamp created; + + private long createId; + + private java.sql.Timestamp updated; + + private long updateId; + + private long isDelete; + + private String extend1; + + private String extend2; + + private String extend3; + + private String extend4; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getMobileNumber() { + return mobileNumber; + } + + public void setMobileNumber(String mobileNumber) { + this.mobileNumber = mobileNumber; + } + + public String getMobileArea() { + return mobileArea; + } + + public void setMobileArea(String mobileArea) { + this.mobileArea = mobileArea; + } + + public String getMobileType() { + return mobileType; + } + + public void setMobileType(String mobileType) { + this.mobileType = mobileType; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getPostCode() { + return postCode; + } + + public void setPostCode(String postCode) { + this.postCode = postCode; + } + + public String getProvinceCode() { + return provinceCode; + } + + public void setProvinceCode(String provinceCode) { + this.provinceCode = provinceCode; + } + + public java.sql.Timestamp getCreated() { + return created; + } + + public void setCreated(java.sql.Timestamp created) { + this.created = created; + } + + public long getCreateId() { + return createId; + } + + public void setCreateId(long createId) { + this.createId = createId; + } + + public java.sql.Timestamp getUpdated() { + return updated; + } + + public void setUpdated(java.sql.Timestamp updated) { + this.updated = updated; + } + + public long getUpdateId() { + return updateId; + } + + public void setUpdateId(long updateId) { + this.updateId = updateId; + } + + public long getIsDelete() { + return isDelete; + } + + public void setIsDelete(long isDelete) { + this.isDelete = isDelete; + } + + public String getExtend1() { + return extend1; + } + + public void setExtend1(String extend1) { + this.extend1 = extend1; + } + + public String getExtend2() { + return extend2; + } + + public void setExtend2(String extend2) { + this.extend2 = extend2; + } + + public String getExtend3() { + return extend3; + } + + public void setExtend3(String extend3) { + this.extend3 = extend3; + } + + public String getExtend4() { + return extend4; + } + + public void setExtend4(String extend4) { + this.extend4 = extend4; + } + +} diff --git a/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java b/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java index 62715bb..8e784c7 100644 --- a/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java +++ b/beacon-test/src/main/java/com/mashibing/test/feignClient/BeaconCacheClient.java @@ -16,19 +16,25 @@ import java.util.Map; @RequestMapping("cache") public interface BeaconCacheClient { @GetMapping("get/{key}") - public String get(@PathVariable String key); + String get(@PathVariable String key); @GetMapping("set/{key}/{value}") - public void set(@PathVariable String key, @PathVariable String value); + void set(@PathVariable String key, @PathVariable String value); @GetMapping("hget/{key}") - public Map hget(@PathVariable String key); + Map hget(@PathVariable String key); @PostMapping("hset/{key}") - public void hset(@PathVariable String key, @RequestBody Map hash); + void hset(@PathVariable String key, @RequestBody Map hash); @PostMapping("/sadd/{key}") - public void sadd(@PathVariable(value = "key") String key, @RequestBody Map... maps); - - + void sadd(@PathVariable(value = "key") String key, @RequestBody Map... maps); + + /** + * 大批量写入String数据 + * + * @param map key是key,value是value + */ + @PostMapping("/pipeline/string") + void pipelineString(@RequestBody Map map); } diff --git a/beacon-test/src/main/java/com/mashibing/test/mapper/MobileAreaMapper.java b/beacon-test/src/main/java/com/mashibing/test/mapper/MobileAreaMapper.java new file mode 100644 index 0000000..bbd88d1 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/mapper/MobileAreaMapper.java @@ -0,0 +1,20 @@ +package com.mashibing.test.mapper; + +import com.mashibing.test.entity.MobileArea; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author heqijun + * @ClassName: MobileAreaMapper + * @Description: TODO(这里用一句话描述这个类的作用) + * @date 2025/6/8 14:47 + */ + +public interface MobileAreaMapper { + + @Select("select mobile_number,mobile_area,mobile_type from mobile_area ") + List findAllMobileArea(); +} diff --git a/beacon-test/src/main/resources/application.yml b/beacon-test/src/main/resources/application.yml index 3fe4a3e..f7bed84 100644 --- a/beacon-test/src/main/resources/application.yml +++ b/beacon-test/src/main/resources/application.yml @@ -13,6 +13,13 @@ spring: url: jdbc:mysql://192.168.1.13:3306/beacon_cloud?characterEncoding=utf-8&useSSL=false username: root password: root + +feign: + client: + config: + default: + connectTimeout: 5000 # 连接超时时间(毫秒) + readTimeout: 30000 # 读取超时时间(毫秒) # 端口号 server: port: 20000 diff --git a/beacon-test/src/test/java/com/mashibing/test/mapper/ClientBusinessMapperTest.java b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientBusinessMapperTest.java index 22afcf5..e5fd5c3 100644 --- a/beacon-test/src/test/java/com/mashibing/test/mapper/ClientBusinessMapperTest.java +++ b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientBusinessMapperTest.java @@ -26,7 +26,7 @@ class ClientBusinessMapperTest { public void findById() { ClientBusiness cb = mapper.findById(1L); cb.setIpAddress("192.168.1.5"); - // System.out.println("\"22.220.124.110\".equals(cb.getIpAddress()) = " + "22.220.124.110".equals(cb.getIpAddress())); + cb.setClientFilters("phase," + cb.getClientFilters()); System.out.println(cb); ObjectMapper mapper = new ObjectMapper(); beaconCacheClient.hset("client_business:" + cb.getApikey(), mapper.convertValue(cb, Map.class)); diff --git a/beacon-test/src/test/java/com/mashibing/test/mapper/MobileAreaMapperTest.java b/beacon-test/src/test/java/com/mashibing/test/mapper/MobileAreaMapperTest.java new file mode 100644 index 0000000..6e967bd --- /dev/null +++ b/beacon-test/src/test/java/com/mashibing/test/mapper/MobileAreaMapperTest.java @@ -0,0 +1,47 @@ +package com.mashibing.test.mapper; + +import com.mashibing.test.entity.MobileArea; +import com.mashibing.test.feignClient.BeaconCacheClient; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +@Slf4j +@SpringBootTest +@RunWith(SpringRunner.class) +class MobileAreaMapperTest { + @Autowired + BeaconCacheClient beaconCacheClient; + + @Autowired + MobileAreaMapper mapper; + + @Test + void findAllMobileArea() { + long startTime = System.currentTimeMillis(); + List allMobileArea = mapper.findAllMobileArea(); + long endTime = System.currentTimeMillis(); + log.info("【数据库查询耗时】: {} ms", endTime - startTime); + Map map = new HashMap<>(allMobileArea.size()); + startTime = System.currentTimeMillis(); + allMobileArea.forEach(mobileArea -> { + map.put(mobileArea.getMobileNumber(), + mobileArea.getMobileArea() + "," + mobileArea.getMobileType()); + }); + endTime = System.currentTimeMillis(); + log.info("【List转Map耗时】: {} ms", endTime - startTime); + startTime = System.currentTimeMillis(); + beaconCacheClient.pipelineString(map); + endTime = System.currentTimeMillis(); + log.info("【写入Redis耗时】: {} ms", endTime - startTime); + } +} \ No newline at end of file