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.
53 lines
1.9 KiB
53 lines
1.9 KiB
using Tiobon.Core.Model;
|
|
|
|
namespace Tiobon.Core.Controllers
|
|
{
|
|
public class BaseApiController : Controller
|
|
{
|
|
[NonAction]
|
|
public ServiceResult<T> Success<T>(T data, string msg = "成功")
|
|
{
|
|
return new ServiceResult<T>() { success = true, msg = msg, response = data, };
|
|
}
|
|
|
|
// [NonAction]
|
|
//public ServiceResult<T> Success<T>(T data, string msg = "成功",bool success = true)
|
|
//{
|
|
// return new ServiceResult<T>()
|
|
// {
|
|
// success = success,
|
|
// msg = msg,
|
|
// response = data,
|
|
// };
|
|
//}
|
|
[NonAction]
|
|
public ServiceResult Success(string msg = "成功")
|
|
{
|
|
return new ServiceResult() { success = true, msg = msg, response = null, };
|
|
}
|
|
|
|
[NonAction]
|
|
public ServiceResult<string> Failed(string msg = "失败", int status = 500)
|
|
{
|
|
return new ServiceResult<string>() { success = false, status = status, msg = msg, response = null, };
|
|
}
|
|
|
|
[NonAction]
|
|
public ServiceResult<T> Failed<T>(string msg = "失败", int status = 500)
|
|
{
|
|
return new ServiceResult<T>() { success = false, status = status, msg = msg, response = default, };
|
|
}
|
|
|
|
[NonAction]
|
|
public ServiceResult<PageModel<T>> SuccessPage<T>(int page, int dataCount, int pageSize, List<T> data, int pageCount, string msg = "获取成功")
|
|
{
|
|
return new ServiceResult<PageModel<T>>() { success = true, msg = msg, response = new PageModel<T>(page, dataCount, pageSize, data) };
|
|
}
|
|
|
|
[NonAction]
|
|
public ServiceResult<PageModel<T>> SuccessPage<T>(PageModel<T> pageModel, string msg = "获取成功")
|
|
{
|
|
return new ServiceResult<PageModel<T>>() { success = true, msg = msg, response = pageModel };
|
|
}
|
|
}
|
|
} |