backend/ExamKing.Application/Services/StudentService.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.DataEncryption;
using Furion.DependencyInjection;
using Furion.FriendlyException;
using Mapster;
using Microsoft.EntityFrameworkCore;

namespace ExamKing.Application.Services
{
    /// <summary>
    /// 学生服务
    /// </summary>
    public class StudentService : IStudentService, ITransient
    {
        private readonly IRepository<TbStudent> _studentRepository;
        
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="studentRepository"></param>
        public StudentService(IRepository<TbStudent> studentRepository)
        {
            _studentRepository = studentRepository;
        }

        /// <summary>
        /// 分页查询学生
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task<PagedList<StudentDto>> FindStudentAllByPage(int pageIndex = 1, int pageSize = 10)
        {
            var pageResult = await _studentRepository.Entities.AsNoTracking()
                .Select(u=>new TbStudent
                {
                    Id=u.Id,
                    StuName=u.StuName,
                    DeptId=u.DeptId,
                    ClassesId=u.ClassesId,
                    Sex=u.Sex,
                    StuNo=u.StuNo,
                    Telphone=u.Telphone,
                    IdCard=u.IdCard,
                    CreateTime=u.CreateTime,
                    Classes = new TbClass
                    {
                        Id=u.Classes.Id,
                        ClassesName=u.Classes.ClassesName,
                        CreateTime=u.Classes.CreateTime,
                        DeptId = u.Classes.DeptId,
                        Dept = new TbDept
后面还有 145 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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