Selaa lähdekoodia

调整创客-首页-开户行查询接口
调整创客-我的-登录接口的token返回

lcl 1 vuosi sitten
vanhempi
commit
9ac4930324

+ 7 - 2
Areas/Api/Controllers/v1/MainServer/OpenBankTableController.cs

@@ -39,8 +39,13 @@ namespace MySystem.Areas.Api.Controllers.v1
             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>>();
-            List<OpenBankTable> query = maindb.OpenBankTable.Where(m => m.BankName.Contains(SearchKey)).Take(PageSize).ToList();
-            foreach (var subdata in query)
+            IQueryable<OpenBankTable> query = maindb.OpenBankTable;
+            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); //开户行名称

+ 15 - 5
Areas/Api/Controllers/v1/MainServer/UsersController.cs

@@ -414,11 +414,17 @@ namespace MySystem.Areas.Api.Controllers.v1
                 maindb.SaveChanges();
             }
             Obj.Add("Id", user.Id);
-            Obj.Add("Token", AppToken(user.Id.ToString()));
+            Obj.Add("Token", AppToken(user.Id));
             return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
         }
-        public string AppToken(string u)
+        public string AppToken(int UserId)
         {
+            string Token = RedisDbconn.Instance.Get<string>("apptoken:" + UserId);
+            if(!string.IsNullOrEmpty(Token))
+            {
+                return Token;
+            }
+            string issuer = "new_" + UserId;
             string test = function.get_Random(10);
             var securityKey = new SigningCredentials(new SymmetricSecurityKey(Encoding.ASCII.GetBytes(JwtSecret)), SecurityAlgorithms.HmacSha256);
             var claims = new Claim[] {
@@ -433,10 +439,14 @@ namespace MySystem.Areas.Api.Controllers.v1
                 expires: DateTime.Now.AddDays(10),//过期时间
                 claims: claims,
                 audience: test,
-                issuer: u
+                issuer: issuer
             );
-            RedisDbconn.Instance.Set("utoken:" + u, test);
-            RedisDbconn.Instance.SetExpire("utoken:" + u, 3600 * 24 * 10);
+            RedisDbconn.Instance.Set("utoken:" + issuer, test);
+            RedisDbconn.Instance.SetExpire("utoken:" + issuer, 3600 * 24 * 10);
+            //生成jwt令牌
+            Token = new JwtSecurityTokenHandler().WriteToken(securityToken);
+            RedisDbconn.Instance.Set("apptoken:" + UserId, Token);
+            RedisDbconn.Instance.SetExpire("apptoken:" + UserId, 3600 * 24 * 10 - 60);
             //生成jwt令牌
             return new JwtSecurityTokenHandler().WriteToken(securityToken);
         }