flower-story/Server/Controller/FlowerApiController.structs.cs

140 lines
2.8 KiB
C#

using Blahblah.FlowerStory.Server.Data.Model;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace Blahblah.FlowerStory.Server.Controller;
/// <summary>
/// 封面参数
/// </summary>
public record CoverParameter
{
/// <summary>
/// 封面
/// </summary>
[FromForm(Name = "cover")]
public IFormFile? Cover { get; init; }
/// <summary>
/// 封面 id
/// </summary>
[FromForm(Name = "cid")]
public int? CoverId { get; init; }
}
/// <summary>
/// 花草参数
/// </summary>
public record FlowerParameter : CoverParameter
{
/// <summary>
/// 类别 id
/// </summary>
[Required]
[FromForm(Name = "categoryId")]
public required int CategoryId { get; init; }
/// <summary>
/// 花草名称
/// </summary>
[Required]
[FromForm(Name = "name")]
public required string Name { get; init; }
/// <summary>
/// 购买时间
/// </summary>
[Required]
[FromForm(Name = "dateBuy")]
public required long DateBuy { get; init; }
/// <summary>
/// 购买花费
/// </summary>
[FromForm(Name = "cost")]
public decimal? Cost { get; init; }
/// <summary>
/// 购买渠道
/// </summary>
[FromForm(Name = "purchase")]
public string? Purchase { get; init; }
/// <summary>
/// 备注
/// </summary>
[FromForm(Name = "memo")]
public string? Memo { get; set; }
/// <summary>
/// 纬度
/// </summary>
[FromForm(Name = "lat")]
public double? Latitude { get; set; }
/// <summary>
/// 经度
/// </summary>
[FromForm(Name = "lon")]
public double? Longitude { get; set; }
/// <summary>
/// 存放位置
/// </summary>
[FromForm(Name = "location")]
public string? Location { get; set; }
}
/// <summary>
/// 花草修改参数
/// </summary>
public record FlowerUpdateParameter : FlowerParameter
{
/// <summary>
/// 花草唯一 id
/// </summary>
[Required]
[FromForm(Name = "id")]
public required int Id { get; init; }
}
/// <summary>
/// 花草封面修改参数
/// </summary>
public record FlowerCoverParameter : CoverParameter
{
/// <summary>
/// 花草唯一 id
/// </summary>
[Required]
[FromForm(Name = "id")]
public required int Id { get; init; }
/// <summary>
/// 纬度
/// </summary>
[FromForm(Name = "lat")]
public double? Latitude { get; set; }
/// <summary>
/// 经度
/// </summary>
[FromForm(Name = "lon")]
public double? Longitude { get; set; }
}
/// <summary>
/// 花草结果对象
/// </summary>
public record FlowerResult
{
/// <summary>
/// 花草列表
/// </summary>
public required FlowerItem[] Flowers { get; init; }
/// <summary>
/// 花草总数
/// </summary>
public int Count { get; init; }
}