SystemSetController.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 LitJson;
  9. using Library;
  10. namespace MySystem.Areas.Api.Controllers
  11. {
  12. [Area("Api")]
  13. [Route("Api/[controller]/[action]")]
  14. public class SystemSetController : BaseController
  15. {
  16. public SystemSetController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  17. {
  18. }
  19. #region 验证获取jwt的token
  20. public JsonResult AppCheck(string value)
  21. {
  22. value = DesDecrypt(value);
  23. // string uuid = data["uuid"].ToString();
  24. // string salt = data["salt"].ToString();
  25. // string u = function.MD5_16(uuid + salt);
  26. Dictionary<string, object> Obj = new Dictionary<string, object>();
  27. //生成jwt令牌
  28. Obj.Add("Token", PublicFunction.AppToken(1, JwtSecret, JwtIss, "consumer"));
  29. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  30. }
  31. #endregion
  32. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  33. /// <summary>
  34. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  35. /// </summary>
  36. /// <param name="value">请求的参数(json字符串)</param>
  37. /// <param name="signField">要签名的字段</param>
  38. /// <returns></returns>
  39. private string CheckSign(string value, string[] signField)
  40. {
  41. JsonData json = JsonMapper.ToObject(value);
  42. Dictionary<string, string> dic = new Dictionary<string, string>();
  43. for (int i = 0; i < signField.Length; i++)
  44. {
  45. dic.Add(signField[i], json[signField[i]].ToString());
  46. }
  47. string sign = json["sign"].ToString(); //客户端签名字符串
  48. return new Sign().sign(dic, sign);
  49. }
  50. #endregion
  51. }
  52. }