You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.8 KiB

3 years ago
using learun.util;
using Microsoft.AspNetCore.Mvc;
namespace learun.website
{
/// <summary>
/// 版 本 Learun-ADMS-Core 力软管理后台
/// Copyright (c) 2019-present 力软信息技术(苏州)有限公司
/// 创建人:tobin
/// 日 期:2019.09.11
/// 描 述:基础控制器
/// </summary>
public class MvcControllerBase : Controller
{
#region 请求响应
/// <summary>
/// 返回成功数据
/// </summary>
/// <param name="data">数据</param>
/// <returns></returns>
protected virtual IActionResult Success(object data)
{
return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
}
/// <summary>
/// 返回成功消息
/// </summary>
/// <param name="info">信息</param>
/// <param name="data">数据</param>
/// <returns></returns>
protected virtual IActionResult Success(string info, object data)
{
return Content(new ResParameter { code = ResponseCode.success, info = info, data = data }.ToJson());
}
/// <summary>
/// 返回成功数据
/// </summary>
/// <param name="info">信息</param>
/// <returns></returns>
protected virtual IActionResult SuccessInfo(string info)
{
return Content(new ResParameter { code = ResponseCode.success, info = info }.ToJson());
}
/// <summary>
/// 返回失败消息
/// </summary>
/// <param name="info">消息</param>
/// <returns></returns>
protected virtual IActionResult Fail(string info)
{
return Content(new ResParameter { code = ResponseCode.fail, info = info }.ToJson());
}
#endregion
}
}