|
|
@@ -89,7 +89,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
OrganizationRelationDao organizationRelationDao;
|
|
|
|
|
|
/**
|
|
|
- * 添加机构
|
|
|
+ * 添加机构 (只是添加、没得编辑)
|
|
|
*
|
|
|
* @param param
|
|
|
* @return
|
|
|
@@ -163,6 +163,29 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
return ResultContent.buildSuccess(organization);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑项目
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent updateProject(ProjectUpdateParam param) {
|
|
|
+ Assert.hasText(param.getId(), "id不能为空");
|
|
|
+ Assert.hasText(param.getName(), "name不能为空");
|
|
|
+ Organization organization = organizationDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
+ }
|
|
|
+ Organization tempOrganization = organizationDao.findTopByName(param.getName());
|
|
|
+ if (ObjectUtils.isNotEmpty(tempOrganization) && !ObjectUtils.equals(organization.getId(), tempOrganization.getId())) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, organization);
|
|
|
+ organizationDao.save(organization);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加学校
|
|
|
*
|
|
|
@@ -186,8 +209,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
ResultContent<Organization> resultContent = addOrganization(addParam);
|
|
|
if (resultContent.isSuccess()) {
|
|
|
Organization main = resultContent.getContent();
|
|
|
- OrganizationRelation organizationRelation = organizationRelationDao
|
|
|
- .findTopByMainOrganizationAndRelationType(main, OrganizationRelationType.SchoolToProject);
|
|
|
+ OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganizationAndRelationType(main, OrganizationRelationType.SchoolToProject);
|
|
|
if (ObjectUtils.isEmpty(organizationRelation)) {
|
|
|
organizationRelation = new OrganizationRelation();
|
|
|
}
|
|
|
@@ -244,8 +266,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
BeanUtils.copyProperties(param, main);
|
|
|
|
|
|
// 找出关联的项目
|
|
|
- OrganizationRelation organizationRelation = organizationRelationDao
|
|
|
- .findTopByMainOrganizationAndRelationType(main, OrganizationRelationType.SchoolToProject);
|
|
|
+ OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganizationAndRelationType(main, OrganizationRelationType.SchoolToProject);
|
|
|
if (ObjectUtils.isEmpty(organizationRelation)) {
|
|
|
organizationRelation = new OrganizationRelation();
|
|
|
}
|
|
|
@@ -356,8 +377,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
if (StringUtils.isNotEmpty(param.getProjectOid())) {
|
|
|
// 查询项目已绑定的学校数据
|
|
|
Organization organization = organizationDao.findTopByOid(param.getProjectOid());
|
|
|
- List<OrganizationRelation> list = organizationRelationDao
|
|
|
- .findByRelOrganizationAndRelationType(organization, OrganizationRelationType.SchoolToProject);
|
|
|
+ List<OrganizationRelation> list = organizationRelationDao.findByRelOrganizationAndRelationType(organization, OrganizationRelationType.SchoolToProject);
|
|
|
if (ObjectUtils.isNotEmpty(list)) {
|
|
|
List<String> oids = list.stream().map(it -> {
|
|
|
return it.getOid();
|
|
|
@@ -666,8 +686,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
// 判断不同的类型
|
|
|
if (entity.getAuthType() == AuthType.School) {
|
|
|
// 学校:查询出关联的项目信息
|
|
|
- OrganizationRelation organization = organizationRelationDao
|
|
|
- .findTopByMainOrganizationAndRelationType(entity, OrganizationRelationType.SchoolToProject);
|
|
|
+ OrganizationRelation organization = organizationRelationDao.findTopByMainOrganizationAndRelationType(entity, OrganizationRelationType.SchoolToProject);
|
|
|
if (ObjectUtils.isNotEmpty(organization)) {
|
|
|
model.setProjectModel(toSimpleModel(organization.getRelOrganization()));
|
|
|
}
|
|
|
@@ -700,8 +719,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
// 统计学校数量
|
|
|
- Long number = organizationRelationDao
|
|
|
- .countByRelOrganizationAndRelationType(entity, OrganizationRelationType.SchoolToProject);
|
|
|
+ Long number = organizationRelationDao.countByRelOrganizationAndRelationType(entity, OrganizationRelationType.SchoolToProject);
|
|
|
model.setSchoolNumber(number);
|
|
|
}
|
|
|
return model;
|