Commit d38534dc authored by 黄奎's avatar 黄奎

页面修改

parent 2ea3979c
using Mall.CacheManager.DataStatistic; using Mall.CacheKey;
using Mall.CacheManager.DataStatistic;
using Mall.Common; using Mall.Common;
using Mall.Common.Plugin;
using Mall.Common.Plugin.Redis; using Mall.Common.Plugin.Redis;
using Mall.Model.Extend.User;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
...@@ -71,5 +74,58 @@ namespace Mall.CacheManager.User ...@@ -71,5 +74,58 @@ namespace Mall.CacheManager.User
{ {
} }
} }
/// <summary>
/// 商户信息仓储层对象
/// </summary>
private static Mall.Repository.User.RB_TenantRepository tenantRepository = new Repository.User.RB_TenantRepository();
/// <summary>
/// 获取用户登录信息
/// </summary>
/// <param name="TenantId">商户Id</param>
/// <returns></returns>
public static UserInfo GetUserLoginInfo(object TenantId)
{
string cacheKey = UserModuleCacheKeyConfig.Mall_Login_Info + TenantId.ToString();
UserInfo userInfo = null;
try
{
userInfo = redis.StringGet<UserInfo>(cacheKey);
}
catch (Exception ex)
{
LogHelper.Write(ex, "GetUserLoginInfo");
}
if (userInfo == null)
{
Int32.TryParse(TenantId.ToString(), out int NewTenantId);
if (NewTenantId > 0)
{
string token = "";
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId);
if (extModel != null)
{
UserInfo obj = new UserInfo
{
TenantId = extModel.TenantId,
Account = extModel.Account,
Name = extModel.Name,
MobilePhone = extModel.MobilePhone,
WeChatNum = extModel.WeChatNum,
IsEffective = extModel.IsEffective,
AccountValidate = extModel.AccountValidate,
CreateMiniPrograme = extModel.CreateMiniPrograme,
MallName = extModel.MallName,
AccountStatus = extModel.AccountStatus,
Token = token,
SecretKey = "",
};
UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + TenantId, obj, Config.JwtExpirTime);
}
}
}
return userInfo;
}
} }
} }
...@@ -46,6 +46,7 @@ namespace Mall.Common.API ...@@ -46,6 +46,7 @@ namespace Mall.Common.API
/// 语言 0中文 1繁体 2日文(未处理) /// 语言 0中文 1繁体 2日文(未处理)
/// </summary> /// </summary>
public int languageId { get; set; } public int languageId { get; set; }
/// <summary> /// <summary>
/// 语种类型 /// 语种类型
/// </summary> /// </summary>
......
...@@ -106,6 +106,11 @@ namespace Mall.Common ...@@ -106,6 +106,11 @@ namespace Mall.Common
/// <summary> /// <summary>
/// token /// token
/// </summary> /// </summary>
public string Token { get; set; } public string Token { get; set; }
/// <summary>
/// SecretKey
/// </summary>
public string SecretKey { get; set; }
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Mall.CacheManager.User;
using Mall.Common; using Mall.Common;
using Mall.Common.API; using Mall.Common.API;
using Mall.Common.Plugin; using Mall.Common.Plugin;
...@@ -10,6 +11,7 @@ using Microsoft.AspNetCore.Cors; ...@@ -10,6 +11,7 @@ using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Web;
namespace Mall.WebApi.Controllers namespace Mall.WebApi.Controllers
{ {
...@@ -32,10 +34,9 @@ namespace Mall.WebApi.Controllers ...@@ -32,10 +34,9 @@ namespace Mall.WebApi.Controllers
#region 读取post参数 #region 读取post参数
var requestMsg = Request.HttpContext.Items[GlobalKey.UserPostInfo]; var requestMsg = Request.HttpContext.Items[GlobalKey.UserPostInfo];
var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString()); var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
var UObj = Request.HttpContext.Items[GlobalKey.TokenUserInfo]; if (Request.HttpContext.Items[GlobalKey.TokenUserInfo] != null)
if (UObj != null)
{ {
JObject parms = JObject.Parse(UObj.ToString()); JObject parms = JObject.Parse(Request.HttpContext.Items[GlobalKey.TokenUserInfo].ToString());
requestParm.uid = parms.GetStringValue("uid"); requestParm.uid = parms.GetStringValue("uid");
} }
#endregion #endregion
...@@ -43,5 +44,18 @@ namespace Mall.WebApi.Controllers ...@@ -43,5 +44,18 @@ namespace Mall.WebApi.Controllers
return requestParm; return requestParm;
} }
} }
/// <summary>
/// 商户缓存信息
/// </summary>
public UserInfo UserInfo
{
get
{
var parm = this.RequestParm;
UserInfo userInfo = UserReidsCache.GetUserLoginInfo(parm.uid);
return userInfo;
}
}
} }
} }
\ No newline at end of file
...@@ -80,10 +80,21 @@ namespace Mall.WebApi.Controllers.User ...@@ -80,10 +80,21 @@ namespace Mall.WebApi.Controllers.User
MallName = model.MallName, MallName = model.MallName,
AccountStatus = model.AccountStatus, AccountStatus = model.AccountStatus,
Token = token, Token = token,
SecretKey="",
}; };
UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + model.TenantId, obj, Config.JwtExpirTime); UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + model.TenantId, obj, Config.JwtExpirTime);
return ApiResult.Success("", obj); return ApiResult.Success("", obj);
} }
} }
/// <summary>
/// 获取商城详情
/// </summary>
/// <returns></returns>
public ApiResult GetTenant()
{
var model = TenantModule.GetTenantModule(base.UserInfo.TenantId);
return ApiResult.Success("", model);
}
} }
} }
\ No newline at end of file
...@@ -178,7 +178,7 @@ namespace Mall.WebApi.Filter ...@@ -178,7 +178,7 @@ namespace Mall.WebApi.Filter
string secret = Config.JwtSecretKey; string secret = Config.JwtSecretKey;
var json = decoder.Decode(token, secret, verify: true);//token为之前生成的字符串 var json = decoder.Decode(token, secret, verify: true);//token为之前生成的字符串
JObject jwtJson = JObject.Parse(json); JObject jwtJson = JObject.Parse(json);
actionContext.HttpContext.Items[GlobalKey.TokenUserInfo] = jwtJson["userInfo"]; actionContext.HttpContext.Items[GlobalKey.TokenUserInfo] = jwtJson["mall_userInfo"];
} }
catch (SignatureVerificationException sve) catch (SignatureVerificationException sve)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment