using System.ComponentModel;
using System.Linq.Expressions;
using Exam.Repository.Sqlsugar.Validators.ExamManages;
using Hotline.Exams.ExamManages;
using Hotline.Repository.SqlSugar.DataPermissions;
using Hotline.Repository.SqlSugar.Exam.Extensions;
using Hotline.Repository.SqlSugar.Exam.Interfaces.ExamManages;
using SqlSugar;
using XF.Domain.Dependency;

namespace Hotline.Repository.SqlSugar.Exam.Repositories.ExamManages
{
    /// <summary>
    /// 考试标签仓储
    /// </summary>
    [Description("考试标签仓储")]
    public class ExamTagRepository : ExamRepository<ExamTag>, IExamTagRepository,IScopeDependency
    {
        public ExamTagRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
        {
            Validator = new ExamTagValidator(this,dataPermissionFilterBuilder, serviceProvider);
        }

        public async Task<List<ExamTag>> GetTreeAsync(Expression<Func<ExamTag, bool>> expression)
        {
            var examTagList = await this.GetTree(expression).OrderBy(o => o.SortIndex).ToTreeAsync(m => m.Children, p => p.ParentId, "");

            return examTagList;
        }
    }
}

