Commit ded784e4 by guojuxing

提供账号分组需要的接口

parent 1dd1d937
package com.gic.auth.dto.accountgroup;
import java.io.Serializable;
/**
* 账号分组
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/3/17 3:53 PM

*/
public class AccountGroupUnionDTO implements Serializable{
private static final long serialVersionUID = 540104578542245703L;
private Integer accountGroupId;
private String accountGroupName;
/**
* 授权出去的联合商户ID
*/
private Integer unionEnterpriseId;
public Integer getAccountGroupId() {
return accountGroupId;
}
public AccountGroupUnionDTO setAccountGroupId(Integer accountGroupId) {
this.accountGroupId = accountGroupId;
return this;
}
public String getAccountGroupName() {
return accountGroupName;
}
public AccountGroupUnionDTO setAccountGroupName(String accountGroupName) {
this.accountGroupName = accountGroupName;
return this;
}
public Integer getUnionEnterpriseId() {
return unionEnterpriseId;
}
public AccountGroupUnionDTO setUnionEnterpriseId(Integer unionEnterpriseId) {
this.unionEnterpriseId = unionEnterpriseId;
return this;
}
@Override
public String toString() {
return "AccountGroupUnionDTO{" +
"accountGroupId=" + accountGroupId +
", accountGroupName='" + accountGroupName + '\'' +
", unionEnterpriseId=" + unionEnterpriseId +
'}';
}
}
......@@ -7,6 +7,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.dto.UserDataShowDTO;
import com.gic.auth.dto.UserListDTO;
import com.gic.auth.dto.accountgroup.AccountGroupUnionDTO;
import com.gic.auth.dto.wechat.WechatUserDTO;
import com.gic.auth.qo.UserListQO;
......@@ -120,6 +121,22 @@ public interface UserApiService {
ServiceResponse<List<Integer>> listAccountGroupByUserId(Integer userId);
/**
* 账号分组组件需要的接口
* @param userId
* @param accountGroupIdList 如果有值,查询并集
* @return
*/
ServiceResponse<List<AccountGroupUnionDTO>> listAccountGroupByUserId(Integer userId, List<Integer> accountGroupIdList);
/**
* 查询授权的账号分组数据
* @param ownEnterpriseId
* @param unionEnterpriseId
* @return
*/
ServiceResponse<List<AccountGroupUnionDTO>> listUnionAuthAccountGroup(Integer ownEnterpriseId, Integer unionEnterpriseId);
/**
* 用户基本信息
* @Title: getUserInfoById

* @Description:
......
......@@ -5,8 +5,11 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import com.gic.auth.dto.accountgroup.AccountGroupUnionDTO;
import com.gic.auth.dto.wechat.WechatUserDTO;
import com.gic.enterprise.dto.union.UnionEnterpriseAuthDTO;
import com.gic.enterprise.exception.CommonException;
import com.gic.enterprise.service.UnionEnterpriseAuthApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -68,6 +71,8 @@ public class UserApiServiceImpl implements UserApiService {
private UserMoveApiService userMoveApiService;
@Autowired
private AuditorApiService auditorApiService;
@Autowired
private UnionEnterpriseAuthApiService unionEnterpriseAuthApiService;
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -386,6 +391,86 @@ public class UserApiServiceImpl implements UserApiService {
}
@Override
public ServiceResponse<List<AccountGroupUnionDTO>> listAccountGroupByUserId(Integer userId, List<Integer> accountGroupIdList) {
TabSysUser user = checkUser(userId);
boolean isAdmin = user.getSuperAdmin() == 1;
//结果集查询ID集合
List<Integer> accountGroupIdListResult = new ArrayList<>();
if (isAdmin) {
List<TabSysAccountGroup> list = accountGroupService.listAccountGroupByEnterpriseId(user.getEnterpriseId());
if (CollectionUtils.isNotEmpty(list)) {
accountGroupIdListResult = list.stream().mapToInt(e -> e.getAccountGroupId()).boxed().collect(Collectors.toList());
}
} else {
List<TabSysAccountGroupRel> tabSysAccountGroupRelList = accountGroupRelService.listByUserId(userId,
AccountGroupMemberTypeEnum.ADMIN.getCode());
if (CollectionUtils.isNotEmpty(tabSysAccountGroupRelList)) {
accountGroupIdListResult = tabSysAccountGroupRelList.stream().mapToInt(e -> e.getAccountGroupId()).boxed().collect(Collectors.toList());
}
}
//取并集(去重)
CollectionUtils.union(accountGroupIdListResult, accountGroupIdList);
List<TabSysAccountGroup> result = accountGroupService.listByIdList(accountGroupIdListResult);
if (CollectionUtils.isNotEmpty(result)) {
//查询已经授权的商户ID
Map<Integer, Integer> accountGroupIdMapEnterpriseId = new HashMap<>();
ServiceResponse<List<UnionEnterpriseAuthDTO>> unionResponse = unionEnterpriseAuthApiService.listUnionEnterpriseAuth(user.getEnterpriseId());
if (unionResponse.isSuccess()) {
List<UnionEnterpriseAuthDTO> unionList = unionResponse.getResult();
if (CollectionUtils.isNotEmpty(unionList)) {
for (UnionEnterpriseAuthDTO temp : unionList) {
String accountGroup = temp.getAccountGroup();
if (StringUtils.isNotBlank(accountGroup)) {
Arrays.stream(accountGroup.split(",")).forEach(e -> {
if (StringUtils.isNotBlank(e)) {
accountGroupIdMapEnterpriseId.put(Integer.valueOf(e), temp.getUnionEnterpriseId());
}
});
}
}
}
}
return ServiceResponse.success(result.stream()
.map(e -> new AccountGroupUnionDTO()
.setAccountGroupId(e.getAccountGroupId())
.setAccountGroupName(e.getAccountGroupName())
.setUnionEnterpriseId(accountGroupIdMapEnterpriseId.get(e.getAccountGroupId())))
.collect(Collectors.toList()));
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<List<AccountGroupUnionDTO>> listUnionAuthAccountGroup(Integer ownEnterpriseId, Integer unionEnterpriseId) {
ServiceResponse<UnionEnterpriseAuthDTO> unionResponse = unionEnterpriseAuthApiService.getUnionEnterpriseAuth(ownEnterpriseId, unionEnterpriseId);
if (unionResponse.isSuccess()) {
UnionEnterpriseAuthDTO union = unionResponse.getResult();
String accountGroup = union.getAccountGroup();
if (StringUtils.isNotBlank(accountGroup)) {
List<Integer> accountGroupIdListResult = Arrays.stream(accountGroup.split(","))
.mapToInt(e -> Integer.valueOf(e)).boxed()
.collect(Collectors.toList());
List<TabSysAccountGroup> result = accountGroupService.listByIdList(accountGroupIdListResult);
if (CollectionUtils.isNotEmpty(result)) {
return ServiceResponse.success(result.stream()
.map(e -> new AccountGroupUnionDTO()
.setAccountGroupId(e.getAccountGroupId())
.setAccountGroupName(e.getAccountGroupName())
.setUnionEnterpriseId(unionEnterpriseId))
.collect(Collectors.toList()));
}
}
return ServiceResponse.success();
}
return ServiceResponse.failure(unionResponse.getCode(), unionResponse.getMessage());
}
@Override
public ServiceResponse<UserDTO> getUserInfoById(Integer userId) {
TabSysUser tabUser = userService.getUserById(userId);
if (tabUser == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment