using GxPress.Common.Exceptions;
using GxPress.Result;
using Microsoft.AspNetCore.Mvc;

namespace GxPress.Api.AppControllers
{


    public class AppController : ControllerBase
    {
        public AppResult AppResult { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="success"></param>
        /// <param name="msg"></param>
        /// <param name="msg1"></param>
        /// <returns></returns>
        public JsonResult JsonResult(bool success, string msg, string msg1)
        {
            var appJsonData = new AppResult();
            if (success)
            {
                appJsonData.Code = 1;
                appJsonData.Msg = msg;
            }
            else
            {
                throw new BusinessException(msg1);
            }

            var json = new JsonResult(appJsonData);
            return json;
        }
    }
}