package com.fdkanfang.dao.backend;

import com.fdkanfang.domain.backend.RoleEntity;
import com.fdkanfang.domain.response.UserResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Mapper
public interface RoleMapper extends IBaseMapper<RoleEntity, Long> {

    /**
     * 根据角色查询用户
     */
//    @Select(value = "select z.role_key from tb_user_role ur left join tb_role z on z.id = ur.role_id where ur.user_id = #{userId}")
    @Select(value = "select c.id, c.user_name, c.real_name, c.status, a.role_key from tb_role a " +
            "left join tb_user_role b on a.id = b.role_id " +
            "left join tb_user c on c.id = b.user_id " +
            "where c.status = '0' and c.rec_status = 'A' and a.role_key = #{roleKey}")
    List<UserResponse> findUserByRoleKey(String roleKey);
}