From dde026fb50ef8d0cbb5d493e087b57f6660ba83e Mon Sep 17 00:00:00 2001 From: kezhen0805 Date: Wed, 28 Dec 2022 21:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AD=BE=E5=90=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=90=8C=E6=AD=A5=E5=88=B0redis=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dataSources.xml | 12 + .idea/encodings.xml | 1 + .idea/jpa-buddy.xml | 6 + .idea/uiDesigner.xml | 124 ++++++++++ .../cache/contorller/CacheController.java | 42 ++++ .../common/model/StandardSubmit.java | 9 +- beacon-test/pom.xml | 50 +++++ .../com/mashibing/test/TestStarterApp.java | 22 ++ .../mashibing/test/client/CacheClient.java | 27 +++ .../mashibing/test/entity/ClientBalance.java | 127 +++++++++++ .../mashibing/test/entity/ClientBusiness.java | 212 ++++++++++++++++++ .../com/mashibing/test/entity/ClientSign.java | 199 ++++++++++++++++ .../mashibing/test/entity/ClientTemplate.java | 167 ++++++++++++++ .../test/mapper/ClientBusinessMapper.java | 15 ++ .../test/mapper/ClientSignMapper.java | 17 ++ .../test/mapper/ClientTemplateMapper.java | 17 ++ .../src/main/resources/application.yml | 19 ++ .../test/mapper/ClientBusinessMapperTest.java | 41 ++++ .../test/mapper/ClientSignMapperTest.java | 49 ++++ beancon-api/pom.xml | 5 + .../java/com/mashibing/api/ApiStarterApp.java | 2 + .../api/client/BeaconCacheClient.java | 12 + .../api/controller/SmsController.java | 10 +- pom.xml | 1 + 24 files changed, 1183 insertions(+), 3 deletions(-) create mode 100644 .idea/dataSources.xml create mode 100644 .idea/jpa-buddy.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 beacon-cache/src/main/java/com/mashibing/cache/contorller/CacheController.java create mode 100644 beacon-test/pom.xml create mode 100644 beacon-test/src/main/java/com/mashibing/test/TestStarterApp.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/client/CacheClient.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/entity/ClientBalance.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/entity/ClientBusiness.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/entity/ClientSign.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/entity/ClientTemplate.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/mapper/ClientBusinessMapper.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/mapper/ClientSignMapper.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/mapper/ClientTemplateMapper.java create mode 100644 beacon-test/src/main/resources/application.yml create mode 100644 beacon-test/src/test/java/com/mashibing/test/mapper/ClientBusinessMapperTest.java create mode 100644 beacon-test/src/test/java/com/mashibing/test/mapper/ClientSignMapperTest.java create mode 100644 beancon-api/src/main/java/com/mashibing/api/client/BeaconCacheClient.java diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..6a00707 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + mysql_aurora + true + org.mariadb.jdbc.Driver + jdbc:mariadb://192.168.1.8:3306/beacon_cloud + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 29f4707..5a74c51 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -3,6 +3,7 @@ + diff --git a/.idea/jpa-buddy.xml b/.idea/jpa-buddy.xml new file mode 100644 index 0000000..966d5f5 --- /dev/null +++ b/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/beacon-cache/src/main/java/com/mashibing/cache/contorller/CacheController.java b/beacon-cache/src/main/java/com/mashibing/cache/contorller/CacheController.java new file mode 100644 index 0000000..d8d696c --- /dev/null +++ b/beacon-cache/src/main/java/com/mashibing/cache/contorller/CacheController.java @@ -0,0 +1,42 @@ +package com.mashibing.cache.contorller; + +import com.msb.framework.redis.RedisClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author kezhen + * @date 2022/12/28 + * @description + */ +@RestController +@Slf4j +public class CacheController { + + @Autowired + private RedisClient redisClient; + + @PostMapping(value = "/cache/hmset/{key}") + public void hmset(@PathVariable(value = "key") String key, @RequestBody Map map) { + log.info("【缓存模块】hmset方法,存储key = {},存储value = {}", key, map); + redisClient.putMap(key,map); + } + + @PostMapping(value = "/cache/set/{key}") + public void set(@PathVariable(value = "key") String key, @RequestParam(value = "value") String value){ + log.info("【缓存模块】set方法,存储key = {},存储value = {}", key, value); + redisClient.set(key,value); + } + + @PostMapping(value = "/cache/sadd/{key}") + public void sadd(@PathVariable(value = "key") String key, @RequestBody Map... value){ + log.info("【缓存模块】sadd 方法,存储key = {},存储value = {}", key, value); + redisClient.sAdd(key,value); + + } + + +} diff --git a/beacon-common/src/main/java/com/mashibing/common/model/StandardSubmit.java b/beacon-common/src/main/java/com/mashibing/common/model/StandardSubmit.java index fed63e7..bdc6cbb 100644 --- a/beacon-common/src/main/java/com/mashibing/common/model/StandardSubmit.java +++ b/beacon-common/src/main/java/com/mashibing/common/model/StandardSubmit.java @@ -51,11 +51,18 @@ public class StandardSubmit { * 短信的发送状态,0-等待/发送ing,1-成功,2-失败,默认情况就是0 */ private int reportState; - /** * 短信的类型 */ private String realIP; + /** + * 客户端请求携带的apikey + */ + private String apikey; + /** + * 短信类型 0-验证码短信,1-通知类短信,2-营销类短信 + */ + private int state; //后续再做封装 } diff --git a/beacon-test/pom.xml b/beacon-test/pom.xml new file mode 100644 index 0000000..c4609e2 --- /dev/null +++ b/beacon-test/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + com.mashibing + beacon-cloud + 1.0-SNAPSHOT + + + beacon-test + 为了快速落地核心业务,在这个test项目中将MySQL中的数据同步到redis中,基于Cache模块去写入 + + + 8 + 8 + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.3.0 + + + mysql + mysql-connector-java + 5.1.49 + + + + \ No newline at end of file diff --git a/beacon-test/src/main/java/com/mashibing/test/TestStarterApp.java b/beacon-test/src/main/java/com/mashibing/test/TestStarterApp.java new file mode 100644 index 0000000..77316ce --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/TestStarterApp.java @@ -0,0 +1,22 @@ +package com.mashibing.test; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * @author kezhen + * @date 2022/12/27 + * @description + */ +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +@MapperScan(basePackages = "com.mashibing.test.mapper") +public class TestStarterApp { + public static void main(String[] args) { + SpringApplication.run(TestStarterApp.class,args); + } +} diff --git a/beacon-test/src/main/java/com/mashibing/test/client/CacheClient.java b/beacon-test/src/main/java/com/mashibing/test/client/CacheClient.java new file mode 100644 index 0000000..af0d90a --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/client/CacheClient.java @@ -0,0 +1,27 @@ +package com.mashibing.test.client; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.Map; + +/** + * @author kezhen + * @date 2022/12/27 + * @description + */ +@FeignClient(value = "beacon-cache") +public interface CacheClient { + @PostMapping(value = "/cache/hmset/{key}") + void hmset(@PathVariable(value = "key") String key, @RequestBody Map map); + + @PostMapping(value = "/cache/set/{key}") + void set(@PathVariable(value = "key") String key, @RequestParam(value = "value") String value); + + @PostMapping(value = "/cache/sadd/{key}") + void sadd(@PathVariable(value = "key") String key, @RequestBody Map... maps); +} diff --git a/beacon-test/src/main/java/com/mashibing/test/entity/ClientBalance.java b/beacon-test/src/main/java/com/mashibing/test/entity/ClientBalance.java new file mode 100644 index 0000000..edd4a42 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/entity/ClientBalance.java @@ -0,0 +1,127 @@ +package com.mashibing.test.entity; + + +public class ClientBalance { + + private long id; + private long clientId; + private long balance; + 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 long getClientId() { + return clientId; + } + + public void setClientId(long clientId) { + this.clientId = clientId; + } + + + public long getBalance() { + return balance; + } + + public void setBalance(long balance) { + this.balance = balance; + } + + + 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/entity/ClientBusiness.java b/beacon-test/src/main/java/com/mashibing/test/entity/ClientBusiness.java new file mode 100644 index 0000000..c24f022 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/entity/ClientBusiness.java @@ -0,0 +1,212 @@ +package com.mashibing.test.entity; + + +public class ClientBusiness { + + private long id; + private String corpname; + private String apikey; + private String ipAddress; + + @Override + public String toString() { + return "ClientBusiness{" + + "id=" + id + + ", corpname='" + corpname + '\'' + + ", apikey='" + apikey + '\'' + + ", ipAddress='" + ipAddress + '\'' + + ", isCallback=" + isCallback + + ", callbackUrl='" + callbackUrl + '\'' + + ", clientLinkname='" + clientLinkname + '\'' + + ", clientPhone='" + clientPhone + '\'' + + ", clientFilters='" + clientFilters + '\'' + + ", created=" + created + + ", createId=" + createId + + ", updated=" + updated + + ", updateId=" + updateId + + ", isDelete=" + isDelete + + ", extend1='" + extend1 + '\'' + + ", extend2='" + extend2 + '\'' + + ", extend3='" + extend3 + '\'' + + ", extend4='" + extend4 + '\'' + + '}'; + } + + private long isCallback; + private String callbackUrl; + private String clientLinkname; + private String clientPhone; + private String clientFilters; + 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 getCorpname() { + return corpname; + } + + public void setCorpname(String corpname) { + this.corpname = corpname; + } + + + public String getApikey() { + return apikey; + } + + public void setApikey(String apikey) { + this.apikey = apikey; + } + + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + + public long getIsCallback() { + return isCallback; + } + + public void setIsCallback(long isCallback) { + this.isCallback = isCallback; + } + + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + + public String getClientLinkname() { + return clientLinkname; + } + + public void setClientLinkname(String clientLinkname) { + this.clientLinkname = clientLinkname; + } + + + public String getClientPhone() { + return clientPhone; + } + + public void setClientPhone(String clientPhone) { + this.clientPhone = clientPhone; + } + + + public String getClientFilters() { + return clientFilters; + } + + public void setClientFilters(String clientFilters) { + this.clientFilters = clientFilters; + } + + + 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/entity/ClientSign.java b/beacon-test/src/main/java/com/mashibing/test/entity/ClientSign.java new file mode 100644 index 0000000..9788467 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/entity/ClientSign.java @@ -0,0 +1,199 @@ +package com.mashibing.test.entity; + + +public class ClientSign { + + private long id; + private long clientId; + private String signInfo; + private long signState; + private long signType; + private String businessWeb; + private String proveDescr; + private String proveFile; + 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 long getClientId() { + return clientId; + } + + public void setClientId(long clientId) { + this.clientId = clientId; + } + + + public String getSignInfo() { + return signInfo; + } + + public void setSignInfo(String signInfo) { + this.signInfo = signInfo; + } + + + public long getSignState() { + return signState; + } + + public void setSignState(long signState) { + this.signState = signState; + } + + + public long getSignType() { + return signType; + } + + public void setSignType(long signType) { + this.signType = signType; + } + + + public String getBusinessWeb() { + return businessWeb; + } + + public void setBusinessWeb(String businessWeb) { + this.businessWeb = businessWeb; + } + + + public String getProveDescr() { + return proveDescr; + } + + public void setProveDescr(String proveDescr) { + this.proveDescr = proveDescr; + } + + + public String getProveFile() { + return proveFile; + } + + public void setProveFile(String proveFile) { + this.proveFile = proveFile; + } + + + 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; + } + + @Override + public String toString() { + return "ClientSign{" + + "id=" + id + + ", clientId=" + clientId + + ", signInfo='" + signInfo + '\'' + + ", signState=" + signState + + ", signType=" + signType + + ", businessWeb='" + businessWeb + '\'' + + ", proveDescr='" + proveDescr + '\'' + + ", proveFile='" + proveFile + '\'' + + ", created=" + created + + ", createId=" + createId + + ", updated=" + updated + + ", updateId=" + updateId + + ", isDelete=" + isDelete + + ", extend1='" + extend1 + '\'' + + ", extend2='" + extend2 + '\'' + + ", extend3='" + extend3 + '\'' + + ", extend4='" + extend4 + '\'' + + '}'; + } +} diff --git a/beacon-test/src/main/java/com/mashibing/test/entity/ClientTemplate.java b/beacon-test/src/main/java/com/mashibing/test/entity/ClientTemplate.java new file mode 100644 index 0000000..5beca9d --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/entity/ClientTemplate.java @@ -0,0 +1,167 @@ +package com.mashibing.test.entity; + + +public class ClientTemplate { + + private long id; + private long signId; + private String templateText; + private long templateType; + private long templateState; + private long useId; + private String useWeb; + 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 long getSignId() { + return signId; + } + + public void setSignId(long signId) { + this.signId = signId; + } + + + public String getTemplateText() { + return templateText; + } + + public void setTemplateText(String templateText) { + this.templateText = templateText; + } + + + public long getTemplateType() { + return templateType; + } + + public void setTemplateType(long templateType) { + this.templateType = templateType; + } + + + public long getTemplateState() { + return templateState; + } + + public void setTemplateState(long templateState) { + this.templateState = templateState; + } + + + public long getUseId() { + return useId; + } + + public void setUseId(long useId) { + this.useId = useId; + } + + + public String getUseWeb() { + return useWeb; + } + + public void setUseWeb(String useWeb) { + this.useWeb = useWeb; + } + + + 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/mapper/ClientBusinessMapper.java b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientBusinessMapper.java new file mode 100644 index 0000000..0d0b377 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientBusinessMapper.java @@ -0,0 +1,15 @@ +package com.mashibing.test.mapper; + +import com.mashibing.test.entity.ClientBusiness; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + * @author kezhen + * @date 2022/12/27 + * @description + */ +public interface ClientBusinessMapper { + @Select("select * from client_business where id = #{id}") + ClientBusiness findByID(@Param("id") Long id); +} diff --git a/beacon-test/src/main/java/com/mashibing/test/mapper/ClientSignMapper.java b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientSignMapper.java new file mode 100644 index 0000000..cac0c5f --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientSignMapper.java @@ -0,0 +1,17 @@ +package com.mashibing.test.mapper; + +import com.mashibing.test.entity.ClientSign; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author kezhen + * @date 2022/12/28 + * @description + */ +public interface ClientSignMapper { + @Select("select * from client_sign where client_id = #{clientId}") + List findByClientId(@Param("clientId") Long clientId); +} diff --git a/beacon-test/src/main/java/com/mashibing/test/mapper/ClientTemplateMapper.java b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientTemplateMapper.java new file mode 100644 index 0000000..2079e66 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientTemplateMapper.java @@ -0,0 +1,17 @@ +package com.mashibing.test.mapper; + +import com.mashibing.test.entity.ClientTemplate; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author kezhen + * @date 2022/12/28 + * @description + */ +public interface ClientTemplateMapper { + @Select("select * from client_template where sign_id = #{signId}") + List findBySignId(@Param("signId") Long signId); +} diff --git a/beacon-test/src/main/resources/application.yml b/beacon-test/src/main/resources/application.yml new file mode 100644 index 0000000..7b9626b --- /dev/null +++ b/beacon-test/src/main/resources/application.yml @@ -0,0 +1,19 @@ +spring: + application: + name: beacon-test + cloud: + nacos: + discovery: + server-addr: 192.168.1.8:8848 + datasource: + driver-class-name: org.gjt.mm.mysql.Driver + url: jdbc:mysql://192.168.1.8:3306/beacon_cloud?characterEncoding=utf-8 + username: root + password: ZhengJinWei123! + +server: + port: 20000 + +mybatis: + configuration: + map-underscore-to-camel-case: true \ No newline at end of file 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 new file mode 100644 index 0000000..d95c409 --- /dev/null +++ b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientBusinessMapperTest.java @@ -0,0 +1,41 @@ +package com.mashibing.test.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mashibing.test.client.CacheClient; +import com.mashibing.test.entity.ClientBusiness; +import org.junit.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.Map; + +import static org.junit.Assert.*; + +/** + * @author kezhen + * @date 2022/12/27 + * @description + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class ClientBusinessMapperTest { + @Autowired + private ClientBusinessMapper clientBusinessMapper; + + @Autowired + private CacheClient cacheClient; + + @Test + public void findByID() throws JsonProcessingException { + ClientBusiness cb = clientBusinessMapper.findByID(1L); + System.out.println("cb = " + cb); + ObjectMapper objectMapper = new ObjectMapper(); + Map map = objectMapper.readValue(objectMapper.writeValueAsString(cb), Map.class); + cacheClient.hmset("client_business:" + cb.getApikey(), map); + + + } +} \ No newline at end of file diff --git a/beacon-test/src/test/java/com/mashibing/test/mapper/ClientSignMapperTest.java b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientSignMapperTest.java new file mode 100644 index 0000000..e86aeef --- /dev/null +++ b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientSignMapperTest.java @@ -0,0 +1,49 @@ +package com.mashibing.test.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mashibing.test.client.CacheClient; +import com.mashibing.test.entity.ClientSign; +import org.junit.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.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author kezhen + * @date 2022/12/28 + * @description + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class ClientSignMapperTest { + + @Autowired + private ClientSignMapper clientSignMapper; + + @Autowired + private CacheClient cacheClient; + + @Test + public void findByClientId() { + List clientSignList = clientSignMapper.findByClientId(1L); + for (ClientSign clientSign : clientSignList) { + System.out.println("clientSign = " + clientSign); + } + ObjectMapper objectMapper = new ObjectMapper(); + List value = clientSignList.stream().map(cs -> { + try { + return objectMapper.readValue(objectMapper.writeValueAsString(cs), Map.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + return null; + } + }).collect(Collectors.toList()); + cacheClient.sadd("client_sign:1", value.toArray(new Map[]{})); + } +} \ No newline at end of file diff --git a/beancon-api/pom.xml b/beancon-api/pom.xml index a0172bd..65cfbb9 100644 --- a/beancon-api/pom.xml +++ b/beancon-api/pom.xml @@ -58,6 +58,11 @@ beacon-common 1.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-starter-openfeign + diff --git a/beancon-api/src/main/java/com/mashibing/api/ApiStarterApp.java b/beancon-api/src/main/java/com/mashibing/api/ApiStarterApp.java index fd1aeec..0742139 100644 --- a/beancon-api/src/main/java/com/mashibing/api/ApiStarterApp.java +++ b/beancon-api/src/main/java/com/mashibing/api/ApiStarterApp.java @@ -3,6 +3,7 @@ package com.mashibing.api; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * @author kezhen @@ -10,6 +11,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; */ @SpringBootApplication @EnableDiscoveryClient +@EnableFeignClients public class ApiStarterApp { public static void main(String[] args) { SpringApplication.run(ApiStarterApp.class,args); diff --git a/beancon-api/src/main/java/com/mashibing/api/client/BeaconCacheClient.java b/beancon-api/src/main/java/com/mashibing/api/client/BeaconCacheClient.java new file mode 100644 index 0000000..ef4e06a --- /dev/null +++ b/beancon-api/src/main/java/com/mashibing/api/client/BeaconCacheClient.java @@ -0,0 +1,12 @@ +package com.mashibing.api.client; + +import org.springframework.cloud.openfeign.FeignClient; + +/** + * @author kezhen + * @date 2022/12/26 + * @description + */ +@FeignClient(value = "beacon-cache") +public class BeaconCacheClient { +} diff --git a/beancon-api/src/main/java/com/mashibing/api/controller/SmsController.java b/beancon-api/src/main/java/com/mashibing/api/controller/SmsController.java index 718dc00..cceb329 100644 --- a/beancon-api/src/main/java/com/mashibing/api/controller/SmsController.java +++ b/beancon-api/src/main/java/com/mashibing/api/controller/SmsController.java @@ -56,12 +56,18 @@ public class SmsController { log.info("【接口模块-单条短信Contorller】 参数不合法,msg = {}", message); return R.error(SmsCodeEnum.PARAMETER_ERROR.getCode(), message); } - //===============构建StandardSubmit================== - + //===============获取真实的ip================== String ip = this.getRealIP(request); System.out.println("ip = " + ip); + //===============构建StandardSubmit,各种封装校验================== StandardSubmit standardSubmit = new StandardSubmit(); + standardSubmit.setRealIP(ip); + standardSubmit.setApikey(singleSendForm.getApikey()); + standardSubmit.setMobile(singleSendForm.getMobile()); + standardSubmit.setText(singleSendForm.getText()); + standardSubmit.setState(singleSendForm.getState()); + standardSubmit.setUid(singleSendForm.getUid()); //===============发送到MQ,交给策略模块处理================== diff --git a/pom.xml b/pom.xml index b27b633..6759490 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ beancon-api beacon-common beacon-cache + beacon-test