添加行程规划功能接口

This commit is contained in:
lulz1 2024-02-20 08:19:39 +08:00
parent c79f61e23e
commit 7b67196eff
4 changed files with 25 additions and 5 deletions

View File

@ -0,0 +1,12 @@
package com.chint.application.dtos.response;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
@Data
public class LocationRes {
@Id
private Long locationId;
private String locationName;
}

View File

@ -1,6 +1,8 @@
package com.chint.application.out; package com.chint.application.out;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.LocationParam; import com.chint.application.dtos.LocationParam;
import com.chint.application.dtos.response.LocationRes;
import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.Location;
import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.LocationRepository;
import com.chint.domain.service.LocationDomainService; import com.chint.domain.service.LocationDomainService;
@ -36,15 +38,21 @@ public class LocationController {
@ApiOperation("根据查询词查询地理信息") @ApiOperation("根据查询词查询地理信息")
@PostMapping("/query/word") @PostMapping("/query/word")
public Result<List<Location>> queryByFirstLetter(@RequestBody LocationParam locationParam) { public Result<List<LocationRes>> queryByFirstLetter(@RequestBody LocationParam locationParam) {
String queryWord = locationParam.getQueryWord(); String queryWord = locationParam.getQueryWord();
List<Location> locations = null; List<Location> locations = null;
List<LocationRes> locationRes = null;
if (StringCheck.isFirstCharacterAlphabetic(queryWord)) { if (StringCheck.isFirstCharacterAlphabetic(queryWord)) {
locations = locationDomainService.queryByFirstLetter(locationParam); locations = locationDomainService.queryByFirstLetter(locationParam);
} }
if(StringCheck.isFirstCharacterChinese(queryWord)){ if (StringCheck.isFirstCharacterChinese(queryWord)) {
locations = locationDomainService.queryByCityName(locationParam); locations = locationDomainService.queryByCityName(locationParam);
} }
return Result.Success(SUCCESS, locations); if (locations != null && !locations.isEmpty()) {
locationRes = locations
.stream()
.map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList();
}
return Result.Success(SUCCESS, locationRes);
} }
} }

View File

@ -12,7 +12,7 @@ import static com.chint.infrastructure.constant.Constant.*;
@Data @Data
public class ApprovalEvent { public class ApprovalEvent {
@Id @Id
private Long approveEventId; private Long approvalEventId;
@Column("route_id") @Column("route_id")
private Long routeId; private Long routeId;

View File

@ -137,7 +137,7 @@ public class RouteOrder extends BaseEntity {
private RouteOrder reloadApprovalStatus(){ private RouteOrder reloadApprovalStatus(){
if (this.approveEvents != null && !this.approveEvents.isEmpty()) { if (this.approveEvents != null && !this.approveEvents.isEmpty()) {
this.approveEvents.stream() this.approveEvents.stream()
.max(Comparator.comparingLong(ApprovalEvent::getApproveEventId)) .max(Comparator.comparingLong(ApprovalEvent::getApprovalEventId))
.ifPresent(event -> this.setApprovalStatus(event.reloadStatus().getEventName())); .ifPresent(event -> this.setApprovalStatus(event.reloadStatus().getEventName()));
} else { } else {
this.setApprovalStatus(APPROVAL_EVENT_PREPARE_NAME); this.setApprovalStatus(APPROVAL_EVENT_PREPARE_NAME);