UserCenterIconListController.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 Microsoft.AspNetCore.Authorization;
  9. using System.Web;
  10. using MySystem.MainModels;
  11. using LitJson;
  12. using Library;
  13. namespace MySystem.Areas.Api.Controllers.v1
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/[controller]/[action]")]
  17. public class UserCenterIconListController : BaseController
  18. {
  19. public UserCenterIconListController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 我的-常用工具
  23. [Authorize]
  24. public JsonResult List(string value)
  25. {
  26. value = DesDecrypt(value);
  27. JsonData data = JsonMapper.ToObject(value);
  28. List<Dictionary<string, object>> dataList = ListDo(value);
  29. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  30. }
  31. public List<Dictionary<string, object>> ListDo(string value)
  32. {
  33. JsonData data = JsonMapper.ToObject(value);
  34. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  35. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  36. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  37. List<Dictionary<string, object>> query = new UserCenterIconListService().List(new List<FieldItem>(), "", PageNum, PageSize);
  38. foreach (var subdata in query)
  39. {
  40. Dictionary<string, object> curData = new Dictionary<string, object>();
  41. curData.Add("Icon", DefaultPic(subdata["Icon"].ToString())); //图标
  42. curData.Add("Title", subdata["Title"].ToString()); //标题
  43. curData.Add("Url", subdata["Url"].ToString()); //跳转地址
  44. dataList.Add(curData);
  45. }
  46. return dataList;
  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. }