商品添加店铺权限数据控制过滤器
This commit is contained in:
parent
76e14d4bd0
commit
108ab7443f
@ -0,0 +1,26 @@
|
||||
package com.suisung.mall.common.utils;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
|
||||
public class FilterUtils <T>{
|
||||
/**
|
||||
* 应用店铺数据权限过滤
|
||||
* @param queryWrapper 查询条件
|
||||
*/
|
||||
public void applyStoreFilter(QueryWrapper<T> queryWrapper) {
|
||||
if (getCurrentUser().isStore()) {
|
||||
queryWrapper.eq("store_id", getCurrentUserStoreId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的店铺ID(店员返回店铺ID,管理员返回null)
|
||||
*/
|
||||
public Integer getCurrentUserStoreId() {
|
||||
return getCurrentUser().isStore() ?
|
||||
Convert.toInt(getCurrentUser().getStore_id()) :
|
||||
null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user