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.
105 lines
3.1 KiB
105 lines
3.1 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using WebApi.Models;
|
|
|
|
namespace WebApi.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class TestController : ControllerBase
|
|
{
|
|
private IConfiguration _cfg;
|
|
|
|
public TestController(IConfiguration cfg)
|
|
{
|
|
this._cfg = cfg;
|
|
}
|
|
|
|
[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}",
|
|
Sex = i % 2 == 0 ? "男" : "女",
|
|
Nation = "汉",
|
|
CardType = "居民身份证",
|
|
IdCardNo = $"22012219830118253{i + 2}",
|
|
Birthday = "1983-01-18",
|
|
ExamNo = $"01234567891234{i + 1}",
|
|
StudentNo = $"01234567891234{i + 1}",
|
|
LanguageNo = "英语",
|
|
StudentType = "普通生",
|
|
Class = $"{i % 10 + 1}班",
|
|
Year = "2020-20-20",
|
|
School = "某某县某某中学",
|
|
HasChecked = false
|
|
});
|
|
}
|
|
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)
|
|
{
|
|
Console.WriteLine(model.Name);
|
|
return new ApiResponse
|
|
{
|
|
Code = 0
|
|
};
|
|
}
|
|
return new ApiResponse { Code = 1, Message = "数据验证失败" };
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("/api/[action]")]
|
|
public ApiResponse Update([FromBody]PushRequest model)
|
|
{
|
|
return new ApiResponse
|
|
{
|
|
Code = 0,
|
|
Data = new
|
|
{
|
|
version = this._cfg["version"],
|
|
file = this._cfg["file"]
|
|
}
|
|
};
|
|
}
|
|
}
|
|
} |