也可前往 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.Application
,F2.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官方文档进行学习
下期研究 :友好异常处理,接口规范化,日志记录