| | |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | |
| | | import java.lang.reflect.Method; |
| | | |
| | |
| | | |
| | | /** |
| | | * 为查询对象加上当前登录人的门店和公司查询限制 |
| | | * |
| | | * @param queryObj |
| | | */ |
| | | public static void setQueryLimit(Object queryObj) { |
| | | SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | Class<Object> objClazz = (Class<Object>) queryObj.getClass(); |
| | | try { |
| | | Method setShopId = (Method) objClazz.getMethod("setShopId",Long.class); |
| | | setShopId.invoke(queryObj, sysUsers.getShopId()); |
| | | Method setCompanyId = (Method) objClazz.getMethod("setCompanyId",Long.class); |
| | | if (!AppConstance.USER_TYPE_ADMIN.equals(sysUsers.getSuUserType())) { |
| | | Method setShopId = (Method) objClazz.getMethod("setShopId", Long.class); |
| | | setShopId.invoke(queryObj, sysUsers.getShopId()); |
| | | } |
| | | Method setCompanyId = (Method) objClazz.getMethod("setCompanyId", Long.class); |
| | | setCompanyId.invoke(queryObj, sysUsers.getCompanyId()); |
| | | } catch (Exception e) { |
| | | LogUtil.error(e.getMessage(), e); |
| | | throw new GlobleException("系统参数错误007"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 限制数据公司id |
| | | * |
| | | * @param queryObj |
| | | */ |
| | | public static void setQueryLimitCom(Object queryObj) { |
| | | SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | Class<Object> objClazz = (Class<Object>) queryObj.getClass(); |
| | | try { |
| | | Method setCompanyId = (Method) objClazz.getMethod("setCompanyId",Long.class); |
| | | Method setCompanyId = (Method) objClazz.getMethod("setCompanyId", Long.class); |
| | | setCompanyId.invoke(queryObj, sysUsers.getCompanyId()); |
| | | } catch (Exception e) { |
| | | LogUtil.error(e.getMessage(), e); |
| | | throw new GlobleException("系统参数错误008"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |