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 LitJson; using Library; using MySystem.Models.Main; using MySystem.Service.Main; namespace MySystem.Areas.Api.Controllers.v1 { [Area("Api")] [Route("Api/v1/[controller]/[action]")] public class OpenBankTableController : BaseController { public OpenBankTableController(IHttpContextAccessor accessor) : base(accessor) { } #region 创客-首页-开户行查询 // [Authorize] public JsonResult List(string value) { value = DesDecrypt(value); value = value.Replace("null", "\"\""); JsonData data = JsonMapper.ToObject(value); List> dataList = ListDo(value); return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList }); } public List> ListDo(string value) { JsonData data = JsonMapper.ToObject(value); string SearchKey = data.getItem("SearchKey").ToString(); //搜索关键词 int PageSize = int.Parse(function.CheckInt(data.getItem("PageSize").ToString())); int PageNum = int.Parse(function.CheckInt(data.getItem("PageNum").ToString())); string condition = ""; //查询条件 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]; condition += " and (BankChild like '%" + p + "%' or BankChild like '%" + c + "%' or BankChild like '%" + a + "%')"; } else if (AreasList.Length == 2) { string p = AreasList[0]; string c = AreasList[1]; condition += " and (BankChild like '%" + p + "%' or BankChild like '%" + c + "%')"; } else { condition += " and BankChild like '%" + Areas + "%'"; } } else { condition += " and BankChild like '%" + Areas + "%'"; } } } // if (value.Contains("\"BankName\"")) // { // if (!string.IsNullOrEmpty(data["BankName"].ToString())) // { // string BankName = data["BankName"].ToString(); // condition += " and BankChild like '%" + BankName + "%'"; // } // } if (!string.IsNullOrEmpty(SearchKey)) { condition += " and BankChild like '%" + SearchKey + "%'"; } List relationData = new List(); List> list = OpenBankAllService.List(relationData, condition, PageNum, PageSize); foreach (Dictionary dic in list) { dic["BankName"] = dic["BankChild"].ToString(); //开户行名称 dic["BankCode"] = dic["BankChildNo"].ToString(); //联行号 } // List> dataList = new List>(); // IQueryable 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.BankChild.Contains(p) || m.BankChild.Contains(c) || m.BankChild.Contains(a))); // } // else if (AreasList.Length == 2) // { // string p = AreasList[0]; // string c = AreasList[1]; // query = query.Where(m => (m.BankChild.Contains(p) || m.BankChild.Contains(c))); // } // else // { // query = query.Where(m => m.BankChild.Contains(Areas)); // } // } // else // { // query = query.Where(m => m.BankChild.Contains(Areas)); // } // } // } // if (value.Contains("\"BankName\"")) // { // if (!string.IsNullOrEmpty(data["BankName"].ToString())) // { // string BankName = data["BankName"].ToString(); // query = query.Where(m => m.BankChild.Contains(BankName)); // } // } // if (!string.IsNullOrEmpty(SearchKey)) // { // query = query.Where(m => m.BankChild.Contains(SearchKey)); // } // query = query.Take(PageSize); // foreach (var subdata in query.ToList()) // { // Dictionary curData = new Dictionary(); // curData.Add("BankName", subdata.BankChild); //开户行名称 // curData.Add("BankCode", subdata.BankChildNo); //联行号 // dataList.Add(curData); // } return list; } #endregion #region 检查签名是否合法,合法返回1,不合法返回提示信息 /// /// 检查签名是否合法,合法返回1,不合法返回提示信息 /// /// 请求的参数(json字符串) /// 要签名的字段 /// private string CheckSign(string value, string[] signField) { JsonData json = JsonMapper.ToObject(value); Dictionary dic = new Dictionary(); 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 } }