作者 朱兆平

路由消费者接口增加,优化其他业务一些参数

... ... @@ -22,7 +22,7 @@ public class RouterReceiverController {
MessageRouterReciverService messageRouterReciverService;
@ApiOperation(value = "添加路由接收者", notes = "添加路由接收者数组,参数必须要有:路由ID,接收者数组rcvrs")
@ApiOperation(value = "添加路由接收者", notes = "添加路由接收者数组,参数必须要有:路由ID,接收者数组List<MessageRouterReciver> rcvrList")
@PostMapping("/receiver")
public ResultJson batchAddRouter(@RequestBody MessageRouter messageRouter){
boolean result = messageRouterReciverService.batchAddMessageRouterReciver(messageRouter);
... ...
... ... @@ -15,7 +15,9 @@ public interface MessageRouterReciverMapper {
List<MessageRouterReciver> selectByRouterKey(String id);
List<MessageRouterReciver> selectByRouterKeyAndTopic(MessageRouterReciver record);
int updateByPrimaryKeySelective(MessageRouterReciver record);
int updateByPrimaryKey(MessageRouterReciver record);
}
\ No newline at end of file
}
... ...
... ... @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Service
public class MessageRouterReciverImpl implements MessageRouterReciverService {
... ... @@ -36,15 +37,19 @@ public class MessageRouterReciverImpl implements MessageRouterReciverService {
public boolean batchAddMessageRouterReciver(MessageRouter messageRouter) {
int i =0;
if (StringUtils.isNotBlank(messageRouter.getId())){
if (messageRouter.getRcvrs()!=null && !messageRouter.getRcvrs().isEmpty()){
if (messageRouter.getRcvrList()!=null && !messageRouter.getRcvrList().isEmpty()){
// 获取订阅者列表,循环添加
for (String rcvr: messageRouter.getRcvrs()
for (MessageRouterReciver rcvr: messageRouter.getRcvrList()
) {
MessageRouterReciver reciver = new MessageRouterReciver();
reciver.setRcvrTopic(rcvr);
reciver.setMessageRouterId(messageRouter.getId());
reciver.setId(IdUtils.generateId());
i += messageRouterReciverMapper.insertSelective(reciver);
if (StringUtils.isNotBlank(rcvr.getRcvrTopic())){
rcvr.setMessageRouterId(messageRouter.getId());
rcvr.setId(IdUtils.generateId());
List<MessageRouterReciver> list = messageRouterReciverMapper.selectByRouterKeyAndTopic(rcvr);
//判断是否已经有这条数据
if(list.isEmpty()){
i += messageRouterReciverMapper.insertSelective(rcvr);
};
}
}
}
return i > 0;
... ...
... ... @@ -24,11 +24,12 @@
from message_router_reciver
where message_router_id = #{messageRouterId,jdbcType=VARCHAR}
</select>
<select id="queReciverList" resultMap="BaseResultMap" parameterType="com.sunyo.wlpt.message.bus.service.model.MessageRouterReciver" >
<select id="selectByRouterKeyAndTopic" resultMap="BaseResultMap" parameterType="com.sunyo.wlpt.message.bus.service.model.MessageRouterReciver" >
select
<include refid="Base_Column_List" />
id
from message_router_reciver
where id = #{id,jdbcType=VARCHAR}
where message_router_id = #{messageRouterId,jdbcType=VARCHAR}
and rcvr_topic = #{rcvrTopic,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from message_router_reciver
... ...