正在显示
37 个修改的文件
包含
824 行增加
和
64 行删除
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 2 | +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" |
3 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | 3 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
4 | <modelVersion>4.0.0</modelVersion> | 4 | <modelVersion>4.0.0</modelVersion> |
5 | <groupId>com.sunyo.wlpt.message.bus.service</groupId> | 5 | <groupId>com.sunyo.wlpt.message.bus.service</groupId> |
@@ -138,6 +138,13 @@ | @@ -138,6 +138,13 @@ | ||
138 | <artifactId>commons-pool2</artifactId> | 138 | <artifactId>commons-pool2</artifactId> |
139 | </dependency> | 139 | </dependency> |
140 | 140 | ||
141 | + <!-- dom4j解析xml --> | ||
142 | + <dependency> | ||
143 | + <groupId>dom4j</groupId> | ||
144 | + <artifactId>dom4j</artifactId> | ||
145 | + <version>1.6.1</version> | ||
146 | + </dependency> | ||
147 | + | ||
141 | <dependency> | 148 | <dependency> |
142 | <groupId>org.springframework.boot</groupId> | 149 | <groupId>org.springframework.boot</groupId> |
143 | <artifactId>spring-boot-starter-test</artifactId> | 150 | <artifactId>spring-boot-starter-test</artifactId> |
1 | +package com.sunyo.wlpt.message.bus.service.config; | ||
2 | + | ||
3 | +import org.springframework.beans.factory.annotation.Value; | ||
4 | +import org.springframework.context.annotation.Configuration; | ||
5 | +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
6 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author 子诚 | ||
10 | + * Description: | ||
11 | + * 时间:2020/7/28 15:18 | ||
12 | + */ | ||
13 | +@Configuration | ||
14 | +public class MyWebMvcConfigurer implements WebMvcConfigurer { | ||
15 | + @Value("${path.dir}") | ||
16 | + private String dir; | ||
17 | + | ||
18 | + @Override | ||
19 | + public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
20 | + registry.addResourceHandler("/bus/**").addResourceLocations("file:" + dir + "/"); | ||
21 | + WebMvcConfigurer.super.addResourceHandlers(registry); | ||
22 | + } | ||
23 | +} |
@@ -4,12 +4,12 @@ import com.github.pagehelper.PageInfo; | @@ -4,12 +4,12 @@ import com.github.pagehelper.PageInfo; | ||
4 | import com.sunyo.wlpt.message.bus.service.domain.*; | 4 | import com.sunyo.wlpt.message.bus.service.domain.*; |
5 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; | 5 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; |
6 | import com.sunyo.wlpt.message.bus.service.service.*; | 6 | import com.sunyo.wlpt.message.bus.service.service.*; |
7 | -import com.sunyo.wlpt.message.bus.service.utils.IdUtils; | ||
8 | import org.springframework.format.annotation.DateTimeFormat; | 7 | import org.springframework.format.annotation.DateTimeFormat; |
9 | import org.springframework.scheduling.annotation.Scheduled; | 8 | import org.springframework.scheduling.annotation.Scheduled; |
10 | import org.springframework.web.bind.annotation.*; | 9 | import org.springframework.web.bind.annotation.*; |
11 | 10 | ||
12 | import javax.annotation.Resource; | 11 | import javax.annotation.Resource; |
12 | +import javax.validation.constraints.NotNull; | ||
13 | import java.util.Date; | 13 | import java.util.Date; |
14 | 14 | ||
15 | /** | 15 | /** |
@@ -71,7 +71,8 @@ public class MessageNoteController { | @@ -71,7 +71,8 @@ public class MessageNoteController { | ||
71 | @DateTimeFormat(pattern = "yyyy-MM-dd") | 71 | @DateTimeFormat(pattern = "yyyy-MM-dd") |
72 | @RequestParam(value = "receiveTime", required = false) Date receiveTime, | 72 | @RequestParam(value = "receiveTime", required = false) Date receiveTime, |
73 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, | 73 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, |
74 | - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { | 74 | + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) |
75 | + { | ||
75 | // 获取查询参数 | 76 | // 获取查询参数 |
76 | MessageNote messageNote = MessageNote.builder() | 77 | MessageNote messageNote = MessageNote.builder() |
77 | .username(username) | 78 | .username(username) |
@@ -97,8 +98,8 @@ public class MessageNoteController { | @@ -97,8 +98,8 @@ public class MessageNoteController { | ||
97 | * @return {@link ResultJson} | 98 | * @return {@link ResultJson} |
98 | */ | 99 | */ |
99 | @DeleteMapping("/delete") | 100 | @DeleteMapping("/delete") |
100 | - public ResultJson deleteMessageNote(@RequestBody MessageNote messageNote) { | ||
101 | - | 101 | + public ResultJson deleteMessageNote(@RequestBody MessageNote messageNote) |
102 | + { | ||
102 | return messageNoteService.deleteByPrimaryKey(messageNote.getId()) > 0 | 103 | return messageNoteService.deleteByPrimaryKey(messageNote.getId()) > 0 |
103 | ? new ResultJson<>("200", "删除-消息收发记录,成功") | 104 | ? new ResultJson<>("200", "删除-消息收发记录,成功") |
104 | : new ResultJson<>("500", "删除-消息收发记录,失败"); | 105 | : new ResultJson<>("500", "删除-消息收发记录,失败"); |
@@ -111,8 +112,8 @@ public class MessageNoteController { | @@ -111,8 +112,8 @@ public class MessageNoteController { | ||
111 | * @return {@link ResultJson} | 112 | * @return {@link ResultJson} |
112 | */ | 113 | */ |
113 | @GetMapping("/batchRemove") | 114 | @GetMapping("/batchRemove") |
114 | - public ResultJson batchRemoveMessageNote(String ids) { | ||
115 | - | 115 | + public ResultJson batchRemoveMessageNote(String ids) |
116 | + { | ||
116 | return messageNoteService.deleteByPrimaryKey(ids) > 0 | 117 | return messageNoteService.deleteByPrimaryKey(ids) > 0 |
117 | ? new ResultJson<>("200", "删除-消息收发记录,成功") | 118 | ? new ResultJson<>("200", "删除-消息收发记录,成功") |
118 | : new ResultJson<>("500", "删除-消息收发记录,失败"); | 119 | : new ResultJson<>("500", "删除-消息收发记录,失败"); |
@@ -125,8 +126,8 @@ public class MessageNoteController { | @@ -125,8 +126,8 @@ public class MessageNoteController { | ||
125 | * @return {@link ResultJson} | 126 | * @return {@link ResultJson} |
126 | */ | 127 | */ |
127 | @PutMapping("/update") | 128 | @PutMapping("/update") |
128 | - public ResultJson updateMessageNote(@RequestBody MessageNote messageNote) { | ||
129 | - | 129 | + public ResultJson updateMessageNote(@RequestBody MessageNote messageNote) |
130 | + { | ||
130 | return messageNoteService.updateByPrimaryKeySelective(note_fillName(messageNote)) > 0 | 131 | return messageNoteService.updateByPrimaryKeySelective(note_fillName(messageNote)) > 0 |
131 | ? new ResultJson<>("200", "编辑-消息收发记录,成功") | 132 | ? new ResultJson<>("200", "编辑-消息收发记录,成功") |
132 | : new ResultJson<>("500", "编辑-消息收发记录,失败"); | 133 | : new ResultJson<>("500", "编辑-消息收发记录,失败"); |
@@ -139,10 +140,9 @@ public class MessageNoteController { | @@ -139,10 +140,9 @@ public class MessageNoteController { | ||
139 | * @return {@link ResultJson} | 140 | * @return {@link ResultJson} |
140 | */ | 141 | */ |
141 | @PostMapping("/insert") | 142 | @PostMapping("/insert") |
142 | - public ResultJson insertMessageNote(@RequestBody MessageNote messageNote) { | ||
143 | - // 设置id | ||
144 | - messageNote.setId(IdUtils.generateId()); | ||
145 | - return messageNoteService.insertSelective(note_fillName(messageNote)) > 0 | 143 | + public ResultJson insertMessageNote(@RequestBody @NotNull MessageNote messageNote) |
144 | + { | ||
145 | + return messageNoteService.insertSelective(messageNote) > 0 | ||
146 | ? new ResultJson<>("200", "编辑-消息收发记录,成功") | 146 | ? new ResultJson<>("200", "编辑-消息收发记录,成功") |
147 | : new ResultJson<>("500", "编辑-消息收发记录,失败"); | 147 | : new ResultJson<>("500", "编辑-消息收发记录,失败"); |
148 | } | 148 | } |
@@ -153,10 +153,11 @@ public class MessageNoteController { | @@ -153,10 +153,11 @@ public class MessageNoteController { | ||
153 | */ | 153 | */ |
154 | @Scheduled(cron = "0 0 4 * * ? ") | 154 | @Scheduled(cron = "0 0 4 * * ? ") |
155 | @GetMapping("/autoDelete") | 155 | @GetMapping("/autoDelete") |
156 | - public void autoDeleteMessageNote() { | 156 | + public void autoDeleteMessageNote() |
157 | + { | ||
157 | // 类型 | 158 | // 类型 |
158 | String deleteType = "message_note"; | 159 | String deleteType = "message_note"; |
159 | - // 首先获取可自主设置的默认时间 | 160 | + // 获取时间 |
160 | SchedulingDelete schedulingDelete = schedulingDeleteService.selectByType(deleteType); | 161 | SchedulingDelete schedulingDelete = schedulingDeleteService.selectByType(deleteType); |
161 | Integer deleteTime = schedulingDelete.getDeleteTime(); | 162 | Integer deleteTime = schedulingDelete.getDeleteTime(); |
162 | // 定时自动删除 | 163 | // 定时自动删除 |
@@ -169,7 +170,9 @@ public class MessageNoteController { | @@ -169,7 +170,9 @@ public class MessageNoteController { | ||
169 | * @param messageNote {@link MessageNote} | 170 | * @param messageNote {@link MessageNote} |
170 | * @return {@link MessageNote} | 171 | * @return {@link MessageNote} |
171 | */ | 172 | */ |
172 | - public MessageNote note_fillName(MessageNote messageNote) { | 173 | + public MessageNote note_fillName(MessageNote messageNote) |
174 | + { | ||
175 | + | ||
173 | // 填充,发送内容(编辑 or 新增) | 176 | // 填充,发送内容(编辑 or 新增) |
174 | messageNote.setSendContent(messageNote.getAlias_sendContent().getBytes()); | 177 | messageNote.setSendContent(messageNote.getAlias_sendContent().getBytes()); |
175 | 178 | ||
@@ -186,8 +189,8 @@ public class MessageNoteController { | @@ -186,8 +189,8 @@ public class MessageNoteController { | ||
186 | messageNote.setExchangeName(busExchange.getExchangeName()); | 189 | messageNote.setExchangeName(busExchange.getExchangeName()); |
187 | 190 | ||
188 | // 填充,队列名称 | 191 | // 填充,队列名称 |
189 | - BusQueue busQueue = busQueueService.selectByPrimaryKey(messageNote.getQueueId()); | ||
190 | - messageNote.setQueueName(busQueue.getQueueName()); | 192 | +// BusQueue busQueue = busQueueService.selectByPrimaryKey(messageNote.getQueueId()); |
193 | +// messageNote.setQueueName(busQueue.getQueueName()); | ||
191 | 194 | ||
192 | // 填充,路由键名称 | 195 | // 填充,路由键名称 |
193 | RoutingKey routingKey = routingKeyService.selectByPrimaryKey(messageNote.getRoutingKeyId()); | 196 | RoutingKey routingKey = routingKeyService.selectByPrimaryKey(messageNote.getRoutingKeyId()); |
1 | package com.sunyo.wlpt.message.bus.service.controller; | 1 | package com.sunyo.wlpt.message.bus.service.controller; |
2 | 2 | ||
3 | -import com.sunyo.wlpt.message.bus.service.rabbit.test.TestProduct; | 3 | +import com.sunyo.wlpt.message.bus.service.domain.XmlData; |
4 | +import com.sunyo.wlpt.message.bus.service.exception.CustomExceptionType; | ||
4 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.DirectUtils; | 5 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.DirectUtils; |
5 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; | 6 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; |
6 | -import org.springframework.web.bind.annotation.CrossOrigin; | ||
7 | -import org.springframework.web.bind.annotation.GetMapping; | ||
8 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
9 | -import org.springframework.web.bind.annotation.RestController; | 7 | +import com.sunyo.wlpt.message.bus.service.response.ResultJson; |
8 | +import com.sunyo.wlpt.message.bus.service.service.UserMessageBindingService; | ||
9 | +import com.sunyo.wlpt.message.bus.service.utils.XmlUtils; | ||
10 | +import org.dom4j.DocumentException; | ||
11 | +import org.springframework.format.annotation.DateTimeFormat; | ||
12 | +import org.springframework.web.bind.annotation.*; | ||
10 | 13 | ||
11 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
12 | import java.io.IOException; | 15 | import java.io.IOException; |
16 | +import java.util.Date; | ||
13 | import java.util.concurrent.TimeoutException; | 17 | import java.util.concurrent.TimeoutException; |
14 | 18 | ||
15 | /** | 19 | /** |
@@ -21,9 +25,11 @@ import java.util.concurrent.TimeoutException; | @@ -21,9 +25,11 @@ import java.util.concurrent.TimeoutException; | ||
21 | @RequestMapping("bus/rabbit") | 25 | @RequestMapping("bus/rabbit") |
22 | @RestController | 26 | @RestController |
23 | public class RabbitController { | 27 | public class RabbitController { |
28 | + @Resource | ||
29 | + private UserMessageBindingService userMessageBindingService; | ||
24 | 30 | ||
25 | @Resource | 31 | @Resource |
26 | - private TestProduct testProduct; | 32 | + private XmlUtils xmlUtils; |
27 | 33 | ||
28 | @Resource | 34 | @Resource |
29 | private RabbitUtils rabbitUtils; | 35 | private RabbitUtils rabbitUtils; |
@@ -31,18 +37,70 @@ public class RabbitController { | @@ -31,18 +37,70 @@ public class RabbitController { | ||
31 | @Resource | 37 | @Resource |
32 | private DirectUtils directUtils; | 38 | private DirectUtils directUtils; |
33 | 39 | ||
34 | - @GetMapping("/test/product") | ||
35 | - public void product() throws IOException, TimeoutException | ||
36 | - { | ||
37 | - rabbitUtils.createExchange("E_zicheng"); | ||
38 | - rabbitUtils.createQueue("Q_zicheng"); | ||
39 | - rabbitUtils.createBing("E_zicheng","Q_zicheng","R_zicheng"); | ||
40 | - directUtils.directProducer("E_zicheng", "R_zicheng", "2020-7-21,进行测试->" + Math.random() * 100); | ||
41 | - } | ||
42 | - | ||
43 | @GetMapping("/test/consumer") | 40 | @GetMapping("/test/consumer") |
44 | public void consumer() throws IOException, TimeoutException | 41 | public void consumer() throws IOException, TimeoutException |
45 | { | 42 | { |
46 | directUtils.directConsumer("Q_zicheng", "E_zicheng", "R_zicheng"); | 43 | directUtils.directConsumer("Q_zicheng", "E_zicheng", "R_zicheng"); |
47 | } | 44 | } |
45 | + | ||
46 | + @PostMapping("/product/old") | ||
47 | + public ResultJson productOld(String xmlStr) throws DocumentException | ||
48 | + { | ||
49 | + // 1、解析 xml 文件,获取数据 | ||
50 | + XmlData xmlData = xmlUtils.parsingMessage(xmlStr); | ||
51 | + | ||
52 | + // 2、校验格式、数据 | ||
53 | + ResultJson resultJson = xmlUtils.checkFormatAndData(xmlData); | ||
54 | + if (!"200".equals(resultJson.getCode())) { | ||
55 | + return resultJson; | ||
56 | + } | ||
57 | + | ||
58 | + // 3、通过格式校验之后,进行配置校验 | ||
59 | + Boolean binding = userMessageBindingService.validateXmlBinding(xmlData); | ||
60 | + if (!binding) { | ||
61 | + return ResultJson.error(CustomExceptionType.BINDING_ERROR); | ||
62 | + } | ||
63 | + | ||
64 | + // 4、发送消息,并讲消息存放到数据库中 | ||
65 | + return ResultJson.success("发送成功"); | ||
66 | + } | ||
67 | + | ||
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) | ||
76 | + { | ||
77 | + // 1、获取数据 | ||
78 | + XmlData xmlData = XmlData.builder() | ||
79 | + .sender(SNDR) | ||
80 | + .queueName(RCVR) | ||
81 | + .sendDateTime(DDTM) | ||
82 | + .exchangeName(TYPE) | ||
83 | + .routingKeyName(STYP) | ||
84 | + .token(TOKN) | ||
85 | + .sequence(SEQN) | ||
86 | + .virtualHostName(VSHT) | ||
87 | + .serverName(SERV) | ||
88 | + .sendContent(content) | ||
89 | + .build(); | ||
90 | + // 2、校验格式、数据 | ||
91 | + ResultJson resultJson = xmlUtils.checkFormatAndData(xmlData); | ||
92 | + if (!"200".equals(resultJson.getCode())) { | ||
93 | + return resultJson; | ||
94 | + } | ||
95 | + | ||
96 | + // 3、通过格式校验之后,进行配置校验 | ||
97 | + Boolean binding = userMessageBindingService.validateXmlBinding(xmlData); | ||
98 | + if (!binding) { | ||
99 | + return ResultJson.error(CustomExceptionType.BINDING_ERROR); | ||
100 | + } | ||
101 | + // 4、mq发送消息,数据库中保存消息 | ||
102 | + ResultJson result = directUtils.sendMessage(); | ||
103 | + | ||
104 | + return ResultJson.success("发送成功", xmlData); | ||
105 | + } | ||
48 | } | 106 | } |
1 | +package com.sunyo.wlpt.message.bus.service.domain; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Builder; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.NoArgsConstructor; | ||
7 | + | ||
8 | +import java.io.Serializable; | ||
9 | +import java.util.Date; | ||
10 | +// 报文模板,如下 | ||
11 | +/* | ||
12 | + <?xml version="1.0" encoding="UTF-8"?> | ||
13 | + <MSG> | ||
14 | + <META> | ||
15 | + <SNDR> 消息发送者账号 </SNDR> | ||
16 | + <RCVR> 指定接受者 </RCVR> | ||
17 | + <DDTM> 发送报文时间 </DDTM> | ||
18 | + <TYPE> 大类型--交换机名称 </TYPE> | ||
19 | + <STYP> 子类型--路由键名称 </STYP> | ||
20 | + <SEQN> 序列号(唯一) </SEQN> | ||
21 | + <TOKN> token值 </TOKN> | ||
22 | + <VSHT> 虚拟机名称 </VSHT> | ||
23 | + <SERV> MQ服务器名称 </SERV> | ||
24 | + </META> | ||
25 | + <BODY> | ||
26 | + 发送内容 | ||
27 | + </BODY> | ||
28 | + </MSG> | ||
29 | + */ | ||
30 | + | ||
31 | +/** | ||
32 | + * @author 子诚 | ||
33 | + * Description: | ||
34 | + * 时间:2020/7/28 10:30 | ||
35 | + */ | ||
36 | +@Data | ||
37 | +@Builder | ||
38 | +@NoArgsConstructor | ||
39 | +@AllArgsConstructor | ||
40 | +public class XmlData implements Serializable { | ||
41 | + | ||
42 | + private static final long serialVersionUID = -2539052741259114774L; | ||
43 | + | ||
44 | + /** | ||
45 | + * 对应:根标签 MSG ->报文 | ||
46 | + */ | ||
47 | + private String message; | ||
48 | + | ||
49 | + /** | ||
50 | + * 对应:标签 BODY -> 发送内容 | ||
51 | + */ | ||
52 | + private String sendContent; | ||
53 | + | ||
54 | + /** | ||
55 | + * 对应:标签 META -> 报文的头部信息 | ||
56 | + */ | ||
57 | + private String meta; | ||
58 | + | ||
59 | + /** | ||
60 | + * 对应:标签 SNDR -> 报文发送者(用户) | ||
61 | + */ | ||
62 | + private String sender; | ||
63 | + | ||
64 | + /** | ||
65 | + * 对应:标签 RCVR -> 指定接收者(队列名称) | ||
66 | + */ | ||
67 | + private String queueName; | ||
68 | + | ||
69 | + /** | ||
70 | + * 对应:标签 DDTM -> 发送报文时间 | ||
71 | + */ | ||
72 | + private String sendTime; | ||
73 | + private Date sendDateTime; | ||
74 | + /** | ||
75 | + * 对应:标签 TYPE -> (一级)交换机名称 | ||
76 | + */ | ||
77 | + private String exchangeName; | ||
78 | + | ||
79 | + /** | ||
80 | + * 对应:标签 STYP -> (二级)路由键名称 | ||
81 | + */ | ||
82 | + private String routingKeyName; | ||
83 | + | ||
84 | + /** | ||
85 | + * 对应:标签 SEQN -> 序列(唯一) | ||
86 | + */ | ||
87 | + private String sequence; | ||
88 | + | ||
89 | + /** | ||
90 | + * 对应:标签 TOKN -> JWT生成的 token 值 | ||
91 | + */ | ||
92 | + private String token; | ||
93 | + | ||
94 | + /** | ||
95 | + * 对应:标签 VSHT -> 指定的虚拟主机 | ||
96 | + */ | ||
97 | + private String virtualHostName; | ||
98 | + | ||
99 | + /** | ||
100 | + * 对应:标签 SERV -> 指定的服务器 | ||
101 | + */ | ||
102 | + private String serverName; | ||
103 | +} |
@@ -7,6 +7,22 @@ package com.sunyo.wlpt.message.bus.service.exception; | @@ -7,6 +7,22 @@ package com.sunyo.wlpt.message.bus.service.exception; | ||
7 | */ | 7 | */ |
8 | 8 | ||
9 | public enum CustomExceptionType { | 9 | public enum CustomExceptionType { |
10 | + BINDING_ERROR("10501", "配置信息,未进行绑定!"), | ||
11 | + | ||
12 | + SENDER_ERROR("10401", "报文格式错误,发送者不能为空!"), | ||
13 | + CONTENT_ERROR("10402", "报文格式错误,消息内容不能为空!"), | ||
14 | + SERVER_ERROR("10403", "报文格式错误,服务器名称不能为空!"), | ||
15 | + HOST_ERROR("10404", "报文格式错误,虚拟主机名称不能为空!"), | ||
16 | + EXCHANGE_ERROR("10405", "报文格式错误,交换机名称不能为空!"), | ||
17 | + ROUTING_KEY_ERROR("10406", "报文格式错误,路由键名称不能为空!"), | ||
18 | + SEQUENCE_ERROR("10407", "报文格式错误,序列不能为空!"), | ||
19 | + TOKEN_ERROR("10408", "报文格式错误,token不能为空!"), | ||
20 | + | ||
21 | + SENDER_NO_EXIST("20401", "报文数据错误,发送者不存在!"), | ||
22 | + SERVER_NO_EXIST("20403", "报文数据错误,服务器不存在!"), | ||
23 | + HOST_NO_EXIST("20404", "报文数据错误,虚拟主机不存在!"), | ||
24 | + EXCHANGE_NO_EXIST("20405", "报文数据错误,交换机不存在!"), | ||
25 | + ROUTING_KEY_NO_EXIST("20406", "报文数据错误,路由键不存在!"), | ||
10 | 26 | ||
11 | CLIENT_ERROR("400", "客户端异常"), | 27 | CLIENT_ERROR("400", "客户端异常"), |
12 | SYSTEM_ERROR("500", "系统服务异常"), | 28 | SYSTEM_ERROR("500", "系统服务异常"), |
@@ -21,16 +37,19 @@ public enum CustomExceptionType { | @@ -21,16 +37,19 @@ public enum CustomExceptionType { | ||
21 | */ | 37 | */ |
22 | private String msg; | 38 | private String msg; |
23 | 39 | ||
24 | - CustomExceptionType(String code, String msg) { | 40 | + CustomExceptionType(String code, String msg) |
41 | + { | ||
25 | this.code = code; | 42 | this.code = code; |
26 | this.msg = msg; | 43 | this.msg = msg; |
27 | } | 44 | } |
28 | 45 | ||
29 | - public String getCode() { | 46 | + public String getCode() |
47 | + { | ||
30 | return code; | 48 | return code; |
31 | } | 49 | } |
32 | 50 | ||
33 | - public String getMsg() { | 51 | + public String getMsg() |
52 | + { | ||
34 | return msg; | 53 | return msg; |
35 | } | 54 | } |
36 | 55 |
@@ -84,4 +84,12 @@ public interface BusExchangeMapper { | @@ -84,4 +84,12 @@ public interface BusExchangeMapper { | ||
84 | * @return List<BusExchange> | 84 | * @return List<BusExchange> |
85 | */ | 85 | */ |
86 | List<BusExchange> getExchangeList(BusExchange busExchange); | 86 | List<BusExchange> getExchangeList(BusExchange busExchange); |
87 | + | ||
88 | + /** | ||
89 | + * 检验交换机是否存在 | ||
90 | + * | ||
91 | + * @param exchange {@link BusExchange} | ||
92 | + * @return List<BusExchange> | ||
93 | + */ | ||
94 | + List<BusExchange> selectExchangeExist(BusExchange exchange); | ||
87 | } | 95 | } |
@@ -2,6 +2,7 @@ package com.sunyo.wlpt.message.bus.service.mapper; | @@ -2,6 +2,7 @@ package com.sunyo.wlpt.message.bus.service.mapper; | ||
2 | 2 | ||
3 | import com.sunyo.wlpt.message.bus.service.domain.BusServer; | 3 | import com.sunyo.wlpt.message.bus.service.domain.BusServer; |
4 | import org.apache.ibatis.annotations.Mapper; | 4 | import org.apache.ibatis.annotations.Mapper; |
5 | +import org.apache.ibatis.annotations.Param; | ||
5 | 6 | ||
6 | import java.util.List; | 7 | import java.util.List; |
7 | 8 | ||
@@ -107,4 +108,12 @@ public interface BusServerMapper { | @@ -107,4 +108,12 @@ public interface BusServerMapper { | ||
107 | * @return List<BusServer> | 108 | * @return List<BusServer> |
108 | */ | 109 | */ |
109 | List<BusServer> getServerAndHostAndExchangeList(); | 110 | List<BusServer> getServerAndHostAndExchangeList(); |
111 | + | ||
112 | + /** | ||
113 | + * 检验用户名是否存在 | ||
114 | + * | ||
115 | + * @param serverName 服务器名称 | ||
116 | + * @return List<BusServer> | ||
117 | + */ | ||
118 | + List<BusServer> selectServerExist(@Param("serverName") String serverName); | ||
110 | } | 119 | } |
@@ -84,4 +84,12 @@ public interface RoutingKeyMapper { | @@ -84,4 +84,12 @@ public interface RoutingKeyMapper { | ||
84 | * @return List<RoutingKey> | 84 | * @return List<RoutingKey> |
85 | */ | 85 | */ |
86 | List<RoutingKey> getRoutingKeyList(RoutingKey routingKey); | 86 | List<RoutingKey> getRoutingKeyList(RoutingKey routingKey); |
87 | + | ||
88 | + /** | ||
89 | + * 检验路由键是否存在,根据交换机id和路由键名称 | ||
90 | + * | ||
91 | + * @param routingKey 路由键 | ||
92 | + * @return List<RoutingKey> | ||
93 | + */ | ||
94 | + List<RoutingKey> selectRoutingKeyExist(RoutingKey routingKey); | ||
87 | } | 95 | } |
1 | package com.sunyo.wlpt.message.bus.service.mapper; | 1 | package com.sunyo.wlpt.message.bus.service.mapper; |
2 | 2 | ||
3 | import com.sunyo.wlpt.message.bus.service.domain.UserInfo; | 3 | import com.sunyo.wlpt.message.bus.service.domain.UserInfo; |
4 | -import org.apache.ibatis.annotations.Mapper;import java.util.List; | 4 | +import org.apache.ibatis.annotations.Mapper; |
5 | +import org.apache.ibatis.annotations.Param; | ||
6 | + | ||
7 | +import java.util.List; | ||
5 | 8 | ||
6 | /** | 9 | /** |
7 | * @author 子诚 | 10 | * @author 子诚 |
@@ -64,4 +67,12 @@ public interface UserInfoMapper { | @@ -64,4 +67,12 @@ public interface UserInfoMapper { | ||
64 | * @return 用户信息集合 | 67 | * @return 用户信息集合 |
65 | */ | 68 | */ |
66 | List<UserInfo> getUserInfoList(); | 69 | List<UserInfo> getUserInfoList(); |
70 | + | ||
71 | + /** | ||
72 | + * 判断该用户名是否存在 | ||
73 | + * | ||
74 | + * @param username 用户登录名 | ||
75 | + * @return 用户列表 | ||
76 | + */ | ||
77 | + List<UserInfo> selectUserExist(@Param("username") String username); | ||
67 | } | 78 | } |
1 | package com.sunyo.wlpt.message.bus.service.mapper; | 1 | package com.sunyo.wlpt.message.bus.service.mapper; |
2 | 2 | ||
3 | +import com.sunyo.wlpt.message.bus.service.domain.MessageNote; | ||
3 | import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding; | 4 | import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding; |
4 | -import org.apache.ibatis.annotations.Mapper;import java.util.List; | 5 | +import com.sunyo.wlpt.message.bus.service.domain.XmlData; |
6 | +import org.apache.ibatis.annotations.Mapper; | ||
7 | + | ||
8 | +import java.util.List; | ||
5 | 9 | ||
6 | /** | 10 | /** |
7 | * @author 子诚 | 11 | * @author 子诚 |
@@ -73,4 +77,21 @@ public interface UserMessageBindingMapper { | @@ -73,4 +77,21 @@ public interface UserMessageBindingMapper { | ||
73 | * @return 判断校验是否通过 | 77 | * @return 判断校验是否通过 |
74 | */ | 78 | */ |
75 | List<UserMessageBinding> validateBinding(UserMessageBinding userMessageBinding); | 79 | List<UserMessageBinding> validateBinding(UserMessageBinding userMessageBinding); |
80 | + | ||
81 | + /** | ||
82 | + * 发送信息之前的检验配置是否存在 | ||
83 | + * | ||
84 | + * @param messageNote {@link MessageNote} | ||
85 | + * @return 判断校验是否通过 | ||
86 | + */ | ||
87 | + List<UserMessageBinding> validateNote(MessageNote messageNote); | ||
88 | + | ||
89 | + | ||
90 | + /** | ||
91 | + * 校验报文配置与否? | ||
92 | + * | ||
93 | + * @param xmlData {@link XmlData} | ||
94 | + * @return 判断校验是否通过 | ||
95 | + */ | ||
96 | + List<UserMessageBinding> validateXmlBinding(XmlData xmlData); | ||
76 | } | 97 | } |
@@ -84,4 +84,11 @@ public interface VirtualHostMapper { | @@ -84,4 +84,11 @@ public interface VirtualHostMapper { | ||
84 | * @return 虚拟主机列表 | 84 | * @return 虚拟主机列表 |
85 | */ | 85 | */ |
86 | List<VirtualHost> getVirtualHostList(VirtualHost virtualHost); | 86 | List<VirtualHost> getVirtualHostList(VirtualHost virtualHost); |
87 | + | ||
88 | + /** | ||
89 | + * 检验是否存在 | ||
90 | + * @param virtualHost {@link VirtualHost} | ||
91 | + * @return List<VirtualHost> | ||
92 | + */ | ||
93 | + List<VirtualHost> selectVirtualHostExist(VirtualHost virtualHost); | ||
87 | } | 94 | } |
1 | package com.sunyo.wlpt.message.bus.service.rabbit.utils; | 1 | package com.sunyo.wlpt.message.bus.service.rabbit.utils; |
2 | 2 | ||
3 | import com.rabbitmq.client.*; | 3 | import com.rabbitmq.client.*; |
4 | +import com.sunyo.wlpt.message.bus.service.response.ResultJson; | ||
4 | import com.sunyo.wlpt.message.bus.service.utils.IdUtils; | 5 | import com.sunyo.wlpt.message.bus.service.utils.IdUtils; |
5 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -87,8 +88,7 @@ public class DirectUtils { | @@ -87,8 +88,7 @@ public class DirectUtils { | ||
87 | factory.setUsername(userName); | 88 | factory.setUsername(userName); |
88 | factory.setPassword(password); | 89 | factory.setPassword(password); |
89 | // 通过工程获取连接 | 90 | // 通过工程获取连接 |
90 | - Connection connection = factory.newConnection(); | ||
91 | - return connection; | 91 | + return factory.newConnection(); |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
@@ -219,6 +219,11 @@ public class DirectUtils { | @@ -219,6 +219,11 @@ public class DirectUtils { | ||
219 | // 消费消息 | 219 | // 消费消息 |
220 | channel.basicConsume(queueName, false, consumer); | 220 | channel.basicConsume(queueName, false, consumer); |
221 | } | 221 | } |
222 | + | ||
223 | + public ResultJson sendMessage() | ||
224 | + { | ||
225 | + return new ResultJson<>(); | ||
226 | + } | ||
222 | } | 227 | } |
223 | 228 | ||
224 | 229 |
@@ -44,7 +44,8 @@ public class ResultJson<T> implements Serializable { | @@ -44,7 +44,8 @@ public class ResultJson<T> implements Serializable { | ||
44 | /** | 44 | /** |
45 | * 无参,构造方法 | 45 | * 无参,构造方法 |
46 | */ | 46 | */ |
47 | - public ResultJson() { | 47 | + public ResultJson() |
48 | + { | ||
48 | } | 49 | } |
49 | 50 | ||
50 | /** | 51 | /** |
@@ -53,7 +54,8 @@ public class ResultJson<T> implements Serializable { | @@ -53,7 +54,8 @@ public class ResultJson<T> implements Serializable { | ||
53 | * @param code 响应状态 | 54 | * @param code 响应状态 |
54 | * @param msg 响应消息 | 55 | * @param msg 响应消息 |
55 | */ | 56 | */ |
56 | - public ResultJson(String code, String msg) { | 57 | + public ResultJson(String code, String msg) |
58 | + { | ||
57 | this.code = code; | 59 | this.code = code; |
58 | this.msg = msg; | 60 | this.msg = msg; |
59 | } | 61 | } |
@@ -65,7 +67,8 @@ public class ResultJson<T> implements Serializable { | @@ -65,7 +67,8 @@ public class ResultJson<T> implements Serializable { | ||
65 | * @param msg 响应消息 | 67 | * @param msg 响应消息 |
66 | * @param data 响应数据 | 68 | * @param data 响应数据 |
67 | */ | 69 | */ |
68 | - public ResultJson(String code, String msg, T data) { | 70 | + public ResultJson(String code, String msg, T data) |
71 | + { | ||
69 | this.code = code; | 72 | this.code = code; |
70 | this.msg = msg; | 73 | this.msg = msg; |
71 | this.data = data; | 74 | this.data = data; |
@@ -76,7 +79,8 @@ public class ResultJson<T> implements Serializable { | @@ -76,7 +79,8 @@ public class ResultJson<T> implements Serializable { | ||
76 | * | 79 | * |
77 | * @return 成功(没有响应数据) | 80 | * @return 成功(没有响应数据) |
78 | */ | 81 | */ |
79 | - public static ResultJson success() { | 82 | + public static ResultJson success() |
83 | + { | ||
80 | return new ResultJson<>("200", "success"); | 84 | return new ResultJson<>("200", "success"); |
81 | } | 85 | } |
82 | 86 | ||
@@ -85,17 +89,29 @@ public class ResultJson<T> implements Serializable { | @@ -85,17 +89,29 @@ public class ResultJson<T> implements Serializable { | ||
85 | * | 89 | * |
86 | * @return 成功(响应数据) | 90 | * @return 成功(响应数据) |
87 | */ | 91 | */ |
88 | - public static ResultJson success(Object data) { | 92 | + public static ResultJson success(Object data) |
93 | + { | ||
89 | return new ResultJson<>("200", "success", data); | 94 | return new ResultJson<>("200", "success", data); |
90 | } | 95 | } |
91 | 96 | ||
92 | /** | 97 | /** |
98 | + * 定义静态、成功方法(重载) | ||
99 | + * | ||
100 | + * @return 成功(响应数据) | ||
101 | + */ | ||
102 | + public static ResultJson success(String message, Object data) | ||
103 | + { | ||
104 | + return new ResultJson<>("200", message, data); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
93 | * 请求出现异常时的响应数据封装 | 108 | * 请求出现异常时的响应数据封装 |
94 | * | 109 | * |
95 | * @param e 自定义异常类 | 110 | * @param e 自定义异常类 |
96 | * @return 返回异常信息 | 111 | * @return 返回异常信息 |
97 | */ | 112 | */ |
98 | - public static ResultJson error(CustomException e) { | 113 | + public static ResultJson error(CustomException e) |
114 | + { | ||
99 | ResultJson result = new ResultJson<>(); | 115 | ResultJson result = new ResultJson<>(); |
100 | result.setCode(e.getCode()); | 116 | result.setCode(e.getCode()); |
101 | if (e.getCode() == CustomExceptionType.CLIENT_ERROR.getCode()) { | 117 | if (e.getCode() == CustomExceptionType.CLIENT_ERROR.getCode()) { |
@@ -109,15 +125,13 @@ public class ResultJson<T> implements Serializable { | @@ -109,15 +125,13 @@ public class ResultJson<T> implements Serializable { | ||
109 | return result; | 125 | return result; |
110 | } | 126 | } |
111 | 127 | ||
112 | - | ||
113 | - /** | ||
114 | - * 请求出现异常时的响应数据封装 | ||
115 | - * | ||
116 | - * @param customExceptionType 自定义异常枚举中的异常 | ||
117 | - * @param errorMessage 错误信息 | ||
118 | - * @return 返回异常信息 | ||
119 | - */ | ||
120 | - public static ResultJson error(CustomExceptionType customExceptionType, String errorMessage) { | 128 | + public static ResultJson error(CustomExceptionType customExceptionType, String errorMessage) |
129 | + { | ||
121 | return new ResultJson<>(customExceptionType.getCode(), errorMessage); | 130 | return new ResultJson<>(customExceptionType.getCode(), errorMessage); |
122 | } | 131 | } |
132 | + | ||
133 | + public static ResultJson error(CustomExceptionType customExceptionType) | ||
134 | + { | ||
135 | + return new ResultJson<>(customExceptionType.getCode(), customExceptionType.getMsg()); | ||
136 | + } | ||
123 | } | 137 | } |
@@ -2,7 +2,6 @@ package com.sunyo.wlpt.message.bus.service.service; | @@ -2,7 +2,6 @@ package com.sunyo.wlpt.message.bus.service.service; | ||
2 | 2 | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | import com.sunyo.wlpt.message.bus.service.domain.BusExchange; | 4 | import com.sunyo.wlpt.message.bus.service.domain.BusExchange; |
5 | -import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | ||
6 | 5 | ||
7 | import java.util.List; | 6 | import java.util.List; |
8 | 7 | ||
@@ -87,4 +86,12 @@ public interface BusExchangeService { | @@ -87,4 +86,12 @@ public interface BusExchangeService { | ||
87 | * @return List<BusExchange> | 86 | * @return List<BusExchange> |
88 | */ | 87 | */ |
89 | List<BusExchange> getExchangeList(BusExchange busExchange); | 88 | List<BusExchange> getExchangeList(BusExchange busExchange); |
89 | + | ||
90 | + /** | ||
91 | + * 检验交换机是否存在 | ||
92 | + * | ||
93 | + * @param exchange {@link BusExchange} | ||
94 | + * @return List<BusExchange> | ||
95 | + */ | ||
96 | + List<BusExchange> selectExchangeExist(BusExchange exchange); | ||
90 | } | 97 | } |
@@ -109,5 +109,10 @@ public interface BusServerService { | @@ -109,5 +109,10 @@ public interface BusServerService { | ||
109 | */ | 109 | */ |
110 | List<BusServer> getServerAndHostAndExchangeList(); | 110 | List<BusServer> getServerAndHostAndExchangeList(); |
111 | 111 | ||
112 | - | 112 | + /** |
113 | + * 查询服务器名称是否存在 | ||
114 | + * @param serverName 服务器名称 | ||
115 | + * @return true or false | ||
116 | + */ | ||
117 | + List<BusServer> selectServerExist(String serverName); | ||
113 | } | 118 | } |
1 | package com.sunyo.wlpt.message.bus.service.service; | 1 | package com.sunyo.wlpt.message.bus.service.service; |
2 | 2 | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | -import com.sunyo.wlpt.message.bus.service.domain.BusExchange; | ||
5 | import com.sunyo.wlpt.message.bus.service.domain.RoutingKey; | 4 | import com.sunyo.wlpt.message.bus.service.domain.RoutingKey; |
6 | 5 | ||
7 | import java.util.List; | 6 | import java.util.List; |
@@ -86,4 +85,12 @@ public interface RoutingKeyService { | @@ -86,4 +85,12 @@ public interface RoutingKeyService { | ||
86 | * @return List<RoutingKey> | 85 | * @return List<RoutingKey> |
87 | */ | 86 | */ |
88 | List<RoutingKey> getRoutingKeyList(RoutingKey routingKey); | 87 | List<RoutingKey> getRoutingKeyList(RoutingKey routingKey); |
88 | + | ||
89 | + /** | ||
90 | + * 检验路由键是否存在,根据交换机id和路由键名称 | ||
91 | + * | ||
92 | + * @param routingKey 路由键 | ||
93 | + * @return List<RoutingKey> | ||
94 | + */ | ||
95 | + List<RoutingKey> selectRoutingKeyExist(RoutingKey routingKey); | ||
89 | } | 96 | } |
@@ -65,6 +65,14 @@ public interface UserInfoService { | @@ -65,6 +65,14 @@ public interface UserInfoService { | ||
65 | * @return 用户信息集合 | 65 | * @return 用户信息集合 |
66 | */ | 66 | */ |
67 | List<UserInfo> getUserInfoList(); | 67 | List<UserInfo> getUserInfoList(); |
68 | + | ||
69 | + /** | ||
70 | + * 判断该用户名是否存在 | ||
71 | + * | ||
72 | + * @param username 用户登录名 | ||
73 | + * @return true or false | ||
74 | + */ | ||
75 | + Boolean selectUserExist(String username); | ||
68 | } | 76 | } |
69 | 77 | ||
70 | 78 |
@@ -2,8 +2,7 @@ package com.sunyo.wlpt.message.bus.service.service; | @@ -2,8 +2,7 @@ package com.sunyo.wlpt.message.bus.service.service; | ||
2 | 2 | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding; | 4 | import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding; |
5 | - | ||
6 | -import java.util.List; | 5 | +import com.sunyo.wlpt.message.bus.service.domain.XmlData; |
7 | 6 | ||
8 | /** | 7 | /** |
9 | * @author 子诚 | 8 | * @author 子诚 |
@@ -69,6 +68,13 @@ public interface UserMessageBindingService { | @@ -69,6 +68,13 @@ public interface UserMessageBindingService { | ||
69 | */ | 68 | */ |
70 | PageInfo selectUserMessageBindingList(UserMessageBinding userMessageBinding, Integer pageNum, Integer pageSize); | 69 | PageInfo selectUserMessageBindingList(UserMessageBinding userMessageBinding, Integer pageNum, Integer pageSize); |
71 | 70 | ||
71 | + /** | ||
72 | + * 校验 报文 是否已经配置 | ||
73 | + * | ||
74 | + * @param xmlData {@link XmlData} 解析之后的数据 | ||
75 | + * @return true or false | ||
76 | + */ | ||
77 | + public Boolean validateXmlBinding(XmlData xmlData); | ||
72 | } | 78 | } |
73 | 79 | ||
74 | 80 |
1 | package com.sunyo.wlpt.message.bus.service.service; | 1 | package com.sunyo.wlpt.message.bus.service.service; |
2 | 2 | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | -import com.sunyo.wlpt.message.bus.service.domain.BusServer; | ||
5 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | 4 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; |
6 | 5 | ||
7 | import java.util.List; | 6 | import java.util.List; |
@@ -86,4 +85,11 @@ public interface VirtualHostService { | @@ -86,4 +85,11 @@ public interface VirtualHostService { | ||
86 | * @return 虚拟主机列表 | 85 | * @return 虚拟主机列表 |
87 | */ | 86 | */ |
88 | List<VirtualHost> getVirtualHostList(VirtualHost virtualHost); | 87 | List<VirtualHost> getVirtualHostList(VirtualHost virtualHost); |
88 | + | ||
89 | + /** | ||
90 | + * 检验是否存在 | ||
91 | + * @param virtualHost {@link VirtualHost} | ||
92 | + * @return List<VirtualHost> | ||
93 | + */ | ||
94 | + List<VirtualHost> selectVirtualHostExist(VirtualHost virtualHost); | ||
89 | } | 95 | } |
@@ -100,4 +100,10 @@ public class BusExchangeServiceImpl implements BusExchangeService { | @@ -100,4 +100,10 @@ public class BusExchangeServiceImpl implements BusExchangeService { | ||
100 | return busExchangeMapper.getExchangeList(busExchange); | 100 | return busExchangeMapper.getExchangeList(busExchange); |
101 | } | 101 | } |
102 | 102 | ||
103 | + @Override | ||
104 | + public List<BusExchange> selectExchangeExist(BusExchange exchange) | ||
105 | + { | ||
106 | + return busExchangeMapper.selectExchangeExist(exchange); | ||
107 | + } | ||
108 | + | ||
103 | } | 109 | } |
@@ -118,4 +118,10 @@ public class BusServerServiceImpl implements BusServerService { | @@ -118,4 +118,10 @@ public class BusServerServiceImpl implements BusServerService { | ||
118 | { | 118 | { |
119 | return busServerMapper.getServerAndHostAndExchangeList(); | 119 | return busServerMapper.getServerAndHostAndExchangeList(); |
120 | } | 120 | } |
121 | + | ||
122 | + @Override | ||
123 | + public List<BusServer> selectServerExist(String serverName) | ||
124 | + { | ||
125 | + return busServerMapper.selectServerExist(serverName); | ||
126 | + } | ||
121 | } | 127 | } |
@@ -2,9 +2,12 @@ package com.sunyo.wlpt.message.bus.service.service.impl; | @@ -2,9 +2,12 @@ package com.sunyo.wlpt.message.bus.service.service.impl; | ||
2 | 2 | ||
3 | import com.github.pagehelper.PageHelper; | 3 | import com.github.pagehelper.PageHelper; |
4 | import com.github.pagehelper.PageInfo; | 4 | import com.github.pagehelper.PageInfo; |
5 | -import com.sunyo.wlpt.message.bus.service.domain.MessageNote; | 5 | +import com.sunyo.wlpt.message.bus.service.domain.*; |
6 | import com.sunyo.wlpt.message.bus.service.mapper.MessageNoteMapper; | 6 | import com.sunyo.wlpt.message.bus.service.mapper.MessageNoteMapper; |
7 | -import com.sunyo.wlpt.message.bus.service.service.MessageNoteService; | 7 | +import com.sunyo.wlpt.message.bus.service.mapper.UserMessageBindingMapper; |
8 | +import com.sunyo.wlpt.message.bus.service.service.*; | ||
9 | +import com.sunyo.wlpt.message.bus.service.utils.IdUtils; | ||
10 | +import lombok.extern.slf4j.Slf4j; | ||
8 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
9 | import org.springframework.transaction.annotation.Propagation; | 12 | import org.springframework.transaction.annotation.Propagation; |
10 | import org.springframework.transaction.annotation.Transactional; | 13 | import org.springframework.transaction.annotation.Transactional; |
@@ -17,8 +20,29 @@ import java.util.List; | @@ -17,8 +20,29 @@ import java.util.List; | ||
17 | * Description: | 20 | * Description: |
18 | * 时间:2020/6/29 17:46 | 21 | * 时间:2020/6/29 17:46 |
19 | */ | 22 | */ |
23 | +@Slf4j | ||
20 | @Service | 24 | @Service |
21 | public class MessageNoteServiceImpl implements MessageNoteService { | 25 | public class MessageNoteServiceImpl implements MessageNoteService { |
26 | + @Resource | ||
27 | + private UserInfoService userInfoService; | ||
28 | + | ||
29 | + @Resource | ||
30 | + private BusServerService busServerService; | ||
31 | + | ||
32 | + @Resource | ||
33 | + private VirtualHostService virtualHostService; | ||
34 | + | ||
35 | + @Resource | ||
36 | + private BusExchangeService busExchangeService; | ||
37 | + | ||
38 | + @Resource | ||
39 | + private BusQueueService busQueueService; | ||
40 | + | ||
41 | + @Resource | ||
42 | + private UserMessageBindingMapper userMessageBindingMapper; | ||
43 | + | ||
44 | + @Resource | ||
45 | + private RoutingKeyService routingKeyService; | ||
22 | 46 | ||
23 | @Resource | 47 | @Resource |
24 | private MessageNoteMapper messageNoteMapper; | 48 | private MessageNoteMapper messageNoteMapper; |
@@ -58,7 +82,7 @@ public class MessageNoteServiceImpl implements MessageNoteService { | @@ -58,7 +82,7 @@ public class MessageNoteServiceImpl implements MessageNoteService { | ||
58 | @Override | 82 | @Override |
59 | public int insertSelective(MessageNote record) | 83 | public int insertSelective(MessageNote record) |
60 | { | 84 | { |
61 | - return messageNoteMapper.insertSelective(record); | 85 | + return validateNoteAndFill(record); |
62 | } | 86 | } |
63 | 87 | ||
64 | @Override | 88 | @Override |
@@ -99,6 +123,64 @@ public class MessageNoteServiceImpl implements MessageNoteService { | @@ -99,6 +123,64 @@ public class MessageNoteServiceImpl implements MessageNoteService { | ||
99 | messageNoteMapper.autoDelete(deleteTime); | 123 | messageNoteMapper.autoDelete(deleteTime); |
100 | } | 124 | } |
101 | 125 | ||
126 | + | ||
127 | + /** | ||
128 | + * 填充名称(使用get方法,如果不存在就会报空指针异常) | ||
129 | + * | ||
130 | + * @param messageNote {@link MessageNote} | ||
131 | + * @return {@link MessageNote} | ||
132 | + */ | ||
133 | + public MessageNote note_fillName(MessageNote messageNote) | ||
134 | + { | ||
135 | + // 设置id | ||
136 | + messageNote.setId(IdUtils.generateId()); | ||
137 | + | ||
138 | + // 填充,用户名称 | ||
139 | + UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId()); | ||
140 | + messageNote.setUsername(userInfo.getUsername()); | ||
141 | + | ||
142 | + // 填充,发送内容(编辑 or 新增) | ||
143 | + messageNote.setSendContent(messageNote.getAlias_sendContent().getBytes()); | ||
144 | + | ||
145 | + // 填充,服务器名称 | ||
146 | + BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId()); | ||
147 | + messageNote.setServerName(busServer.getServerName()); | ||
148 | + | ||
149 | + // 填充,虚拟主机名称 | ||
150 | + VirtualHost virtualHost = virtualHostService.selectByPrimaryKey(messageNote.getVirtualHostId()); | ||
151 | + messageNote.setVirtualHostName(virtualHost.getVirtualHostName()); | ||
152 | + | ||
153 | + // 填充,交换机名称 | ||
154 | + BusExchange busExchange = busExchangeService.selectByPrimaryKey(messageNote.getExchangeId()); | ||
155 | + messageNote.setExchangeName(busExchange.getExchangeName()); | ||
156 | + | ||
157 | + // 填充,路由键名称 | ||
158 | + RoutingKey routingKey = routingKeyService.selectByPrimaryKey(messageNote.getRoutingKeyId()); | ||
159 | + messageNote.setRoutingKeyName(routingKey.getRoutingKeyName()); | ||
160 | + return messageNote; | ||
161 | + } | ||
162 | + | ||
163 | + /** | ||
164 | + * 校验,messageNote是否已经存在于配置中 | ||
165 | + * | ||
166 | + * @param messageNote {@link MessageNote} | ||
167 | + */ | ||
168 | + public Boolean validateNote(MessageNote messageNote) | ||
169 | + { | ||
170 | + // 用户id, 服务器id,虚拟主机id,交换机id,路由键id | ||
171 | + return userMessageBindingMapper.validateNote(messageNote).size() > 0; | ||
172 | + } | ||
173 | + | ||
174 | + /** | ||
175 | + * 检验、填充、添加 | ||
176 | + * | ||
177 | + * @param messageNote {@link MessageNote} | ||
178 | + * @return 发送信息记录的条数 | ||
179 | + */ | ||
180 | + public int validateNoteAndFill(MessageNote messageNote) | ||
181 | + { | ||
182 | + return validateNote(messageNote) ? messageNoteMapper.insertSelective(note_fillName(messageNote)) : 0; | ||
183 | + } | ||
102 | } | 184 | } |
103 | 185 | ||
104 | 186 |
@@ -114,4 +114,10 @@ public class RoutingKeyServiceImpl implements RoutingKeyService { | @@ -114,4 +114,10 @@ public class RoutingKeyServiceImpl implements RoutingKeyService { | ||
114 | } | 114 | } |
115 | return routingKeyMapper.getRoutingKeyList(routingKey); | 115 | return routingKeyMapper.getRoutingKeyList(routingKey); |
116 | } | 116 | } |
117 | + | ||
118 | + @Override | ||
119 | + public List<RoutingKey> selectRoutingKeyExist(RoutingKey routingKey) | ||
120 | + { | ||
121 | + return routingKeyMapper.selectRoutingKeyExist(routingKey); | ||
122 | + } | ||
117 | } | 123 | } |
@@ -61,6 +61,13 @@ public class UserInfoServiceImpl implements UserInfoService { | @@ -61,6 +61,13 @@ public class UserInfoServiceImpl implements UserInfoService { | ||
61 | return userInfoMapper.getUserInfoList(); | 61 | return userInfoMapper.getUserInfoList(); |
62 | } | 62 | } |
63 | 63 | ||
64 | + @Override | ||
65 | + public Boolean selectUserExist(String username) | ||
66 | + { | ||
67 | + List<UserInfo> list = userInfoMapper.selectUserExist(username); | ||
68 | + return list.size() > 0; | ||
69 | + } | ||
70 | + | ||
64 | } | 71 | } |
65 | 72 | ||
66 | 73 |
@@ -326,6 +326,7 @@ public class UserMessageBindingServiceImpl implements UserMessageBindingService | @@ -326,6 +326,7 @@ public class UserMessageBindingServiceImpl implements UserMessageBindingService | ||
326 | return pageInfo; | 326 | return pageInfo; |
327 | } | 327 | } |
328 | 328 | ||
329 | + | ||
329 | /** | 330 | /** |
330 | * 编辑 or 新增方法,根绝前端传递来的id值,来填充对应的name | 331 | * 编辑 or 新增方法,根绝前端传递来的id值,来填充对应的name |
331 | * 服务器id,虚拟主机id,交换机id,队列id,路由键id | 332 | * 服务器id,虚拟主机id,交换机id,队列id,路由键id |
@@ -394,8 +395,16 @@ public class UserMessageBindingServiceImpl implements UserMessageBindingService | @@ -394,8 +395,16 @@ public class UserMessageBindingServiceImpl implements UserMessageBindingService | ||
394 | return 0; | 395 | return 0; |
395 | } | 396 | } |
396 | } | 397 | } |
398 | + | ||
399 | + @Override | ||
400 | + public Boolean validateXmlBinding(XmlData xmlData) | ||
401 | + { | ||
402 | + List<UserMessageBinding> list = userMessageBindingMapper.validateXmlBinding(xmlData); | ||
403 | + return list.size() > 0; | ||
404 | + } | ||
397 | } | 405 | } |
398 | 406 | ||
399 | 407 | ||
400 | 408 | ||
401 | 409 | ||
410 | + |
@@ -102,4 +102,10 @@ public class VirtualHostServiceImpl implements VirtualHostService { | @@ -102,4 +102,10 @@ public class VirtualHostServiceImpl implements VirtualHostService { | ||
102 | return virtualHostMapper.getVirtualHostList(virtualHost); | 102 | return virtualHostMapper.getVirtualHostList(virtualHost); |
103 | } | 103 | } |
104 | 104 | ||
105 | + @Override | ||
106 | + public List<VirtualHost> selectVirtualHostExist(VirtualHost virtualHost) | ||
107 | + { | ||
108 | + return virtualHostMapper.selectVirtualHostExist(virtualHost); | ||
109 | + } | ||
110 | + | ||
105 | } | 111 | } |
1 | +package com.sunyo.wlpt.message.bus.service.utils; | ||
2 | + | ||
3 | +import com.sunyo.wlpt.message.bus.service.domain.*; | ||
4 | +import com.sunyo.wlpt.message.bus.service.exception.CustomExceptionType; | ||
5 | +import com.sunyo.wlpt.message.bus.service.response.ResultJson; | ||
6 | +import com.sunyo.wlpt.message.bus.service.service.*; | ||
7 | +import io.netty.util.internal.StringUtil; | ||
8 | +import lombok.extern.slf4j.Slf4j; | ||
9 | +import org.dom4j.Document; | ||
10 | +import org.dom4j.DocumentException; | ||
11 | +import org.dom4j.Element; | ||
12 | +import org.dom4j.io.SAXReader; | ||
13 | +import org.springframework.beans.factory.annotation.Value; | ||
14 | +import org.springframework.stereotype.Component; | ||
15 | + | ||
16 | +import javax.annotation.Resource; | ||
17 | +import java.util.List; | ||
18 | + | ||
19 | +/** | ||
20 | + * @author 子诚 | ||
21 | + * Description:Dom4j 解析 xml的工具类 | ||
22 | + * 时间:2020/7/28 10:29 | ||
23 | + */ | ||
24 | +@Slf4j | ||
25 | +@Component | ||
26 | +public class XmlUtils { | ||
27 | + | ||
28 | + @Resource | ||
29 | + private UserInfoService userInfoService; | ||
30 | + | ||
31 | + @Resource | ||
32 | + private BusServerService busServerService; | ||
33 | + | ||
34 | + @Resource | ||
35 | + private VirtualHostService virtualHostService; | ||
36 | + | ||
37 | + @Resource | ||
38 | + private BusExchangeService busExchangeService; | ||
39 | + | ||
40 | + private RoutingKeyService routingKeyService; | ||
41 | + | ||
42 | + @Value("${path.dir}") | ||
43 | + private String dir; | ||
44 | + | ||
45 | + /** | ||
46 | + * 解析字符串类型的 xml | ||
47 | + * | ||
48 | + * @return {@link XmlData} | ||
49 | + */ | ||
50 | + public XmlData parsingMessage(String xmlStr) throws DocumentException | ||
51 | + { | ||
52 | + // 设置文件名 | ||
53 | + String title = "test.xml"; | ||
54 | + String filePath = dir + "/" + title; | ||
55 | + | ||
56 | + SAXReader reader = new SAXReader(); | ||
57 | + Document document = reader.read(filePath); | ||
58 | + Element msg = document.getRootElement(); | ||
59 | + Element meta = msg.element("META"); | ||
60 | + | ||
61 | + XmlData xmlData = XmlData.builder() | ||
62 | + .sendContent(xmlStr) | ||
63 | + .sender(meta.elementText("SNDR")) | ||
64 | + .queueName(meta.elementText("RCVR")) | ||
65 | + .sendTime(meta.elementText("DDTM")) | ||
66 | + .exchangeName(meta.elementText("TYPE")) | ||
67 | + .routingKeyName(meta.elementText("STYP")) | ||
68 | + .sequence(meta.elementText("SEQN")) | ||
69 | + .token(meta.elementText("TOKN")) | ||
70 | + .virtualHostName(meta.elementText("VSHT")) | ||
71 | + .serverName(meta.elementText("SERV")) | ||
72 | + .build(); | ||
73 | + return xmlData; | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * @param xmlData {@link XmlData} 需要被检查的 xml 报文数据与格式 | ||
78 | + * @return | ||
79 | + */ | ||
80 | + public ResultJson checkFormatAndData(XmlData xmlData) | ||
81 | + { | ||
82 | + if (StringUtil.isNullOrEmpty(xmlData.getSendContent())) { | ||
83 | + // 消息内容为空 | ||
84 | + return ResultJson.error(CustomExceptionType.CONTENT_ERROR); | ||
85 | + } else if (StringUtil.isNullOrEmpty(xmlData.getSender())) { | ||
86 | + // 发送者名称为空 | ||
87 | + return ResultJson.error(CustomExceptionType.SERVER_ERROR); | ||
88 | + } else if (StringUtil.isNullOrEmpty(xmlData.getServerName())) { | ||
89 | + // 服务器名称为空 | ||
90 | + return ResultJson.error(CustomExceptionType.SERVER_ERROR); | ||
91 | + } else if (StringUtil.isNullOrEmpty(xmlData.getVirtualHostName())) { | ||
92 | + // 虚拟主机为空 | ||
93 | + return ResultJson.error(CustomExceptionType.HOST_ERROR); | ||
94 | + } else if (StringUtil.isNullOrEmpty(xmlData.getExchangeName())) { | ||
95 | + // 交换机为空 | ||
96 | + return ResultJson.error(CustomExceptionType.EXCHANGE_ERROR); | ||
97 | + } else if (StringUtil.isNullOrEmpty(xmlData.getRoutingKeyName())) { | ||
98 | + // 路由键为空 | ||
99 | + return ResultJson.error(CustomExceptionType.ROUTING_KEY_ERROR); | ||
100 | + } else if (StringUtil.isNullOrEmpty(xmlData.getSequence())) { | ||
101 | + // 序列为空 | ||
102 | + return ResultJson.error(CustomExceptionType.SEQUENCE_ERROR); | ||
103 | + } else if (StringUtil.isNullOrEmpty(xmlData.getToken())) { | ||
104 | + // token为空 | ||
105 | + return ResultJson.error(CustomExceptionType.TOKEN_ERROR); | ||
106 | + } | ||
107 | + if (!userInfoService.selectUserExist(xmlData.getSender())) { | ||
108 | + // 发送者不存在 | ||
109 | + return ResultJson.error(CustomExceptionType.SENDER_NO_EXIST); | ||
110 | + } | ||
111 | + List<BusServer> serverList = busServerService.selectServerExist(xmlData.getServerName()); | ||
112 | + if (serverList.size() == 0) { | ||
113 | + // 服务器不存在 | ||
114 | + return ResultJson.error(CustomExceptionType.SERVER_NO_EXIST); | ||
115 | + } | ||
116 | + VirtualHost virtualHost = VirtualHost.builder() | ||
117 | + .serverId(serverList.get(0).getId()) | ||
118 | + .virtualHostName(xmlData.getVirtualHostName()).build(); | ||
119 | + List<VirtualHost> virtualHostList = virtualHostService.selectVirtualHostExist(virtualHost); | ||
120 | + if (virtualHostList.size() == 0) { | ||
121 | + // 虚拟主机不存在 | ||
122 | + return ResultJson.error(CustomExceptionType.HOST_NO_EXIST); | ||
123 | + } | ||
124 | + BusExchange exchange = BusExchange.builder() | ||
125 | + .virtualHostId(virtualHostList.get(0).getId()) | ||
126 | + .exchangeName(xmlData.getExchangeName()).build(); | ||
127 | + List<BusExchange> exchangeList = busExchangeService.selectExchangeExist(exchange); | ||
128 | + if (exchangeList.size() == 0) { | ||
129 | + // 交换机不存在 | ||
130 | + return ResultJson.error(CustomExceptionType.EXCHANGE_NO_EXIST); | ||
131 | + } | ||
132 | + RoutingKey routingKey = RoutingKey.builder() | ||
133 | + .exchangeId(exchangeList.get(0).getId()) | ||
134 | + .routingKeyName(xmlData.getRoutingKeyName()).build(); | ||
135 | + List<RoutingKey> routingKeyList = routingKeyService.selectRoutingKeyExist(routingKey); | ||
136 | + if (routingKeyList.size() == 0) { | ||
137 | + // 路由键不存在 | ||
138 | + return ResultJson.error(CustomExceptionType.ROUTING_KEY_NO_EXIST); | ||
139 | + } | ||
140 | + return ResultJson.success(); | ||
141 | + } | ||
142 | +} |
@@ -238,4 +238,21 @@ | @@ -238,4 +238,21 @@ | ||
238 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | 238 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} |
239 | where id = #{id,jdbcType=VARCHAR} | 239 | where id = #{id,jdbcType=VARCHAR} |
240 | </update> | 240 | </update> |
241 | + | ||
242 | + <select id="selectExchangeExist" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusExchange" | ||
243 | + resultMap="BaseResultMap"> | ||
244 | + select | ||
245 | + <include refid="Base_Column_List"/> | ||
246 | + from bus_exchange | ||
247 | + <where> | ||
248 | + <!-- 交换机名称 --> | ||
249 | + <if test="exchangeName != null and exchangeName != ''"> | ||
250 | + exchange_name = #{exchangeName,jdbcType=VARCHAR} | ||
251 | + </if> | ||
252 | + <!-- 所属虚拟主机ID --> | ||
253 | + <if test="virtualHostId != null and virtualHostId != ''"> | ||
254 | + and virtual_host_id = #{virtualHostId,jdbcType=VARCHAR} | ||
255 | + </if> | ||
256 | + </where> | ||
257 | + </select> | ||
241 | </mapper> | 258 | </mapper> |
@@ -229,4 +229,13 @@ | @@ -229,4 +229,13 @@ | ||
229 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | 229 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} |
230 | where id = #{id,jdbcType=VARCHAR} | 230 | where id = #{id,jdbcType=VARCHAR} |
231 | </update> | 231 | </update> |
232 | + | ||
233 | + <select id="selectServerExist" parameterType="java.lang.String" resultMap="BaseResultMap"> | ||
234 | + <!--@mbg.generated--> | ||
235 | + select | ||
236 | + <include refid="Base_Column_List"/> | ||
237 | + from bus_server | ||
238 | + where server_name = #{serverName,jdbcType=VARCHAR} | ||
239 | + </select> | ||
240 | + | ||
232 | </mapper> | 241 | </mapper> |
@@ -85,6 +85,22 @@ | @@ -85,6 +85,22 @@ | ||
85 | </where> | 85 | </where> |
86 | </select> | 86 | </select> |
87 | 87 | ||
88 | + <select id="selectRoutingKeyExist" parameterType="com.sunyo.wlpt.message.bus.service.domain.RoutingKey" | ||
89 | + resultMap="BaseResultMap"> | ||
90 | + select | ||
91 | + <include refid="Base_Column_List"/> | ||
92 | + from routing_key | ||
93 | + <where> | ||
94 | + <!-- 所属交换机ID --> | ||
95 | + <if test="exchangeId != null and exchangeId != ''"> | ||
96 | + exchange_id = #{exchangeId,jdbcType=VARCHAR} | ||
97 | + </if> | ||
98 | + <!-- 路由键名称 --> | ||
99 | + <if test="routingKeyName != null and routingKeyName != ''"> | ||
100 | + and routing_key_name = #{routingKeyName,jdbcType=VARCHAR} | ||
101 | + </if> | ||
102 | + </where> | ||
103 | + </select> | ||
88 | <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> | 104 | <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
89 | <!--@mbg.generated--> | 105 | <!--@mbg.generated--> |
90 | delete | 106 | delete |
@@ -122,4 +122,12 @@ | @@ -122,4 +122,12 @@ | ||
122 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | 122 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} |
123 | where id = #{id,jdbcType=VARCHAR} | 123 | where id = #{id,jdbcType=VARCHAR} |
124 | </update> | 124 | </update> |
125 | + | ||
126 | + <select id="selectUserExist" parameterType="java.lang.String" resultMap="BaseResultMap"> | ||
127 | + <!--@mbg.generated--> | ||
128 | + select | ||
129 | + <include refid="Base_Column_List"/> | ||
130 | + from user_info | ||
131 | + where username = #{username,jdbcType=VARCHAR} | ||
132 | + </select> | ||
125 | </mapper> | 133 | </mapper> |
@@ -323,4 +323,61 @@ | @@ -323,4 +323,61 @@ | ||
323 | </if> | 323 | </if> |
324 | </where> | 324 | </where> |
325 | </select> | 325 | </select> |
326 | + <select id="validateNote" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote" | ||
327 | + resultMap="BaseResultMap"> | ||
328 | + select | ||
329 | + <include refid="Base_Column_List"/> | ||
330 | + from user_message_binding | ||
331 | + <where> | ||
332 | + <!-- 所属用户id --> | ||
333 | + <if test="userId != null and userId != ''"> | ||
334 | + user_id = #{userId,jdbcType=VARCHAR} | ||
335 | + </if> | ||
336 | + <!-- 所属服务器id --> | ||
337 | + <if test="serverId != null and serverId != ''"> | ||
338 | + AND server_id = #{serverId,jdbcType=VARCHAR} | ||
339 | + </if> | ||
340 | + <!-- 所属虚拟主机id --> | ||
341 | + <if test="virtualHostId != null and virtualHostId != ''"> | ||
342 | + AND virtual_host_id = #{virtualHostId,jdbcType=VARCHAR} | ||
343 | + </if> | ||
344 | + <!-- 所属交换机id --> | ||
345 | + <if test="exchangeId != null and exchangeId != ''"> | ||
346 | + AND exchange_id = #{exchangeId,jdbcType=VARCHAR} | ||
347 | + </if> | ||
348 | + <!-- 所属路由键id --> | ||
349 | + <if test="routingKeyId != null and routingKeyId != ''"> | ||
350 | + AND routing_key_id = #{routingKeyId,jdbcType=VARCHAR} | ||
351 | + </if> | ||
352 | + </where> | ||
353 | + </select> | ||
354 | + | ||
355 | + <select id="validateXmlBinding" parameterType="com.sunyo.wlpt.message.bus.service.domain.XmlData" | ||
356 | + resultMap="BaseResultMap"> | ||
357 | + select | ||
358 | + <include refid="Base_Column_List"/> | ||
359 | + from user_message_binding | ||
360 | + <where> | ||
361 | + <!-- 用户 --> | ||
362 | + <if test="sender != null and sender != ''"> | ||
363 | + username = #{sender,jdbcType=VARCHAR} | ||
364 | + </if> | ||
365 | + <!-- 服务器名称 --> | ||
366 | + <if test="serverName != null and serverName != ''"> | ||
367 | + AND server_name = #{serverName,jdbcType=VARCHAR} | ||
368 | + </if> | ||
369 | + <!-- 虚拟主机名称 --> | ||
370 | + <if test="virtualHostName != null and virtualHostName != ''"> | ||
371 | + AND virtual_host_name = #{virtualHostName,jdbcType=VARCHAR} | ||
372 | + </if> | ||
373 | + <!-- 交换机名称 --> | ||
374 | + <if test="exchangeName != null and exchangeName != ''"> | ||
375 | + AND exchange_name = #{exchangeName,jdbcType=VARCHAR} | ||
376 | + </if> | ||
377 | + <!-- 路由键名称 --> | ||
378 | + <if test="routingKeyName != null and routingKeyName != ''"> | ||
379 | + AND routing_key_name = #{routingKeyName,jdbcType=VARCHAR} | ||
380 | + </if> | ||
381 | + </where> | ||
382 | + </select> | ||
326 | </mapper> | 383 | </mapper> |
@@ -191,4 +191,21 @@ | @@ -191,4 +191,21 @@ | ||
191 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | 191 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} |
192 | where id = #{id,jdbcType=VARCHAR} | 192 | where id = #{id,jdbcType=VARCHAR} |
193 | </update> | 193 | </update> |
194 | + | ||
195 | + <select id="selectVirtualHostExist" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" | ||
196 | + resultMap="HostAndServerMap"> | ||
197 | + select | ||
198 | + <include refid="Base_Column_List"/> | ||
199 | + from virtual_host | ||
200 | + <where> | ||
201 | + <!-- 所属服务器ID --> | ||
202 | + <if test="serverId != null and serverId != ''"> | ||
203 | + server_id = #{serverId,jdbcType=VARCHAR} | ||
204 | + </if> | ||
205 | + <!-- 虚拟主机名称 --> | ||
206 | + <if test="virtualHostName != null and virtualHostName != ''"> | ||
207 | + and virtual_host_name = #{virtualHostName,jdbcType=VARCHAR} | ||
208 | + </if> | ||
209 | + </where> | ||
210 | + </select> | ||
194 | </mapper> | 211 | </mapper> |
xml/test.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<MSG> | ||
3 | + <META> | ||
4 | + <SNDR>zicheng</SNDR> | ||
5 | + <RCVR></RCVR> | ||
6 | + <DDTM>2020728151024</DDTM> | ||
7 | + <TYPE>E_zicheng</TYPE> | ||
8 | + <STYP>R_zicheng</STYP> | ||
9 | + <SEQN>12345</SEQN> | ||
10 | + <TOKN>token</TOKN> | ||
11 | + <VSHT>V_zicheng</VSHT> | ||
12 | + <SERV>S_server</SERV> | ||
13 | + </META> | ||
14 | + <BODY>测试一下,发送xml,进行解析</BODY> | ||
15 | +</MSG><!-- 根标签,结束 --> |
模板.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<MSG><!-- 根标签,开始 --> | ||
3 | + <META><!-- 头标签,开始 --> | ||
4 | + <SNDR>消息发送者(用户名称)</SNDR> | ||
5 | + <RCVR>指定接收者(队列名称)</RCVR><!-- 指定接受者为空,则代表发送给 预配置的接收者 --> | ||
6 | + <DDTM>发送报文时间</DDTM><!-- 发送时间,格式为yyyyMMddHHmmss --> | ||
7 | + <TYPE>交换机名称</TYPE><!-- 消息大类型:交换机名称 --> | ||
8 | + <STYP>路由键名称</STYP><!-- 消息子类型:路由键名称 --> | ||
9 | + <SEQN>序列号(唯一)</SEQN><!-- 该消息的序列,消息唯一标识 --> | ||
10 | + <TOKN>token值</TOKN><!-- token --> | ||
11 | + <VSHT>虚拟机名称</VSHT><!-- 虚拟主机名称 --> | ||
12 | + <SERV>MQ服务器名称</SERV><!-- 服务器名称 --> | ||
13 | + </META><!-- 头标签,结束 --> | ||
14 | + | ||
15 | + <BODY><!-- 内容标签,开始 --> | ||
16 | + 发送内容 | ||
17 | + </BODY><!-- 内容标签,结束 --> | ||
18 | +</MSG><!-- 根标签,结束 --> |
-
请 注册 或 登录 后发表评论