Parcourir la source

字典项目获取所有接口

master
zouhantao il y a 2 mois
Parent
révision
ba4c78cf06

+ 7
- 0
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/api/DictController.java Voir le fichier

@@ -81,4 +81,11 @@ public class DictController extends MyValidController {
DictItemUpdateResponse response = dictItemManager.updateDictItem(req);
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 Voir le fichier

@@ -9,5 +9,5 @@ public interface DictItemManager {
DictItemAddResponse createDictItem(DictItemAddRequest req) throws ManagerException;
DictItemUpdateResponse updateDictItem(DictItemUpdateRequest 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 Voir le fichier

@@ -112,4 +112,22 @@ public class DictItemManagerImpl extends AbstractManager implements DictItemMana
dictItemModel.setOrder(dictItem.getItemOrder());
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;
}

}

Chargement…
Annuler
Enregistrer