Browse Source

log DeviceSn接口 log详情接口修改

S0025136190 1 year ago
parent
commit
de55a03214

+ 7 - 0
Backend/sample/src/main/java/com/dji/sample/manage/controller/DeviceLogsController.java

@@ -142,6 +142,13 @@ public class DeviceLogsController {
         return HttpResultResponse.success(data);
     }
 
+    @GetMapping("/{workspace_id}/devices/{device_sn}/deviceSnLogsList")
+    public HttpResultResponse getDeviceSnLogsList(ManagerLogsQueryParam param, @PathVariable("device_sn") String deviceSn)
+    {
+        PaginationData<DeviceLogsRespDTO> data = deviceLogsService.getDeviceSnLogsList(deviceSn,param);
+        return HttpResultResponse.success(data);
+    }
+
     @GetMapping("/{workspace_id}/devices/logsDetail")
     public HttpResultResponse getLogsDetail(@NotNull String logsId
                                             ) {

+ 2 - 0
Backend/sample/src/main/java/com/dji/sample/manage/service/IDeviceLogsService.java

@@ -92,5 +92,7 @@ public interface IDeviceLogsService {
 
     PaginationData<DeviceLogsRespDTO> getLogsList(ManagerLogsQueryParam param);
 
+    PaginationData<DeviceLogsRespDTO> getDeviceSnLogsList(String deviceSn,ManagerLogsQueryParam parms);
+
     DeviceLogsDetailRespDTO getLogsDetail(String logsId);
 }

+ 21 - 1
Backend/sample/src/main/java/com/dji/sample/manage/service/impl/DeviceLogsServiceImpl.java

@@ -410,6 +410,26 @@ public class DeviceLogsServiceImpl extends AbstractLogService implements IDevice
         return new PaginationData<DeviceLogsRespDTO>(deviceLogsList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal()));
     }
 
+    @Override
+    public PaginationData<DeviceLogsRespDTO> getDeviceSnLogsList(String deviceSn,ManagerLogsQueryParam parms) {
+        LambdaQueryWrapper<DeviceLogsEntity> queryWrapper = new LambdaQueryWrapper<DeviceLogsEntity>()
+                .between(Objects.nonNull(parms.getBeginTime()) && Objects.nonNull(parms.getEndTime()),
+                        DeviceLogsEntity::getCreateTime, parms.getBeginTime(), parms.getEndTime())
+                .eq( DeviceLogsEntity::getDeviceSn, deviceSn)
+                .like(Objects.nonNull(parms.getUsername()), DeviceLogsEntity::getUsername, parms.getUsername())
+                .like(StringUtils.hasText(parms.getSearchInfo()),
+                         DeviceLogsEntity::getLogsInfo, parms.getSearchInfo()
+                )
+                .orderByDesc(DeviceLogsEntity::getCreateTime);
+
+        Page<DeviceLogsEntity> pagination = mapper.selectPage(new Page<>(parms.getPage(), parms.getPageSize()), queryWrapper);
+
+
+        List<DeviceLogsRespDTO> deviceLogsList = pagination.getRecords().stream().map(this::entity2RespDto).collect(Collectors.toList());
+
+        return new PaginationData<DeviceLogsRespDTO>(deviceLogsList, new Pagination(pagination.getCurrent(), pagination.getSize(), pagination.getTotal()));
+    }
+
     @Override
     public DeviceLogsDetailRespDTO getLogsDetail(String logsId) {
         DeviceLogsDetailRespDTO deviceLogsDetailRespDTO = new DeviceLogsDetailRespDTO();
@@ -421,7 +441,7 @@ public class DeviceLogsServiceImpl extends AbstractLogService implements IDevice
             deviceLogsDetailRespDTO.setContactEmail(deviceLogsEntity.getContactEmail());
             deviceLogsDetailRespDTO.setContactNumber(deviceLogsEntity.getContactNumber());
             deviceLogsDetailRespDTO.setHappenTime(deviceLogsEntity.getHappenTime());
-            if(deviceLogsEntity.getOssIds() != null) {
+            if(deviceLogsEntity.getOssIds() != null && !deviceLogsEntity.getOssIds().equals("")) {
                 List<String> urlList = new ArrayList<>();
                 String[] ossIds = deviceLogsEntity.getOssIds().split(",");
                 for (String ossId : ossIds) {