初始提交
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Manage.Configs;
|
||||
using Hncore.Pass.Manage.Util;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Hncore.Pass.Manage.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 管理员权限模块专用父控制器(提供了一些在管理员权限模块中专用的功能)
|
||||
/// </summary>
|
||||
///
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/Manage/v{version:apiVersion}/[controller]/[action]")]
|
||||
public class ManageControllerBase : HncoreControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置文件数据承载对象
|
||||
/// </summary>
|
||||
protected readonly AppSettings _appSettings;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="hca">HTTP上下文访问对象</param>
|
||||
///
|
||||
public ManageControllerBase (IHttpContextAccessor hca)
|
||||
{
|
||||
//获取当前应用配置信息承载对象
|
||||
var oa=hca.HttpContext.RequestServices.GetService(typeof(IOptionsMonitor<AppSettings>)) as IOptionsMonitor<AppSettings>;
|
||||
this._appSettings = oa.CurrentValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建成功分页结果对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据类型</typeparam>
|
||||
/// <param name="total">记录总数</param>
|
||||
/// <param name="data">数据对象</param>
|
||||
/// <param name="message">提示信息</param>
|
||||
/// <returns>响应给客户端的结果对象</returns>
|
||||
///
|
||||
protected ApiResultPaged<T> SuccessPaged<T>(int total, T data, string message = "") where T : class, new()
|
||||
{
|
||||
return new ApiResultPaged<T>(ResultCode.C_SUCCESS, message) {TotalCount=total, Data = data };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建失败分页结果对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据类型</typeparam>
|
||||
/// <param name="message">提示信息</param>
|
||||
/// <returns>响应给客户端的结果对象</returns>
|
||||
///
|
||||
protected ApiResultPaged<T> ErrorPaged<T>(string message = "") where T : class, new()
|
||||
{
|
||||
return new ApiResultPaged<T>(ResultCode.C_UNKNOWN_ERROR, message) { TotalCount = 0 };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user