正在显示
4 个修改的文件
包含
20 行增加
和
12 行删除
@@ -22,7 +22,7 @@ public class RouterReceiverController { | @@ -22,7 +22,7 @@ public class RouterReceiverController { | ||
22 | MessageRouterReciverService messageRouterReciverService; | 22 | MessageRouterReciverService messageRouterReciverService; |
23 | 23 | ||
24 | 24 | ||
25 | - @ApiOperation(value = "添加路由接收者", notes = "添加路由接收者数组,参数必须要有:路由ID,接收者数组rcvrs") | 25 | + @ApiOperation(value = "添加路由接收者", notes = "添加路由接收者数组,参数必须要有:路由ID,接收者数组List<MessageRouterReciver> rcvrList") |
26 | @PostMapping("/receiver") | 26 | @PostMapping("/receiver") |
27 | public ResultJson batchAddRouter(@RequestBody MessageRouter messageRouter){ | 27 | public ResultJson batchAddRouter(@RequestBody MessageRouter messageRouter){ |
28 | boolean result = messageRouterReciverService.batchAddMessageRouterReciver(messageRouter); | 28 | boolean result = messageRouterReciverService.batchAddMessageRouterReciver(messageRouter); |
@@ -15,7 +15,9 @@ public interface MessageRouterReciverMapper { | @@ -15,7 +15,9 @@ public interface MessageRouterReciverMapper { | ||
15 | 15 | ||
16 | List<MessageRouterReciver> selectByRouterKey(String id); | 16 | List<MessageRouterReciver> selectByRouterKey(String id); |
17 | 17 | ||
18 | + List<MessageRouterReciver> selectByRouterKeyAndTopic(MessageRouterReciver record); | ||
19 | + | ||
18 | int updateByPrimaryKeySelective(MessageRouterReciver record); | 20 | int updateByPrimaryKeySelective(MessageRouterReciver record); |
19 | 21 | ||
20 | int updateByPrimaryKey(MessageRouterReciver record); | 22 | int updateByPrimaryKey(MessageRouterReciver record); |
21 | -} | ||
23 | +} |
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; | ||
12 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
13 | 13 | ||
14 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
15 | +import java.util.List; | ||
15 | 16 | ||
16 | @Service | 17 | @Service |
17 | public class MessageRouterReciverImpl implements MessageRouterReciverService { | 18 | public class MessageRouterReciverImpl implements MessageRouterReciverService { |
@@ -36,15 +37,19 @@ public class MessageRouterReciverImpl implements MessageRouterReciverService { | @@ -36,15 +37,19 @@ public class MessageRouterReciverImpl implements MessageRouterReciverService { | ||
36 | public boolean batchAddMessageRouterReciver(MessageRouter messageRouter) { | 37 | public boolean batchAddMessageRouterReciver(MessageRouter messageRouter) { |
37 | int i =0; | 38 | int i =0; |
38 | if (StringUtils.isNotBlank(messageRouter.getId())){ | 39 | if (StringUtils.isNotBlank(messageRouter.getId())){ |
39 | - if (messageRouter.getRcvrs()!=null && !messageRouter.getRcvrs().isEmpty()){ | 40 | + if (messageRouter.getRcvrList()!=null && !messageRouter.getRcvrList().isEmpty()){ |
40 | // 获取订阅者列表,循环添加 | 41 | // 获取订阅者列表,循环添加 |
41 | - for (String rcvr: messageRouter.getRcvrs() | 42 | + for (MessageRouterReciver rcvr: messageRouter.getRcvrList() |
42 | ) { | 43 | ) { |
43 | - MessageRouterReciver reciver = new MessageRouterReciver(); | ||
44 | - reciver.setRcvrTopic(rcvr); | ||
45 | - reciver.setMessageRouterId(messageRouter.getId()); | ||
46 | - reciver.setId(IdUtils.generateId()); | ||
47 | - i += messageRouterReciverMapper.insertSelective(reciver); | 44 | + if (StringUtils.isNotBlank(rcvr.getRcvrTopic())){ |
45 | + rcvr.setMessageRouterId(messageRouter.getId()); | ||
46 | + rcvr.setId(IdUtils.generateId()); | ||
47 | + List<MessageRouterReciver> list = messageRouterReciverMapper.selectByRouterKeyAndTopic(rcvr); | ||
48 | + //判断是否已经有这条数据 | ||
49 | + if(list.isEmpty()){ | ||
50 | + i += messageRouterReciverMapper.insertSelective(rcvr); | ||
51 | + }; | ||
52 | + } | ||
48 | } | 53 | } |
49 | } | 54 | } |
50 | return i > 0; | 55 | return i > 0; |
@@ -24,11 +24,12 @@ | @@ -24,11 +24,12 @@ | ||
24 | from message_router_reciver | 24 | from message_router_reciver |
25 | where message_router_id = #{messageRouterId,jdbcType=VARCHAR} | 25 | where message_router_id = #{messageRouterId,jdbcType=VARCHAR} |
26 | </select> | 26 | </select> |
27 | - <select id="queReciverList" resultMap="BaseResultMap" parameterType="com.sunyo.wlpt.message.bus.service.model.MessageRouterReciver" > | 27 | + <select id="selectByRouterKeyAndTopic" resultMap="BaseResultMap" parameterType="com.sunyo.wlpt.message.bus.service.model.MessageRouterReciver" > |
28 | select | 28 | select |
29 | - <include refid="Base_Column_List" /> | 29 | + id |
30 | from message_router_reciver | 30 | from message_router_reciver |
31 | - where id = #{id,jdbcType=VARCHAR} | 31 | + where message_router_id = #{messageRouterId,jdbcType=VARCHAR} |
32 | + and rcvr_topic = #{rcvrTopic,jdbcType=VARCHAR} | ||
32 | </select> | 33 | </select> |
33 | <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > | 34 | <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > |
34 | delete from message_router_reciver | 35 | delete from message_router_reciver |
-
请 注册 或 登录 后发表评论