/**
 * 
 */
package org.springblade.modules.system.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springblade.modules.system.entity.DataPermission;
import org.springblade.modules.system.vo.UserVO;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @author wookvn
 *
 */
public interface DataPermissionMapper extends BaseMapper<DataPermission> {

	@Select({
		"select a.* from data_permission a",
		"inner join data_permission_user b on a.id = b.data_perm_id",
		"where b.user_id = #{value} and a.super_status = 0"
	})
	public List<DataPermission> selectOwnerList(Long userId);
	
	@Select({
		"<script>",
		"select b.user_id as id, GROUP_CONCAT(a.perm_name) as data_perm_name",
		"from data_permission a inner join data_permission_user b on a.id = b.data_perm_id",
		"where b.user_id in",
		"<foreach collection='userIdList' item='item' open='(' separator=',' close=')'>",
		"#{item}",
		"</foreach>",
		"group by b.user_id",
		"</script>"
	})
	public List<UserVO> selectDataPerms(@Param("userIdList")List<Long> userIdList);
}
