Esempio n. 1
0
        /// <summary>
        /// 成功返回结果.body为空
        /// </summary>
        /// <param name="msg">成功提示消息</param>
        /// <returns></returns>
        public static IActionResult ToSuccessResult(string msg = "")
        {
            var result = new ApiResultModel()
            {
                ErrorCode = 0,
                Msg       = msg
            };

            return(new JsonResult(result));
        }
Esempio n. 2
0
        /// <summary>
        /// 成功返回结果.带body数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="body"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static IActionResult ToSuccessResult <T>(T body, string msg = "")
        {
            var result = new ApiResultModel <T>()
            {
                Body      = body,
                ErrorCode = 0,
                Msg       = msg
            };

            return(new JsonResult(result));
        }
Esempio n. 3
0
        public static IActionResult ToFailResult(string msg, int errorCode = 100)
        {
            var resultModel = new ApiResultModel()
            {
                ErrorCode = errorCode,
                Msg       = msg
            };
            var result = new ObjectResult(resultModel);

            result.StatusCode = errorCode;
            return(result);
        }