apply datapermission

This commit is contained in:
sxu 2025-03-10 19:02:39 +08:00
parent c94153d979
commit db6d6cc005
2 changed files with 12 additions and 87 deletions

View File

@ -3,6 +3,8 @@ package com.bonus.canteen.core.menu.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.auth.config.LeNiuDataPermission;
import com.bonus.canteen.core.auth.enums.DataPermissionTypeEnum;
import com.bonus.canteen.core.auth.po.MgrUserAuthPO;
import com.bonus.canteen.core.menu.dto.*;
import com.bonus.canteen.core.menu.entity.MenuDishes;
@ -78,6 +80,11 @@ public interface MenuDishesMapper extends BaseMapper<MenuDishes> {
// @Select({"select id, dishes_name from menu_dishes ${ew.customSqlSegment}"})
// List<MenuDishes> selectIdAndNameByWrapper(@Param("ew") Wrapper<MenuDishes> wrapper);
//
@LeNiuDataPermission(
alias = "aa",
permissionType = DataPermissionTypeEnum.PERMISSION_AREA
)
Page<MenuDishesV2PageVO> selectAllV2List(Page<MenuDishesV2PageVO> resultPage, @Param("content") MenuDishesV2PageDTO content, @Param("canteenEnable") boolean canteenEnable, @Param("authPO") MgrUserAuthPO authPO);
//
MenuDishesDetailVO selectDishesDetailById(Long dishesId);
@ -85,6 +92,11 @@ public interface MenuDishesMapper extends BaseMapper<MenuDishes> {
@Select({"select custom_id from menu_dishes ${ew.customSqlSegment}"})
List<Integer> selectCustomIdByWrapper(@Param("ew") Wrapper<MenuDishes> wrapper);
//
@LeNiuDataPermission(
alias = "aa",
permissionType = DataPermissionTypeEnum.PERMISSION_AREA
)
List<MenuAllTypeDishesVO> selectTypeDishesList(@Param("content") MenuTypeDishesDTO content, @Param("authPO") MgrUserAuthPO authPO);
//
// @Select({"select 1 from menu_dishes ${ew.customSqlSegment}"})

View File

@ -541,14 +541,9 @@
left join alloc_area aa on md.area_id = aa.area_id
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
left join alloc_stall ast on md.shopstall_id = ast.stall_id
LEFT JOIN sys_role sr ON aa.area_id = sr.area_id
LEFT JOIN sys_user_role sur ON sr.role_id = sur.role_id
where
md.del_flag = 2
and hide_flag = 2
AND sr.del_flag = 0
AND sr.role_key = #{authPO.roleCode}
AND sur.user_id = #{authPO.userId}
<if test="content.salesMode != null ">
and md.sales_mode = #{content.salesMode}
</if>
@ -595,56 +590,6 @@
and mmd.material_id = #{content.materialId}
)
</if>
<!-- <if test="'3'.toString() == authPO.roleType.toString()">-->
<!-- and exists(-->
<!-- select-->
<!-- null-->
<!-- from mgr_role_canteen it1-->
<!-- left join mgr_role it2 on it2.role_id = it1.role_id-->
<!-- left join mgr_user_role it3 on it1.role_id = it3.role_id-->
<!-- where-->
<!-- it2.del_flag = 2-->
<!-- and it2.role_code = #{authPO.roleCode}-->
<!-- and it3.user_id = #{authPO.userId}-->
<!-- and (md.canteen_id = it1.data_id or md.canteen_id = -1)-->
<!-- )-->
<!-- AND EXISTS(-->
<!-- select-->
<!-- null-->
<!-- from mgr_role_canteen it1-->
<!-- left join mgr_role it2 on it2.role_id = it1.role_id-->
<!-- left join mgr_user_role it3 on it1.role_id = it3.role_id-->
<!-- where-->
<!-- it2.del_flag = 2-->
<!-- and it2.role_code = #{authPO.roleCode}-->
<!-- and it3.user_id = #{authPO.userId}-->
<!-- and (md.shopstall_id = it1.data_id or md.shopstall_id = -1)-->
<!-- )-->
<!-- and EXISTS (-->
<!-- SELECT null-->
<!-- FROM mgr_role_area it1-->
<!-- LEFT JOIN mgr_role it2 ON it2.role_id = it1.role_id-->
<!-- LEFT JOIN mgr_user_role it3 ON it1.role_id = it3.role_id-->
<!-- WHERE it2.del_flag = 2-->
<!-- AND it2.role_code = #{authPO.roleCode}-->
<!-- AND it1.half_select = 1-->
<!-- AND it3.user_id = #{authPO.userId}-->
<!-- AND (md.area_id = it1.data_id or md.area_id = -1)-->
<!-- )-->
<!-- </if>-->
<!-- <if test="'2'.toString() == authPO.roleType.toString() or '1'.toString() == authPO.roleType.toString()">-->
<!-- and EXISTS (-->
<!-- SELECT null-->
<!-- FROM mgr_role_area it1-->
<!-- LEFT JOIN mgr_role it2 ON it2.role_id = it1.role_id-->
<!-- LEFT JOIN mgr_user_role it3 ON it1.role_id = it3.role_id-->
<!-- WHERE it2.del_flag = 2-->
<!-- AND it2.role_code = #{authPO.roleCode}-->
<!-- AND it1.half_select = 1-->
<!-- AND it3.user_id = #{authPO.userId}-->
<!-- AND (md.area_id = it1.data_id or md.area_id = -1)-->
<!-- )-->
<!-- </if>-->
order by
md.id desc
</select>
@ -728,13 +673,8 @@
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
left join alloc_stall ass on ass.stall_id = md.shopstall_id
left join menu_dishes_type mdt on md.type_id = mdt.type_id
LEFT JOIN sys_role sr ON aa.area_id = sr.area_id
LEFT JOIN sys_user_role sur ON sr.role_id = sur.role_id
where
md.del_flag = 2
AND sr.del_flag = 0
AND sr.role_key = #{authPO.roleCode}
AND sur.user_id = #{authPO.userId}
<if test="content.typeId != null">
and md.type_id = #{content.typeId}
</if>
@ -772,33 +712,6 @@
<if test="content.salesMode != null">
and md.sales_mode = #{content.salesMode}
</if>
<!-- <if test="'3'.toString() == authPO.roleType.toString()">-->
<!-- and exists(-->
<!-- select-->
<!-- null-->
<!-- from mgr_role_canteen it1-->
<!-- left join mgr_role it2 on it2.role_id = it1.role_id-->
<!-- left join mgr_user_role it3 on it1.role_id = it3.role_id-->
<!-- where-->
<!-- it2.del_flag = 2-->
<!-- and it2.role_code = #{authPO.roleCode}-->
<!-- and it3.user_id = #{authPO.userId}-->
<!-- and (md.canteen_id = it1.data_id or md.canteen_id = -1)-->
<!-- )-->
<!-- </if>-->
<!-- <if test="'-1'.toString() != authPO.roleType.toString() ">-->
<!-- and EXISTS (-->
<!-- SELECT null-->
<!-- FROM mgr_role_area it1-->
<!-- LEFT JOIN mgr_role it2 ON it2.role_id = it1.role_id-->
<!-- LEFT JOIN mgr_user_role it3 ON it1.role_id = it3.role_id-->
<!-- WHERE it2.del_flag = 2-->
<!-- AND it2.role_code = #{authPO.roleCode}-->
<!-- AND it1.half_select = 1-->
<!-- AND it3.user_id = #{authPO.userId}-->
<!-- AND (md.area_id = it1.data_id or md.area_id = -1)-->
<!-- )-->
<!-- </if>-->
</select>
<!-- &lt;!&ndash; 获取指定人员指定日期的饮食详情 &ndash;&gt;-->