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.
iot/labs/CameraCard/WebApi/Controllers/TestController.cs

65 lines
1.7 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)
{
return new ApiResponse
{
Code = 0,
Data = new List<Student> {
new Student{ Id=Guid.NewGuid().ToString(),Name="小明"}
}
};
}
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 = "数据验证失败" };
}
}
}