From a55cbe2eb80b5cbdf099df2c2270a4619b338394 Mon Sep 17 00:00:00 2001 From: zhangli <123879394@qq.com> Date: Tue, 5 Aug 2025 23:50:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E5=9E=8B=E5=88=97=E8=A1=A8=E7=A7=9F?= =?UTF-8?q?=E8=BD=A6=E7=B1=BB=E5=9E=8B=E5=A2=9E=E5=8A=A0=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sczx/car/dto/CarModelSimpleDTO.java | 3 ++ .../car/service/impl/CarModelServiceImpl.java | 24 ++++++++++++++- .../car/thirdpart/dto/SysDictDataDTO.java | 22 ++++++++++++++ .../car/thirdpart/facade/StoreFacade.java | 9 ++++++ .../car/thirdpart/integration/StoreInteg.java | 29 +++++++++++++++++++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/sczx/car/thirdpart/dto/SysDictDataDTO.java diff --git a/src/main/java/com/sczx/car/dto/CarModelSimpleDTO.java b/src/main/java/com/sczx/car/dto/CarModelSimpleDTO.java index 2542cc6..67ea3ec 100644 --- a/src/main/java/com/sczx/car/dto/CarModelSimpleDTO.java +++ b/src/main/java/com/sczx/car/dto/CarModelSimpleDTO.java @@ -26,6 +26,9 @@ public class CarModelSimpleDTO { @ApiModelProperty("租赁类型(时租/日租/按天数/以租代售),用逗号分隔") private String rentalTypes; + @ApiModelProperty("租赁类型标签(时租/日租/按天数/以租代售),用|分隔") + private String rentalTypesLabel; + @ApiModelProperty("是否支持免押(0不支持 1支持)") private String depositFree; diff --git a/src/main/java/com/sczx/car/service/impl/CarModelServiceImpl.java b/src/main/java/com/sczx/car/service/impl/CarModelServiceImpl.java index 2b433c6..f0580fa 100644 --- a/src/main/java/com/sczx/car/service/impl/CarModelServiceImpl.java +++ b/src/main/java/com/sczx/car/service/impl/CarModelServiceImpl.java @@ -7,19 +7,41 @@ import com.sczx.car.dto.req.StoreCarModelReq; import com.sczx.car.po.CarModelPO; import com.sczx.car.repository.CarModelRepo; 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 org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + @Slf4j @Service public class CarModelServiceImpl implements CarModelService { @Autowired private CarModelRepo carModelRepo; + + @Autowired + private StoreInteg storeInteg; + @Override public IPage pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize) { - return carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize); + IPage page = carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize); + page.getRecords().forEach(carModelSimpleDTO -> { + if(StringUtils.isNotBlank(carModelSimpleDTO.getRentalTypes())){ + List rentalTypeList = Arrays.asList(carModelSimpleDTO.getRentalTypes().split(",")); + List 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 diff --git a/src/main/java/com/sczx/car/thirdpart/dto/SysDictDataDTO.java b/src/main/java/com/sczx/car/thirdpart/dto/SysDictDataDTO.java new file mode 100644 index 0000000..073b0cf --- /dev/null +++ b/src/main/java/com/sczx/car/thirdpart/dto/SysDictDataDTO.java @@ -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; +} diff --git a/src/main/java/com/sczx/car/thirdpart/facade/StoreFacade.java b/src/main/java/com/sczx/car/thirdpart/facade/StoreFacade.java index 238d2b7..26b810d 100644 --- a/src/main/java/com/sczx/car/thirdpart/facade/StoreFacade.java +++ b/src/main/java/com/sczx/car/thirdpart/facade/StoreFacade.java @@ -2,13 +2,22 @@ package com.sczx.car.thirdpart.facade; import com.sczx.car.common.Result; import com.sczx.car.thirdpart.dto.CompanyStoreDTO; +import com.sczx.car.thirdpart.dto.SysDictDataDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + @FeignClient(name = "sczx-store") public interface StoreFacade { @GetMapping("/pub/getStoreById") Result getStoreById(@RequestParam(name = "storeId") Integer storeId); + + @GetMapping("/sys/getDictDataByDicTypeAndValue") + Result getDictDataByDicTypeAndValue(@RequestParam(name = "dicType") String dicType, @RequestParam(name = "dicValue") String dicValue); + + @GetMapping("/sys/listDictDataByDicType") + Result> listDictDataByDicType(@RequestParam(name = "dicType") String dicType); } diff --git a/src/main/java/com/sczx/car/thirdpart/integration/StoreInteg.java b/src/main/java/com/sczx/car/thirdpart/integration/StoreInteg.java index e196026..6c3c40c 100644 --- a/src/main/java/com/sczx/car/thirdpart/integration/StoreInteg.java +++ b/src/main/java/com/sczx/car/thirdpart/integration/StoreInteg.java @@ -3,11 +3,14 @@ package com.sczx.car.thirdpart.integration; import com.sczx.car.common.Result; import com.sczx.car.exception.InnerException; import com.sczx.car.thirdpart.dto.CompanyStoreDTO; +import com.sczx.car.thirdpart.dto.SysDictDataDTO; import com.sczx.car.thirdpart.facade.StoreFacade; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; + @Slf4j @Component public class StoreInteg { @@ -27,4 +30,30 @@ public class StoreInteg { } return null; } + + public SysDictDataDTO getDictDataByDicTypeAndValue(String dicType, String dicValue){ + try{ + Result result = storeFacade.getDictDataByDicTypeAndValue(dicType, dicValue); + if(result.isSuccess()){ + return result.getData(); + } + } catch (Exception e){ + log.error("根据字典类型和字典值获取字典数据失败",e); + throw new InnerException("根据字典类型和字典值获取字典数据失败"); + } + return null; + } + + public List listDictDataByDicType(String dicType){ + try{ + Result> result = storeFacade.listDictDataByDicType(dicType); + if(result.isSuccess()){ + return result.getData(); + } + } catch (Exception e){ + log.error("根据字典类型获取字典数据失败",e); + throw new InnerException("根据字典类型获取字典数据失败"); + } + return null; + } }