|
@@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fire.admin.mapper.DistributeGroupMapper;
|
|
|
-import com.fire.admin.service.ChannelInfoService;
|
|
|
+import com.fire.admin.service.DistGroupChannelService;
|
|
|
import com.fire.admin.service.DistributeGroupService;
|
|
|
import com.fire.admin.util.SecurityUtil;
|
|
|
import com.fire.common.exception.BaseException;
|
|
@@ -37,7 +37,7 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
|
|
|
public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMapper, DistributeGroup> implements DistributeGroupService {
|
|
|
|
|
|
@Resource
|
|
|
- private ChannelInfoService channelInfoService;
|
|
|
+ private DistGroupChannelService distGroupChannelService;
|
|
|
|
|
|
@Resource
|
|
|
private JedisCluster jedisCluster;
|
|
@@ -50,6 +50,9 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
|
|
|
if (ObjectUtil.isNotEmpty(channelGroupId)) {
|
|
|
List<DistributeGroup> distributeGroupList = new LambdaQueryChainWrapper<>(baseMapper).eq(channelGroupId != null, DistributeGroup::getChannelGroupId, channelGroupId).list();
|
|
|
if (ObjectUtil.isNotEmpty(distributeGroupList)) {
|
|
|
+ for (DistributeGroup distributeGroup : distributeGroupList) {
|
|
|
+ distributeGroup.setChannels(distGroupChannelService.getChannelInfoByDistGroupId(distributeGroup.getDistributeGroupId()));
|
|
|
+ }
|
|
|
return distributeGroupList;
|
|
|
}
|
|
|
}
|
|
@@ -64,6 +67,9 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
|
|
|
distributeGroup.setDistributeGroupId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
distributeGroup.setCreator(SecurityUtil.getUser().getUsername());
|
|
|
distributeGroup.setCreateTime(new Date());
|
|
|
+ if (distributeGroup.getChannelGroupId() == null) {
|
|
|
+ distributeGroup.setChannelId(1L);
|
|
|
+ }
|
|
|
log.info("添加的分发组是:", distributeGroups);
|
|
|
} else {
|
|
|
distributeGroup.setUpdator(SecurityUtil.getUser().getUsername());
|
|
@@ -97,38 +103,18 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public int removeDistGroupAndChannelByChannelId(Long channelId) {
|
|
|
- if (channelId != null) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("channel_id", channelId);
|
|
|
- int distResult = baseMapper.deleteByMap(map);
|
|
|
- int channelResult = channelInfoService.deleteChannelByChannelId(channelId);
|
|
|
+ public void removeDistGroupAndChannelByDistGroupId(Long distGroupId) {
|
|
|
+ if (distGroupId != null) {
|
|
|
+ int distResult = baseMapper.deleteById(distGroupId);
|
|
|
+ int channelResult = distGroupChannelService.removeChannelByDistGroupId(distGroupId);
|
|
|
if (distResult > 0 && channelResult > 0) {
|
|
|
rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
- log.info("编号为【{}】的分发组删除成功!", channelId);
|
|
|
- log.info("编号为【{}】的通道删除成功!", channelId);
|
|
|
- return distResult + channelResult;
|
|
|
+ log.info("编号为【{}】的分发组删除成功!", distGroupId);
|
|
|
+ log.info("分发组编号为【{}】的通道删除成功!", distGroupId);
|
|
|
}
|
|
|
} else {
|
|
|
throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
}
|
|
|
- return 0;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void updateDistributeGroupById(DistributeGroup distributeGroup) {
|
|
|
- if (distributeGroup != null) {
|
|
|
- distributeGroup.setUpdator(SecurityUtil.getUser().getUsername());
|
|
|
- distributeGroup.setUpdateTime(new Date());
|
|
|
- }
|
|
|
- int distResult = baseMapper.updateById(distributeGroup);
|
|
|
- if (distResult > 0) {
|
|
|
- rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
- log.info("分发组已修改为【{}】:", distributeGroup);
|
|
|
- }
|
|
|
-
|
|
|
- if (ObjectUtil.isNotEmpty(distributeGroup.getChannelInfos())) {
|
|
|
- channelInfoService.saveOrUpdateChannelInfos(distributeGroup.getChannelInfos());
|
|
|
- }
|
|
|
- }
|
|
|
}
|