添加 dto

This commit is contained in:
milimoe 2025-12-29 01:47:11 +08:00
parent 67e907e6c8
commit cdf3fad718
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
3 changed files with 20 additions and 2 deletions

View File

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Milimoe.FunGame.Core.Api.Transmittal;
using Milimoe.FunGame.WebAPI.Models;
namespace Milimoe.FunGame.WebAPI.Controllers
{
@ -12,8 +13,14 @@ namespace Milimoe.FunGame.WebAPI.Controllers
public class APIController(SQLHelper sql, ILogger<APIController> logger) : ControllerBase
{
[HttpPost("scadd")]
public string SCAdd(long uid, long group, double sc, int year = 0, int month = 0, string content = "")
public string SCAdd([FromBody] SCDTO dto)
{
long uid = dto.UID;
long group = dto.Group;
double sc = dto.SC;
int year = dto.Year;
int month = dto.Month;
string content = dto.Content;
string result = "";
if (year == 0) year = DateTime.Today.Year;
if (month == 0) month = DateTime.Today.Month;

View File

@ -29,7 +29,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
<Folder Include="Services\" />
</ItemGroup>

View File

@ -0,0 +1,12 @@
namespace Milimoe.FunGame.WebAPI.Models
{
public class SCDTO
{
public long UID { get; set; }
public long Group { get; set; }
public double SC { get; set; }
public int Year { get; set; } = 0;
public int Month { get; set; } = 0;
public string Content { get; set; } = "";
}
}