DictItemUpdateResponse response = dictItemManager.updateDictItem(req); | DictItemUpdateResponse response = dictItemManager.updateDictItem(req); | ||||
return ApiResponse.of(response); | return ApiResponse.of(response); | ||||
} | } | ||||
@ApiOperation(value = "2-4.字典项目获取所有") | |||||
@PostMapping(value = "/itemGetAll") | |||||
public ApiResponse<DictItemGetAllResponse> itemGetAll(@RequestBody @Valid DictItemGetAllRequest req) throws ManagerException { | |||||
DictItemGetAllResponse response = dictItemManager.getAllDictItem(req); | |||||
return ApiResponse.of(response); | |||||
} | |||||
} | } |
DictItemAddResponse createDictItem(DictItemAddRequest req) throws ManagerException; | DictItemAddResponse createDictItem(DictItemAddRequest req) throws ManagerException; | ||||
DictItemUpdateResponse updateDictItem(DictItemUpdateRequest req) throws ManagerException; | DictItemUpdateResponse updateDictItem(DictItemUpdateRequest req) throws ManagerException; | ||||
DictItemDeleteResponse deleteDictItem(DictItemDeleteRequest req) throws ManagerException; | DictItemDeleteResponse deleteDictItem(DictItemDeleteRequest req) throws ManagerException; | ||||
DictItemGetAllResponse getAllDictItem(DictItemGetAllRequest typeId) throws ManagerException; | |||||
} | } |
dictItemModel.setOrder(dictItem.getItemOrder()); | dictItemModel.setOrder(dictItem.getItemOrder()); | ||||
return dictItemModel; | return dictItemModel; | ||||
} | } | ||||
@Override | |||||
public DictItemGetAllResponse getAllDictItem(DictItemGetAllRequest req) throws ManagerException { | |||||
DictItemGetAllResponse res = new DictItemGetAllResponse(); | |||||
Map<String, List<DictItemModel>> dictTypeModels = Maps.newHashMap(); | |||||
List<DictType> dictTypes = dictTypeRepo.findAll(); | |||||
for (DictType dictType : dictTypes) { | |||||
List<DictItem> dictItemList = dictItemRepo.findByTypeId(dictType.getId()); | |||||
if (dictItemList == null) | |||||
throw new ManagerException("未查询到对应数据,请检查参数!"); | |||||
List<DictItemModel> dictItemModels = | |||||
dictItemList.stream().map(DictItemModel::fromDictItem).collect(Collectors.toList()); | |||||
dictTypeModels.put(dictType.getCode(), dictItemModels); | |||||
} | |||||
res.setDictTypeAndItem(dictTypeModels); | |||||
return res; | |||||
} | |||||
} | } |