OpenBankTableController.cs 3.0 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 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 OpenBankTableController : BaseController
  17. {
  18. public OpenBankTableController(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. string SearchKey = data["SearchKey"].ToString(); //搜索关键词
  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<OpenBankTable> query = maindb.OpenBankTable.Where(m => m.BankName.Contains(SearchKey)).Take(PageSize).ToList();
  38. foreach (var subdata in query)
  39. {
  40. Dictionary<string, object> curData = new Dictionary<string, object>();
  41. curData.Add("BankName", subdata.BankName); //开户行名称
  42. curData.Add("BankCode", subdata.BankCode); //联行号
  43. dataList.Add(curData);
  44. }
  45. return dataList;
  46. }
  47. #endregion
  48. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  49. /// <summary>
  50. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  51. /// </summary>
  52. /// <param name="value">请求的参数(json字符串)</param>
  53. /// <param name="signField">要签名的字段</param>
  54. /// <returns></returns>
  55. private string CheckSign(string value, string[] signField)
  56. {
  57. JsonData json = JsonMapper.ToObject(value);
  58. Dictionary<string, string> dic = new Dictionary<string, string>();
  59. for (int i = 0; i < signField.Length; i++)
  60. {
  61. dic.Add(signField[i], json[signField[i]].ToString());
  62. }
  63. string sign = json["sign"].ToString(); //客户端签名字符串
  64. return new Sign().sign(dic, sign);
  65. }
  66. #endregion
  67. }
  68. }