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 : 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 Success(T data) { return new ResultDto(CodeEnum.Success, "执行成功!", data); } public static new ResultDto Fail(string message) { return new ResultDto(CodeEnum.Fail, message); } } }