Compare commits
2 Commits
e8ee0ff8c8
...
b66a9974df
Author | SHA1 | Date |
---|---|---|
|
b66a9974df | 4 months ago |
|
341c6049ae | 4 months ago |
@ -0,0 +1,15 @@
|
||||
package com.mashibing.api.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: SmsService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 16:56
|
||||
*/
|
||||
|
||||
public interface SmsService {
|
||||
|
||||
String getRealIP(HttpServletRequest request);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.mashibing.api.service.impl;
|
||||
|
||||
import com.mashibing.api.service.SmsService;
|
||||
import com.mashibing.common.constant.SMSConstant;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: SmsServiceImpl
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 16:57
|
||||
*/
|
||||
|
||||
@Service
|
||||
@RefreshScope
|
||||
public class SmsServiceImpl implements SmsService {
|
||||
|
||||
@Value("${headers}")
|
||||
private String[] headers;
|
||||
|
||||
@Override
|
||||
public String getRealIP(HttpServletRequest request) {
|
||||
|
||||
String ip;
|
||||
for (String header : headers) {
|
||||
if (StringUtils.isNotBlank(header)) {
|
||||
ip = request.getHeader(header);
|
||||
if (StringUtils.isNotBlank(ip) && !SMSConstant.UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = (SMSConstant.X_FORWARDED_FOR.equalsIgnoreCase(header) && ip.indexOf(",") > 0) ? ip.split(",")[0] : ip;
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
ip = request.getRemoteAddr();
|
||||
return ip;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mashibing.common.constant;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: Constant
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 17:10
|
||||
*/
|
||||
|
||||
public class SMSConstant {
|
||||
|
||||
public static final double EARTH_RADIUS = 6378.137;
|
||||
|
||||
public static final String UNKNOWN = "unknown";
|
||||
|
||||
public static final String X_FORWARDED_FOR = "x-forwarded-for";
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.mashibing</groupId>
|
||||
<artifactId>beacon-cloud</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>beacon-test</artifactId>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- nacos注册中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<!-- openFeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.49</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mashibing</groupId>
|
||||
<artifactId>beacon-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,24 @@
|
||||
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 heqijun
|
||||
* @ClassName: TestApplication
|
||||
* @Description: TestApplication启动类
|
||||
* @date 2025/6/5 18:42
|
||||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
@MapperScan(basePackages = "com.mashibing.test.mapper")
|
||||
public class TestApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TestApplication.class, args);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
package com.mashibing.test.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
public class ClientBusiness {
|
||||
|
||||
private long id;
|
||||
|
||||
private String corpname;
|
||||
|
||||
private String apikey;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package com.mashibing.test.entity;
|
||||
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.mashibing.test.feignClient;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: BeaconCacheClient
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 20:13
|
||||
*/
|
||||
|
||||
@FeignClient("beacon-cache")
|
||||
@RequestMapping("cache")
|
||||
public interface BeaconCacheClient {
|
||||
@GetMapping("get/{key}")
|
||||
public String get(@PathVariable String key);
|
||||
|
||||
@GetMapping("set/{key}/{value}")
|
||||
public void set(@PathVariable String key, @PathVariable String value);
|
||||
|
||||
@GetMapping("hget/{key}")
|
||||
public Map hget(@PathVariable String key);
|
||||
|
||||
@PostMapping("hset/{key}")
|
||||
public void hset(@PathVariable String key, @RequestBody Map hash);
|
||||
|
||||
@PostMapping("/sadd/{key}")
|
||||
public void sadd(@PathVariable(value = "key") String key, @RequestBody Map<String, Object>... maps);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.mashibing.test.entity.ClientBusiness;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: ClientBalanceMapper
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 18:58
|
||||
*/
|
||||
|
||||
public interface ClientBusinessMapper {
|
||||
|
||||
@Select("select * from client_business where id = #{id}")
|
||||
ClientBusiness findById(@Param("id") Long id);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.mashibing.test.entity.ClientBusiness;
|
||||
import com.mashibing.test.entity.ClientSign;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: ClientSignMapper
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 20:51
|
||||
*/
|
||||
|
||||
public interface ClientSignMapper {
|
||||
|
||||
@Select("select * from client_sign where client_id = #{clientId}")
|
||||
List<ClientSign> findAllByClientId(@Param("clientId") Long clientId);
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
# 服务名
|
||||
spring:
|
||||
application:
|
||||
name: beacon-test
|
||||
# nacos地址
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.1.10:8848
|
||||
# datasource
|
||||
datasource:
|
||||
driver-class-name: org.gjt.mm.mysql.Driver
|
||||
url: jdbc:mysql://192.168.1.10:3306/beacon_cloud?characterEncoding=utf-8&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
# 端口号
|
||||
server:
|
||||
port: 20000
|
||||
|
||||
# mybatis
|
||||
mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
@ -0,0 +1,33 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import com.mashibing.test.entity.ClientBusiness;
|
||||
import com.mashibing.test.feignClient.BeaconCacheClient;
|
||||
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.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ClientBusinessMapperTest {
|
||||
|
||||
@Autowired
|
||||
private ClientBusinessMapper mapper;
|
||||
|
||||
@Autowired
|
||||
BeaconCacheClient beaconCacheClient;
|
||||
|
||||
@Test
|
||||
public void findById() {
|
||||
ClientBusiness cb = mapper.findById(1L);
|
||||
System.out.println(cb);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
beaconCacheClient.hset("client_business:" + cb.getApikey(), mapper.convertValue(cb, Map.class));
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mashibing.test.entity.ClientSign;
|
||||
import com.mashibing.test.feignClient.BeaconCacheClient;
|
||||
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.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
class ClientSignMapperTest {
|
||||
|
||||
@Autowired
|
||||
private ClientSignMapper mapper;
|
||||
|
||||
@Autowired
|
||||
BeaconCacheClient beaconCacheClient;
|
||||
|
||||
@Test
|
||||
void findAllByClientId() {
|
||||
List<ClientSign> clientSignList = mapper.findAllByClientId(1L);
|
||||
clientSignList.forEach(System.out::println);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<Map> maps = clientSignList
|
||||
.stream()
|
||||
.map(clientSign -> mapper.convertValue(clientSign, Map.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
beaconCacheClient.sadd("client_sign:1", maps.toArray(new Map[]{}));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue