LocalPushController.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using System.Web;
  9. using MySystem.BsModels;
  10. using LitJson;
  11. using Library;
  12. using System.Text.RegularExpressions;
  13. namespace MySystem.Areas.Api.Controllers
  14. {
  15. [Area("Api")]
  16. [Route("Api/[controller]/[action]")]
  17. public class LocalPushController : Admin.Controllers.BaseController
  18. {
  19. public LocalPushController(IHttpContextAccessor accessor, ILogger<Admin.Controllers.BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 系统-本地推送
  23. public JsonResult List(string value)
  24. {
  25. value = HttpUtility.UrlDecode(value);
  26. Dictionary<string, object> Obj = new Dictionary<string, object>();
  27. List<Dictionary<string, object>> RegistrationList = new List<Dictionary<string, object>>();
  28. Dictionary<string, object> item = new Dictionary<string, object>();
  29. item.Add("Title", "title1");
  30. item.Add("Subtitle", "subtitle");
  31. item.Add("Body", "日");
  32. item.Add("Url", "");
  33. item.Add("MiniAppId", "");
  34. item.Add("Params", "");
  35. item.Add("PushDate", "1658734489");
  36. item.Add("Repeats", "0");
  37. item.Add("LocalPushId", "user-setting");
  38. item.Add("RepeatType","");
  39. RegistrationList.Add(item);
  40. List<string> ClearList = new List<string>();
  41. ClearList.Add("1");
  42. string ClearAll = "";
  43. Obj.Add("RegistrationList", RegistrationList);
  44. Obj.Add("ClearList", ClearList);
  45. Obj.Add("ClearAll", ClearAll);
  46. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  47. }
  48. #endregion
  49. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  50. /// <summary>
  51. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  52. /// </summary>
  53. /// <param name="value">请求的参数(json字符串)</param>
  54. /// <param name="signField">要签名的字段</param>
  55. /// <returns></returns>
  56. private string CheckSign(string value, string[] signField)
  57. {
  58. JsonData json = JsonMapper.ToObject(value);
  59. Dictionary<string, string> dic = new Dictionary<string, string>();
  60. for (int i = 0; i < signField.Length; i++)
  61. {
  62. dic.Add(signField[i], json[signField[i]].ToString());
  63. }
  64. string sign = json["sign"].ToString(); //客户端签名字符串
  65. return new Sign().sign(dic, sign);
  66. }
  67. #endregion
  68. }
  69. }