AppController.cs 899 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using GxPress.Common.Exceptions;
  2. using GxPress.Result;
  3. using Microsoft.AspNetCore.Mvc;
  4. namespace GxPress.Api.AppControllers
  5. {
  6. public class AppController : ControllerBase
  7. {
  8. public AppResult AppResult { get; set; }
  9. /// <summary>
  10. ///
  11. /// </summary>
  12. /// <param name="success"></param>
  13. /// <param name="msg"></param>
  14. /// <param name="msg1"></param>
  15. /// <returns></returns>
  16. public JsonResult JsonResult(bool success, string msg, string msg1)
  17. {
  18. var appJsonData = new AppResult();
  19. if (success)
  20. {
  21. appJsonData.Code = 1;
  22. appJsonData.Msg = msg;
  23. }
  24. else
  25. {
  26. throw new BusinessException(msg1);
  27. }
  28. var json = new JsonResult(appJsonData);
  29. return json;
  30. }
  31. }
  32. }