|
@@ -18,6 +18,7 @@ import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.org.OrganizationService;
|
|
import com.zhongshu.card.client.service.org.OrganizationService;
|
|
|
import com.zhongshu.card.client.utils.type.OrganizationState;
|
|
import com.zhongshu.card.client.utils.type.OrganizationState;
|
|
|
|
|
+import com.zhongshu.card.client.utils.type.RoleType;
|
|
|
import com.zhongshu.card.client.utils.type.UserState;
|
|
import com.zhongshu.card.client.utils.type.UserState;
|
|
|
import com.zhongshu.card.server.core.dao.org.*;
|
|
import com.zhongshu.card.server.core.dao.org.*;
|
|
|
import com.zhongshu.card.server.core.dataConfig.CardDefault;
|
|
import com.zhongshu.card.server.core.dataConfig.CardDefault;
|
|
@@ -96,7 +97,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public ResultContent<Organization> addOrganization(OrganizationAddParam param) {
|
|
public ResultContent<Organization> addOrganization(OrganizationAddParam param) {
|
|
|
- if(StringUtils.isNotEmpty(param.getPassword())) {
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(param.getPassword())) {
|
|
|
// 验证密码是否符合格式
|
|
// 验证密码是否符合格式
|
|
|
ValidateResult validateResult = ValidateUtils.validatePassWord(param.getPassword());
|
|
ValidateResult validateResult = ValidateUtils.validatePassWord(param.getPassword());
|
|
|
if (!validateResult.isSuccess()) {
|
|
if (!validateResult.isSuccess()) {
|
|
@@ -134,8 +135,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
organizationModel.setName(param.getName());
|
|
organizationModel.setName(param.getName());
|
|
|
organizationModel.setAuthType(authType);
|
|
organizationModel.setAuthType(authType);
|
|
|
organizationModel.setRemark(param.getRemark());
|
|
organizationModel.setRemark(param.getRemark());
|
|
|
- com.github.microservice.auth.client.content.ResultContent<String>
|
|
|
|
|
- resultContent = organizationService.add(organizationModel);
|
|
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> resultContent = organizationService.add(organizationModel);
|
|
|
|
|
|
|
|
if (resultContent.getState() == ResultState.Success) {
|
|
if (resultContent.getState() == ResultState.Success) {
|
|
|
log.info("平台初始成功: {}", resultContent.getContent());
|
|
log.info("平台初始成功: {}", resultContent.getContent());
|
|
@@ -300,6 +300,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询结构详情
|
|
* 查询结构详情
|
|
|
|
|
+ *
|
|
|
* @param oid
|
|
* @param oid
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
@@ -435,8 +436,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
organizationModel.setName(CardDefault.DEFAULT_PLATFORM_NAME);
|
|
organizationModel.setName(CardDefault.DEFAULT_PLATFORM_NAME);
|
|
|
organizationModel.setAuthType(authType);
|
|
organizationModel.setAuthType(authType);
|
|
|
organizationModel.setRemark("系统自动初始化");
|
|
organizationModel.setRemark("系统自动初始化");
|
|
|
- com.github.microservice.auth.client.content.ResultContent<String>
|
|
|
|
|
- resultContent = organizationService.add(organizationModel);
|
|
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> resultContent = organizationService.add(organizationModel);
|
|
|
|
|
|
|
|
if (resultContent.getState() == ResultState.Success) {
|
|
if (resultContent.getState() == ResultState.Success) {
|
|
|
log.info("平台初始成功: {}", resultContent.getContent());
|
|
log.info("平台初始成功: {}", resultContent.getContent());
|
|
@@ -477,17 +477,14 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
public ResultContent initOrganization(Organization organization, String password) {
|
|
public ResultContent initOrganization(Organization organization, String password) {
|
|
|
String userId = "";
|
|
String userId = "";
|
|
|
// 查询用户是否存在
|
|
// 查询用户是否存在
|
|
|
- com.github.microservice.auth.client.content.ResultContent<UserModel> userModelResult =
|
|
|
|
|
- userService.queryFromLoginType(LoginType.Phone, organization.getContactPhone());
|
|
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<UserModel> userModelResult = userService.queryFromLoginType(LoginType.Phone, organization.getContactPhone());
|
|
|
if (userModelResult.getState() != ResultState.Success) {
|
|
if (userModelResult.getState() != ResultState.Success) {
|
|
|
//未注册
|
|
//未注册
|
|
|
//TODO 权限中心: 注册用户
|
|
//TODO 权限中心: 注册用户
|
|
|
if (StringUtils.isEmpty(password)) {
|
|
if (StringUtils.isEmpty(password)) {
|
|
|
password = CardDefault.DEFAULT_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(password).build());
|
|
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> addModelResult = userService.add(UserAuthModel.builder().loginType(LoginType.Phone).loginValue(organization.getContactPhone()).passWord(password).build());
|
|
|
userId = addModelResult.getContent();
|
|
userId = addModelResult.getContent();
|
|
|
log.info("初始权限中心 用户成功:{}", userId);
|
|
log.info("初始权限中心 用户成功:{}", userId);
|
|
|
} else {
|
|
} else {
|
|
@@ -562,16 +559,16 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
roleModel.setName(CardDefault.DEFAULT_ROLE_NAME);
|
|
roleModel.setName(CardDefault.DEFAULT_ROLE_NAME);
|
|
|
roleModel.setRemark(CardDefault.DEFAULT_ROLE_NAME);
|
|
roleModel.setRemark(CardDefault.DEFAULT_ROLE_NAME);
|
|
|
roleModel.setAuth(auth);
|
|
roleModel.setAuth(auth);
|
|
|
- com.github.microservice.auth.client.content.ResultContent<String> updateRole =
|
|
|
|
|
- roleService.updateRole(roleModel);
|
|
|
|
|
- roleService.addRoleToRoleGroup(groupId, new String[]{updateRole.getContent()});
|
|
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> updateRole = roleService.updateRole(roleModel);
|
|
|
|
|
+ String roleId = updateRole.getContent();
|
|
|
|
|
+ roleService.addRoleToRoleGroup(groupId, new String[]{roleId});
|
|
|
log.info("权限中心:初始角色和角色组关系成功");
|
|
log.info("权限中心:初始角色和角色组关系成功");
|
|
|
|
|
|
|
|
// 添加本地角色信息
|
|
// 添加本地角色信息
|
|
|
adminRole = new Role();
|
|
adminRole = new Role();
|
|
|
if (organization.getAuthType().equals(AuthType.Platform)) {
|
|
if (organization.getAuthType().equals(AuthType.Platform)) {
|
|
|
adminRole.setCode(AuthConstant.SuperAdmin);
|
|
adminRole.setCode(AuthConstant.SuperAdmin);
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
adminRole.setCode(AuthConstant.Admin);
|
|
adminRole.setCode(AuthConstant.Admin);
|
|
|
}
|
|
}
|
|
|
adminRole.setAuth(auth);
|
|
adminRole.setAuth(auth);
|
|
@@ -579,7 +576,9 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
adminRole.setRoleGroupId(groupId);
|
|
adminRole.setRoleGroupId(groupId);
|
|
|
adminRole.setName(CardDefault.DEFAULT_ROLE_NAME);
|
|
adminRole.setName(CardDefault.DEFAULT_ROLE_NAME);
|
|
|
adminRole.setRemark(CardDefault.DEFAULT_ROLE_NAME);
|
|
adminRole.setRemark(CardDefault.DEFAULT_ROLE_NAME);
|
|
|
- adminRole.setAdmin(true);
|
|
|
|
|
|
|
+ adminRole.setRoleType(RoleType.BuildIn);
|
|
|
|
|
+ adminRole.setIsAdmin(Boolean.TRUE);
|
|
|
|
|
+ adminRole.setRoleId(roleId);
|
|
|
roleDao.save(adminRole);
|
|
roleDao.save(adminRole);
|
|
|
|
|
|
|
|
//权限中心: 将用户添加进管理员角色组
|
|
//权限中心: 将用户添加进管理员角色组
|
|
@@ -607,7 +606,7 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
// 判断不同的类型
|
|
// 判断不同的类型
|
|
|
- if(entity.getAuthType() == AuthType.School) {
|
|
|
|
|
|
|
+ if (entity.getAuthType() == AuthType.School) {
|
|
|
// 学校:查询出关联的项目信息
|
|
// 学校:查询出关联的项目信息
|
|
|
OrganizationRelation organization = organizationRelationDao.findTopByMainOrganizationAndAuthType(entity, AuthType.School);
|
|
OrganizationRelation organization = organizationRelationDao.findTopByMainOrganizationAndAuthType(entity, AuthType.School);
|
|
|
if (ObjectUtils.isNotEmpty(organization)) {
|
|
if (ObjectUtils.isNotEmpty(organization)) {
|
|
@@ -617,13 +616,13 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
|
|
|
|
|
// 区域信息
|
|
// 区域信息
|
|
|
String adminDivisionItemCode = entity.getAdminDivisionItemCode();
|
|
String adminDivisionItemCode = entity.getAdminDivisionItemCode();
|
|
|
- if(StringUtils.isEmpty(adminDivisionItemCode)) {
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(adminDivisionItemCode)) {
|
|
|
List<String> codes = List.of(adminDivisionItemCode.split(","));
|
|
List<String> codes = List.of(adminDivisionItemCode.split(","));
|
|
|
List<Region> regions = regionDao.findByCodeIn(codes);
|
|
List<Region> regions = regionDao.findByCodeIn(codes);
|
|
|
- List<RegionModel> regionList = regions.stream().map(it->{
|
|
|
|
|
|
|
+ List<RegionModel> regionList = regions.stream().map(it -> {
|
|
|
RegionModel regionModel = new RegionModel();
|
|
RegionModel regionModel = new RegionModel();
|
|
|
BeanUtils.copyProperties(it, regionModel);
|
|
BeanUtils.copyProperties(it, regionModel);
|
|
|
- return regionModel;
|
|
|
|
|
|
|
+ return regionModel;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
model.setRegionList(regionList);
|
|
model.setRegionList(regionList);
|
|
|
}
|
|
}
|