Virtuesoft.Framework.Gateaway 7.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Virtuesoft.Framework.Gateaway --version 7.0.0
NuGet\Install-Package Virtuesoft.Framework.Gateaway -Version 7.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Virtuesoft.Framework.Gateaway" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Virtuesoft.Framework.Gateaway --version 7.0.0
#r "nuget: Virtuesoft.Framework.Gateaway, 7.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Virtuesoft.Framework.Gateaway as a Cake Addin
#addin nuget:?package=Virtuesoft.Framework.Gateaway&version=7.0.0

// Install Virtuesoft.Framework.Gateaway as a Cake Tool
#tool nuget:?package=Virtuesoft.Framework.Gateaway&version=7.0.0

Virtuesoft.Framework.Gateaway

������,������,�򵥵Ľӿڿ��,������.NET6

���

��2018����һֱ��ʹ������µ���,һ��Ϊ�˼�,Ϊ�˼򵥵�һ��.
ֻ��Ϊ��������С���ɵĽӿڷ���,ȥ��ӷ��.�ÿ�������������б�������,
��չ��ǿ,������Խ,�ر������㹻�ļ�!
���ڽӿڿ��ٿ���,��չǩ����֤,IP����,��ʽ������,���ʼ�¼�ȵ�.
���������ʹ�ù��ܺ���,����Ϊ�ͻ���������/�յĽ��׳ɼ�,
��ס�˴�ʮ��ķ��ʲ���.

��װʹ��

Install-Package Virtuesoft.Framework.Gateaway -Version 6.0.1

Program.cs ��ʹ��

using Virtuesoft.Framework.Gateaway;

var builder = WebApplication.CreateBuilder(args);
var sqlConnectionString = builder.Configuration.GetConnectionString("DbContext");
builder
    .Logging
    .AddConsole()
    .Services
    //����EF
    .AddDbContextPool<DataContext>(option =>
    {
        option.UseSqlServer(sqlConnectionString);
    })
    .AddGateaway();
var app = builder.Build();
//ʹ�ýӿ�
app.UseGateaway();
app.Run("http://*:5000");

��д�ӿ�

public class User:GateawayBase
{
    ILogger<User> Logger { get; }
    DataContext Db { get; }
    public User(DataContext context,ILogger<User> logger)
    {
        Logger=logger;
        Db = context;
    }
    public async Task<object> Add()
    {
        try
        {
            var result= await Db.Accounts.AddAsync(new MemberAccount()
            {
                Name = $"N{new Random((int)DateTime.Now.Ticks).Next(1111, 9999)}",
                Role = Db.Roles.FirstOrDefault()
            });
            await Db.SaveChangesAsync();
            return Success(new {
                result.Entity.ID,
                result.Entity.No,
                result.Entity.Name,
                result.Entity.Phone,
                result.Entity.CreateTime
            });
        }
        catch (Exception ex)
        {
            Logger.LogError(ex, $"Add:{ex.Message}");
            throw;
        }
    }
    public object Get()
    {
        var result = Db.Accounts
            .OrderByDescending(t => t.No)
            .Select(t => new
            {
                t.ID,
                t.Name,
                t.Phone,
                t.Age,
                t.No,
                t.Status,
                Role = new
                {
                    t.Role.ID,
                    t.Role.Name
                }
            })
            .FirstOrDefault();
        return Success(result);
    }
     public dynamic Detail(string id){
     var t = Db.Accounts.Include(t=>t.Role).FirstOrDefault(t=>t.ID==id);
        return new
        {
            t.ID,
            t.Name,
            t.Phone,
            t.Age,
            t.No,
            t.Status,
            Role = new
            {
                t.Role.ID,
                t.Role.Name
            }
        };
     }
}

����

Ĭ���ĵ���ַ
GET:http://localhost:5000/api/doc
POST: JSON {"method":"api.doc"}

POST / HTTP/1.1
Host: localhost:5000
Content-Type: application/json
User-Agent: App/1.0

{
	"method":"user.detail",
    "id":1000
}

GET / HTTP/1.1 http://localhost:5000/user/detail?id=10000

���ݷ���

//�����ͷ���
public object Get(){
    //�Զ�����������
    return Success();//Ĭ��ִ�гɹ�,�������κ�����
    return Success(new {name="�����"});//�����ݷ���
    return Error();
    return Error("�˻����������");
}
//ǿ���ͷ���
public Account Get(){
    return new Account(){Name="�����"};
}

Ĭ�ϸ�ʽ

{
    "s": true,//ִ��״̬
    "c": 200, //ִ�д��� ��Ȩʧ��:401,������������Զ���
    "m": "ok",//ִ����Ϣ
    //��������
    "d": {
        "ID": "99ead98b666549b590a529f453336e41",
        "No": 7364,
        "Name": "N9189",
        "Phone": "+861642609352",
        "CreateTime": "2022-01-20T00:22:32.5188842+08:00"
    }
}

·�������

·�ɲ���:��Сд,
����֧��:json,from,path
����֧��:POST,GET

//Ĭ��·�� user.*
public class User:GateawayBase
{
    //Ĭ��·�� user.get
    public object Get(string id){
        ...
    }
}
//�Զ���·��
[Gateaway(Name ="account",Display ="�û��ӿ�")]
public class User:GateawayBase{
    //����·��: account.detail.get
    [Gateaway(Name ="detail.get",Display ="��ȡ�û�")]
    public object Get(string id){}
}

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.9 452 8/8/2022
7.0.8 453 2/25/2022
7.0.7 450 2/19/2022
7.0.6 416 2/18/2022
7.0.5 441 2/16/2022
7.0.4 443 2/6/2022
7.0.3 457 1/27/2022
7.0.2 442 1/27/2022
7.0.1 441 1/27/2022
7.0.0 463 1/23/2022
6.0.1 460 1/19/2022
6.0.0 296 12/22/2021
5.0.1.1 385 9/12/2021
5.0.1 334 9/8/2021
5.0.0 341 9/6/2021
3.1.3 334 8/28/2021
3.1.2 329 8/28/2021
3.1.1 342 8/28/2021
3.1.0 382 6/30/2021
1.5.6 344 5/12/2021
1.5.4 410 12/7/2020
1.5.3 409 12/7/2020
1.5.2 420 12/7/2020
1.5.1 470 8/16/2020
1.5.0 461 8/15/2020
1.4.8 491 4/16/2020
1.4.6 497 3/28/2020
1.4.5 497 3/15/2020
1.4.4 526 3/15/2020
1.4.2 513 3/15/2020
1.4.1 493 3/12/2020
1.4.0 487 3/11/2020
1.3.8 484 2/14/2020
1.3.5 515 2/14/2020
1.3.4 479 1/30/2020
1.3.3 468 1/30/2020
1.3.2 488 1/30/2020
1.3.1 538 1/7/2020
1.3.0 521 1/7/2020
1.2.9 503 1/7/2020
1.2.8 507 1/7/2020
1.2.2 504 12/26/2019
1.1.9 477 12/1/2019
1.1.8 483 12/1/2019
1.1.7 485 12/1/2019
1.1.6 482 12/1/2019
1.1.3 479 12/1/2019
1.1.2 487 12/1/2019
1.1.1 484 7/25/2019
1.1.0 529 7/15/2019
1.0.9 572 2/26/2020
1.0.8 554 6/1/2019
1.0.7 576 6/1/2019
1.0.6 558 4/10/2019
1.0.5 563 4/10/2019
1.0.4 562 4/10/2019
1.0.3 565 4/10/2019
1.0.2 574 4/10/2019
1.0.1 547 4/10/2019

重构版