(cherry picked from commit 71be841f4d65a63a61059bb45bbc6e6f4bb35b42)
This commit is contained in:
Guoqs
2024-05-28 11:54:02 +08:00
parent 9370274859
commit cc777bd9fb
5 changed files with 37 additions and 62 deletions

View File

@@ -16,6 +16,7 @@ import com.jsowell.pile.service.PileStationInfoService;
import com.jsowell.pile.vo.base.LoginUserDetailVO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -89,53 +90,7 @@ public class UserUtils {
return resultVO;
}
/**
* 获取当前会员中的运营商列表(带权限校验)
*/
/*public static List<MerchantInfoVO> getMerchantListByAuth() {
List<MerchantInfoVO> resultList = Lists.newArrayList();
// 获取登录用户 所有有权限运营商
LoginUser loginUser = SecurityUtils.getLoginUser();
if (Objects.isNull(loginUser)) {
return resultList;
}
// 获取登录用户对应的user对象
SysUser user = loginUser.getUser();
if (Objects.isNull(user)) {
return resultList;
}
// 获取所属部门id
SysDept dept = user.getDept();
if (Objects.isNull(dept)) {
return resultList;
}
String deptLevel = dept.getDeptLevel();
String deptId = String.valueOf(dept.getDeptId());
if (Constants.ZERO.equals(deptLevel)) {
// 平台级权限 查询所有生效的运营商
resultList = pileMerchantInfoService.selectAll();
} else if (Constants.ONE.equals(deptLevel)) {
// 一级运营商权限 查询该一级运营商下面的所有运营商
PileMerchantInfo merchantInfo = pileMerchantInfoService.queryInfoByDeptId(deptId);
resultList = pileMerchantInfoService.selectListByFirstMerchant(merchantInfo.getId() + "");
} else if (Constants.TWO.equals(deptLevel) ) {
// 二级运营商权限 返回自身运营商
MerchantInfoVO merchantInfoVO = pileMerchantInfoService.queryMerchantInfoVOByDeptId(deptId);
if (Objects.nonNull(merchantInfoVO)) {
resultList.add(merchantInfoVO);
}
} else if (Constants.THREE.equals(deptLevel)) {
// 站点权限 返回自身运营商
PileStationInfo stationInfo = pileStationInfoService.queryInfoByDeptId(deptId);
if (Objects.nonNull(stationInfo)) {
MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(stationInfo.getMerchantId() + "");
if (Objects.nonNull(merchantInfoVO)) {
resultList.add(merchantInfoVO);
}
}
}
return resultList;
}*/
/**
* 获取登录用户信息
@@ -221,4 +176,22 @@ public class UserUtils {
resultVO.setFirstMerchantIdList(firstMerchantIdList);
return resultVO;
}
/**
* 获取当前登录用户中有权限的运营商列表
* @return
*/
public static List<MerchantInfoVO> getMerchantInfoVOList() {
LoginUserDetailVO loginUserDetail = UserUtils.getLoginUserDetail();
return loginUserDetail.getMerchantInfoVOList();
}
/**
* 获取当前登录用户有权限的一级运营商idList
* @return
*/
public static List<String> getFirstMerchantIdList() {
LoginUserDetailVO loginUserDetail = UserUtils.getLoginUserDetail();
return loginUserDetail.getFirstMerchantIdList();
}
}