2020-03-30 10:12:52 +08:00
|
|
|
|
using System;
|
2020-04-14 16:44:05 +08:00
|
|
|
|
using Falcon.Extend;
|
|
|
|
|
using FAuth.DataBase;
|
2020-05-12 11:24:56 +08:00
|
|
|
|
using FAuth.Models;
|
2020-03-30 10:12:52 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2020-04-14 16:44:05 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-03-30 10:12:52 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-05-12 11:24:56 +08:00
|
|
|
|
using Microsoft.Extensions.Options;
|
2020-03-30 10:12:52 +08:00
|
|
|
|
|
|
|
|
|
namespace FAuth.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 控制器类基类
|
|
|
|
|
/// </summary>
|
2020-05-09 11:44:07 +08:00
|
|
|
|
//[Route("[Controller]/[Action]")]
|
2020-03-30 16:10:51 +08:00
|
|
|
|
public abstract class ControllerBase<LoggerType>:Controller
|
2020-03-30 10:12:52 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志记录服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ILogger Logger { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 服务集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IServiceProvider Services { get; set; }
|
2020-04-14 16:44:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据库
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FAuthDb Db { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据缓冲
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICacheProvider Cache { get; set; }
|
2020-03-30 10:12:52 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过日志组件和服务集合生成控制器
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">控制器日志组件</param>
|
|
|
|
|
/// <param name="service">服务集合</param>
|
2020-03-30 16:10:51 +08:00
|
|
|
|
public ControllerBase(ILogger<LoggerType> logger,IServiceProvider service) {
|
2020-03-30 10:12:52 +08:00
|
|
|
|
this.Logger = logger;
|
|
|
|
|
this.Services = service;
|
2020-04-14 16:44:05 +08:00
|
|
|
|
this.Db = service.GetService<FAuthDb>();
|
|
|
|
|
this.Cache = service.GetService<ICacheProvider>();
|
2020-03-30 10:12:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|