123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Microsoft.AspNetCore.Authorization;
- using MySystem.MainModels;
- using LitJson;
- using Library;
- namespace MySystem.Areas.Api.Controllers.v1
- {
- [Area("Api")]
- [Route("Api/v1/[controller]/[action]")]
- public class OpenBankTableController : BaseController
- {
- public OpenBankTableController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 创客-首页-开户行查询
- [Authorize]
- public JsonResult List(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = ListDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
- }
- public List<Dictionary<string, object>> ListDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string SearchKey = data["SearchKey"].ToString(); //搜索关键词
- int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
- int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- IQueryable<OpenBankTable> query = maindb.OpenBankTable;
- if(value.Contains("\"Areas\""))
- {
- if(!string.IsNullOrEmpty(data["Areas"].ToString()))
- {
- string Areas = data["Areas"].ToString();
- if(Areas.Contains(","))
- {
- string[] AreasList = Areas.Split(',');
- if(AreasList.Length == 3)
- {
- string p = AreasList[0];
- string c = AreasList[1];
- string a = AreasList[2];
- query = query.Where(m => (m.BankName.Contains(p) || m.BankName.Contains(c) || m.BankName.Contains(a)));
- }
- else if(AreasList.Length == 2)
- {
- string p = AreasList[0];
- string c = AreasList[1];
- query = query.Where(m => (m.BankName.Contains(p) || m.BankName.Contains(c)));
- }
- else
- {
- query = query.Where(m => m.BankName.Contains(Areas));
- }
- }
- else
- {
- query = query.Where(m => m.BankName.Contains(Areas));
- }
- }
- }
- if(value.Contains("\"BankName\""))
- {
- if(!string.IsNullOrEmpty(data["BankName"].ToString()))
- {
- string BankName = data["BankName"].ToString();
- query = query.Where(m => m.BankName.Contains(BankName));
- }
- }
- if(!string.IsNullOrEmpty(SearchKey))
- {
- query = query.Where(m => m.BankName.Contains(SearchKey));
- }
- query = query.Take(PageSize);
- foreach (var subdata in query.ToList())
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- curData.Add("BankName", subdata.BankName); //开户行名称
- curData.Add("BankCode", subdata.BankCode); //联行号
- dataList.Add(curData);
- }
- return dataList;
- }
- #endregion
- #region 检查签名是否合法,合法返回1,不合法返回提示信息
- /// <summary>
- /// 检查签名是否合法,合法返回1,不合法返回提示信息
- /// </summary>
- /// <param name="value">请求的参数(json字符串)</param>
- /// <param name="signField">要签名的字段</param>
- /// <returns></returns>
- private string CheckSign(string value, string[] signField)
- {
- JsonData json = JsonMapper.ToObject(value);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- for (int i = 0; i < signField.Length; i++)
- {
- dic.Add(signField[i], json[signField[i]].ToString());
- }
- string sign = json["sign"].ToString(); //客户端签名字符串
- return new Sign().sign(dic, sign);
- }
- #endregion
- }
- }
|