|
|
@@ -165,11 +165,11 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultContent addSchool(SchoolAddParam param) {
|
|
|
- Assert.hasText(param.getProjectId(), "projectId 项目ID不能为空");
|
|
|
+ Assert.hasText(param.getProjectOid(), "projectId 项目ID不能为空");
|
|
|
Assert.hasText(param.getPassword(), "密码不能为空");
|
|
|
Assert.hasText(param.getContactPhone(), "手机号不能为空");
|
|
|
|
|
|
- String projectId = param.getProjectId();
|
|
|
+ String projectId = param.getProjectOid();
|
|
|
Organization organization = organizationDao.findTopByOid(projectId);
|
|
|
if (ObjectUtils.isEmpty(organization)) {
|
|
|
return ResultContent.buildSuccess(String.format("项目不存在:%s", projectId));
|
|
|
@@ -185,10 +185,11 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
ResultContent<Organization> resultContent = addOrganization(addParam);
|
|
|
if (resultContent.isSuccess()) {
|
|
|
Organization main = resultContent.getContent();
|
|
|
- OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganization(main);
|
|
|
+ OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganizationAndAuthType(main, AuthType.School);
|
|
|
if (ObjectUtils.isEmpty(organizationRelation)) {
|
|
|
organizationRelation = new OrganizationRelation();
|
|
|
}
|
|
|
+ organizationRelation.setAuthType(AuthType.School);
|
|
|
organizationRelation.setMainOrganization(main);
|
|
|
organizationRelation.setRelOrganization(organization);
|
|
|
organizationRelationDao.save(organizationRelation);
|
|
|
@@ -198,6 +199,44 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑学校
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent updateSchool(SchoolUpdateParam param) {
|
|
|
+ Assert.hasText(param.getProjectOid(), "projectId 项目ID不能为空");
|
|
|
+ Assert.hasText(param.getContactPhone(), "手机号不能为空");
|
|
|
+
|
|
|
+ String projectId = param.getProjectOid();
|
|
|
+ Organization organization = organizationDao.findTopByOid(projectId);
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return ResultContent.buildSuccess(String.format("项目不存在:%s", projectId));
|
|
|
+ }
|
|
|
+ Organization main = organizationDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(main)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
+ }
|
|
|
+ if (param.getState() == null) {
|
|
|
+ param.setState(OrganizationState.Normal);
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, main);
|
|
|
+
|
|
|
+ // 找出关联的项目
|
|
|
+ OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganizationAndAuthType(main, AuthType.School);
|
|
|
+ if (ObjectUtils.isEmpty(organizationRelation)) {
|
|
|
+ organizationRelation = new OrganizationRelation();
|
|
|
+ }
|
|
|
+ organizationRelation.setAuthType(AuthType.School);
|
|
|
+ organizationRelation.setMainOrganization(main);
|
|
|
+ organizationRelation.setRelOrganization(organization);
|
|
|
+ organizationRelationDao.save(organizationRelation);
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 编辑机构 (编辑基本信息)
|
|
|
*
|
|
|
@@ -253,6 +292,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
|
|
|
// 删除部门
|
|
|
|
|
|
+
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -283,8 +323,22 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
param.setStartTime(startTime);
|
|
|
param.setEndTime(endTime);
|
|
|
}
|
|
|
+
|
|
|
+ // 学校查询的特有参数
|
|
|
+ if (param.getAuthType() == AuthType.School) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getProjectOid())) {
|
|
|
+ Organization organization = organizationDao.findTopByOid(param.getProjectOid());
|
|
|
+ List<OrganizationRelation> list = organizationRelationDao.findByRelOrganizationAndAuthType(organization, AuthType.School);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ List<String> oids = list.stream().map(it -> {
|
|
|
+ return it.getOid();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ param.setOids(oids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Page<Organization> page = organizationDao.page(pageable, param);
|
|
|
- return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -306,7 +360,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
param.setEndTime(endTime);
|
|
|
}
|
|
|
Page<Organization> page = organizationDao.page(pageable, param);
|
|
|
- return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toProjectModel));
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toProjectModel));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -541,6 +595,14 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
OrganizationModel model = new OrganizationModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
+ // 判断不同的类型
|
|
|
+ if(entity.getAuthType() == AuthType.School) {
|
|
|
+ // 学校:查询出关联的项目信息
|
|
|
+ OrganizationRelation organization = organizationRelationDao.findTopByMainOrganizationAndAuthType(entity, AuthType.School);
|
|
|
+ if (ObjectUtils.isNotEmpty(organization)) {
|
|
|
+ model.setProjectModel(toSimpleModel(organization.getRelOrganization()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
@@ -553,9 +615,21 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
*/
|
|
|
public ProjectOrgModel toProjectModel(Organization entity) {
|
|
|
ProjectOrgModel model = new ProjectOrgModel();
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ // 统计学校数量
|
|
|
+ Long number = organizationRelationDao.countByRelOrganizationAndAuthType(entity, AuthType.School);
|
|
|
+ model.setSchoolNumber(number);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
+ public OrganizationSimpleModel toSimpleModel(Organization entity) {
|
|
|
+ OrganizationSimpleModel model = new OrganizationSimpleModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
+
|
|
|
}
|