namespace JSMachine.WMS.WebHost.Models { /// /// webapi查询结果封装 /// public class CommonQueryResult { public CommonQueryResult() { } public CommonQueryResult(bool isParamValid, bool isSucess, T result) { if (!isParamValid) { IsSucess = false; ErrorCode = ErrorCode.InValidInputParam; } else { IsSucess = isSucess; ErrorCode = isSucess ? ErrorCode.Sucess : ErrorCode.OperateFailed; Result = result; } } public bool IsSucess { get; set; } public ErrorCode ErrorCode { get; set; } /// /// 返回数据(可以是bool也可是实体等等) /// public T Result { get; set; } public string Msg { get; set; } } public enum ErrorCode { Sucess = 0, OperateFailed = 1, InValidInputParam = 2, InternalServerError = 3, UnknownError = 4 } }