|
@@ -17,11 +17,11 @@ import com.fire.dto.FireProductInfo;
|
|
|
import com.fire.dto.enums.Status;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.messaging.support.MessageBuilder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import redis.clients.jedis.JedisCluster;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -39,19 +39,19 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
|
|
|
@Slf4j
|
|
|
public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, ChannelInfo> implements ChannelInfoService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SupplierService supplierService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private ChannelProductService channelProductService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private FireProductMapper fireProductMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private JedisCluster jedisCluster;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private RocketMQTemplate rocketMQTemplate;
|
|
|
|
|
|
@Override
|
|
@@ -84,32 +84,41 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
|
|
|
@Override
|
|
|
public void updateChannelInfoById(ChannelInfo channelInfo) {
|
|
|
- channelInfo.setUpdator("admin");
|
|
|
- channelInfo.setUpdateTime(new Date());
|
|
|
- int result = baseMapper.updateById(channelInfo);
|
|
|
- if (result > 0) {
|
|
|
- rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
- log.info("通道已修改为:【{}】", channelInfo);
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(channelInfo.getChannelProductInfos())) {
|
|
|
- channelProductService.saveChannelProducts(channelInfo.getChannelProductInfos());
|
|
|
- log.info("添加的通道产品是:【{}】", channelInfo.getChannelProductInfos().toString());
|
|
|
+ if (channelInfo != null) {
|
|
|
+ channelInfo.setUpdator("admin");
|
|
|
+ channelInfo.setUpdateTime(new Date());
|
|
|
+ int result = baseMapper.updateById(channelInfo);
|
|
|
+ if (result > 0) {
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
+ log.info("通道已修改为:【{}】", channelInfo);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(channelInfo.getChannelProductInfos())) {
|
|
|
+ channelProductService.saveChannelProducts(channelInfo.getChannelProductInfos());
|
|
|
+ log.info("添加的通道产品是:【{}】", channelInfo.getChannelProductInfos().toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void insertChannelInfo(ChannelInfo channelInfo) {
|
|
|
- if (channelInfo.getChannelId() == null) {
|
|
|
- channelInfo.setChannelId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
- }
|
|
|
- channelInfo.setCreator("admin");
|
|
|
- channelInfo.setCreateTime(new Date());
|
|
|
- int result = baseMapper.insert(channelInfo);
|
|
|
- if (result > 0) {
|
|
|
- rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
- log.info("添加的通道是:【{}】", channelInfo);
|
|
|
+ if (channelInfo != null) {
|
|
|
+ if (channelInfo.getChannelId() == null) {
|
|
|
+ channelInfo.setChannelId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
+ }
|
|
|
+ channelInfo.setCreator("admin");
|
|
|
+ channelInfo.setCreateTime(new Date());
|
|
|
+ int result = baseMapper.insert(channelInfo);
|
|
|
+ if (result > 0) {
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
+ log.info("添加的通道是:【{}】", channelInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -124,4 +133,19 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setInvalid(Long channelId, Integer isValid) {
|
|
|
+ ChannelInfo channelInfo = ChannelInfo.builder().channelId(channelId)
|
|
|
+ .isValid(isValid).build();
|
|
|
+ int result = baseMapper.updateById(channelInfo);
|
|
|
+ if (result > 0) {
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
+ if (channelInfo.getIsValid() == 0) {
|
|
|
+ log.info("编号为【{}】的通道已置无效", channelId);
|
|
|
+ } else {
|
|
|
+ log.info("编号为【{}】的通道已置有效", channelId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|