车型列表租车类型增加标签
This commit is contained in:
@ -26,6 +26,9 @@ public class CarModelSimpleDTO {
|
||||
@ApiModelProperty("租赁类型(时租/日租/按天数/以租代售),用逗号分隔")
|
||||
private String rentalTypes;
|
||||
|
||||
@ApiModelProperty("租赁类型标签(时租/日租/按天数/以租代售),用|分隔")
|
||||
private String rentalTypesLabel;
|
||||
|
||||
@ApiModelProperty("是否支持免押(0不支持 1支持)")
|
||||
private String depositFree;
|
||||
|
||||
|
||||
@ -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<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
|
||||
|
||||
22
src/main/java/com/sczx/car/thirdpart/dto/SysDictDataDTO.java
Normal file
22
src/main/java/com/sczx/car/thirdpart/dto/SysDictDataDTO.java
Normal 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;
|
||||
}
|
||||
@ -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<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);
|
||||
}
|
||||
|
||||
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user