using Exam.Infrastructure.Extensions; using Hotline.Application.Exam.Extensions; using Hotline.Share.Requests.Question; using JiebaNet.Segmenter.Common; using SqlSugar; using System.Linq.Expressions; using Hotline.Application.Exam.Core.Utilities; using Hotline.Exams.ExamManages; using Hotline.Exams.Questions; using ExamQuestion = Hotline.Exams.Questions.ExamQuestion; using ExamQuestionKnowladge = Hotline.Exams.Questions.ExamQuestionKnowladge; namespace Hotline.Application.Exam.QueryExtensions.Questions { public static class QuestionQueryExtesions { public static Expression> GetExpression(this QuestionPagedRequest questionPagedRequest) { Expression> expression = m => m.Id != null; expression = ExpressionableUtility.CreateExpression().AndIF(questionPagedRequest.DifficultyLevel.IsNotNull(), x => questionPagedRequest.DifficultyLevel == x.DifficultyLevel) .AndIF(questionPagedRequest.Title.IsNotNullOrEmpty(), x => x.Title.Contains(questionPagedRequest.Title)) .AndIF(questionPagedRequest.QuestionType.IsNotNull(),x=>x.QuestionType == questionPagedRequest.QuestionType) .ToExpression(); return expression; } public static Expression> GetQuestionTagExpression(this QuestionPagedRequest questionPagedRequest) { Expression> expression = m => m.Id != null; expression = ExpressionableUtility.CreateExpression().AndIF(questionPagedRequest.TagIds.IsNotNullOrEmpty(), x => questionPagedRequest.TagIds.Contains(x.TagId)) .ToExpression(); return expression; } public static Expression> GetExamTagExpression(this QuestionPagedRequest questionPagedRequest) { Expression> expression = m => m.Id != null; expression = ExpressionableUtility.CreateExpression(). AndIF(questionPagedRequest.TagIds.IsNotNullOrEmpty(), x => questionPagedRequest.TagIds.Contains(x.Id)) .ToExpression(); return expression; } public static Expression> GetQuestionKnowladgeExpression(this QuestionPagedRequest questionPagedRequest) { Expression> expression = m => m.Id != null; expression = ExpressionableUtility.CreateExpression(). AndIF(questionPagedRequest.KnowladgeIds.IsNotNullOrEmpty(), x => questionPagedRequest.KnowladgeIds.Contains(x.KnowladgeId)) .ToExpression(); return expression; } } }