瀏覽代碼

字典项目获取所有接口

master
zouhantao 2 月之前
父節點
當前提交
ba4c78cf06

+ 7
- 0
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/api/DictController.java 查看文件

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);
}
} }

+ 1
- 1
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/dict/DictItemManager.java 查看文件

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;
} }

+ 18
- 0
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/dict/DictItemManagerImpl.java 查看文件

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;
}

} }

Loading…
取消
儲存