@Test public void testListRecipeTemplate() throws Exception { }
@Override public CommonResult listRecipeTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); if (departmentId == null || roleId == null) return CommonResult.fail(ResultCode.E_800); List<HashMap> recipeTemplates = recipeTemplateMapper.listAvailableByType(roleId, departmentId, type); HashMap<String, List<HashMap>> personal = new HashMap<>(); HashMap<String, List<HashMap>> department = new HashMap<>(); HashMap<String, List<HashMap>> hospital = new HashMap<>(); for(HashMap recipeTemplate : recipeTemplates){ String recipeName = (String)recipeTemplate.get("name"); Integer scope = (Integer) recipeTemplate.get("scope"); recipeTemplate.remove("name"); recipeTemplate.remove("scope"); recipeTemplate.remove("roleId"); recipeTemplate.remove("departmentId"); List<HashMap> medicines; if(scope == 1) { System.out.println(personal); if(personal.containsKey(recipeName)) medicines = personal.get(recipeName); else medicines = new ArrayList<>(); medicines.add(recipeTemplate); personal.put(recipeName, medicines); } if (scope == 2) { if(department.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); department.put(recipeName, medicines); } } if (scope == 3) { if(hospital.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); hospital.put(recipeName, medicines); } } } returnJson.put("personal", toJson(personal)); returnJson.put("department", toJson(department)); returnJson.put("hospital", toJson(hospital)); return CommonResult.success(returnJson); }
RecipeTemplateManagementServiceImpl implements RecipeTemplateManagementService { @Override public CommonResult listRecipeTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); if (departmentId == null || roleId == null) return CommonResult.fail(ResultCode.E_800); List<HashMap> recipeTemplates = recipeTemplateMapper.listAvailableByType(roleId, departmentId, type); HashMap<String, List<HashMap>> personal = new HashMap<>(); HashMap<String, List<HashMap>> department = new HashMap<>(); HashMap<String, List<HashMap>> hospital = new HashMap<>(); for(HashMap recipeTemplate : recipeTemplates){ String recipeName = (String)recipeTemplate.get("name"); Integer scope = (Integer) recipeTemplate.get("scope"); recipeTemplate.remove("name"); recipeTemplate.remove("scope"); recipeTemplate.remove("roleId"); recipeTemplate.remove("departmentId"); List<HashMap> medicines; if(scope == 1) { System.out.println(personal); if(personal.containsKey(recipeName)) medicines = personal.get(recipeName); else medicines = new ArrayList<>(); medicines.add(recipeTemplate); personal.put(recipeName, medicines); } if (scope == 2) { if(department.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); department.put(recipeName, medicines); } } if (scope == 3) { if(hospital.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); hospital.put(recipeName, medicines); } } } returnJson.put("personal", toJson(personal)); returnJson.put("department", toJson(department)); returnJson.put("hospital", toJson(hospital)); return CommonResult.success(returnJson); } }
RecipeTemplateManagementServiceImpl implements RecipeTemplateManagementService { @Override public CommonResult listRecipeTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); if (departmentId == null || roleId == null) return CommonResult.fail(ResultCode.E_800); List<HashMap> recipeTemplates = recipeTemplateMapper.listAvailableByType(roleId, departmentId, type); HashMap<String, List<HashMap>> personal = new HashMap<>(); HashMap<String, List<HashMap>> department = new HashMap<>(); HashMap<String, List<HashMap>> hospital = new HashMap<>(); for(HashMap recipeTemplate : recipeTemplates){ String recipeName = (String)recipeTemplate.get("name"); Integer scope = (Integer) recipeTemplate.get("scope"); recipeTemplate.remove("name"); recipeTemplate.remove("scope"); recipeTemplate.remove("roleId"); recipeTemplate.remove("departmentId"); List<HashMap> medicines; if(scope == 1) { System.out.println(personal); if(personal.containsKey(recipeName)) medicines = personal.get(recipeName); else medicines = new ArrayList<>(); medicines.add(recipeTemplate); personal.put(recipeName, medicines); } if (scope == 2) { if(department.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); department.put(recipeName, medicines); } } if (scope == 3) { if(hospital.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); hospital.put(recipeName, medicines); } } } returnJson.put("personal", toJson(personal)); returnJson.put("department", toJson(department)); returnJson.put("hospital", toJson(hospital)); return CommonResult.success(returnJson); }  }
RecipeTemplateManagementServiceImpl implements RecipeTemplateManagementService { @Override public CommonResult listRecipeTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); if (departmentId == null || roleId == null) return CommonResult.fail(ResultCode.E_800); List<HashMap> recipeTemplates = recipeTemplateMapper.listAvailableByType(roleId, departmentId, type); HashMap<String, List<HashMap>> personal = new HashMap<>(); HashMap<String, List<HashMap>> department = new HashMap<>(); HashMap<String, List<HashMap>> hospital = new HashMap<>(); for(HashMap recipeTemplate : recipeTemplates){ String recipeName = (String)recipeTemplate.get("name"); Integer scope = (Integer) recipeTemplate.get("scope"); recipeTemplate.remove("name"); recipeTemplate.remove("scope"); recipeTemplate.remove("roleId"); recipeTemplate.remove("departmentId"); List<HashMap> medicines; if(scope == 1) { System.out.println(personal); if(personal.containsKey(recipeName)) medicines = personal.get(recipeName); else medicines = new ArrayList<>(); medicines.add(recipeTemplate); personal.put(recipeName, medicines); } if (scope == 2) { if(department.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); department.put(recipeName, medicines); } } if (scope == 3) { if(hospital.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); hospital.put(recipeName, medicines); } } } returnJson.put("personal", toJson(personal)); returnJson.put("department", toJson(department)); returnJson.put("hospital", toJson(hospital)); return CommonResult.success(returnJson); }  @Override CommonResult insertRecipeTemplate(RecipeTemplateParam recipeTemplateParam); @Override CommonResult deleteRecipeTemplate(Integer roleId, String recipeName); @Override CommonResult listRecipeTemplate(Integer roleId, Integer type); CommonResult modifyRecipeTemplate(RecipeTemplateParam recipeTemplateParam); JSONArray toJson(HashMap<String, List<HashMap>> hashMap); }
RecipeTemplateManagementServiceImpl implements RecipeTemplateManagementService { @Override public CommonResult listRecipeTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); if (departmentId == null || roleId == null) return CommonResult.fail(ResultCode.E_800); List<HashMap> recipeTemplates = recipeTemplateMapper.listAvailableByType(roleId, departmentId, type); HashMap<String, List<HashMap>> personal = new HashMap<>(); HashMap<String, List<HashMap>> department = new HashMap<>(); HashMap<String, List<HashMap>> hospital = new HashMap<>(); for(HashMap recipeTemplate : recipeTemplates){ String recipeName = (String)recipeTemplate.get("name"); Integer scope = (Integer) recipeTemplate.get("scope"); recipeTemplate.remove("name"); recipeTemplate.remove("scope"); recipeTemplate.remove("roleId"); recipeTemplate.remove("departmentId"); List<HashMap> medicines; if(scope == 1) { System.out.println(personal); if(personal.containsKey(recipeName)) medicines = personal.get(recipeName); else medicines = new ArrayList<>(); medicines.add(recipeTemplate); personal.put(recipeName, medicines); } if (scope == 2) { if(department.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); department.put(recipeName, medicines); } } if (scope == 3) { if(hospital.containsKey(recipeName)) { medicines = personal.get(recipeName); medicines.add(recipeTemplate); } else { medicines = new ArrayList<>(); medicines.add(recipeTemplate); hospital.put(recipeName, medicines); } } } returnJson.put("personal", toJson(personal)); returnJson.put("department", toJson(department)); returnJson.put("hospital", toJson(hospital)); return CommonResult.success(returnJson); }  @Override CommonResult insertRecipeTemplate(RecipeTemplateParam recipeTemplateParam); @Override CommonResult deleteRecipeTemplate(Integer roleId, String recipeName); @Override CommonResult listRecipeTemplate(Integer roleId, Integer type); CommonResult modifyRecipeTemplate(RecipeTemplateParam recipeTemplateParam); JSONArray toJson(HashMap<String, List<HashMap>> hashMap);  }