Browse Source

2轮测试bug:修复一些已知bug

wangPH 2 years ago
parent
commit
49de6d132f

+ 1 - 1
background-common/src/main/java/cn/kdan/compdf/enums/RabbitMQEnum.java

@@ -54,6 +54,6 @@ public interface RabbitMQEnum {
     /**
      * webhooks更新路由规则
      */
-    String BACKGROUND_WEBHOOKS_UPD_ROUTING_KEY = "background.webhooks.del";
+    String BACKGROUND_WEBHOOKS_UPD_ROUTING_KEY = "background.webhooks.upd";
 
 }

+ 1 - 1
background-user/src/main/java/cn/kdan/compdf/controller/v1/BackgroundUserProjectController.java

@@ -69,7 +69,7 @@ public class BackgroundUserProjectController {
      */
     @PutMapping("editProject")
     public R<Void> editProject(@Validated @RequestBody EditProjectDTO editProjectDTO) {
-        backgroundUserProjectService.editProject(editProjectDTO);
+        backgroundUserProjectService.editProject(editProjectDTO,TokenUtil.getRequestHeader().getId());
         return R.ok();
     }
 

+ 13 - 0
background-user/src/main/java/cn/kdan/compdf/controller/v1/BackgroundUserWebhookController.java

@@ -101,4 +101,17 @@ public class BackgroundUserWebhookController {
         return R.ok();
     }
 
+    /**
+     * editWebhookStatus 修改webhook状态
+     * @param id webhookId
+     * @param status 状态, -1:关闭,0:删除,1:正常
+     * @return Void
+     */
+    @PutMapping("/editWebhookStatus")
+    public R<Void> editWebhookStatus(Long id,Integer status){
+        backgroundUserWebhookService.updateWebhookStatus(id,status);
+        return R.ok();
+    }
+
+
 }

+ 4 - 0
background-user/src/main/java/cn/kdan/compdf/dto/EditWebhookDTO.java

@@ -39,4 +39,8 @@ public class EditWebhookDTO implements Serializable {
      */
     @JsonIgnore
     private Long userId;
+    /**
+     * 状态
+     */
+    private Integer status;
 }

+ 1 - 1
background-user/src/main/java/cn/kdan/compdf/service/BackgroundUserProjectService.java

@@ -44,7 +44,7 @@ public interface BackgroundUserProjectService extends IService<BackgroundUserPro
      * 编辑项目
      * @param editProjectDTO 编辑参数
      */
-    void editProject(EditProjectDTO editProjectDTO);
+    void editProject(EditProjectDTO editProjectDTO,Long userId);
 
     /**
      * 删除项目

+ 7 - 0
background-user/src/main/java/cn/kdan/compdf/service/BackgroundUserWebhookService.java

@@ -55,4 +55,11 @@ public interface BackgroundUserWebhookService extends IService<BackgroundUserWeb
      * 修改webhook最后调用时间
      */
     void updateWebhookLastSendTime(List<WebhookLogsDTO> webhookLogsDTOList);
+
+    /**
+     * 修改webhook状态
+     * @param webhookId webhookId
+     * @param status    status
+     */
+    void updateWebhookStatus(Long webhookId, Integer status);
 }

+ 1 - 1
background-user/src/main/java/cn/kdan/compdf/service/impl/BackgroundUserBalanceServiceImpl.java

@@ -125,7 +125,7 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
     public void exportBalanceRecordList(Integer isDecs, Long userId, HttpServletResponse response) {
         LambdaQueryWrapper<BackgroundUserBalance> eq = new LambdaQueryWrapper<BackgroundUserBalance>()
                 .eq(BackgroundUserBalance::getUserId, userId)
-                .orderByDesc(BackgroundUserBalance::getCreateDate);
+                .orderByDesc(BackgroundUserBalance::getDate);
         List<BackgroundUserBalance> backgroundUserBalanceList = this.baseMapper.selectList(eq);
         // 处理返回数据
         List<BackgroundUserBalanceVO> backgroundUserBalanceVOList = new ArrayList<>();

+ 2 - 1
background-user/src/main/java/cn/kdan/compdf/service/impl/BackgroundUserProjectServiceImpl.java

@@ -140,10 +140,11 @@ public class BackgroundUserProjectServiceImpl extends ServiceImpl<BackgroundUser
      * @param editProjectDTO 编辑参数
      */
     @Override
-    public void editProject(EditProjectDTO editProjectDTO) {
+    public void editProject(EditProjectDTO editProjectDTO,Long userId) {
         // 验证名称是否重复
         LambdaQueryWrapper<BackgroundUserProject> eq = new LambdaQueryWrapper<BackgroundUserProject>()
                 .ne(BackgroundUserProject::getId, editProjectDTO.getId())
+                .eq(BackgroundUserProject::getUserId,userId)
                 .eq(BackgroundUserProject::getStatus, 1)
                 .eq(BackgroundUserProject::getProjectName, editProjectDTO.getProjectName());
         Long selectCount = baseMapper.selectCount(eq);

+ 20 - 2
background-user/src/main/java/cn/kdan/compdf/service/impl/BackgroundUserWebhookServiceImpl.java

@@ -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);
+    }
+
 
 
 }

+ 1 - 1
background-user/src/main/java/cn/kdan/compdf/vo/BackgroundUserWebhookVO.java

@@ -38,7 +38,7 @@ public class BackgroundUserWebhookVO {
     /**
      * 上一次发送请求的时间
      */
-    private Date responseTime;
+    private String responseTime;
 
     /**
      * Events

+ 3 - 3
background-user/src/main/resources/application.yml

@@ -8,10 +8,10 @@ spring:
     date-format: yyyy-MM-dd HH:mm:ss
     time-zone: GMT+8
   rabbitmq:
-    host: ${MQ_HOST:101.132.103.13}
-    port: ${MQ_PORT:35672}
+    host: ${MQ_HOST:106.55.99.175}
+    port: ${MQ_PORT:5672}
     username: ${MQ_USERNAME:admin}
-    password: ${MQ_PASSWORD:1qazZAQ!2}
+    password: ${MQ_PASSWORD:admin}
     virtualHost: /
     # 发送端确认
     publisher-confirm-type: correlated