67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
using AutoMapper;
|
|
using Entities.Contracts;
|
|
using Entities.DTO;
|
|
using SharedDATA.Api;
|
|
using TechHelper.Services;
|
|
|
|
namespace TechHelper.Server.Services
|
|
{
|
|
public class QuestionGroupService : IAssignmentGroupService
|
|
{
|
|
|
|
private readonly IUnitOfWork _work;
|
|
// 如果不再需要 AutoMapper 进行实体到 DTO 的映射,可以移除 _mapper 字段
|
|
// 但如果 AutoMapper 在其他服务中用于其他映射,或者将来可能需要,可以保留
|
|
private readonly IMapper _mapper;
|
|
private readonly IExamService _examService;
|
|
|
|
public QuestionGroupService(IUnitOfWork work, IMapper mapper, IExamService examService)
|
|
{
|
|
_work = work;
|
|
_mapper = mapper;
|
|
_examService = examService;
|
|
}
|
|
|
|
|
|
public Task<ApiResponse> AddAsync(AssignmentGroup model)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<ApiResponse> DeleteAsync(Guid id)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<ApiResponse> GetAllAsync(QueryParameter query)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public async Task<ApiResponse> GetAsync(Guid id)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = await _work.GetRepository<AssignmentGroup>().GetFirstOrDefaultAsync(predicate: ag => ag.Id == id);
|
|
QuestionGroupDto qgd = new QuestionGroupDto();
|
|
if (result != null)
|
|
{
|
|
qgd = _examService.MapAssignmentGroupToDto(result);
|
|
return ApiResponse.Success(result: qgd);
|
|
}
|
|
return ApiResponse.Error("没找到问题组");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ApiResponse.Error($"出现了一点问题: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
public Task<ApiResponse> UpdateAsync(AssignmentGroup model)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|