12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ProductionLineMonitor.Core.Dtos
- {
- public enum CodeEnum
- {
- Success,
- Fail,
- Error
- }
- public class ResultDto
- {
- public CodeEnum Code { get; set; }
- public string Message { get; set; }
- public ResultDto(CodeEnum code, string message)
- {
- Code = code;
- Message = message;
- }
- public static ResultDto Success()
- {
- return new ResultDto(CodeEnum.Success, "执行成功!");
- }
- public static ResultDto Fail(string message)
- {
- return new ResultDto(CodeEnum.Fail, message);
- }
- public static ResultDto Error()
- {
- return new ResultDto(CodeEnum.Error, "程序内部错误,请联系管理员!");
- }
- public static ResultDto Error(string message)
- {
- return new ResultDto(CodeEnum.Error, message);
- }
- }
- public class ResultDto<T> : ResultDto where T : class
- {
- public ResultDto(CodeEnum code, string message)
- : base(code, message)
- {
- }
- public T Data { get; set; }
- public ResultDto(CodeEnum code, string message, T data)
- : base(code, message)
- {
- Code = code;
- Message = message;
- Data = data;
- }
- public static ResultDto<T> Success(T data)
- {
- return new ResultDto<T>(CodeEnum.Success, "执行成功!", data);
- }
- public static new ResultDto<T> Fail(string message)
- {
- return new ResultDto<T>(CodeEnum.Fail, message);
- }
- }
- }
|