Commit ef4aec86 authored by 吴春's avatar 吴春
parents ad9d812c adf45be8
......@@ -87,44 +87,52 @@ namespace Mall.CacheManager.User
/// <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)
if (TenantId != null)
{
LogHelper.Write(ex, "GetUserLoginInfo");
}
if (userInfo == null)
{
Int32.TryParse(TenantId.ToString(), out int NewTenantId);
if (NewTenantId > 0)
string cacheKey = UserModuleCacheKeyConfig.Mall_Login_Info + TenantId.ToString();
try
{
string token = "";
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId);
if (extModel != null)
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)
{
UserInfo obj = new UserInfo
string token = "";
var extModel = tenantRepository.GetEntity<RB_Tenant_Extend>(NewTenantId);
if (extModel != null)
{
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);
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);
}
}
}
}
else
{
userInfo = new UserInfo();
}
return userInfo;
}
......
......@@ -883,45 +883,22 @@ namespace Mall.Model.Extend.MarketingCenter
/// <summary>
/// 商品编号
/// </summary>
public int Id { get; set; }
public int id { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string Name { get; set; }
public string name { get; set; }
/// <summary>
/// 商品图片
/// </summary>
public string CoverImage { get; set; }
public string picUrl { get; set; }
/// <summary>
/// 售价
/// </summary>
public decimal SellingPrice { 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; }
public decimal price { get; set; }
}
/// <summary>
......@@ -935,12 +912,12 @@ namespace Mall.Model.Extend.MarketingCenter
public int id { get; set; }
/// <summary>
/// 分类名称
/// 商品分类
/// </summary>
public string name { get; set; }
/// <summary>
/// 分类名称
/// 菜单名称
/// </summary>
public string menuName { get; set; }
......@@ -950,36 +927,16 @@ namespace Mall.Model.Extend.MarketingCenter
public int goodsNum { get; set; }
/// <summary>
/// 商品列表
/// </summary>
public List<GoodsDetailsItem> goodsList { get; set; }
}
/// <summary>
/// 商品详情项
/// </summary>
public class GoodsDetailsItem
{
/// <summary>
/// 商品编号
/// </summary>
public int id { get; set; }
/// <summary>
/// 商品名称
/// 是否显示自定义商品
/// </summary>
public string Name { get; set; }
public bool staticGoods { get; set; }
/// <summary>
/// 商品图片
/// </summary>
public string picUrl { get; set; }
/// <summary>
/// 售价
/// 商品列表
/// </summary>
public decimal SellingPrice { get; set; }
public List<GoodsDetailsItem2> goodsList { get; set; }
}
/// <summary>
/// 门店插件
......
......@@ -11,6 +11,7 @@ using Mall.Model.Extend.MarketingCenter;
using Mall.Module.BaseSetUp;
using Mall.Module.MarketingCenter;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
......@@ -56,6 +57,7 @@ namespace Mall.WebApi.Controllers.MallBase
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult GetHome()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
......@@ -114,8 +116,8 @@ namespace Mall.WebApi.Controllers.MallBase
homePage = new
{
id = selfHomePage.Id,
title = selfHomePage.PageName,
id = miniProgram.MallBaseId,
title = miniProgram.MallName,
show_navs = selfHomePage.IsShowNav,
is_home_page = selfHomePage.IsHome,
navs = list
......@@ -127,6 +129,153 @@ namespace Mall.WebApi.Controllers.MallBase
//配置了首页
if (miniProgram.HomeDataList != null && miniProgram.HomeDataList.Count > 0)
{
var templateData = new
{
id = 0,
name = "",
data = new List<object>()
};
foreach (var subitem in miniProgram.HomeDataList)
{
switch (subitem.key)
{
//搜索框
case "search":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.imgBg
});
break;
//轮播图
case "banner":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.row_num,
subitem.imgBg
});
break;
//导航图标
case "home_nav":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.row_num,
subitem.imgBg
});
break;
//视频
case "video":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.video_url,
subitem.video_pic_url,
subitem.imgBg
});
break;
//公告
case "notice":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.notice_url,
subitem.notice_bg_color,
subitem.notice_text_color,
subitem.imgBg
});
break;
//专题
case "topic":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.topic_num,
subitem.topic_url,
subitem.topic_url_2,
subitem.label_url,
subitem.imgBg
});
break;
//领券中心
case "coupon":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.coupon_url,
subitem.coupon_not_url,
subitem.imgBg
});
break;
//所有分类
case "cat":
break;
//图片魔方
case "block":
break;
//预约
case "booking":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.imgBg
});
break;
//拼团
case "pintuan":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.imgBg
});
break;
//预售
case "advance":
templateData.data.Add(new
{
subitem.key,
subitem.name,
subitem.relation_id,
subitem.is_edit,
subitem.imgBg
});
break;
}
}
homePage = new
{
id = 0,
......@@ -151,7 +300,10 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
}
return ApiResult.Success(data: homePage);
var objResult = new {
home_pages = homePage
};
return ApiResult.Success(data: objResult);
}
/// <summary>
......@@ -209,16 +361,25 @@ namespace Mall.WebApi.Controllers.MallBase
data = noticeData
};
break;
//空组件
case "empty":
var emptyData = subItem.data as emptyItem;
//专题组件
case "topic":
var topicData = subItem.data as topicItem;
obj = new
{
id = subItem.Id,
data = emptyData
data = topicData
};
break;
//标题组件
case "link":
var linkData = subItem.data as linkItem;
obj = new
{
id = subItem.Id,
data = linkData
};
break;
//图片广告插件
case "rubik":
var rubikData = subItem.data as rubikItem;
obj = new
......@@ -227,17 +388,253 @@ namespace Mall.WebApi.Controllers.MallBase
data = rubikData
};
break;
//视频插件
case "video":
var videoData = subItem.data as videoItem;
obj = new
{
id = subItem.Id,
data = videoData
};
break;
//商品插件
case "goods":
var goodsData = subItem.data as goodsItem;
if (goodsData != null)
{
if (goodsData.list != null && goodsData.list.Count > 0)
{
foreach (var childItem in goodsData.list)
{
childItem.picUrl = Common.Config.GetFileUrl(childItem.picUrl);
}
}
if (goodsData.catList != null && goodsData.catList.Count > 0)
{
foreach (var childItem in goodsData.catList)
{
if (childItem.goodsList != null && childItem.goodsList.Count > 0)
{
foreach (var lastItem in childItem.goodsList)
{
lastItem.picUrl = Common.Config.GetFileUrl(lastItem.picUrl);
}
}
}
}
}
obj = new
{
id = subItem.Id,
data = goodsData
};
break;
}
//门店插件
case "store":
var storeData = subItem.data as storeItem;
obj = new
{
id = subItem.Id,
data = storeData
};
break;
//版权插件
case "copyright":
var copyrightData = subItem.data as copyrightItem;
obj = new
{
id = subItem.Id,
data = copyrightData
};
break;
//签到插件
case "check-in":
var checkinData = subItem.data as checkinItem;
obj = new
{
id = subItem.Id,
data = checkinData
};
break;
//用户信息插件
case "user-info":
var userinfoData = subItem.data as userinfoItem;
obj = new
{
id = subItem.Id,
data = userinfoData
};
break;
//用户订单插件
case "user-order":
var userorderData = subItem.data as userorderItem;
obj = new
{
id = subItem.Id,
data = userorderData
};
break;
//地图插件
case "map":
var mapData = subItem.data as mapItem;
obj = new
{
id = subItem.Id,
data = mapData
};
break;
//微信公众号插件
case "mp-link":
var mplinkData = subItem.data as mplinkItem;
obj = new
{
id = subItem.Id,
data = mplinkData
};
break;
//图文插件
case "image-text":
var imagetextData = subItem.data as imagetextItem;
obj = new
{
id = subItem.Id,
data = imagetextData
};
break;
//优惠券插件
case "coupon":
var couponData = subItem.data as couponItem;
obj = new
{
id = subItem.Id,
data = couponData
};
break;
//倒计时插件
case "timer":
var timerData = subItem.data as timerItem;
obj = new
{
id = subItem.Id,
data = timerData
};
break;
//拼团插件
case "pintuan":
var pintuanData = subItem.data as pintuanItem;
obj = new
{
id = subItem.Id,
data = pintuanData
};
break;
//预约插件
case "booking":
var bookingData = subItem.data as bookingItem;
obj = new
{
id = subItem.Id,
data = bookingData
};
break;
//砍价插件
case "bargain":
var bargainData = subItem.data as bargainItem;
obj = new
{
id = subItem.Id,
data = bargainData
};
break;
//积分商城插件
case "integral-mall":
var integralmallData = subItem.data as integralmallItem;
obj = new
{
id = subItem.Id,
data = integralmallData
};
break;
//抽奖插件
case "lottery":
var lotteryData = subItem.data as lotteryItem;
obj = new
{
id = subItem.Id,
data = lotteryData
};
break;
//预售
case "advance":
var advanceData = subItem.data as advanceItem;
obj = new
{
id = subItem.Id,
data = advanceData
};
break;
//超级会员卡
case "vip-card":
var vipcardData = subItem.data as vipcardItem;
obj = new
{
id = subItem.Id,
data = vipcardData
};
break;
//直播组件
case "live":
var liveData = subItem.data as liveItem;
obj = new
{
id = subItem.Id,
data = liveData
};
break;
//空组件
case "empty":
var emptyData = subItem.data as emptyItem;
obj = new
{
id = subItem.Id,
data = emptyData
};
break;
//流量主广告
case "ad":
var adData = subItem.data as adItem;
obj = new
{
id = subItem.Id,
data = adData
};
break;
//弹窗广告
case "modal":
var modalData = subItem.data as modalItem;
obj = new
{
id = subItem.Id,
data = modalData
};
break;
//弹窗广告
case "quick-nav":
var quicknavData = subItem.data as quicknavItem;
obj = new
{
id = subItem.Id,
data = quicknavData
};
break;
}
return obj;
}
......@@ -289,7 +686,7 @@ namespace Mall.WebApi.Controllers.MallBase
member_pic_url = miniProgram.MemberBgImg,
//会员中心背景图
member_bg_pic_url = miniProgram.VipBgImg,
//头像内嵌背景图
//头像内嵌背景图[暂无]
style_bg_pic_url = "",
//账户相关菜单
......
......@@ -20,6 +20,7 @@ using Mall.Common.Plugin;
using Mall.Common.Enum.MallBase;
using Mall.Model.Entity.User;
using Mall.Module.Product;
using Microsoft.AspNetCore.Authorization;
namespace Mall.WebApi.Controllers.User
{
......@@ -76,6 +77,7 @@ namespace Mall.WebApi.Controllers.User
#region 商户信息
[AllowAnonymous]
/// <summary>
/// 用户登录
/// </summary>
......@@ -151,6 +153,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户注册第一步
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ApiResult SetTenantFirst()
{
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......@@ -170,6 +173,7 @@ namespace Mall.WebApi.Controllers.User
/// 用户注册第二步
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ApiResult SetTenantSecond()
{
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......@@ -193,6 +197,7 @@ namespace Mall.WebApi.Controllers.User
/// 修改密码账号
/// </summary>
/// <returns></returns>
[AllowAnonymous]
public ApiResult UpdateTenantPwd()
{
var extModel = JsonConvert.DeserializeObject<RB_Tenant_Extend>(RequestParm.msg.ToString());
......
......@@ -14,6 +14,7 @@ using Mall.Common.Enum.User;
using Mall.CacheManager.User;
using Newtonsoft.Json.Linq;
using Mall.Common;
using Microsoft.AspNetCore.Authorization;
namespace Mall.WebApi.Controllers.User
{
......
......@@ -17,6 +17,10 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
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
{
......@@ -39,22 +43,15 @@ namespace Mall.WebApi.Filter
#region api监控日志
parm = DoApiMonitorLog(actionContext, ref token);
#endregion
//不需要验证TOKEN的CMD
List<string> notValidatList = new List<string>()
{
"/api/Tenant/Login",//用户登录
"/api/Tenant/SetTenantFirst",//用户注册第一步
"/api/Tenant/SetTenantSecond",//用户注册第二步
"/api/Tenant/UpdateTenantPwd",//忘记密码
};
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校验
if (isCheckToken)
......
......@@ -5,6 +5,7 @@ using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.Threading.Tasks;
using Mall.ThirdCore.Message;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
......@@ -34,7 +35,8 @@ namespace Mall.WebApi
.Configure<IISServerOptions>(x => x.AllowSynchronousIO = true);
services.AddControllers();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); //注入http上下文
services.AddMvc().AddJsonOptions(options =>
{
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
......@@ -44,7 +46,9 @@ namespace Mall.WebApi
{
"http://localhost:8081",
"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())));
}
......@@ -65,6 +69,7 @@ namespace Mall.WebApi
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
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