package com.cool.store.mapper;

import com.cool.store.entity.UserAuthMappingDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 人员权限映射表
 *
 * @author zyp
 * @Description 人员权限映射
 */
@Mapper
public interface UserAuthMappingMapper {

    /**
     * 根据UserId获取权限
     * @param userId
     * @return
     */
    List<UserAuthMappingDO> listUserAuthMappingByUserId(@Param("userId") String userId);

    /**
     * 根据UserId和权限来源获取权限

     * @param userId
     * @param source
     * @return
     */
    List<UserAuthMappingDO> listByUserIdAndSource( @Param("userId") String userId, @Param("source") String source);
    /**
     * 查询用户区域

     * @param userList
     * @return
     */
    List<UserAuthMappingDO> listUserAuthMappingByUserIdList(@Param("userList") List<String> userList);

    List<UserAuthMappingDO> listUserAuthMappingByMappingList(@Param("mappingIdList") List<String> mappingIdList,
                                                             @Param("type") String type);

    /**
     *查询不包含可视化范围的区域人员

     * @param mappingIdList
     * @return
     */
    List<UserAuthMappingDO> listUserAuthMappingByAuth(@Param("type") String type,
                                                      @Param("mappingIdList") List<String> mappingIdList,
                                                      @Param("positionType")String positionType,
                                                      @Param("notRoleAuth")String notRoleAuth);


    List<UserAuthMappingDO> listUserAuthMappingByUserList(@Param("userIdList") List<String> userIdList);


    List<UserAuthMappingDO> listUserAuthMappingByUserAndType(@Param("userId") String userId,
                                                             @Param("type") String type);
    /**
     * 根据用户id获得权限映射信息主键列表

     * @param userId
     * @return: java.util.List<java.lang.Long>
     * @Author: xugangkun
     * @Date: 2021/3/25 14:24
     */
    List<Long> selectIdsByUserId( @Param("userId") String userId);


    List<Long> selectIdsByUserIds( @Param("userIds") List<String> userIds);

    UserAuthMappingDO getUserAuthByUserIdAndMappingId(
                                                             @Param("userId") String userId,
                                                             @Param("mappingId") String mappingId,
                                                             @Param("type") String type);

    /**
     * 分页订正  门店类型的权限
     * @param enterpriseId
     * @return
     */
    List<UserAuthMappingDO> listStoreAuthByEid(@Param("enterpriseId") String enterpriseId);

    List<UserAuthMappingDO> getAllAuthMapping(@Param("enterpriseId") String enterpriseId);

    List<String> getUserIdsByMappingIds(@Param("mappingIdList") List<String> mappingIdList);

    List<UserAuthMappingDO> getUserAuthByMappingIds(@Param("mappingIdList") List<String> mappingIdList);

    List<String> getMappingIdsByUserId(@Param("userId")String userId);


    List<String> getRegionIdByUserId(@Param("userId") String userId);

    /**
     * 根据UserId和权限来源获取权限

     * @param userIdList
     * @param source
     * @return
     */
    List<UserAuthMappingDO> listByUserIdListAndSource(@Param("userIdList") List<String> userIdList, @Param("source") String source);

    List<UserAuthMappingDO> getAllByUserIds(@Param("userIdsByRoleIdList") List<String> userIdsByRoleIdList);
}