|
|
@@ -13,6 +13,7 @@ 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.org.role.RoleModel;
|
|
|
+import com.zhongshu.card.client.model.orgModel.OrgBindUserAllParam;
|
|
|
import com.zhongshu.card.client.model.school.DictInfoSimpleModel;
|
|
|
import com.zhongshu.card.client.service.org.UserAccountService;
|
|
|
import com.zhongshu.card.client.type.Sex;
|
|
|
@@ -26,8 +27,8 @@ import com.zhongshu.card.server.core.dataConfig.CardSystemDefault;
|
|
|
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.UserAccount;
|
|
|
+import com.zhongshu.card.server.core.service.base.CommonService;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
-import com.zhongshu.card.server.core.service.devices.DevicePermissEventService;
|
|
|
import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.org.OrganizationUserServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
|
|
|
@@ -42,13 +43,17 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -89,6 +94,8 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
|
|
|
@Autowired
|
|
|
private OrganizationUserServiceImpl organizationUserService;
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
|
|
|
/**
|
|
|
* 注册基本用户 (没有就注册,有就修改)
|
|
|
@@ -162,6 +169,14 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
}
|
|
|
userAccount.setRealName(realName);
|
|
|
userCountDao.save(userAccount);
|
|
|
+
|
|
|
+ // 更新关联的
|
|
|
+ Map<String, Object> where = new HashMap<>();
|
|
|
+ where.put("userId", userAccount.getUserId());
|
|
|
+
|
|
|
+ Map<String, Object> standardData = new HashMap<>();
|
|
|
+ standardData.put("name", userAccount.getName());
|
|
|
+ commonService.updateData(where, standardData, OrganizationUser.class.getSimpleName());
|
|
|
}
|
|
|
return ResultContent.buildSuccess(userAccount.getUserId());
|
|
|
}
|
|
|
@@ -259,6 +274,10 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultContent updateOrgUserState(UpdateUserStateParam param) {
|
|
|
+ String userId = "";
|
|
|
+
|
|
|
+ // 初始基本用户信息
|
|
|
+ RegisterUserAccountParam userAccountParam = new RegisterUserAccountParam();
|
|
|
if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
// 新增加
|
|
|
if (StringUtils.isEmpty(param.getName())) {
|
|
|
@@ -274,43 +293,71 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
if (!validateResult.isSuccess()) {
|
|
|
return ResultContent.buildFail(validateResult.getMsg());
|
|
|
}
|
|
|
-
|
|
|
- // 初始基本用户信息
|
|
|
- RegisterUserAccountParam userAccountParam = new RegisterUserAccountParam();
|
|
|
userAccountParam.setLoginName(param.getPhone());
|
|
|
userAccountParam.setPassword(param.getPassword());
|
|
|
userAccountParam.setPhone(param.getPhone());
|
|
|
- userAccountParam.setName(param.getName());
|
|
|
- ResultContent<String> userAccountContent = registerUserAccount(userAccountParam);
|
|
|
- if (userAccountContent.isFailed()) {
|
|
|
- return ResultContent.buildFail(userAccountContent.getMsg());
|
|
|
- }
|
|
|
- String userId = userAccountContent.getContent();
|
|
|
-
|
|
|
} else {
|
|
|
+ userId = param.getUserId();
|
|
|
+ UserAccount temp = userCountDao.findTopByUserId(userId);
|
|
|
+ userAccountParam.setLoginName(temp.getLoginName());
|
|
|
+ userAccountParam.setPhone(temp.getPhone());
|
|
|
+ userAccountParam.setUserType(temp.getUserType());
|
|
|
+ }
|
|
|
+ userAccountParam.setName(param.getName());
|
|
|
+ userAccountParam.setState(param.getState());
|
|
|
|
|
|
+ ResultContent<String> userAccountContent = registerUserAccount(userAccountParam);
|
|
|
+ if (userAccountContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(userAccountContent.getMsg());
|
|
|
}
|
|
|
- String userId = param.getUserId();
|
|
|
+ userId = userAccountContent.getContent();
|
|
|
+
|
|
|
+
|
|
|
String oid = param.getOid();
|
|
|
if (StringUtils.isEmpty(oid)) {
|
|
|
oid = getCurrentOid();
|
|
|
}
|
|
|
- Assert.hasText(oid, "oid不能为空");
|
|
|
+ if (StringUtils.isEmpty(oid)) {
|
|
|
+ return ResultContent.buildFail("oid不能为空");
|
|
|
+ }
|
|
|
Assert.hasText(userId, "userId不能为空");
|
|
|
- // 价差用户数据
|
|
|
+
|
|
|
+ // 机构信息
|
|
|
Organization organization = organizationDao.findTopByOid(oid);
|
|
|
if (ObjectUtils.isEmpty(organization)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, oid));
|
|
|
}
|
|
|
+ // 用户数据
|
|
|
UserAccount temp = userCountDao.findTopByUserId(userId);
|
|
|
if (ObjectUtils.isEmpty(temp)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, userId));
|
|
|
}
|
|
|
|
|
|
+ OrgBindUserAllParam orgBindUserAllParam = new OrgBindUserAllParam();
|
|
|
+ orgBindUserAllParam.setUserId(userId);
|
|
|
+ // 要绑定的机构
|
|
|
+ orgBindUserAllParam.setOrgOid(organization.getOid());
|
|
|
+ orgBindUserAllParam.setRoleIds(param.getRoleIds());
|
|
|
+ orgBindUserAllParam.setState(param.getState());
|
|
|
+ orgBindUserAllParam.setRemark(param.getRemark());
|
|
|
+ orgBindUserAllParam.setProjectOid(organization.getOid());
|
|
|
OrganizationUser organizationUser = organizationUserDao.findTopByOrganizationAndUser(organization, temp);
|
|
|
if (ObjectUtils.isNotEmpty(organizationUser)) {
|
|
|
- organizationUser.setState(param.getState());
|
|
|
- organizationUserDao.save(organizationUser);
|
|
|
+ orgBindUserAllParam.setId(organizationUser.getId());
|
|
|
+ orgBindUserAllParam.setCode(organizationUser.getCode());
|
|
|
+ if (organizationUser.getPosition() != null) {
|
|
|
+ orgBindUserAllParam.setPositionId(organizationUser.getPosition().getId());
|
|
|
+ }
|
|
|
+ if (organizationUser.getDepartment() != null) {
|
|
|
+ orgBindUserAllParam.setDepartmentId(organizationUser.getDepartment().getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ orgBindUserAllParam.setIsAdmin(Boolean.FALSE);
|
|
|
+ }
|
|
|
+ // 绑定用户到机构
|
|
|
+ ResultContent<OrganizationUser> bindUserContent = organizationUserService.orgBindUser(orgBindUserAllParam);
|
|
|
+ if (bindUserContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(bindUserContent.getMsg());
|
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -549,8 +596,21 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultContent<Page<UserCountModel>> list(UserCountSearchParam param, Pageable pageable) {
|
|
|
+ String oid = param.getOid();
|
|
|
+ if (StringUtils.isEmpty(oid)) {
|
|
|
+ oid = getCurrentOid();
|
|
|
+ }
|
|
|
Page<UserAccount> page = userCountDao.page(pageable, param);
|
|
|
- return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
+ List<UserCountAboutRoleModel> models = new ArrayList<>();
|
|
|
+ List<UserAccount> list = page.getContent();
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ String finalOid = oid;
|
|
|
+ models = list.parallelStream().map(it -> {
|
|
|
+ return toAboutRoleModel(it, finalOid);
|
|
|
+ }).collect(Collectors.toUnmodifiableList());
|
|
|
+ }
|
|
|
+ Page<UserCountAboutRoleModel> page1 = new PageImpl<>(models, PageRequest.of(page.getNumber(), page.getSize(), page.getSort()), page.getTotalElements());
|
|
|
+ return ResultContent.buildSuccess(page1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -595,6 +655,23 @@ public class UserAccountServiceImpl extends SuperService implements UserAccountS
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
+ public UserCountAboutRoleModel toAboutRoleModel(UserAccount entity, String oid) {
|
|
|
+ UserCountAboutRoleModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new UserCountAboutRoleModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ // 角色
|
|
|
+ if (StringUtils.isNotEmpty(oid)) {
|
|
|
+ OrganizationUser organizationUser = organizationUserDao.findTopByUserIdAndOid(entity.getUserId(), oid);
|
|
|
+ if (ObjectUtils.isNotEmpty(organizationUser)) {
|
|
|
+ model.setRoles(roleServiceImpl.toModels(organizationUser.getRoles()));
|
|
|
+ model.setRemark(organizationUser.getRemark());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 用户的基本信息 (简介模型)
|
|
|
*
|