12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Bowin.Common.WebModels
- {
- public class ServiceResultMessage<T> : ServiceResultMessage
- {
- public new T Data { get; set; }
- }
- public class ServiceResultMessage
- {
- public bool IsSuccess { get; set; }
- public int Code { get; set; } = 0;
- public string Message { get; set; }
- public object Data { get; set; }
- public static ServiceResultMessage<T> Convert<T>(ServiceResultMessage error)
- {
- return new ServiceResultMessage<T> { IsSuccess = error.IsSuccess, Message = error.Message };
- }
- public static ServiceResultMessage GetError(string _message)
- {
- return new ServiceResultMessage { IsSuccess = false, Message = _message };
- }
- public static ServiceResultMessage<T> GetError<T>(string _message) where T : class
- {
- return Convert<T>(GetError(_message));
- }
- public static ServiceResultMessage GetError(int code, string _message)
- {
- return new ServiceResultMessage { Code = code, IsSuccess = false, Message = _message };
- }
- public static ServiceResultMessage<T> GetError<T>(int code, string _message)
- {
- return new ServiceResultMessage<T> { Code = code, IsSuccess = false, Message = _message };
- }
- public static ServiceResultMessage GetError(string _message, object _data)
- {
- return new ServiceResultMessage { IsSuccess = false, Message = _message, Data = _data };
- }
- public static ServiceResultMessage<T> GetError<T>(string _message, T _data) where T : class
- {
- return new ServiceResultMessage<T> { IsSuccess = false, Message = _message, Data = _data };
- }
- public static ServiceResultMessage Success()
- {
- return new ServiceResultMessage { IsSuccess = true, Message = "" };
- }
- public static ServiceResultMessage Success(object _data)
- {
- return new ServiceResultMessage { IsSuccess = true, Message = "", Data = _data };
- }
- public static ServiceResultMessage<T> Success<T>() where T : class
- {
- return Convert<T>(Success());
- }
- public static ServiceResultMessage<T> Success<T>(T _data) where T : class
- {
- return new ServiceResultMessage<T> { IsSuccess = true, Message = "", Data = _data };
- }
- }
- }
|