package com.kmall.admin.utils; import com.kmall.common.constant.Dict; import com.kmall.admin.fromcomm.entity.SysUserEntity; import com.kmall.common.utils.RRException; import org.apache.commons.lang3.StringUtils; import java.util.Map; /** * 参数工具类 */ public class ParamUtils { /** * 根据用户类型设置查询权限 * * @param params 查询参数 * @param storeKey 当用户是门店时,放入的key,值为门店id * @param merchKey 当用户是商户时,放入的key,值为商户编号 * @param thirdMerchKey 当用户是商户时,放入的key,值为第三方商户编号 */ public static void setQueryPowerByRoleType(Map params, String storeKey, String merchKey, String thirdMerchKey) { SysUserEntity user = ShiroUtils.getUserEntity(); if (user == null) { throw new RRException("用户登录超时,请重新登录"); } if (Dict.roleType.item_2.getItem().equals(user.getRoleType())) { if (storeKey == null) { throw new RRException("参数错误"); } if(StringUtils.isNotEmpty(merchKey)){ params.put(merchKey, user.getMerchSn()); } if(StringUtils.isNotEmpty(thirdMerchKey)){ params.put(thirdMerchKey, user.getThirdPartyMerchCode()); } if(StringUtils.isNotEmpty(storeKey)){ params.put(storeKey, user.getStoreId()); } } if (Dict.roleType.item_3.getItem().equals(user.getRoleType())) { if(StringUtils.isNotEmpty(merchKey)){ params.put(merchKey, user.getMerchSn()); } } if (Dict.roleType.item_4.getItem().equals(user.getRoleType())) { if(StringUtils.isNotEmpty(merchKey)){ params.put(merchKey, user.getMerchSn()); } if(StringUtils.isNotEmpty(thirdMerchKey)){ params.put(thirdMerchKey, user.getThirdPartyMerchCode()); } } } }