|
|
@@ -2,6 +2,7 @@ package com.zhongshu.card.server.core.service.org;
|
|
|
|
|
|
import com.github.microservice.auth.client.content.ResultState;
|
|
|
import com.github.microservice.auth.client.model.UserAuthModel;
|
|
|
+import com.github.microservice.auth.client.service.OrganizationUserService;
|
|
|
import com.github.microservice.auth.client.service.RoleService;
|
|
|
import com.github.microservice.auth.client.service.UserService;
|
|
|
import com.github.microservice.auth.client.type.LoginType;
|
|
|
@@ -9,11 +10,14 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.zhongshu.card.client.model.base.AuthTypeParam;
|
|
|
import com.zhongshu.card.client.model.base.UserIdModel;
|
|
|
import com.zhongshu.card.client.model.org.*;
|
|
|
+import com.zhongshu.card.client.model.school.DictInfoParam;
|
|
|
+import com.zhongshu.card.client.model.school.DictInfoSimpleModel;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.org.DepartmentService;
|
|
|
import com.zhongshu.card.client.service.org.OrganizationService;
|
|
|
import com.zhongshu.card.client.service.org.UserAccountService;
|
|
|
+import com.zhongshu.card.client.service.school.DictInfoService;
|
|
|
import com.zhongshu.card.client.utils.type.*;
|
|
|
import com.zhongshu.card.server.core.dao.org.*;
|
|
|
import com.zhongshu.card.server.core.dao.school.DictInfoDao;
|
|
|
@@ -21,6 +25,7 @@ import com.zhongshu.card.server.core.dataConfig.CardDefault;
|
|
|
import com.zhongshu.card.server.core.domain.org.*;
|
|
|
import com.zhongshu.card.server.core.domain.school.DictInfo;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.school.DictInfoServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import com.zhongshu.card.server.core.util.DateUtils;
|
|
|
@@ -81,6 +86,12 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
@Autowired
|
|
|
DictInfoDao dictInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrganizationUserService organizationUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DictInfoServiceImpl dictInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加编辑用户 添加机构用户
|
|
|
*
|
|
|
@@ -144,7 +155,10 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
temp.setLoginName(loginName);
|
|
|
temp.setIsLogined(Boolean.FALSE);
|
|
|
temp.setSpellCode(CommonUtil.getPinyin(param.getName()));
|
|
|
+ temp.setIsUpdatedPsw(Boolean.FALSE);
|
|
|
userCountDao.save(temp);
|
|
|
+ } else {
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
OrganizationUser organizationUser = organizationUserDao.findTopById(param.getId());
|
|
|
@@ -158,6 +172,7 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
userCountDao.save(temp);
|
|
|
}
|
|
|
|
|
|
+ userId = temp.getUserId();
|
|
|
//权限中心: 在角色组添加用户
|
|
|
String[] roleGroupIds = roles.stream().map(it -> it.getRoleGroupId()).collect(Collectors.toList()).toArray(String[]::new);
|
|
|
roleService.addUsersToRoleGroup(userId, roleGroupIds);
|
|
|
@@ -166,12 +181,13 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
// 不在机构中
|
|
|
organizationUser = new OrganizationUser();
|
|
|
+ initEntity(organizationUser);
|
|
|
organizationUser.setOid(organization.getOid());
|
|
|
organizationUser.setOrganization(organization);
|
|
|
organizationUser.setUser(temp);
|
|
|
organizationUser.setUserId(temp.getUserId());
|
|
|
organizationUser.setIsAdmin(Boolean.FALSE);
|
|
|
- organizationUser.setAuthType(organizationUser.getAuthType());
|
|
|
+ organizationUser.setAuthType(organization.getAuthType());
|
|
|
organizationUser.setCreateUserId(getCurrentUserId());
|
|
|
organizationUser.setUserType(OrganizationUserType.Common);
|
|
|
} else {
|
|
|
@@ -188,15 +204,26 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- BeanUtils.copyProperties(param, temp, "id", "oid");
|
|
|
+ BeanUtils.copyProperties(param, organizationUser, "id", "oid");
|
|
|
// 职位信息
|
|
|
if (StringUtils.isNotEmpty(param.getPositionId())) {
|
|
|
organizationUser.setPosition(dictInfoDao.findTopById(param.getPositionId()));
|
|
|
}
|
|
|
+ organizationUser.setAuthType(organization.getAuthType());
|
|
|
+ // 设置角色
|
|
|
organizationUser.setRoles(roles);
|
|
|
+ // 设置部门
|
|
|
organizationUser.setDepartments(departments);
|
|
|
organizationUserDao.save(organizationUser);
|
|
|
|
|
|
+ // 权限中心
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<Void> resultContent = organizationUserService.update(organization.getOid(), new String[]{userId});
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
+ log.info("权限中心:绑定机构和用户关系成功");
|
|
|
+ } else {
|
|
|
+ log.error("权限中心:绑定机构和用户关系出错:{}", resultContent.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -343,21 +370,7 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultContent<Page<OrganizationUserModel>> pageOrgUser(OrganizationUserSearch param, Pageable pageable) {
|
|
|
- String oid = param.getOid();
|
|
|
- if (StringUtils.isEmpty(oid)) {
|
|
|
- oid = getCurrentOid();
|
|
|
- }
|
|
|
- param.setOid(oid);
|
|
|
- Assert.hasText(oid, "oid不能为空");
|
|
|
- List<Long> times = param.getTimes();
|
|
|
- if (ObjectUtils.isNotEmpty(times) && times.size() == 2) {
|
|
|
- Long startTime = times.get(0);
|
|
|
- startTime = DateUtils.getDayStartTime(startTime);
|
|
|
- Long endTime = times.get(1);
|
|
|
- endTime = DateUtils.getDayEndTime(endTime);
|
|
|
- param.setStartTime(startTime);
|
|
|
- param.setEndTime(endTime);
|
|
|
- }
|
|
|
+ initOidSearchParam(param);
|
|
|
Page<OrganizationUser> page = organizationUserDao.page(pageable, param);
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toOrgUserModel));
|
|
|
}
|
|
|
@@ -474,6 +487,10 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
UserCountModel userCountModel = toModel(entity.getUser());
|
|
|
model.setUser(userCountModel);
|
|
|
|
|
|
+ // 职务
|
|
|
+ DictInfoSimpleModel position = dictInfoService.toSimpleModel(entity.getPosition());
|
|
|
+ model.setPosition(position);
|
|
|
+
|
|
|
// 角色信息
|
|
|
if (ObjectUtils.isNotEmpty(entity.getRoles())) {
|
|
|
List<RoleModel> roleModels = entity.getRoles().stream().map(roleServiceImpl::toModel)
|