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

This commit is contained in:
2023-11-11 16:47:20 +08:00
parent 659705e70d
commit 4fd28a156b
3 changed files with 32 additions and 24 deletions

View File

@@ -28,4 +28,6 @@ public class QueryMemberInfoDTO {
private List<String> merchantDeptIds;
private String vinCode;
private List<String> firstMerchantIds;
}

View File

@@ -4,12 +4,14 @@ 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.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.StringUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.domain.MemberBasicInfo;
import com.jsowell.pile.domain.MemberPlateNumberRelation;
import com.jsowell.pile.domain.MemberWalletInfo;
import com.jsowell.pile.domain.MemberWalletLog;
import com.jsowell.pile.dto.PlatformTesterDTO;
import com.jsowell.pile.dto.QueryMemberInfoDTO;
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
@@ -19,6 +21,7 @@ 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.LoginUserDetailVO;
import com.jsowell.pile.vo.uniapp.MemberBalanceVO;
import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
@@ -29,7 +32,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -317,35 +319,33 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService {
*/
@Override
public List<MemberVO> selectMemberList(QueryMemberInfoDTO dto) {
StopWatch sw = new StopWatch("查询会员列表");
sw.start("获取登录账号信息");
// 获取登录账号信息
// AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
AuthorizedDeptVO authorizedMap = UserUtils.getAuthorizedMap();
if (authorizedMap == null) {
return new ArrayList<>();
}
List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
if (CollectionUtils.isNotEmpty(merchantDeptIds)) {
dto.setMerchantDeptIds(merchantDeptIds);
}
sw.stop();
// AuthorizedDeptVO authorizedMap = UserUtils.getAuthorizedMap();
// if (authorizedMap == null) {
// return new ArrayList<>();
// }
// List<String> merchantDeptIds = authorizedMap.getMerchantDeptIds();
// if (CollectionUtils.isNotEmpty(merchantDeptIds)) {
// dto.setMerchantDeptIds(merchantDeptIds);
// }
sw.start("获取一级运营商信息");
PileMerchantInfo pileMerchantInfo = pileMerchantInfoService.queryInfoByDeptId(authorizedMap.getDeptId());
if (pileMerchantInfo != null) {
String id = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(pileMerchantInfo.getId() + "");
dto.setMerchantId(id);
}
sw.stop();
// PileMerchantInfo pileMerchantInfo = pileMerchantInfoService.queryInfoByDeptId(authorizedMap.getDeptId());
// if (pileMerchantInfo != null) {
// String id = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(pileMerchantInfo.getId() + "");
// dto.setMerchantId(id);
// }
LoginUserDetailVO loginUserDetail = UserUtils.getLoginUserDetail();
List<String> firstMerchantIdList = loginUserDetail.getFirstMerchantIdList();
if (CollectionUtils.isNotEmpty(firstMerchantIdList)) {
dto.setFirstMerchantIds(firstMerchantIdList);
}
sw.start("查询数据库会员信息");
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
List<MemberVO> memberVOS = memberBasicInfoMapper.selectMemberList(dto);
sw.stop();
log.info("查询耗时:{}", sw.prettyPrint());
return memberVOS;
}