调整mock 结构
This commit is contained in:
parent
7ade47acac
commit
e7dd8162dc
@ -1,22 +1,12 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.event.MockMessageDataEvent;
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.MockAppContext;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONWriter.Feature;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
public class OccMessageDecoder extends ByteToMessageDecoder {
|
||||
@ -41,23 +31,5 @@ public class OccMessageDecoder extends ByteToMessageDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
public static class MockAppContext implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext appContext;
|
||||
|
||||
public static void publish(List<MessageData> datas) {
|
||||
NccMockData mockData = new NccMockData();
|
||||
mockData.setMockData(JSON.toJSONString(datas)).setMockReceiveTime(LocalDateTime.now());
|
||||
appContext.publishEvent(new MockMessageDataEvent(mockData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (Objects.isNull(appContext)) {
|
||||
System.out.println("获取 spring appContext");
|
||||
appContext = applicationContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
package club.joylink.xiannccda.mapper;
|
||||
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.NccMockData;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.cursor.Cursor;
|
||||
import org.apache.ibatis.mapping.ResultSetType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mapper namespace="club.joylink.xiannccda.mapper.NccMockDataMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="club.joylink.xiannccda.entity.NccMockData">
|
||||
<resultMap id="BaseResultMap" type="club.joylink.xiannccda.mock.message.NccMockData">
|
||||
<id column="id" property="id"/>
|
||||
<result column="mock_data" property="mockData"/>
|
||||
<result column="mock_receive_time" property="mockReceiveTime"/>
|
||||
|
@ -0,0 +1,32 @@
|
||||
package club.joylink.xiannccda.mock.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.mock.message.event.MockMessageDataEvent;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MockAppContext implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext appContext;
|
||||
|
||||
public static void publish(List<MessageData> datas) {
|
||||
NccMockData mockData = new NccMockData();
|
||||
mockData.setMockData(JSON.toJSONString(datas)).setMockReceiveTime(LocalDateTime.now());
|
||||
appContext.publishEvent(new MockMessageDataEvent(mockData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (Objects.isNull(appContext)) {
|
||||
System.out.println("获取 spring appContext");
|
||||
appContext = applicationContext;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.xiannccda.entity;
|
||||
package club.joylink.xiannccda.mock.message;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -11,7 +11,7 @@ import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
@ -24,16 +24,16 @@ import lombok.experimental.Accessors;
|
||||
@Schema(name = "NccMockData", description = "$!{table.comment}")
|
||||
public class NccMockData {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String mockData;
|
||||
private String mockData;
|
||||
|
||||
private LocalDateTime mockReceiveTime;
|
||||
private LocalDateTime mockReceiveTime;
|
||||
|
||||
public static final String ID = "id";
|
||||
public static final String ID = "id";
|
||||
|
||||
public static final String MOCK_DATA = "mock_data";
|
||||
public static final String MOCK_DATA = "mock_data";
|
||||
|
||||
public static final String MOCK_RECEIVE_TIME = "mock_receive_time";
|
||||
public static final String MOCK_RECEIVE_TIME = "mock_receive_time";
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package club.joylink.xiannccda.service;
|
||||
package club.joylink.xiannccda.mock.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.NccMockData;
|
||||
import club.joylink.xiannccda.repository.impl.NccMockDataRepository;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
@ -0,0 +1,5 @@
|
||||
package club.joylink.xiannccda.mock.message.event;
|
||||
|
||||
public class MockAppContext {
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.xiannccda.ats.message.event;
|
||||
package club.joylink.xiannccda.mock.message.event;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
@ -1,10 +1,9 @@
|
||||
package club.joylink.xiannccda.ats.message.event;
|
||||
package club.joylink.xiannccda.mock.message.event;
|
||||
|
||||
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.NccMockData;
|
||||
import club.joylink.xiannccda.repository.INccMockDataRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package club.joylink.xiannccda.repository;
|
||||
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.NccMockData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
@ -15,5 +15,5 @@ public interface INccMockDataRepository extends IService<NccMockData> {
|
||||
|
||||
// public void dd();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
package club.joylink.xiannccda.repository.impl;
|
||||
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.NccMockData;
|
||||
import club.joylink.xiannccda.mapper.NccMockDataMapper;
|
||||
import club.joylink.xiannccda.repository.INccMockDataRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.cursor.Cursor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -34,6 +34,7 @@ mybatis-plus:
|
||||
call-setters-on-nulls: true
|
||||
jdbc-type-for-null: 'null'
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
jwt:
|
||||
key:
|
||||
pub: classpath:app.pub
|
||||
|
@ -3,22 +3,17 @@ package club.joylink.xiannccda.service;
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.OccMessageDecoder.MockAppContext;
|
||||
import club.joylink.xiannccda.ats.message.event.MockMessageDataEvent;
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ActionReportResponse;
|
||||
import club.joylink.xiannccda.entity.NccMockData;
|
||||
import club.joylink.xiannccda.mock.message.NccMockDataService;
|
||||
import club.joylink.xiannccda.protocal.x.TestUtil;
|
||||
import club.joylink.xiannccda.repository.INccMockDataRepository;
|
||||
import club.joylink.xiannccda.repository.impl.NccMockDataRepository;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
Loading…
Reference in New Issue
Block a user