12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using Exam.Infrastructure.Data.Entity;
- using Exam.Insfrastructure.Service.Service;
- using Exam.Questions;
- using Exam.Share;
- using Hotline.Application.Exam.QueryExtensions.Questions;
- using Hotline.Repository.SqlSugar;
- using Hotline.Repository.SqlSugar.Exam.Interfaces.Questions;
- using Hotline.Share.Dtos.Questions;
- using Hotline.Share.Requests.Question;
- using Mapster;
- using System.ComponentModel;
- using XF.Domain.Dependency;
- namespace Exam.Application
- {
- /// <summary>
- /// 关联知识服务
- /// </summary>
- [Description("关联知识服务")]
- public class QuestionKnowladgeService : ApiService<QuestionKnowladge, QuestionKnowladgeDto,HotlineDbContext>,IQuestionKnowladgeService, IScopeDependency
- {
- private readonly IQuestionKnowladgeRepository _repository;
- public QuestionKnowladgeService(IQuestionKnowladgeRepository repository) : base(repository)
- {
- _repository = repository;
- }
- public async Task<QuestionKnowladgeDto> GetAsync(EntityQueryRequest entityQueryRequest)
- {
- var entity = await _repository.GetAsync(entityQueryRequest.Id);
- return entity.Adapt<QuestionKnowladgeDto>();
- }
- public async Task<(int, List<QuestionKnowladgeViewResponse>)> GetListAsync(QuestionKnowladgePagedRequest queryRequest)
- {
- var query = _repository.Queryable();
- var result = await query.Select(m => new QuestionKnowladgeViewResponse {
- QuestionId = m.QuestionId,
- KnowladgeId = m.KnowladgeId,
- Id = m.Id,
- }).ToListAsync();
- var total = await query.CountAsync();
- return (total,result);
- }
- public async Task<PageViewResponse<QuestionKnowladgeViewResponse>> GetPagedListAsync(QuestionKnowladgePagedRequest queryRequest)
- {
- var expression = queryRequest.GetExpression();
- var questionKnowladgeTable = _repository.Queryable().Where(expression);
- var queryable = questionKnowladgeTable.Select((m) => new QuestionKnowladgeViewResponse
- {
- QuestionId = m.QuestionId,
- KnowladgeId = m.KnowladgeId,
- Id = m.Id,
- });
- var list = await queryable.ToPageListAsync(queryRequest.PageIndex, queryRequest.PageSize);
- var total = await queryable.CountAsync();
- var result = new PageViewResponse<QuestionKnowladgeViewResponse>
- {
- Items = list,
- Pagination = new Pagination(queryRequest.PageIndex, queryRequest.PageSize, total)
- };
- return result;
- }
- }
- }
|