Commit 996034df by 陶光胜

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-auth into developer
parents 73f8ca25 206da1f3
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; ...@@ -7,6 +7,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO; import com.gic.auth.dto.UserDTO;
import com.gic.auth.dto.UserDataShowDTO; import com.gic.auth.dto.UserDataShowDTO;
import com.gic.auth.dto.UserListDTO; import com.gic.auth.dto.UserListDTO;
import com.gic.auth.dto.accountgroup.AccountGroupUnionDTO;
import com.gic.auth.dto.wechat.WechatUserDTO; import com.gic.auth.dto.wechat.WechatUserDTO;
import com.gic.auth.qo.UserListQO; import com.gic.auth.qo.UserListQO;
...@@ -120,6 +121,22 @@ public interface UserApiService { ...@@ -120,6 +121,22 @@ public interface UserApiService {
ServiceResponse<List<Integer>> listAccountGroupByUserId(Integer userId); 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
 * @Title: getUserInfoById

* @Description: * @Description:
......
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.gic.platform.member.constant.enums.CuTypeEnum;
import com.gic.store.service.UnionStoreChangeApiService; import com.gic.store.service.UnionStoreChangeApiService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -163,7 +164,7 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{ ...@@ -163,7 +164,7 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
GicMQClient client = GICMQClientUtil.getClientInstance(); GicMQClient client = GICMQClientUtil.getClientInstance();
try { try {
logger.info("联合商户资源授权通知"); logger.info("联合商户资源授权通知:{}", JSON.toJSONString(unionEnterpriseAuthResNoticeDTO));
client.sendMessage("syncResourceAuthChangeMQ", JSONObject.toJSONString(unionEnterpriseAuthResNoticeDTO)); client.sendMessage("syncResourceAuthChangeMQ", JSONObject.toJSONString(unionEnterpriseAuthResNoticeDTO));
} catch (Exception e) { } catch (Exception e) {
logger.warn("联合商户资源授权路由:{}", e.getMessage(), e); logger.warn("联合商户资源授权路由:{}", e.getMessage(), e);
...@@ -320,6 +321,17 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{ ...@@ -320,6 +321,17 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
}); });
} }
} }
//补充类型数据
if (oldUserAreaMap.get(CuTypeEnum.ACU.getType()) == null) {
oldUserAreaMap.put(CuTypeEnum.ACU.getType(), new ArrayList<>());
}
if (oldUserAreaMap.get(CuTypeEnum.SCU.getType()) == null) {
oldUserAreaMap.put(CuTypeEnum.SCU.getType(), new ArrayList<>());
}
if (oldUserAreaMap.get(CuTypeEnum.MCU.getType()) == null) {
oldUserAreaMap.put(CuTypeEnum.MCU.getType(), new ArrayList<>());
}
return oldUserAreaMap; return oldUserAreaMap;
} }
} }
...@@ -5,8 +5,11 @@ import java.text.SimpleDateFormat; ...@@ -5,8 +5,11 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.gic.auth.dto.accountgroup.AccountGroupUnionDTO;
import com.gic.auth.dto.wechat.WechatUserDTO; import com.gic.auth.dto.wechat.WechatUserDTO;
import com.gic.enterprise.dto.union.UnionEnterpriseAuthDTO;
import com.gic.enterprise.exception.CommonException; import com.gic.enterprise.exception.CommonException;
import com.gic.enterprise.service.UnionEnterpriseAuthApiService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -68,6 +71,8 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -68,6 +71,8 @@ public class UserApiServiceImpl implements UserApiService {
private UserMoveApiService userMoveApiService; private UserMoveApiService userMoveApiService;
@Autowired @Autowired
private AuditorApiService auditorApiService; private AuditorApiService auditorApiService;
@Autowired
private UnionEnterpriseAuthApiService unionEnterpriseAuthApiService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
...@@ -386,6 +391,88 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -386,6 +391,88 @@ public class UserApiServiceImpl implements UserApiService {
} }
@Override @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());
}
}
//取并集(去重)
if (CollectionUtils.isNotEmpty(accountGroupIdList)) {
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) { public ServiceResponse<UserDTO> getUserInfoById(Integer userId) {
TabSysUser tabUser = userService.getUserById(userId); TabSysUser tabUser = userService.getUserById(userId);
if (tabUser == null) { 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