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.
43 lines
1.0 KiB
43 lines
1.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Web.Http.Results;
|
|
|
|
namespace Warehouse.WebApi
|
|
{
|
|
public class BaseController: ApiController
|
|
{
|
|
/// <summary>
|
|
/// 返回成功数据
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
public JsonResult<dynamic> Success(object data)
|
|
{
|
|
var result = new
|
|
{
|
|
State = 1,
|
|
Message = "",
|
|
Data = data
|
|
};
|
|
return Json<dynamic>(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返回失败数据
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
/// <param name="data"></param>
|
|
public JsonResult<dynamic> Failure(string message, object data = null)
|
|
{
|
|
var result = new
|
|
{
|
|
State = 0,
|
|
Message = message,
|
|
Data = data
|
|
};
|
|
return Json<dynamic>(result);
|
|
}
|
|
}
|
|
}
|