Browse Source

新增查询事件的最新图片接口

tags/V1.0.0^2
xiaoying 1 year ago
parent
commit
387387829e
3 changed files with 33 additions and 2 deletions
  1. +11
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/EventController.java
  2. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/EventService.java
  3. +20
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/EventServiceImpl.java

+ 11
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/EventController.java View File

@@ -73,4 +73,15 @@ public class EventController {
return eventService.findCoordinate(eventId);
}

/**
* 查询最新事件的最新一张图片
* @param eventId
* @return
*/
@GetMapping("/findLastImg")
public JsonResult findLastImg(String eventId){
return eventService.findLastImg(eventId);
}


}

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/EventService.java View File

@@ -28,4 +28,6 @@ public interface EventService extends IService<Event> {
JsonResult findImgList();

JsonResult findCoordinate(String eventId);

JsonResult findLastImg(String eventId);
}

+ 20
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/EventServiceImpl.java View File

@@ -180,7 +180,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event>
//查询出对应事件对应的最新三张图片
List<TargetData> targetData = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery()
.eq(TargetData::getTargetId, event.getTargetId())
.eq(TargetData::getTenantId,CurrentUserUtil.getTenantId())
.eq(TargetData::getTenantId, CurrentUserUtil.getTenantId())
.orderByDesc(BaseEntity::getCreateTime).last("limit 3"));
//拼接域名
targetData = targetData.stream().map(t -> {
@@ -207,7 +207,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event>
}
//图片集合
List<TargetData> targetData = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery()
.eq(TargetData::getTenantId,CurrentUserUtil.getTenantId())
.eq(TargetData::getTenantId, CurrentUserUtil.getTenantId())
.eq(TargetData::getTargetId, event.getTargetId()));
List<String> list = new ArrayList<>();
//经纬度集合
@@ -217,6 +217,24 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event>
}
return JsonResult.success(list);
}

@Override
public JsonResult findLastImg(String eventId) {

Event event = eventMapper.selectById(eventId);
if (ObjectUtils.isNull(event.getInspectionId())) {
return JsonResult.error("该事件不存在");
}
//图片集合
List<TargetData> targetDataList = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery()
.eq(TargetData::getTenantId, CurrentUserUtil.getTenantId())
.eq(TargetData::getTargetId, event.getTargetId())
.orderByDesc(BaseEntity::getCreateTime).last("limit 1"));
TargetData data = targetDataList.get(0);
data.setImageUrl(CommonConfig.ossURL + data.getImageUrl());

return JsonResult.success(data);
}
}



Loading…
Cancel
Save