@Test public void testInsertCollectionTemplate() throws Exception { }
@Override public CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam){ Integer type = collectionTemplateParam.getType(); String name = collectionTemplateParam.getNewName(); Integer roleId = collectionTemplateParam.getRoleId(); if(roleId == null || name == null || (type != 1 && type != 2 && type !=3)) return CommonResult.fail(ResultCode.E_801); if(false == isAvailable(roleId, name, type)) return CommonResult.fail(ResultCode.E_806); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); collectionTemplateParam.setDepartmentId(departmentId); List<ProjectTemplateParam> projectTemplateParams = collectionTemplateParam.getProjects(); for (ProjectTemplateParam projectTemplateParam: projectTemplateParams){ if (projectTemplateParam.getProjectId() == null) return CommonResult.fail(ResultCode.E_801); if(type == 3) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, null).getCode()) { return CommonResult.fail(ResultCode.E_802); } } else { List<ItemParam> items = projectTemplateParam.getItems(); for (ItemParam item : items) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, item.getItemId()).getCode()) { return CommonResult.fail(ResultCode.E_802); } } } } return CommonResult.success(0); }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam){ Integer type = collectionTemplateParam.getType(); String name = collectionTemplateParam.getNewName(); Integer roleId = collectionTemplateParam.getRoleId(); if(roleId == null || name == null || (type != 1 && type != 2 && type !=3)) return CommonResult.fail(ResultCode.E_801); if(false == isAvailable(roleId, name, type)) return CommonResult.fail(ResultCode.E_806); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); collectionTemplateParam.setDepartmentId(departmentId); List<ProjectTemplateParam> projectTemplateParams = collectionTemplateParam.getProjects(); for (ProjectTemplateParam projectTemplateParam: projectTemplateParams){ if (projectTemplateParam.getProjectId() == null) return CommonResult.fail(ResultCode.E_801); if(type == 3) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, null).getCode()) { return CommonResult.fail(ResultCode.E_802); } } else { List<ItemParam> items = projectTemplateParam.getItems(); for (ItemParam item : items) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, item.getItemId()).getCode()) { return CommonResult.fail(ResultCode.E_802); } } } } return CommonResult.success(0); } }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam){ Integer type = collectionTemplateParam.getType(); String name = collectionTemplateParam.getNewName(); Integer roleId = collectionTemplateParam.getRoleId(); if(roleId == null || name == null || (type != 1 && type != 2 && type !=3)) return CommonResult.fail(ResultCode.E_801); if(false == isAvailable(roleId, name, type)) return CommonResult.fail(ResultCode.E_806); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); collectionTemplateParam.setDepartmentId(departmentId); List<ProjectTemplateParam> projectTemplateParams = collectionTemplateParam.getProjects(); for (ProjectTemplateParam projectTemplateParam: projectTemplateParams){ if (projectTemplateParam.getProjectId() == null) return CommonResult.fail(ResultCode.E_801); if(type == 3) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, null).getCode()) { return CommonResult.fail(ResultCode.E_802); } } else { List<ItemParam> items = projectTemplateParam.getItems(); for (ItemParam item : items) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, item.getItemId()).getCode()) { return CommonResult.fail(ResultCode.E_802); } } } } return CommonResult.success(0); }  }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam){ Integer type = collectionTemplateParam.getType(); String name = collectionTemplateParam.getNewName(); Integer roleId = collectionTemplateParam.getRoleId(); if(roleId == null || name == null || (type != 1 && type != 2 && type !=3)) return CommonResult.fail(ResultCode.E_801); if(false == isAvailable(roleId, name, type)) return CommonResult.fail(ResultCode.E_806); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); collectionTemplateParam.setDepartmentId(departmentId); List<ProjectTemplateParam> projectTemplateParams = collectionTemplateParam.getProjects(); for (ProjectTemplateParam projectTemplateParam: projectTemplateParams){ if (projectTemplateParam.getProjectId() == null) return CommonResult.fail(ResultCode.E_801); if(type == 3) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, null).getCode()) { return CommonResult.fail(ResultCode.E_802); } } else { List<ItemParam> items = projectTemplateParam.getItems(); for (ItemParam item : items) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, item.getItemId()).getCode()) { return CommonResult.fail(ResultCode.E_802); } } } } return CommonResult.success(0); }  @Override CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam); CommonResult saveItems(CollectionTemplateParam collectionTemplateParam,
                                  ProjectTemplateParam projectTemplateParam, String item); Boolean isAvailable(Integer roleId, String name, Integer type); @Override CommonResult listCollectionTemplate(Integer roleId, Integer type); CommonResult deleteCollectionTemplate(CollectionTemplateParam collectionTemplateParam); @Override CommonResult modifyCollectionTemplate(CollectionTemplateParam collectionTemplateParam); }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam){ Integer type = collectionTemplateParam.getType(); String name = collectionTemplateParam.getNewName(); Integer roleId = collectionTemplateParam.getRoleId(); if(roleId == null || name == null || (type != 1 && type != 2 && type !=3)) return CommonResult.fail(ResultCode.E_801); if(false == isAvailable(roleId, name, type)) return CommonResult.fail(ResultCode.E_806); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); collectionTemplateParam.setDepartmentId(departmentId); List<ProjectTemplateParam> projectTemplateParams = collectionTemplateParam.getProjects(); for (ProjectTemplateParam projectTemplateParam: projectTemplateParams){ if (projectTemplateParam.getProjectId() == null) return CommonResult.fail(ResultCode.E_801); if(type == 3) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, null).getCode()) { return CommonResult.fail(ResultCode.E_802); } } else { List<ItemParam> items = projectTemplateParam.getItems(); for (ItemParam item : items) { if (200 != saveItems(collectionTemplateParam, projectTemplateParam, item.getItemId()).getCode()) { return CommonResult.fail(ResultCode.E_802); } } } } return CommonResult.success(0); }  @Override CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam); CommonResult saveItems(CollectionTemplateParam collectionTemplateParam,
                                  ProjectTemplateParam projectTemplateParam, String item); Boolean isAvailable(Integer roleId, String name, Integer type); @Override CommonResult listCollectionTemplate(Integer roleId, Integer type); CommonResult deleteCollectionTemplate(CollectionTemplateParam collectionTemplateParam); @Override CommonResult modifyCollectionTemplate(CollectionTemplateParam collectionTemplateParam);  }