如何手动搭建Furion脚手架

发布于:2022-12-24 ⋅ 阅读:(490) ⋅ 点赞:(0)

 也可前往 Furion官方文档进行学习

1.环境简介

  • 编程工具: vs 2022
  • 目标框架: .net core 6
  • 脚手架: Furion
  • Mssql: 2008

2.创建.Net Croe 程序 

3.创建脚手架类库 

  • 依次添加类库 F2.Application
  • 添加类库   F2.Core
  • 添加类库 F2.Database.Migrations
  • 添加类库 F2.EntityFramework.Core
  • 添加类库 F2.Web.Core

4.引用Furion相关包

  • F2.Application:添加 YourName.Core 引用
  • F2.Core:添加 Furion 引用SqlSugar 版本添加 Furion.Pure 🎗
  • F2.Database.Migrations:添加 F2.EntityFramework.Core 引用
  • F2.EntityFramework.Core:添加 F2.Core 引用
  • F2.Web.Core:添加 F2.ApplicationF2.Database.Migrations 引用
  • F2.Web.Entry:添加 F2.Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools 包

5.修改F2.Web.Entry 的 Program.cs 代码

var builder = WebApplication.CreateBuilder(args).Inject();
builder.Services.AddControllers().AddInject();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseInject();
app.MapControllers();
app.Run();

 6. 在 F2.Application 新建FurionAppService.cs类并继承 IDynamicApiController接口

using Furion.DynamicApiController;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace F2.Application
{
    public class FurionAppService : IDynamicApiController
    {

        public string Getwhat()
        {
            return "第一个接口";
        }
    }
}

7.启动 F2.Web.Entry 层 地址输入 /api/index.html

 注解:也可在配置文件定义自启动页

 8. 点击 Try it out  ,在点击Execute  访问接口

 也可前往 Furion官方文档进行学习

下期研究 :友好异常处理,接口规范化,日志记录


网站公告

今日签到

点亮在社区的每一天
去签到