mirror of
https://github.com/nsnail/IGeekFan.AspNetCore.Knife4jUI.git
synced 2025-08-04 09:37:59 +08:00
添加项目文件。
This commit is contained in:
38
test/Basic/Controllers/JsonAnnotationsController.cs
Normal file
38
test/Basic/Controllers/JsonAnnotationsController.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Basic.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
public class JsonAnnotationsController
|
||||
{
|
||||
[HttpGet("/promotions")]
|
||||
public IEnumerable<Promotion> GetPromotions()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new Promotion { Code = "A", DiscountType = DiscountType.Amount, Discount = 30 },
|
||||
new Promotion { Code = "B", DiscountType = DiscountType.Percentage, Discount = 10 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Promotion
|
||||
{
|
||||
[JsonPropertyName("promo-code")]
|
||||
public string Code { get; set; }
|
||||
|
||||
public DiscountType DiscountType { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int Discount { get; set; }
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum DiscountType
|
||||
{
|
||||
Percentage,
|
||||
Amount
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user