parent
29ee4f7ad6
commit
b51e28ec74
@ -0,0 +1,125 @@
|
||||
package com.mashibing.test.entity;
|
||||
|
||||
/**
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
public class Channel {
|
||||
private Long id;
|
||||
private String channelName;
|
||||
private Integer channelType;
|
||||
private String channelArea;
|
||||
private String channelAreaCode;
|
||||
private Long channelPrice;
|
||||
private Integer channelProtocal;
|
||||
private String channelIp;
|
||||
private Integer channelPort;
|
||||
private String channelUsername;
|
||||
private String channelPassword;
|
||||
private String channelNumber;
|
||||
private Integer isAvailable;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
public void setChannelName(String channelName) {
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
public Integer getChannelType() {
|
||||
return channelType;
|
||||
}
|
||||
|
||||
public void setChannelType(Integer channelType) {
|
||||
this.channelType = channelType;
|
||||
}
|
||||
|
||||
public String getChannelArea() {
|
||||
return channelArea;
|
||||
}
|
||||
|
||||
public void setChannelArea(String channelArea) {
|
||||
this.channelArea = channelArea;
|
||||
}
|
||||
|
||||
public String getChannelAreaCode() {
|
||||
return channelAreaCode;
|
||||
}
|
||||
|
||||
public void setChannelAreaCode(String channelAreaCode) {
|
||||
this.channelAreaCode = channelAreaCode;
|
||||
}
|
||||
|
||||
public Long getChannelPrice() {
|
||||
return channelPrice;
|
||||
}
|
||||
|
||||
public void setChannelPrice(Long channelPrice) {
|
||||
this.channelPrice = channelPrice;
|
||||
}
|
||||
|
||||
public Integer getChannelProtocal() {
|
||||
return channelProtocal;
|
||||
}
|
||||
|
||||
public void setChannelProtocal(Integer channelProtocal) {
|
||||
this.channelProtocal = channelProtocal;
|
||||
}
|
||||
|
||||
public String getChannelIp() {
|
||||
return channelIp;
|
||||
}
|
||||
|
||||
public void setChannelIp(String channelIp) {
|
||||
this.channelIp = channelIp;
|
||||
}
|
||||
|
||||
public Integer getChannelPort() {
|
||||
return channelPort;
|
||||
}
|
||||
|
||||
public void setChannelPort(Integer channelPort) {
|
||||
this.channelPort = channelPort;
|
||||
}
|
||||
|
||||
public String getChannelUsername() {
|
||||
return channelUsername;
|
||||
}
|
||||
|
||||
public void setChannelUsername(String channelUsername) {
|
||||
this.channelUsername = channelUsername;
|
||||
}
|
||||
|
||||
public String getChannelPassword() {
|
||||
return channelPassword;
|
||||
}
|
||||
|
||||
public void setChannelPassword(String channelPassword) {
|
||||
this.channelPassword = channelPassword;
|
||||
}
|
||||
|
||||
public String getChannelNumber() {
|
||||
return channelNumber;
|
||||
}
|
||||
|
||||
public void setChannelNumber(String channelNumber) {
|
||||
this.channelNumber = channelNumber;
|
||||
}
|
||||
|
||||
public Integer getIsAvailable() {
|
||||
return isAvailable;
|
||||
}
|
||||
|
||||
public void setIsAvailable(Integer isAvailable) {
|
||||
this.isAvailable = isAvailable;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.mashibing.test.entity;
|
||||
|
||||
/**
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
public class ClientChannel {
|
||||
|
||||
private Long clientId;
|
||||
private Long channelId;
|
||||
private Integer clientChannelWeight;
|
||||
private String clientChannelNumber;
|
||||
private Integer isAvailable;
|
||||
|
||||
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 Integer getClientChannelWeight() {
|
||||
return clientChannelWeight;
|
||||
}
|
||||
|
||||
public void setClientChannelWeight(Integer clientChannelWeight) {
|
||||
this.clientChannelWeight = clientChannelWeight;
|
||||
}
|
||||
|
||||
public String getClientChannelNumber() {
|
||||
return clientChannelNumber;
|
||||
}
|
||||
|
||||
public void setClientChannelNumber(String clientChannelNumber) {
|
||||
this.clientChannelNumber = clientChannelNumber;
|
||||
}
|
||||
|
||||
public Integer getIsAvailable() {
|
||||
return isAvailable;
|
||||
}
|
||||
|
||||
public void setIsAvailable(Integer isAvailable) {
|
||||
this.isAvailable = isAvailable;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.mashibing.test.entity.Channel;
|
||||
import com.mashibing.test.entity.ClientBalance;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
public interface ChannelMapper {
|
||||
|
||||
@Select("select * from channel where is_delete = 0")
|
||||
List<Channel> findAll();
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mashibing.test.mapper;
|
||||
|
||||
import com.mashibing.test.entity.Channel;
|
||||
import com.mashibing.test.entity.ClientChannel;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zjw
|
||||
* @description
|
||||
*/
|
||||
public interface ClientChannelMapper {
|
||||
|
||||
@Select("select * from client_channel where is_delete = 0")
|
||||
List<ClientChannel> findAll();
|
||||
|
||||
}
|
@ -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.client.CacheClient;
|
||||
import com.mashibing.test.entity.Channel;
|
||||
import com.mashibing.test.entity.MobileBlack;
|
||||
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;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ChannelMapperTest {
|
||||
|
||||
@Autowired
|
||||
private ChannelMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private CacheClient cacheClient;
|
||||
|
||||
|
||||
@Test
|
||||
public void findAll() throws JsonProcessingException {
|
||||
List<Channel> list = mapper.findAll();
|
||||
for (Channel channel : list) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map map = objectMapper.readValue(objectMapper.writeValueAsString(channel), Map.class);
|
||||
cacheClient.hmset("channel:" + channel.getId(),map);
|
||||
}
|
||||
}
|
||||
}
|
@ -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.client.CacheClient;
|
||||
import com.mashibing.test.entity.Channel;
|
||||
import com.mashibing.test.entity.ClientChannel;
|
||||
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;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ClientChannelMapperTest {
|
||||
|
||||
@Autowired
|
||||
private ClientChannelMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private CacheClient cacheClient;
|
||||
|
||||
|
||||
@Test
|
||||
public void findAll() throws JsonProcessingException {
|
||||
List<ClientChannel> list = mapper.findAll();
|
||||
for (ClientChannel clientChannel : list) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map map = objectMapper.readValue(objectMapper.writeValueAsString(clientChannel), Map.class);
|
||||
cacheClient.sadd("client_channel:" + clientChannel.getClientId(),map);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue