|
@@ -2,6 +2,7 @@ package cn.kdan.compdf.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import cn.kdan.compdf.dto.AddNewWebhookDTO;
|
|
@@ -12,6 +13,7 @@ import cn.kdan.compdf.entity.BackgroundEvent;
|
|
|
import cn.kdan.compdf.entity.BackgroundUserProject;
|
|
|
import cn.kdan.compdf.entity.BackgroundUserWebhook;
|
|
|
import cn.kdan.compdf.entity.BackgroundWebhookEvent;
|
|
|
+import cn.kdan.compdf.enums.DateTImeFormatEnum;
|
|
|
import cn.kdan.compdf.enums.RabbitMQEnum;
|
|
|
import cn.kdan.compdf.exception.BusinessException;
|
|
|
import cn.kdan.compdf.mapper.BackgroundUserWebhookMapper;
|
|
@@ -69,7 +71,7 @@ public class BackgroundUserWebhookServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
public List<BackgroundUserWebhookVO> getWebhookList(Long userId,Integer timeZone) {
|
|
|
// 查找用户下面状态正常的Webhook记录
|
|
|
LambdaQueryWrapper<BackgroundUserWebhook> backgroundUserWebhookeq = new LambdaQueryWrapper<BackgroundUserWebhook>()
|
|
|
- .between(BackgroundUserWebhook::getStatus, 1, 2)
|
|
|
+ .ne(BackgroundUserWebhook::getStatus,0) // 不等于删除状态
|
|
|
.eq(BackgroundUserWebhook::getUserId, TokenUtil.getRequestHeader().getId())
|
|
|
.orderByDesc(BackgroundUserWebhook::getCreateDate);
|
|
|
List<BackgroundUserWebhook> backgroundUserWebhookList = this.baseMapper.selectList(backgroundUserWebhookeq);
|
|
@@ -78,9 +80,9 @@ public class BackgroundUserWebhookServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
// 获取系统所有事件
|
|
|
List<BackgroundEvent> backgroundEventList = backgroundEventService.getEventList();
|
|
|
backgroundUserWebhookList.forEach(c -> {
|
|
|
- c.setResponseTime(MyLocalDateUtil.timeZoneConversion(c.getResponseTime(),timeZone));
|
|
|
BackgroundUserWebhookVO backgroundUserWebhookVO = new BackgroundUserWebhookVO();
|
|
|
BeanUtil.copyProperties(c, backgroundUserWebhookVO);
|
|
|
+ backgroundUserWebhookVO.setResponseTime(DateUtil.format(MyLocalDateUtil.timeZoneConversion(c.getResponseTime(),timeZone), DateTImeFormatEnum.DATE_TIME));
|
|
|
// 获取webhook关联事件
|
|
|
LambdaQueryWrapper<BackgroundWebhookEvent> backgroundWebhookEventeq = new LambdaQueryWrapper<BackgroundWebhookEvent>()
|
|
|
.eq(BackgroundWebhookEvent::getStatus, 1)
|
|
@@ -184,6 +186,7 @@ public class BackgroundUserWebhookServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
backgroundWebhookEvent.setStatus(1);
|
|
|
backgroundWebhookEventService.save(backgroundWebhookEvent);
|
|
|
});
|
|
|
+ editWebhookDTO.setStatus(null);
|
|
|
// 发送消息同步SaaS服务
|
|
|
String jsonStr = JSONUtil.toJsonStr(editWebhookDTO);
|
|
|
rabbitTemplate.convertAndSend(RabbitMQEnum.BACKGROUND_EXCHANGE, RabbitMQEnum.BACKGROUND_WEBHOOKS_UPD_ROUTING_KEY, jsonStr);
|
|
@@ -208,6 +211,21 @@ public class BackgroundUserWebhookServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateWebhookStatus(Long webhookId,Integer status){
|
|
|
+ BackgroundUserWebhook backgroundUserWebhook = new BackgroundUserWebhook();
|
|
|
+ backgroundUserWebhook.setId(webhookId);
|
|
|
+ backgroundUserWebhook.setStatus(status);
|
|
|
+ this.baseMapper.updateById(backgroundUserWebhook);
|
|
|
+
|
|
|
+ EditWebhookDTO editWebhookDTO = new EditWebhookDTO();
|
|
|
+ editWebhookDTO.setId(webhookId);
|
|
|
+ editWebhookDTO.setStatus(status);
|
|
|
+ // 发送消息同步SaaS服务
|
|
|
+ String jsonStr = JSONUtil.toJsonStr(editWebhookDTO);
|
|
|
+ rabbitTemplate.convertAndSend(RabbitMQEnum.BACKGROUND_EXCHANGE, RabbitMQEnum.BACKGROUND_WEBHOOKS_UPD_ROUTING_KEY, jsonStr);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|