using XYY.Model.Standard;
using XYY.Core.Standard.Data.Infrastructure;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;

namespace XYY.Data.Standard
{
    public interface IUserRoleRepository : IBaseRepository<User_Role>
    {
        Task<List<User_Role>> GetUserRoles(int userId);
    }
    public class UserRoleRepository : BaseRepository<User_Role>, IUserRoleRepository
    {
        public UserRoleRepository(IUnitOfWork unitOfWork)
            : base(unitOfWork)
        { }


        public async Task<List<User_Role>> GetUserRoles(int userId)
        {
            string sql = "Select UR.* from User_Role UR Join User_UserRole  URR on URR.UserId=" + userId + " and URR.RoleId = UR.Id";
            var result = await base.QueryBySqlAsync(sql);
            return result.ToList();
        }
    }
}
