jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/DevModelController.java
@@ -92,4 +92,20 @@ BeanUtils.toBean(list, DevModelRespVO.class)); } @GetMapping("/brand-option") @Operation(summary = "è·å¾åçé项") @PreAuthorize("@ss.hasPermission('ecg:dev-model:query')") public CommonResult<List<OptionVO>> getBrandOption(String category) { List<OptionVO> optionVOList = devModelService.getBrandOptions( category ); return success( optionVOList ); } @GetMapping("/model-option") @Operation(summary = "è·å¾æ¨¡åé项") @PreAuthorize("@ss.hasPermission('ecg:dev-model:query')") public CommonResult<List<OptionVO>> getModelOption(String category, String brand) { List<OptionVO> optionVOList = devModelService.getBrandModelOptions( category, brand ); return success( optionVOList ); } } jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/vo/OptionVO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,19 @@ package cn.lihu.jh.module.ecg.controller.admin.devmanage.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import javax.validation.constraints.NotEmpty; @Schema(description = "管çåå° - 设å¤åå·æ°å¢/ä¿®æ¹ Option VO") @Data public class OptionVO { @Schema(description = "æ¾ç¤ºå", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "æ¾ç¤ºåä¸è½ä¸ºç©º") private String label; @Schema(description = "éåå¼", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "éåå¼ä¸è½ä¸ºç©º") private String value; } jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devmanage/DevModelMapper.java
@@ -8,6 +8,8 @@ import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DevModelDO; import org.apache.ibatis.annotations.Mapper; import cn.lihu.jh.module.ecg.controller.admin.devmanage.vo.*; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; /** * 设å¤åå· Mapper @@ -26,4 +28,10 @@ .orderByDesc(DevModelDO::getId)); } @Select("select distinct brand from lihu.device_model where category=#{category}") List<String> getBrandByCategory(@Param("category") String category); @Select("select model from lihu.device_model where category=#{category} and brand=#{brand}") List<String> getModelByCategoryBrand(@Param("category") String category, @Param("brand") String brand); } jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelService.java
@@ -5,6 +5,7 @@ import cn.lihu.jh.framework.common.pojo.PageResult; import javax.validation.Valid; import java.util.List; /** * 设å¤åå· Service æ¥å£ @@ -51,4 +52,13 @@ */ PageResult<DevModelDO> getDevModelPage(DevModelPageReqVO pageReqVO); /** * æ ¹æ®åç±»è·ååç */ List<OptionVO> getBrandOptions(String devCategory); /** * æ ¹æ®åç±»ååçï¼è·ååå· */ List<OptionVO> getBrandModelOptions(String devCategory, String devBrand); } jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelServiceImpl.java
@@ -1,5 +1,7 @@ package cn.lihu.jh.module.ecg.service.devmanage; import cn.lihu.jh.module.system.api.dict.DictDataApi; import cn.lihu.jh.module.system.api.dict.dto.DictDataRespDTO; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -11,6 +13,11 @@ import cn.lihu.jh.module.ecg.dal.mysql.devmanage.DevModelMapper; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*; @@ -26,6 +33,9 @@ @Resource private DevModelMapper devModelMapper; @Resource private DictDataApi dictDataApi; @Override public Integer createDevModel(DevModelSaveReqVO createReqVO) { @@ -69,4 +79,34 @@ return devModelMapper.selectPage(pageReqVO); } @Override public List<OptionVO> getBrandOptions(String devCategory) { List<String> list = devModelMapper.getBrandByCategory(devCategory); List<DictDataRespDTO> dictDataRespDTOList = dictDataApi.getDictDataList("ecg_dev_brand"); Map<String, String> map = dictDataRespDTOList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel)); List<OptionVO> optionVOList = new ArrayList<>(); list.forEach(item -> { OptionVO optionVO = new OptionVO(); optionVO.setLabel( map.get(item) ); optionVO.setValue( item ); optionVOList.add( optionVO ); }); return optionVOList; } @Override public List<OptionVO> getBrandModelOptions(String devCategory, String devBrand) { List<String> list = devModelMapper.getModelByCategoryBrand(devCategory, devBrand); List<OptionVO> optionVOList = new ArrayList<>(); list.forEach(item -> { OptionVO optionVO = new OptionVO(); optionVO.setLabel( item ); optionVO.setValue( item ); optionVOList.add( optionVO ); }); return optionVOList; } }