backend/ExamKing.Application/Services/SelectService.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ExamKing.Application.ErrorCodes;
using ExamKing.Application.Mappers;
using ExamKing.Core.Entites;
using Furion.DatabaseAccessor.Extensions;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.FriendlyException;
using Mapster;
using Microsoft.EntityFrameworkCore;
namespace ExamKing.Application.Services
{
/// <summary>
/// 选择题服务
/// </summary>
public class SelectService : ISelectService, ITransient
{
private readonly IRepository<TbSelect> _selectRepository;
/// <summary>
/// 依赖注入
/// </summary>
public SelectService(IRepository<TbSelect> selectRepository)
{
_selectRepository = selectRepository;
}
/// <summary>
/// 创建选择题
/// </summary>
/// <param name="selectDto"></param>
/// <returns></returns>
public async Task<SelectDto> CreateSelect(SelectDto selectDto)
{
// selectDto.CreateTime = TimeUtil.GetTimeStampNow();
var selectInsert = await _selectRepository
.InsertNowAsync(selectDto.Adapt<TbSelect>());
return selectInsert.Entity.Adapt<SelectDto>();
}
/// <summary>
/// 更新选择题
/// </summary>
/// <param name="selectDto"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<SelectDto> UpdateSelect(SelectDto selectDto)
{
var selectEntity = await _selectRepository.FirstOrDefaultAsync(u => u.Id == selectDto.Id);
if (selectEntity==null)
{
throw Oops.Oh(SelectErrorCodes.x1701);
}
var selectUpdate = selectDto.Adapt(selectEntity);
后面还有 161 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。