UserBackKindController.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 MySystem.MainModels;
  10. using LitJson;
  11. using Library;
  12. namespace MySystem.Areas.Api.Controllers.v1
  13. {
  14. [Area("Api")]
  15. [Route("Api/v1/[controller]/[action]")]
  16. public class UserBackKindController : BaseController
  17. {
  18. public UserBackKindController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  19. {
  20. }
  21. #region 商户-反馈类型
  22. [Authorize]
  23. public JsonResult List(string value)
  24. {
  25. value = DesDecrypt(value);
  26. JsonData data = JsonMapper.ToObject(value);
  27. List<Dictionary<string, object>> dataList = ListDo(value);
  28. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  29. }
  30. public List<Dictionary<string, object>> ListDo(string value)
  31. {
  32. JsonData data = JsonMapper.ToObject(value);
  33. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  34. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  35. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  36. List<Dictionary<string, object>> query = new UserBackKindService().List(new List<FieldItem>(), "", PageNum, PageSize);
  37. foreach (var subdata in query)
  38. {
  39. Dictionary<string, object> curData = new Dictionary<string, object>();
  40. curData.Add("Name", subdata["Name"].ToString()); //名称
  41. curData.Add("Id", subdata["Id"].ToString()); //Id
  42. dataList.Add(curData);
  43. }
  44. return dataList;
  45. }
  46. #endregion
  47. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  48. /// <summary>
  49. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  50. /// </summary>
  51. /// <param name="value">请求的参数(json字符串)</param>
  52. /// <param name="signField">要签名的字段</param>
  53. /// <returns></returns>
  54. private string CheckSign(string value, string[] signField)
  55. {
  56. JsonData json = JsonMapper.ToObject(value);
  57. Dictionary<string, string> dic = new Dictionary<string, string>();
  58. for (int i = 0; i < signField.Length; i++)
  59. {
  60. dic.Add(signField[i], json[signField[i]].ToString());
  61. }
  62. string sign = json["sign"].ToString(); //客户端签名字符串
  63. return new Sign().sign(dic, sign);
  64. }
  65. #endregion
  66. }
  67. }