|
|
@@ -17,13 +17,11 @@ import com.zhongshu.card.client.model.org.*;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.org.OrganizationService;
|
|
|
+import com.zhongshu.card.client.utils.type.OrganizationState;
|
|
|
import com.zhongshu.card.client.utils.type.UserState;
|
|
|
import com.zhongshu.card.server.core.dao.org.*;
|
|
|
import com.zhongshu.card.server.core.dataConfig.CardDefault;
|
|
|
-import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
-import com.zhongshu.card.server.core.domain.org.OrganizationUser;
|
|
|
-import com.zhongshu.card.server.core.domain.org.Role;
|
|
|
-import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
+import com.zhongshu.card.server.core.domain.org.*;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.DateUtils;
|
|
|
@@ -155,7 +153,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
// 不为项目的时候,要初始数据
|
|
|
if (authType != AuthType.Project) {
|
|
|
// 初始机构数据
|
|
|
- initOrganization(organization);
|
|
|
+ initOrganization(organization, param.getPassword());
|
|
|
}
|
|
|
|
|
|
return ResultContent.buildSuccess(organization);
|
|
|
@@ -163,13 +161,39 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
|
|
|
/**
|
|
|
* 添加学校
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResultContent addSchool(SchoolAddParam param){
|
|
|
+ public ResultContent addSchool(SchoolAddParam param) {
|
|
|
+ Assert.hasText(param.getProjectId(), "projectId 项目ID不能为空");
|
|
|
+ Assert.hasText(param.getPassword(), "密码不能为空");
|
|
|
+ Assert.hasText(param.getContactPhone(), "手机号不能为空");
|
|
|
|
|
|
+ String projectId = param.getProjectId();
|
|
|
+ Organization organization = organizationDao.findTopByOid(projectId);
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return ResultContent.buildSuccess(String.format("项目不存在:%s", projectId));
|
|
|
+ }
|
|
|
+ // 验证密码是否符合格式
|
|
|
|
|
|
+
|
|
|
+ OrganizationAddParam addParam = new SchoolAddParam();
|
|
|
+ BeanUtils.copyProperties(param, addParam);
|
|
|
+ ResultContent<Organization> resultContent = addOrganization(addParam);
|
|
|
+ if (resultContent.isSuccess()) {
|
|
|
+ Organization main = resultContent.getContent();
|
|
|
+ OrganizationRelation organizationRelation = organizationRelationDao.findTopByMainOrganization(main);
|
|
|
+ if (ObjectUtils.isEmpty(organizationRelation)) {
|
|
|
+ organizationRelation = new OrganizationRelation();
|
|
|
+ }
|
|
|
+ organizationRelation.setMainOrganization(main);
|
|
|
+ organizationRelation.setRelOrganization(organization);
|
|
|
+ organizationRelationDao.save(organizationRelation);
|
|
|
+ } else {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -231,7 +255,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
- public ResultContent<OrganizationModel> getDetail(String oid){
|
|
|
+ public ResultContent<OrganizationModel> getDetail(String oid) {
|
|
|
Organization organization = organizationDao.findTopByOid(oid);
|
|
|
if (ObjectUtils.isEmpty(organization)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, oid));
|
|
|
@@ -284,6 +308,20 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toProjectModel));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询所有可用的项目
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<List<OrganizationModel>> getProjectList() {
|
|
|
+ List<Organization> list = organizationDao.findByAuthTypeAndStateOrderByCreateTimeDesc(AuthType.Project, OrganizationState.Normal);
|
|
|
+ List<OrganizationModel> models = new ArrayList<>();
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ models = list.stream().map(this::toModel).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(models);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询用户加入的机构列表
|
|
|
*
|
|
|
@@ -328,7 +366,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
String oid = "";
|
|
|
|
|
|
AuthType authType = AuthType.Platform;
|
|
|
- Organization organization = organizationDao.findByAuthType(authType);
|
|
|
+ Organization organization = organizationDao.findTopByAuthType(authType);
|
|
|
if (ObjectUtils.isEmpty(organization)) {
|
|
|
log.info("initSuperOrganization 开始初始平台结构信息");
|
|
|
com.github.microservice.auth.client.model.OrganizationModel organizationModel = new com.github.microservice.auth.client.model.OrganizationModel();
|
|
|
@@ -360,7 +398,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
organization.setContactPhone(CardDefault.SUPER_ADMIN_NAME);
|
|
|
organizationDao.save(organization);
|
|
|
// 初始用户信息
|
|
|
- initOrganization(organization);
|
|
|
+ initOrganization(organization, "");
|
|
|
} else {
|
|
|
oid = organization.getOid();
|
|
|
log.info("平台管理员账号已存在...");
|
|
|
@@ -374,7 +412,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
* @param organization
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent initOrganization(Organization organization) {
|
|
|
+ public ResultContent initOrganization(Organization organization, String password) {
|
|
|
String userId = "";
|
|
|
// 查询用户是否存在
|
|
|
com.github.microservice.auth.client.content.ResultContent<UserModel> userModelResult =
|
|
|
@@ -382,9 +420,12 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
if (userModelResult.getState() != ResultState.Success) {
|
|
|
//未注册
|
|
|
//TODO 权限中心: 注册用户
|
|
|
+ if (StringUtils.isEmpty(password)) {
|
|
|
+ password = CardDefault.DEFAULT_PASSWORD;
|
|
|
+ }
|
|
|
com.github.microservice.auth.client.content.ResultContent<String> addModelResult = userService.add(
|
|
|
UserAuthModel.builder().loginType(LoginType.Phone).loginValue(organization.getContactPhone())
|
|
|
- .passWord(CardDefault.DEFAULT_PASSWORD).build());
|
|
|
+ .passWord(password).build());
|
|
|
userId = addModelResult.getContent();
|
|
|
log.info("初始权限中心 用户成功:{}", userId);
|
|
|
} else {
|