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

return eventService.findCoordinate(eventId); 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

JsonResult findImgList(); JsonResult findImgList();


JsonResult findCoordinate(String eventId); 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

//查询出对应事件对应的最新三张图片 //查询出对应事件对应的最新三张图片
List<TargetData> targetData = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery() List<TargetData> targetData = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery()
.eq(TargetData::getTargetId, event.getTargetId()) .eq(TargetData::getTargetId, event.getTargetId())
.eq(TargetData::getTenantId,CurrentUserUtil.getTenantId())
.eq(TargetData::getTenantId, CurrentUserUtil.getTenantId())
.orderByDesc(BaseEntity::getCreateTime).last("limit 3")); .orderByDesc(BaseEntity::getCreateTime).last("limit 3"));
//拼接域名 //拼接域名
targetData = targetData.stream().map(t -> { targetData = targetData.stream().map(t -> {
} }
//图片集合 //图片集合
List<TargetData> targetData = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery() List<TargetData> targetData = targetDataMapper.selectList(Wrappers.<TargetData>lambdaQuery()
.eq(TargetData::getTenantId,CurrentUserUtil.getTenantId())
.eq(TargetData::getTenantId, CurrentUserUtil.getTenantId())
.eq(TargetData::getTargetId, event.getTargetId())); .eq(TargetData::getTargetId, event.getTargetId()));
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
//经纬度集合 //经纬度集合
} }
return JsonResult.success(list); 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