正在显示
9 个修改的文件
包含
56 行增加
和
32 行删除
@@ -38,7 +38,8 @@ public class BusServerController { | @@ -38,7 +38,8 @@ public class BusServerController { | ||
38 | public ResultJson selectBusServerList( | 38 | public ResultJson selectBusServerList( |
39 | @RequestParam(value = "serverName", required = false) String serverName, | 39 | @RequestParam(value = "serverName", required = false) String serverName, |
40 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, | 40 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, |
41 | - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { | 41 | + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) |
42 | + { | ||
42 | // 获取查询参数 | 43 | // 获取查询参数 |
43 | BusServer busServer = BusServer.builder().serverName(serverName).build(); | 44 | BusServer busServer = BusServer.builder().serverName(serverName).build(); |
44 | // 分页查询 | 45 | // 分页查询 |
@@ -55,7 +56,8 @@ public class BusServerController { | @@ -55,7 +56,8 @@ public class BusServerController { | ||
55 | * @return {@link ResultJson} | 56 | * @return {@link ResultJson} |
56 | */ | 57 | */ |
57 | @DeleteMapping("/delete") | 58 | @DeleteMapping("/delete") |
58 | - public ResultJson deleteBusServer(@RequestBody BusServer busServer) { | 59 | + public ResultJson deleteBusServer(@RequestBody BusServer busServer) |
60 | + { | ||
59 | return busServerService.deleteByPrimaryKey(busServer.getId()) > 0 | 61 | return busServerService.deleteByPrimaryKey(busServer.getId()) > 0 |
60 | ? new ResultJson<>("200", "删除MQ服务器,成功") | 62 | ? new ResultJson<>("200", "删除MQ服务器,成功") |
61 | : new ResultJson<>("500", "删除MQ服务器,失败"); | 63 | : new ResultJson<>("500", "删除MQ服务器,失败"); |
@@ -68,7 +70,8 @@ public class BusServerController { | @@ -68,7 +70,8 @@ public class BusServerController { | ||
68 | * @return {@link ResultJson} | 70 | * @return {@link ResultJson} |
69 | */ | 71 | */ |
70 | @GetMapping("/batchRemove") | 72 | @GetMapping("/batchRemove") |
71 | - public ResultJson batchRemoveBusServer(String ids) { | 73 | + public ResultJson batchRemoveBusServer(String ids) |
74 | + { | ||
72 | return busServerService.deleteByPrimaryKey(ids) > 0 | 75 | return busServerService.deleteByPrimaryKey(ids) > 0 |
73 | ? new ResultJson<>("200", "批量删除服务器,成功") | 76 | ? new ResultJson<>("200", "批量删除服务器,成功") |
74 | : new ResultJson<>("500", "批量删除服务器,失败"); | 77 | : new ResultJson<>("500", "批量删除服务器,失败"); |
@@ -81,7 +84,8 @@ public class BusServerController { | @@ -81,7 +84,8 @@ public class BusServerController { | ||
81 | * @return {@link ResultJson} | 84 | * @return {@link ResultJson} |
82 | */ | 85 | */ |
83 | @PutMapping("/update") | 86 | @PutMapping("/update") |
84 | - public ResultJson updateBusServer(@RequestBody BusServer busServer) { | 87 | + public ResultJson updateBusServer(@RequestBody BusServer busServer) |
88 | + { | ||
85 | //先验证,修改好的核心信息(ip和port,同时存在)是否已存在 | 89 | //先验证,修改好的核心信息(ip和port,同时存在)是否已存在 |
86 | String message = validateBusServer(busServer); | 90 | String message = validateBusServer(busServer); |
87 | if (EXIST_SERVERNAME.equals(message)) { | 91 | if (EXIST_SERVERNAME.equals(message)) { |
@@ -101,7 +105,8 @@ public class BusServerController { | @@ -101,7 +105,8 @@ public class BusServerController { | ||
101 | * @return {@link ResultJson} | 105 | * @return {@link ResultJson} |
102 | */ | 106 | */ |
103 | @PostMapping("/insert") | 107 | @PostMapping("/insert") |
104 | - public ResultJson insertBusServer(@RequestBody BusServer busServer) { | 108 | + public ResultJson insertBusServer(@RequestBody BusServer busServer) |
109 | + { | ||
105 | //先验证,增加的服务器的核心信息(ip和port,同时存在)是否已存在 | 110 | //先验证,增加的服务器的核心信息(ip和port,同时存在)是否已存在 |
106 | String message = validateBusServer(busServer); | 111 | String message = validateBusServer(busServer); |
107 | if (EXIST_SERVERNAME.equals(message)) { | 112 | if (EXIST_SERVERNAME.equals(message)) { |
@@ -122,14 +127,15 @@ public class BusServerController { | @@ -122,14 +127,15 @@ public class BusServerController { | ||
122 | * @param busServer {@link BusServer} | 127 | * @param busServer {@link BusServer} |
123 | * @return 通过,无返回消息 | 128 | * @return 通过,无返回消息 |
124 | */ | 129 | */ |
125 | - private String validateBusServer(BusServer busServer) { | 130 | + private String validateBusServer(BusServer busServer) |
131 | + { | ||
126 | if ("".equals(busServer.getServerName()) || busServer.getServerName() == null) { | 132 | if ("".equals(busServer.getServerName()) || busServer.getServerName() == null) { |
127 | return "该服务器信息中,没有服务器名称"; | 133 | return "该服务器信息中,没有服务器名称"; |
128 | } | 134 | } |
129 | if ("".equals(busServer.getServerIp()) || busServer.getServerIp() == null) { | 135 | if ("".equals(busServer.getServerIp()) || busServer.getServerIp() == null) { |
130 | return "该服务器信息中,没有服务器IP"; | 136 | return "该服务器信息中,没有服务器IP"; |
131 | } | 137 | } |
132 | - if ("".equals(busServer.getServerPort()) || busServer.getServerPort() == null) { | 138 | + if (busServer.getServerPort() == null) { |
133 | return "该服务器信息中,没有服务器Port"; | 139 | return "该服务器信息中,没有服务器Port"; |
134 | } | 140 | } |
135 | 141 | ||
@@ -153,7 +159,7 @@ public class BusServerController { | @@ -153,7 +159,7 @@ public class BusServerController { | ||
153 | * 则校验 该 ServerIp以及ServerPort(同时) 是否已存在 | 159 | * 则校验 该 ServerIp以及ServerPort(同时) 是否已存在 |
154 | */ | 160 | */ |
155 | if ( | 161 | if ( |
156 | - !oldBusServer.getServerPort().equals(busServer.getServerPort()) || | 162 | + oldBusServer.getServerPort().equals(busServer.getServerPort()) || |
157 | !oldBusServer.getServerIp().equals(busServer.getServerIp())) { | 163 | !oldBusServer.getServerIp().equals(busServer.getServerIp())) { |
158 | 164 | ||
159 | // 根据 ServerIp以及ServerPort(同时),进行查询校验 | 165 | // 根据 ServerIp以及ServerPort(同时),进行查询校验 |
@@ -66,13 +66,17 @@ public class RabbitController { | @@ -66,13 +66,17 @@ public class RabbitController { | ||
66 | } | 66 | } |
67 | 67 | ||
68 | @PostMapping("/product/new") | 68 | @PostMapping("/product/new") |
69 | - public ResultJson productNew(String SNDR, | ||
70 | - @RequestParam(value = "queueName", required = false) String RCVR, | ||
71 | - @DateTimeFormat(pattern = "yyyyMMddHHmmss") Date DDTM, | ||
72 | - String TYPE, String STYP, | ||
73 | - String TOKN, String SEQN, | ||
74 | - String VSHT, String SERV, | ||
75 | - String content) | 69 | + public ResultJson productNew(@RequestParam(value = "SNDR") String SNDR, |
70 | + @RequestParam(value = "RCVR", required = false) String RCVR, | ||
71 | + @DateTimeFormat(pattern = "yyyyMMddHHmmss") | ||
72 | + @RequestParam(value = "DDTM") Date DDTM, | ||
73 | + @RequestParam(value = "TYPE") String TYPE, | ||
74 | + @RequestParam(value = "STYP") String STYP, | ||
75 | + @RequestParam(value = "TOKN", required = false) String TOKN, | ||
76 | + @RequestParam(value = "SEQN", required = false) String SEQN, | ||
77 | + @RequestParam(value = "VSHT") String VSHT, | ||
78 | + @RequestParam(value = "SERV") String SERV, | ||
79 | + @RequestParam(value = "content") String content) | ||
76 | { | 80 | { |
77 | // 1、获取数据 | 81 | // 1、获取数据 |
78 | XmlData xmlData = XmlData.builder() | 82 | XmlData xmlData = XmlData.builder() |
@@ -92,15 +96,15 @@ public class RabbitController { | @@ -92,15 +96,15 @@ public class RabbitController { | ||
92 | if (!"200".equals(resultJson.getCode())) { | 96 | if (!"200".equals(resultJson.getCode())) { |
93 | return resultJson; | 97 | return resultJson; |
94 | } | 98 | } |
95 | - | 99 | + XmlData sentData = (XmlData) resultJson.getData(); |
96 | // 3、通过格式校验之后,进行配置校验 | 100 | // 3、通过格式校验之后,进行配置校验 |
97 | - Boolean binding = userMessageBindingService.validateXmlBinding(xmlData); | 101 | + Boolean binding = userMessageBindingService.validateXmlBinding(sentData); |
98 | if (!binding) { | 102 | if (!binding) { |
99 | return ResultJson.error(CustomExceptionType.BINDING_ERROR); | 103 | return ResultJson.error(CustomExceptionType.BINDING_ERROR); |
100 | } | 104 | } |
101 | // 4、mq发送消息,数据库中保存消息 | 105 | // 4、mq发送消息,数据库中保存消息 |
102 | ResultJson result = directUtils.sendMessage(); | 106 | ResultJson result = directUtils.sendMessage(); |
103 | 107 | ||
104 | - return ResultJson.success("发送成功", xmlData); | 108 | + return ResultJson.success("发送成功", sentData); |
105 | } | 109 | } |
106 | } | 110 | } |
1 | package com.sunyo.wlpt.message.bus.service.domain; | 1 | package com.sunyo.wlpt.message.bus.service.domain; |
2 | 2 | ||
3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
3 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
4 | import lombok.Builder; | 5 | import lombok.Builder; |
5 | import lombok.Data; | 6 | import lombok.Data; |
@@ -70,6 +71,7 @@ public class XmlData implements Serializable { | @@ -70,6 +71,7 @@ public class XmlData implements Serializable { | ||
70 | * 对应:标签 DDTM -> 发送报文时间 | 71 | * 对应:标签 DDTM -> 发送报文时间 |
71 | */ | 72 | */ |
72 | private String sendTime; | 73 | private String sendTime; |
74 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||
73 | private Date sendDateTime; | 75 | private Date sendDateTime; |
74 | /** | 76 | /** |
75 | * 对应:标签 TYPE -> (一级)交换机名称 | 77 | * 对应:标签 TYPE -> (一级)交换机名称 |
@@ -100,4 +102,10 @@ public class XmlData implements Serializable { | @@ -100,4 +102,10 @@ public class XmlData implements Serializable { | ||
100 | * 对应:标签 SERV -> 指定的服务器 | 102 | * 对应:标签 SERV -> 指定的服务器 |
101 | */ | 103 | */ |
102 | private String serverName; | 104 | private String serverName; |
105 | + | ||
106 | + private String password; | ||
107 | + | ||
108 | + private String hostIp; | ||
109 | + | ||
110 | + private Integer hostPort; | ||
103 | } | 111 | } |
@@ -169,6 +169,7 @@ public class DirectUtils { | @@ -169,6 +169,7 @@ public class DirectUtils { | ||
169 | closeConnectionAndChanel(channel, connection); | 169 | closeConnectionAndChanel(channel, connection); |
170 | } | 170 | } |
171 | 171 | ||
172 | + | ||
172 | /** | 173 | /** |
173 | * DirectExchange的 消息消费者 | 174 | * DirectExchange的 消息消费者 |
174 | * | 175 | * |
@@ -220,6 +221,7 @@ public class DirectUtils { | @@ -220,6 +221,7 @@ public class DirectUtils { | ||
220 | channel.basicConsume(queueName, false, consumer); | 221 | channel.basicConsume(queueName, false, consumer); |
221 | } | 222 | } |
222 | 223 | ||
224 | + | ||
223 | public ResultJson sendMessage() | 225 | public ResultJson sendMessage() |
224 | { | 226 | { |
225 | return new ResultJson<>(); | 227 | return new ResultJson<>(); |
@@ -70,9 +70,9 @@ public interface UserInfoService { | @@ -70,9 +70,9 @@ public interface UserInfoService { | ||
70 | * 判断该用户名是否存在 | 70 | * 判断该用户名是否存在 |
71 | * | 71 | * |
72 | * @param username 用户登录名 | 72 | * @param username 用户登录名 |
73 | - * @return true or false | 73 | + * @return List<UserInfo> |
74 | */ | 74 | */ |
75 | - Boolean selectUserExist(String username); | 75 | + List<UserInfo> selectUserExist(String username); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 |
@@ -62,10 +62,9 @@ public class UserInfoServiceImpl implements UserInfoService { | @@ -62,10 +62,9 @@ public class UserInfoServiceImpl implements UserInfoService { | ||
62 | } | 62 | } |
63 | 63 | ||
64 | @Override | 64 | @Override |
65 | - public Boolean selectUserExist(String username) | 65 | + public List<UserInfo> selectUserExist(String username) |
66 | { | 66 | { |
67 | - List<UserInfo> list = userInfoMapper.selectUserExist(username); | ||
68 | - return list.size() > 0; | 67 | + return userInfoMapper.selectUserExist(username); |
69 | } | 68 | } |
70 | 69 | ||
71 | } | 70 | } |
@@ -37,6 +37,7 @@ public class XmlUtils { | @@ -37,6 +37,7 @@ public class XmlUtils { | ||
37 | @Resource | 37 | @Resource |
38 | private BusExchangeService busExchangeService; | 38 | private BusExchangeService busExchangeService; |
39 | 39 | ||
40 | + @Resource | ||
40 | private RoutingKeyService routingKeyService; | 41 | private RoutingKeyService routingKeyService; |
41 | 42 | ||
42 | @Value("${path.dir}") | 43 | @Value("${path.dir}") |
@@ -104,7 +105,8 @@ public class XmlUtils { | @@ -104,7 +105,8 @@ public class XmlUtils { | ||
104 | // token为空 | 105 | // token为空 |
105 | return ResultJson.error(CustomExceptionType.TOKEN_ERROR); | 106 | return ResultJson.error(CustomExceptionType.TOKEN_ERROR); |
106 | } | 107 | } |
107 | - if (!userInfoService.selectUserExist(xmlData.getSender())) { | 108 | + List<UserInfo> userList = userInfoService.selectUserExist(xmlData.getSender()); |
109 | + if (userList.size() == 0) { | ||
108 | // 发送者不存在 | 110 | // 发送者不存在 |
109 | return ResultJson.error(CustomExceptionType.SENDER_NO_EXIST); | 111 | return ResultJson.error(CustomExceptionType.SENDER_NO_EXIST); |
110 | } | 112 | } |
@@ -137,6 +139,9 @@ public class XmlUtils { | @@ -137,6 +139,9 @@ public class XmlUtils { | ||
137 | // 路由键不存在 | 139 | // 路由键不存在 |
138 | return ResultJson.error(CustomExceptionType.ROUTING_KEY_NO_EXIST); | 140 | return ResultJson.error(CustomExceptionType.ROUTING_KEY_NO_EXIST); |
139 | } | 141 | } |
140 | - return ResultJson.success(); | 142 | + // 获取密码 |
143 | + xmlData.setPassword(userList.get(0).getPassword()); | ||
144 | + ResultJson<XmlData> result = new ResultJson<>("200","通过格式与数据校验",xmlData); | ||
145 | + return result; | ||
141 | } | 146 | } |
142 | } | 147 | } |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | <result column="server_name" jdbcType="VARCHAR" property="serverName"/> | 8 | <result column="server_name" jdbcType="VARCHAR" property="serverName"/> |
9 | <result column="server_name" jdbcType="VARCHAR" property="aliasName"/> | 9 | <result column="server_name" jdbcType="VARCHAR" property="aliasName"/> |
10 | <result column="server_ip" jdbcType="VARCHAR" property="serverIp"/> | 10 | <result column="server_ip" jdbcType="VARCHAR" property="serverIp"/> |
11 | - <result column="server_port" jdbcType="VARCHAR" property="serverPort"/> | 11 | + <result column="server_port" jdbcType="INTEGER" property="serverPort"/> |
12 | <result column="description" jdbcType="VARCHAR" property="description"/> | 12 | <result column="description" jdbcType="VARCHAR" property="description"/> |
13 | <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/> | 13 | <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/> |
14 | <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/> | 14 | <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/> |
@@ -123,7 +123,7 @@ | @@ -123,7 +123,7 @@ | ||
123 | </if> | 123 | </if> |
124 | <!-- 服务器的port --> | 124 | <!-- 服务器的port --> |
125 | <if test="serverPort != null and serverPort != ''"> | 125 | <if test="serverPort != null and serverPort != ''"> |
126 | - AND server_port = #{serverPort,jdbcType=VARCHAR} | 126 | + AND server_port = #{serverPort,jdbcType=INTEGER} |
127 | </if> | 127 | </if> |
128 | </where> | 128 | </where> |
129 | </select> | 129 | </select> |
@@ -140,7 +140,7 @@ | @@ -140,7 +140,7 @@ | ||
140 | server_port, description, gmt_create, | 140 | server_port, description, gmt_create, |
141 | gmt_modified) | 141 | gmt_modified) |
142 | values (#{id,jdbcType=VARCHAR}, #{serverName,jdbcType=VARCHAR}, #{serverIp,jdbcType=VARCHAR}, | 142 | values (#{id,jdbcType=VARCHAR}, #{serverName,jdbcType=VARCHAR}, #{serverIp,jdbcType=VARCHAR}, |
143 | - #{serverPort,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, | 143 | + #{serverPort,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, |
144 | #{gmtModified,jdbcType=TIMESTAMP}) | 144 | #{gmtModified,jdbcType=TIMESTAMP}) |
145 | </insert> | 145 | </insert> |
146 | <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | 146 | <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> |
@@ -180,7 +180,7 @@ | @@ -180,7 +180,7 @@ | ||
180 | #{serverIp,jdbcType=VARCHAR}, | 180 | #{serverIp,jdbcType=VARCHAR}, |
181 | </if> | 181 | </if> |
182 | <if test="serverPort != null"> | 182 | <if test="serverPort != null"> |
183 | - #{serverPort,jdbcType=VARCHAR}, | 183 | + #{serverPort,jdbcType=INTEGER}, |
184 | </if> | 184 | </if> |
185 | <if test="description != null"> | 185 | <if test="description != null"> |
186 | #{description,jdbcType=VARCHAR}, | 186 | #{description,jdbcType=VARCHAR}, |
@@ -204,7 +204,7 @@ | @@ -204,7 +204,7 @@ | ||
204 | server_ip = #{serverIp,jdbcType=VARCHAR}, | 204 | server_ip = #{serverIp,jdbcType=VARCHAR}, |
205 | </if> | 205 | </if> |
206 | <if test="serverPort != null"> | 206 | <if test="serverPort != null"> |
207 | - server_port = #{serverPort,jdbcType=VARCHAR}, | 207 | + server_port = #{serverPort,jdbcType=INTEGER}, |
208 | </if> | 208 | </if> |
209 | <if test="description != null"> | 209 | <if test="description != null"> |
210 | description = #{description,jdbcType=VARCHAR}, | 210 | description = #{description,jdbcType=VARCHAR}, |
@@ -223,7 +223,7 @@ | @@ -223,7 +223,7 @@ | ||
223 | update bus_server | 223 | update bus_server |
224 | set `server_name` = #{serverName,jdbcType=VARCHAR}, | 224 | set `server_name` = #{serverName,jdbcType=VARCHAR}, |
225 | server_ip = #{serverIp,jdbcType=VARCHAR}, | 225 | server_ip = #{serverIp,jdbcType=VARCHAR}, |
226 | - server_port = #{serverPort,jdbcType=VARCHAR}, | 226 | + server_port = #{serverPort,jdbcType=INTEGER}, |
227 | description = #{description,jdbcType=VARCHAR}, | 227 | description = #{description,jdbcType=VARCHAR}, |
228 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, | 228 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, |
229 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | 229 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} |
-
请 注册 或 登录 后发表评论