添加项目文件。

This commit is contained in:
luoyunchong
2020-08-09 14:50:47 +08:00
parent 5d21b53ae2
commit 483c410943
51 changed files with 2367 additions and 0 deletions

View File

@ -0,0 +1,55 @@
using System;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;
namespace Basic.Controllers
{
[Produces("application/json")]
public class DataAnnotationsController : Controller
{
[HttpPost("payments/authorize")]
[ProducesResponseType(200, Type = typeof(string))]
public IActionResult AuthorizePayment([FromBody, Required]PaymentRequest request)
{
if (!ModelState.IsValid)
return new BadRequestObjectResult(ModelState);
return new ObjectResult("123456");
}
[HttpPut("payments/{paymentId}/cancel")]
public IActionResult CancelPayment([MinLength(6)]string paymentId)
{
return Ok();
}
}
public class PaymentRequest
{
[Required]
public Transaction Transaction { get; set; }
[Required]
public CreditCard CreditCard { get; set; }
}
public class Transaction
{
[Required]
public decimal Amount { get; set; }
public string Note { get; set; }
}
public class CreditCard
{
[Required, RegularExpression("^[3-6]?\\d{12,15}$")]
public string CardNumber { get; set; }
[Required, Range(1, 12)]
public int ExpMonth { get; set; }
[Required, Range(14, 99)]
public int ExpYear { get; set; }
}
}