查询登录用户权限信息,使用UserUtils

This commit is contained in:
2023-11-11 15:40:30 +08:00
parent 5f44c35d03
commit 7c5e55b9ee
5 changed files with 91 additions and 65 deletions

View File

@@ -4,7 +4,6 @@ import com.jsowell.pile.domain.MemberBasicInfo;
import com.jsowell.pile.dto.PlatformTesterDTO;
import com.jsowell.pile.dto.QueryMemberInfoDTO;
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.uniapp.MemberBalanceVO;
import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
@@ -147,10 +146,4 @@ public interface IMemberBasicInfoService {
* @return
*/
List<MemberBalanceVO> getMemberRefundAmount(List<String> memberIds);
/**
* 获取当前会员中的运营商列表(带权限校验)
*/
List<MerchantInfoVO> getMerchantListByAuth();
}

View File

@@ -4,14 +4,10 @@ import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.entity.SysDept;
import com.jsowell.common.core.domain.entity.SysUser;
import com.jsowell.common.core.domain.model.LoginUser;
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.MemberWalletEnum;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.SecurityUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.PlatformTesterDTO;
@@ -23,7 +19,6 @@ import com.jsowell.pile.mapper.MemberWalletInfoMapper;
import com.jsowell.pile.mapper.MemberWalletLogMapper;
import com.jsowell.pile.service.*;
import com.jsowell.pile.util.UserUtils;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.uniapp.MemberBalanceVO;
import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
@@ -39,7 +34,6 @@ import org.springframework.util.StopWatch;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 会员基础信息Service业务层处理
@@ -425,54 +419,4 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
return memberWalletLogMapper.getMemberRefundAmount(memberIds);
}
/**
* 获取当前会员中的运营商列表(带权限校验)
*/
@Override
public 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;
}
}