ParamUtils.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.kmall.admin.utils;
  2. import com.kmall.common.constant.Dict;
  3. import com.kmall.admin.fromcomm.entity.SysUserEntity;
  4. import com.kmall.common.utils.RRException;
  5. import org.apache.commons.lang3.StringUtils;
  6. import java.util.Map;
  7. /**
  8. * 参数工具类
  9. */
  10. public class ParamUtils {
  11. /**
  12. * 根据用户类型设置查询权限
  13. *
  14. * @param params 查询参数
  15. * @param storeKey 当用户是门店时,放入的key,值为门店id
  16. * @param merchKey 当用户是商户时,放入的key,值为商户编号
  17. * @param thirdMerchKey 当用户是商户时,放入的key,值为第三方商户编号
  18. */
  19. public static void setQueryPowerByRoleType(Map params, String storeKey, String merchKey, String thirdMerchKey) {
  20. SysUserEntity user = ShiroUtils.getUserEntity();
  21. if (user == null) {
  22. throw new RRException("用户登录超时,请重新登录");
  23. }
  24. if (Dict.roleType.item_2.getItem().equals(user.getRoleType())) {
  25. if (storeKey == null) {
  26. throw new RRException("参数错误");
  27. }
  28. if(StringUtils.isNotEmpty(merchKey)){
  29. params.put(merchKey, user.getMerchSn());
  30. }
  31. if(StringUtils.isNotEmpty(thirdMerchKey)){
  32. params.put(thirdMerchKey, user.getThirdPartyMerchCode());
  33. }
  34. if(StringUtils.isNotEmpty(storeKey)){
  35. params.put(storeKey, user.getStoreId());
  36. }
  37. }
  38. if (Dict.roleType.item_3.getItem().equals(user.getRoleType())) {
  39. if(StringUtils.isNotEmpty(merchKey)){
  40. params.put(merchKey, user.getMerchSn());
  41. }
  42. }
  43. if (Dict.roleType.item_4.getItem().equals(user.getRoleType())) {
  44. if(StringUtils.isNotEmpty(merchKey)){
  45. params.put(merchKey, user.getMerchSn());
  46. }
  47. if(StringUtils.isNotEmpty(thirdMerchKey)){
  48. params.put(thirdMerchKey, user.getThirdPartyMerchCode());
  49. }
  50. }
  51. }
  52. }