Admin.Core/src/platform/ZhonTai.DynamicApi/Attributes/FormatResultAttribute.cs

(完整代码) 808B

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;

namespace ZhonTai.DynamicApi.Attributes;

[Serializable]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class FormatResultAttribute : ProducesResponseTypeAttribute
{
    public FormatResultAttribute(int statusCode) : base(statusCode)
    {
    }

    public FormatResultAttribute(Type type) : base(type, StatusCodes.Status200OK)
    {
        FormatType(type);
    }

    public FormatResultAttribute(Type type, int statusCode) : base(type, statusCode)
    {
        FormatType(type);
    }

    private void FormatType(Type type)
    {
        if (type != null && type != typeof(void))
        {
            Type = AppConsts.FormatResultType.MakeGenericType(type);
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。