Commit ef4aec86 authored by 吴春's avatar 吴春
parents ad9d812c adf45be8
...@@ -87,44 +87,52 @@ namespace Mall.CacheManager.User ...@@ -87,44 +87,52 @@ namespace Mall.CacheManager.User
/// <returns></returns> /// <returns></returns>
public static UserInfo GetUserLoginInfo(object TenantId) public static UserInfo GetUserLoginInfo(object TenantId)
{ {
string cacheKey = UserModuleCacheKeyConfig.Mall_Login_Info + TenantId.ToString();
UserInfo userInfo = null; UserInfo userInfo = null;
try if (TenantId != null)
{
userInfo = redis.StringGet<UserInfo>(cacheKey);
}
catch (Exception ex)
{ {
LogHelper.Write(ex, "GetUserLoginInfo"); string cacheKey = UserModuleCacheKeyConfig.Mall_Login_Info + TenantId.ToString();
} try
if (userInfo == null)
{
Int32.TryParse(TenantId.ToString(), out int NewTenantId);
if (NewTenantId > 0)
{ {
string token = ""; userInfo = redis.StringGet<UserInfo>(cacheKey);
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId); }
if (extModel != null) catch (Exception ex)
{
LogHelper.Write(ex, "GetUserLoginInfo");
}
if (userInfo == null)
{
Int32.TryParse(TenantId.ToString(), out int NewTenantId);
if (NewTenantId > 0)
{ {
UserInfo obj = new UserInfo string token = "";
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId);
if (extModel != null)
{ {
TenantId = extModel.TenantId, UserInfo obj = new UserInfo
Account = extModel.Account, {
Name = extModel.Name, TenantId = extModel.TenantId,
MobilePhone = extModel.MobilePhone, Account = extModel.Account,
WeChatNum = extModel.WeChatNum, Name = extModel.Name,
IsEffective = extModel.IsEffective, MobilePhone = extModel.MobilePhone,
AccountValidate = extModel.AccountValidate, WeChatNum = extModel.WeChatNum,
CreateMiniPrograme = extModel.CreateMiniPrograme, IsEffective = extModel.IsEffective,
//MallName = extModel.MallName, AccountValidate = extModel.AccountValidate,
AccountStatus = extModel.AccountStatus, CreateMiniPrograme = extModel.CreateMiniPrograme,
Token = token, //MallName = extModel.MallName,
SecretKey = "", AccountStatus = extModel.AccountStatus,
}; Token = token,
UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + TenantId, obj, Config.JwtExpirTime); SecretKey = "",
};
UserInfoSet(UserModuleCacheKeyConfig.Mall_Login_Info + TenantId, obj, Config.JwtExpirTime);
}
} }
} }
} }
else
{
userInfo = new UserInfo();
}
return userInfo; return userInfo;
} }
......
...@@ -883,45 +883,22 @@ namespace Mall.Model.Extend.MarketingCenter ...@@ -883,45 +883,22 @@ namespace Mall.Model.Extend.MarketingCenter
/// <summary> /// <summary>
/// 商品编号 /// 商品编号
/// </summary> /// </summary>
public int Id { get; set; } public int id { get; set; }
/// <summary> /// <summary>
/// 商品名称 /// 商品名称
/// </summary> /// </summary>
public string Name { get; set; } public string name { get; set; }
/// <summary> /// <summary>
/// 商品图片 /// 商品图片
/// </summary> /// </summary>
public string CoverImage { get; set; } public string picUrl { get; set; }
/// <summary> /// <summary>
/// 售价 /// 售价
/// </summary> /// </summary>
public decimal SellingPrice { get; set; } public decimal price { get; set; }
public int SalesNum { get; set; }
/// <summary>
/// 商品分类列表
/// </summary>
public List<CategoryItem> CategoryList { get; set; }
}
/// <summary>
/// 商品分类
/// </summary>
public class CategoryItem
{
/// <summary>
/// 商品分类编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 商品分类名称
/// </summary>
public string CategoryName { get; set; }
} }
/// <summary> /// <summary>
...@@ -935,12 +912,12 @@ namespace Mall.Model.Extend.MarketingCenter ...@@ -935,12 +912,12 @@ namespace Mall.Model.Extend.MarketingCenter
public int id { get; set; } public int id { get; set; }
/// <summary> /// <summary>
/// 分类名称 /// 商品分类
/// </summary> /// </summary>
public string name { get; set; } public string name { get; set; }
/// <summary> /// <summary>
/// 分类名称 /// 菜单名称
/// </summary> /// </summary>
public string menuName { get; set; } public string menuName { get; set; }
...@@ -950,36 +927,16 @@ namespace Mall.Model.Extend.MarketingCenter ...@@ -950,36 +927,16 @@ namespace Mall.Model.Extend.MarketingCenter
public int goodsNum { get; set; } public int goodsNum { get; set; }
/// <summary> /// <summary>
/// 商品列表 /// 是否显示自定义商品
/// </summary>
public List<GoodsDetailsItem> goodsList { get; set; }
}
/// <summary>
/// 商品详情项
/// </summary>
public class GoodsDetailsItem
{
/// <summary>
/// 商品编号
/// </summary>
public int id { get; set; }
/// <summary>
/// 商品名称
/// </summary> /// </summary>
public string Name { get; set; } public bool staticGoods { get; set; }
/// <summary> /// <summary>
/// 商品图片 /// 商品列表
/// </summary>
public string picUrl { get; set; }
/// <summary>
/// 售价
/// </summary> /// </summary>
public decimal SellingPrice { get; set; } public List<GoodsDetailsItem2> goodsList { get; set; }
} }
/// <summary> /// <summary>
/// 门店插件 /// 门店插件
......
...@@ -20,6 +20,7 @@ using Mall.Common.Plugin; ...@@ -20,6 +20,7 @@ using Mall.Common.Plugin;
using Mall.Common.Enum.MallBase; using Mall.Common.Enum.MallBase;
using Mall.Model.Entity.User; using Mall.Model.Entity.User;
using Mall.Module.Product; using Mall.Module.Product;
using Microsoft.AspNetCore.Authorization;
namespace Mall.WebApi.Controllers.User namespace Mall.WebApi.Controllers.User
{ {
...@@ -76,6 +77,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -76,6 +77,7 @@ namespace Mall.WebApi.Controllers.User
#region 商户信息 #region 商户信息
[AllowAnonymous]
/// <summary> /// <summary>
/// 用户登录 /// 用户登录
/// </summary> /// </summary>
...@@ -151,6 +153,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -151,6 +153,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户注册第一步 /// 用户注册第一步
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous]
public ApiResult SetTenantFirst() public ApiResult SetTenantFirst()
{ {
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString()); var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
...@@ -170,6 +173,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -170,6 +173,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户注册第二步 /// 用户注册第二步
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous]
public ApiResult SetTenantSecond() public ApiResult SetTenantSecond()
{ {
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString()); var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
...@@ -193,6 +197,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -193,6 +197,7 @@ namespace Mall.WebApi.Controllers.User
/// 修改密码账号 /// 修改密码账号
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous]
public ApiResult UpdateTenantPwd() public ApiResult UpdateTenantPwd()
{ {
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString()); var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......
...@@ -14,6 +14,7 @@ using Mall.Common.Enum.User; ...@@ -14,6 +14,7 @@ using Mall.Common.Enum.User;
using Mall.CacheManager.User; using Mall.CacheManager.User;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Mall.Common; using Mall.Common;
using Microsoft.AspNetCore.Authorization;
namespace Mall.WebApi.Controllers.User namespace Mall.WebApi.Controllers.User
{ {
......
...@@ -17,6 +17,10 @@ using Microsoft.AspNetCore.Http; ...@@ -17,6 +17,10 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json; using Microsoft.Extensions.Configuration.Json;
using Mall.CacheManager.User; using Mall.CacheManager.User;
using System.Linq;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.Features;
namespace Mall.WebApi.Filter namespace Mall.WebApi.Filter
{ {
...@@ -39,22 +43,15 @@ namespace Mall.WebApi.Filter ...@@ -39,22 +43,15 @@ namespace Mall.WebApi.Filter
#region api监控日志 #region api监控日志
parm = DoApiMonitorLog(actionContext, ref token); parm = DoApiMonitorLog(actionContext, ref token);
#endregion #endregion
//不需要验证TOKEN的CMD
List<string> notValidatList = new List<string>()
{
"/api/Tenant/Login",//用户登录
"/api/Tenant/SetTenantFirst",//用户注册第一步
"/api/Tenant/SetTenantSecond",//用户注册第二步
"/api/Tenant/UpdateTenantPwd",//忘记密码
};
bool isCheckToken = true; bool isCheckToken = true;
foreach (var item in notValidatList) var endpoint = actionContext.HttpContext.Features.Get<IEndpointFeature>()?.Endpoint;
if (endpoint != null && endpoint.Metadata.GetMetadata<AllowAnonymousAttribute>() != null)
{ {
if (item== parm["cmd"].ToString()) isCheckToken = false;
{
isCheckToken = false;
}
} }
#region Token校验 #region Token校验
if (isCheckToken) if (isCheckToken)
......
...@@ -5,6 +5,7 @@ using System.Text.Encodings.Web; ...@@ -5,6 +5,7 @@ using System.Text.Encodings.Web;
using System.Text.Unicode; using System.Text.Unicode;
using System.Threading.Tasks; using System.Threading.Tasks;
using Mall.ThirdCore.Message; using Mall.ThirdCore.Message;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
...@@ -34,7 +35,8 @@ namespace Mall.WebApi ...@@ -34,7 +35,8 @@ namespace Mall.WebApi
.Configure<IISServerOptions>(x => x.AllowSynchronousIO = true); .Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
services.AddControllers(); services.AddControllers();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); //注入http上下文 services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); //注入http上下文
services.AddMvc().AddJsonOptions(options => services.AddMvc().AddJsonOptions(options =>
{ {
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
...@@ -44,7 +46,9 @@ namespace Mall.WebApi ...@@ -44,7 +46,9 @@ namespace Mall.WebApi
{ {
"http://localhost:8081", "http://localhost:8081",
"http://localhost:8080", "http://localhost:8080",
"http://localhost:8082" "http://localhost:8082",
"http://127.0.0.1:50512",
"http://127.0.0.1:20224"
}; };
services.AddCors(options => options.AddPolicy("AllowCors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins(corsArray.ToArray()))); services.AddCors(options => options.AddPolicy("AllowCors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins(corsArray.ToArray())));
} }
...@@ -65,6 +69,7 @@ namespace Mall.WebApi ...@@ -65,6 +69,7 @@ namespace Mall.WebApi
app.UseAuthorization(); app.UseAuthorization();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllers(); endpoints.MapControllers();
......
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