From b7d731ef9c3905167f3eedfb09b1e0e380ee53b1 Mon Sep 17 00:00:00 2001 From: heqijun Date: Wed, 11 Jun 2025 18:42:13 +0800 Subject: [PATCH] =?UTF-8?q?client=5Fchannel=E6=95=B0=E6=8D=AE=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=88=B0redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mashibing/test/entity/ClientChannel.java | 167 ++++++++++++++++++ .../test/mapper/ClientChannelMapper.java | 22 +++ .../test/mapper/ChannelMapperTest.java | 2 +- .../test/mapper/ClientChannelMapperTest.java | 37 ++++ 4 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 beacon-test/src/main/java/com/mashibing/test/entity/ClientChannel.java create mode 100644 beacon-test/src/main/java/com/mashibing/test/mapper/ClientChannelMapper.java create mode 100644 beacon-test/src/test/java/com/mashibing/test/mapper/ClientChannelMapperTest.java diff --git a/beacon-test/src/main/java/com/mashibing/test/entity/ClientChannel.java b/beacon-test/src/main/java/com/mashibing/test/entity/ClientChannel.java new file mode 100644 index 0000000..8099e09 --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/entity/ClientChannel.java @@ -0,0 +1,167 @@ +package com.mashibing.test.entity; + + +public class ClientChannel { + + private long id; + private long clientId; + private long channelId; + private long clientChannelWeight; + private long clientChannelPrice; + private String clientChannelNumber; + private long isAvailable; + 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 getChannelId() { + return channelId; + } + + public void setChannelId(long channelId) { + this.channelId = channelId; + } + + + public long getClientChannelWeight() { + return clientChannelWeight; + } + + public void setClientChannelWeight(long clientChannelWeight) { + this.clientChannelWeight = clientChannelWeight; + } + + + public long getClientChannelPrice() { + return clientChannelPrice; + } + + public void setClientChannelPrice(long clientChannelPrice) { + this.clientChannelPrice = clientChannelPrice; + } + + + public String getClientChannelNumber() { + return clientChannelNumber; + } + + public void setClientChannelNumber(String clientChannelNumber) { + this.clientChannelNumber = clientChannelNumber; + } + + + public long getIsAvailable() { + return isAvailable; + } + + public void setIsAvailable(long isAvailable) { + this.isAvailable = isAvailable; + } + + + 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/ClientChannelMapper.java b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientChannelMapper.java new file mode 100644 index 0000000..19b578e --- /dev/null +++ b/beacon-test/src/main/java/com/mashibing/test/mapper/ClientChannelMapper.java @@ -0,0 +1,22 @@ +package com.mashibing.test.mapper; + +import com.mashibing.test.entity.Channel; +import com.mashibing.test.entity.ClientBusiness; +import com.mashibing.test.entity.ClientChannel; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author heqijun + * @ClassName: ClientChannelMapper + * @Description: TODO(这里用一句话描述这个类的作用) + * @date 2025/6/11 18:20 + */ + +public interface ClientChannelMapper { + + @Select("select * from client_channel where is_delete = 0") + List findAll(); +} diff --git a/beacon-test/src/test/java/com/mashibing/test/mapper/ChannelMapperTest.java b/beacon-test/src/test/java/com/mashibing/test/mapper/ChannelMapperTest.java index ce87efb..e74a461 100644 --- a/beacon-test/src/test/java/com/mashibing/test/mapper/ChannelMapperTest.java +++ b/beacon-test/src/test/java/com/mashibing/test/mapper/ChannelMapperTest.java @@ -29,7 +29,7 @@ class ChannelMapperTest { @Test void findAll() throws JsonProcessingException { List channelList = mapper.findAll(); - ObjectMapper objectMapper = new ObjectMapper + ObjectMapper objectMapper = new ObjectMapper(); for (Channel channel : channelList) { Map map = objectMapper.readValue(objectMapper.writeValueAsString(channel), Map.class); cacheClient.hset("channel:" + channel.getId(), map); diff --git a/beacon-test/src/test/java/com/mashibing/test/mapper/ClientChannelMapperTest.java b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientChannelMapperTest.java new file mode 100644 index 0000000..e876664 --- /dev/null +++ b/beacon-test/src/test/java/com/mashibing/test/mapper/ClientChannelMapperTest.java @@ -0,0 +1,37 @@ +package com.mashibing.test.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mashibing.test.entity.ClientChannel; +import com.mashibing.test.feignClient.CacheClient; +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.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +@SpringBootTest +@RunWith(SpringRunner.class) +class ClientChannelMapperTest { + + @Autowired + CacheClient cacheClient; + + @Autowired + ClientChannelMapper mapper; + + @Test + void findAll() throws JsonProcessingException { + List clientChannelList = mapper.findAll(); + ObjectMapper objectMapper = new ObjectMapper(); + for (ClientChannel clientChannel : clientChannelList) { + Map map = objectMapper.readValue(objectMapper.writeValueAsString(clientChannel), Map.class); + cacheClient.sadd("client_channel:" + clientChannel.getClientId(), map); + } + } +} \ No newline at end of file