车型列表租车类型增加标签

This commit is contained in:
2025-08-05 23:50:40 +08:00
parent 8f15c0cc6f
commit a55cbe2eb8
5 changed files with 86 additions and 1 deletions

View File

@ -26,6 +26,9 @@ public class CarModelSimpleDTO {
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售),用逗号分隔") @ApiModelProperty("租赁类型(时租/日租/按天数/以租代售),用逗号分隔")
private String rentalTypes; private String rentalTypes;
@ApiModelProperty("租赁类型标签(时租/日租/按天数/以租代售),用|分隔")
private String rentalTypesLabel;
@ApiModelProperty("是否支持免押(0不支持 1支持)") @ApiModelProperty("是否支持免押(0不支持 1支持)")
private String depositFree; private String depositFree;

View File

@ -7,19 +7,41 @@ import com.sczx.car.dto.req.StoreCarModelReq;
import com.sczx.car.po.CarModelPO; import com.sczx.car.po.CarModelPO;
import com.sczx.car.repository.CarModelRepo; import com.sczx.car.repository.CarModelRepo;
import com.sczx.car.service.CarModelService; import com.sczx.car.service.CarModelService;
import com.sczx.car.thirdpart.dto.SysDictDataDTO;
import com.sczx.car.thirdpart.integration.StoreInteg;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
public class CarModelServiceImpl implements CarModelService { public class CarModelServiceImpl implements CarModelService {
@Autowired @Autowired
private CarModelRepo carModelRepo; private CarModelRepo carModelRepo;
@Autowired
private StoreInteg storeInteg;
@Override @Override
public IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize) { public IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize) {
return carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize); IPage<CarModelSimpleDTO> page = carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize);
page.getRecords().forEach(carModelSimpleDTO -> {
if(StringUtils.isNotBlank(carModelSimpleDTO.getRentalTypes())){
List<String> rentalTypeList = Arrays.asList(carModelSimpleDTO.getRentalTypes().split(","));
List<SysDictDataDTO> rentalTypeLabelList = storeInteg.listDictDataByDicType("key_rental_type");
String rentalTypesLabel = rentalTypeLabelList.stream()
.filter(sysDictDataDTO -> rentalTypeList.contains(sysDictDataDTO.getDictValue()))
.map(SysDictDataDTO::getDictLabel).collect(Collectors.joining("|"));
carModelSimpleDTO.setRentalTypesLabel(rentalTypesLabel);
}
});
return page;
} }
@Override @Override

View File

@ -0,0 +1,22 @@
package com.sczx.car.thirdpart.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "SysDictDataDTO对象", description = "字典数据传输对象")
@Data
public class SysDictDataDTO {
@ApiModelProperty("字典标签")
private String dictLabel;
@ApiModelProperty("字典键值")
private String dictValue;
@ApiModelProperty("字典类型")
private String dictType;
@ApiModelProperty("状态0正常 1停用")
private String status;
}

View File

@ -2,13 +2,22 @@ package com.sczx.car.thirdpart.facade;
import com.sczx.car.common.Result; import com.sczx.car.common.Result;
import com.sczx.car.thirdpart.dto.CompanyStoreDTO; import com.sczx.car.thirdpart.dto.CompanyStoreDTO;
import com.sczx.car.thirdpart.dto.SysDictDataDTO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name = "sczx-store") @FeignClient(name = "sczx-store")
public interface StoreFacade { public interface StoreFacade {
@GetMapping("/pub/getStoreById") @GetMapping("/pub/getStoreById")
Result<CompanyStoreDTO> getStoreById(@RequestParam(name = "storeId") Integer storeId); Result<CompanyStoreDTO> getStoreById(@RequestParam(name = "storeId") Integer storeId);
@GetMapping("/sys/getDictDataByDicTypeAndValue")
Result<SysDictDataDTO> getDictDataByDicTypeAndValue(@RequestParam(name = "dicType") String dicType, @RequestParam(name = "dicValue") String dicValue);
@GetMapping("/sys/listDictDataByDicType")
Result<List<SysDictDataDTO>> listDictDataByDicType(@RequestParam(name = "dicType") String dicType);
} }

View File

@ -3,11 +3,14 @@ package com.sczx.car.thirdpart.integration;
import com.sczx.car.common.Result; import com.sczx.car.common.Result;
import com.sczx.car.exception.InnerException; import com.sczx.car.exception.InnerException;
import com.sczx.car.thirdpart.dto.CompanyStoreDTO; import com.sczx.car.thirdpart.dto.CompanyStoreDTO;
import com.sczx.car.thirdpart.dto.SysDictDataDTO;
import com.sczx.car.thirdpart.facade.StoreFacade; import com.sczx.car.thirdpart.facade.StoreFacade;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j @Slf4j
@Component @Component
public class StoreInteg { public class StoreInteg {
@ -27,4 +30,30 @@ public class StoreInteg {
} }
return null; return null;
} }
public SysDictDataDTO getDictDataByDicTypeAndValue(String dicType, String dicValue){
try{
Result<SysDictDataDTO> result = storeFacade.getDictDataByDicTypeAndValue(dicType, dicValue);
if(result.isSuccess()){
return result.getData();
}
} catch (Exception e){
log.error("根据字典类型和字典值获取字典数据失败",e);
throw new InnerException("根据字典类型和字典值获取字典数据失败");
}
return null;
}
public List<SysDictDataDTO> listDictDataByDicType(String dicType){
try{
Result<List<SysDictDataDTO>> result = storeFacade.listDictDataByDicType(dicType);
if(result.isSuccess()){
return result.getData();
}
} catch (Exception e){
log.error("根据字典类型获取字典数据失败",e);
throw new InnerException("根据字典类型获取字典数据失败");
}
return null;
}
} }