backend/ExamKing.WebApp.Admin/ApiController/StudentController.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Generic;
using System.Threading.Tasks;
using ExamKing.Application.Mappers;
using ExamKing.Application.Services;
using Furion.DatabaseAccessor;
using Mapster;
using Microsoft.AspNetCore.Mvc;

namespace ExamKing.WebApp.Admin
{
    /// <summary>
    /// 学生接口
    /// </summary>
    public class StudentController : ApiControllerBase
    {
        private readonly IStudentService _studentService;
        /// <summary>
        /// 依赖注入
        /// </summary>
        public StudentController(IStudentService studentService)
        {
            _studentService = studentService;
        }

        /// <summary>
        /// 学生列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task<PagedList<StudentClassesOutput>> GetStudentList(
            [FromQuery] int pageIndex = 1, 
            [FromQuery] int pageSize = 10)
        {
            var stuList = await _studentService.FindStudentAllByPage(pageIndex, pageSize);
            return stuList.Adapt<PagedList<StudentClassesOutput>>();
        }
        
        /// <summary>
        /// 创建学生
        /// </summary>
        /// <param name="addStudentInput"></param>
        /// <returns></returns>
        public async Task<StudentInfoOutput> PostCreateStudent(AddStudentInput addStudentInput)
        {
            var stu = await _studentService.RegisterStudent(addStudentInput.Adapt<StudentDto
            >());
            return stu.Adapt<StudentInfoOutput>();
        }

        /// <summary>
        /// 修改学生
        /// </summary>
        /// <param name="editStudentInput"></param>
        /// <returns></returns>
        public async Task<string> UpdateEditStudent(EditStudentInput editStudentInput)
        { 
            await _studentService.UpdateStudent(editStudentInput
                .Adapt<StudentDto>());
            return "success";
后面还有 25 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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