backend/ExamKing.Application/Services/JudgeService.cs

(开头部分) 5KB

这里只显示每个文件的开头 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 JudgeService : IJudgeService, ITransient
    {
        private readonly IRepository<TbJudge> _judgeRepository;

        /// <summary>
        /// 依赖注入
        /// </summary>
        public JudgeService(IRepository<TbJudge> judgeRepository)
        {
            _judgeRepository = judgeRepository;
        }
        
        /// <summary>
        /// 创建是非题 
        /// </summary>
        /// <param name="judgeDto"></param>
        /// <returns></returns>
        public async Task<JudgeDto> CreateJudge(JudgeDto judgeDto)
        {
            // judgeDto.CreateTime = TimeUtil.GetTimeStampNow();
            var judgeInsert = await _judgeRepository
                .InsertNowAsync(judgeDto.Adapt<TbJudge>());

            return judgeInsert.Entity.Adapt<JudgeDto>();
        }

        /// <summary>
        /// 更新是非题 
        /// </summary>
        /// <param name="judgeDto"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task<JudgeDto> UpdateJudge(JudgeDto judgeDto)
        {
            var judgeEntity = await _judgeRepository.FirstOrDefaultAsync(u => u.Id == judgeDto.Id);
            if (judgeEntity==null)
            {
                throw Oops.Oh(JudgeErrorCodes.s1801);
            }

            var judgeUpdate = judgeDto.Adapt(judgeEntity);
后面还有 104 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。