You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.1 KiB
77 lines
2.1 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using WebApi.Models;
|
|
|
|
namespace WebApi.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class TestController : ControllerBase
|
|
{
|
|
public TestController()
|
|
{
|
|
}
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
[Route("/")]
|
|
public string Home()
|
|
{
|
|
return "";
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("/api/[action]")]
|
|
public ApiResponse Login([FromBody]LoginRequest model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
return new ApiResponse { Code = 0, Data = model.UserName };
|
|
}
|
|
return new ApiResponse { Code = 1, Message = "用户名或密码错误" };
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("/api/[action]")]
|
|
public ApiResponse Pull([FromBody]PullRequest model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
var list = new List<Student>();
|
|
for (int i = 0; i < 222; i++)
|
|
{
|
|
list.Add(new Student
|
|
{
|
|
Id = i.ToString(),
|
|
Name = $"小明{i + 1}",
|
|
Class = $"{i % 10 + 1}班",
|
|
Sex = "男",
|
|
Nation = "汉",
|
|
IdCardNo = $"22012219830118253{i + 2}",
|
|
Number = $"01234567891234{i + 1}"
|
|
});
|
|
}
|
|
return new ApiResponse
|
|
{
|
|
Code = 0,
|
|
Data = list
|
|
};
|
|
}
|
|
return new ApiResponse { Code = 1, Message = "用户名不能为空" };
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("/api/[action]")]
|
|
public ApiResponse Push([FromBody]PushRequest model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
return new ApiResponse
|
|
{
|
|
Code = 0
|
|
};
|
|
}
|
|
return new ApiResponse { Code = 1, Message = "数据验证失败" };
|
|
}
|
|
}
|
|
} |