Commit aea910ad authored by 黄奎's avatar 黄奎

新增页面

parent a704dfc6
......@@ -43,7 +43,7 @@ namespace Mall.Model.Entity.User
/// <summary>
/// 自定义页面名称
/// </summary>
public string SelePageName
public string SelfPageName
{
get;
set;
......
......@@ -42,5 +42,15 @@ namespace Mall.Model.Extend.User
return str;
}
}
/// <summary>
/// 自定义页面标题
/// </summary>
public string SelfPageName { get; set; }
/// <summary>
/// 小程序页面表Id
/// </summary>
public int Id { get; set; }
}
}
......@@ -60,7 +60,7 @@ namespace Mall.Module.User
{ nameof(RB_MiniProgram_Page_Extend.Id),extModel.Id},
{ nameof(RB_MiniProgram_Page_Extend.MallBaseId),extModel.MallBaseId},
{ nameof(RB_MiniProgram_Page_Extend.PageId),extModel.PageId},
{ nameof(RB_MiniProgram_Page_Extend.SelePageName),extModel.SelePageName},
};
flag = miniProgram_PageRepository.Update(fileds, new WhereHelper(nameof(RB_MiniProgram_Page_Extend.Id), extModel.Id));
}
......@@ -73,6 +73,80 @@ namespace Mall.Module.User
return flag;
}
/// <summary>
/// 判断小程序是否存在页面
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public int CheckMiniProgram_Page(RB_MiniProgram_Page_Extend query)
{
List<WhereHelper> list = new List<WhereHelper>()
{
new WhereHelper (nameof(RB_MiniProgram_Page_Extend.PageId),query.PageId),
new WhereHelper (nameof(RB_MiniProgram_Page_Extend.MallBaseId),query.MallBaseId),
};
return miniProgram_PageRepository.Exists("Id", list);
}
/// <summary>
/// 批量添加页面到小程序
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool SetMiniProgram_Page_ByListModule(List<RB_MiniProgram_Page_Extend> list)
{
bool flag = false;
foreach (var item in list)
{
var Id = CheckMiniProgram_Page(item);
item.Id = Id;
if (item.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_MiniProgram_Page_Extend.Id),item.Id},
{ nameof(RB_MiniProgram_Page_Extend.MallBaseId),item.MallBaseId},
{ nameof(RB_MiniProgram_Page_Extend.PageId),item.PageId},
};
flag = miniProgram_PageRepository.Update(fileds, new WhereHelper(nameof(RB_MiniProgram_Page_Extend.Id), item.Id));
}
else
{
int NewId = miniProgram_PageRepository.Insert(item);
item.Id = NewId;
flag = NewId > 0;
}
}
return flag;
}
/// <summary>
/// 批量设置小程序页面标题
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool SetMiniProgram_PageTitle_ByListModule(List<RB_MiniProgram_Page_Extend> list)
{
bool flag = false;
foreach (var item in list)
{
if (item.SelfPageName == null)
{
item.SelfPageName = "";
}
if (item.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_MiniProgram_Page_Extend.SelfPageName),item.SelfPageName},
};
flag = miniProgram_PageRepository.Update(fileds, new WhereHelper(nameof(RB_MiniProgram_Page_Extend.Id), item.Id));
}
}
return flag;
}
/// <summary>
/// 根据小程序页面编号获取小程序页面实体(单个)
......@@ -89,6 +163,26 @@ namespace Mall.Module.User
return extModel;
}
/// <summary>
/// 根据Id批量删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public bool RemoveBeatchMiniprogram_Page_Module(string Ids)
{
return miniProgram_PageRepository.RemoveBeatchMiniprogram_Page_Repository(Ids);
}
/// <summary>
/// 根据条件获取小程序页面列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Miniprogram_PageManage_Extend> GetMiniprogram_Page_ListExtModule(RB_MiniProgram_Page_Extend query)
{
return miniprogram_PageManageRepository.GetListExtRepository(query);
}
/// <summary>
/// 根据查询条件获取小程序页面管理列表【管理页面】
/// </summary>
......
......@@ -52,5 +52,17 @@ namespace Mall.Repository.User
}
return GetPage<RB_MiniProgram_Page_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 根据Id批量删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public bool RemoveBeatchMiniprogram_Page_Repository(string Ids)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" DELETE FROM RB_MiniProgram_Page WHERE Id IN ({0}) ", Ids);
return base.Execute(builder.ToString()) > 0;
}
}
}
......@@ -70,5 +70,27 @@ namespace Mall.Repository.User
builder.Append(" ORDER BY PageSort ");
return GetPage<RB_Miniprogram_PageManage_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 根据条件获取小程序页面列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Miniprogram_PageManage_Extend> GetListExtRepository(RB_MiniProgram_Page_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT B.PageId, B.PageName,B.PageType,B.PageUrl,B.PageSort,B.IsParameter,B.ParameterValue,IFNULL(A.SelfPageName,'') AS SelfPageName,A.Id
FROM rb_miniprogram_page AS A INNER JOIN rb_miniprogram_pagemanage AS B ON A.PageId = B.PageId
WHERE B.`Status`= 0 ");
if (query != null)
{
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_MiniProgram_Page_Extend.MallBaseId), query.MallBaseId);
}
}
return Get<RB_Miniprogram_PageManage_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -185,7 +185,7 @@ namespace Mall.WebApi.Controllers.User
Int32.TryParse(RequestParm.uid.ToString(), out int TenantId);
var programNum = programModule.CheckMallNumModule(TenantId);
var createMiniPrograme = TenantModule.GetTenantModule(TenantId)?.CreateMiniPrograme ?? 0;
if (extModel.MallBaseId==0 && programNum >= createMiniPrograme)
if (extModel.MallBaseId == 0 && programNum >= createMiniPrograme)
{
return ApiResult.Failed(message: "只能创建" + createMiniPrograme + "个小程序");
}
......@@ -219,8 +219,8 @@ namespace Mall.WebApi.Controllers.User
int MallShopStyle = parms.GetInt("MallShopStyle");
var extModel = new RB_MiniProgram_Extend()
{
MallBaseId=MallBaseId,
MallShopStyle=(MallShopStyleEnum)MallShopStyle
MallBaseId = MallBaseId,
MallShopStyle = (MallShopStyleEnum)MallShopStyle
};
var flag = programModule.SetMiniProgramMallShopStyleModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
......@@ -377,7 +377,7 @@ namespace Mall.WebApi.Controllers.User
#endregion
#region 小程序图标
/// <summary>
/// 获取小程序分页列表
/// </summary>
......@@ -492,6 +492,104 @@ namespace Mall.WebApi.Controllers.User
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 获取小程序菜单管理
/// </summary>
/// <returns></returns>
public ApiResult GetMiniProgramePageManageList()
{
List<object> resultList = new List<object>();
var list = programPageModule.GetMiniprogram_PageManage_ListModule(new RB_Miniprogram_PageManage_Extend() { Status = 0 });
var mimiPageList = programPageModule.GetMiniProgramPage_ListModule(new RB_MiniProgram_Page_Extend() { MallBaseId = UserInfo.MallBaseId });
var pageTypeList = Common.Plugin.EnumHelper.EnumToList(typeof(PageTypeEnum));
foreach (var item in pageTypeList)
{
List<object> SubMenuList = new List<object>();
var subList = list.Where(qitem => qitem.PageType == (PageTypeEnum)item.Id).OrderBy(qitem => qitem.PageSort).ToList();
foreach (var subItem in subList)
{
var pageItem = mimiPageList?.Where(qitem => qitem.PageId == subItem.PageId)?.FirstOrDefault();
SubMenuList.Add(new
{
subItem.PageId,
subItem.PageName,
Id = pageItem?.Id ?? 0,
IsChecked = (pageItem?.Id ?? 0) > 0,
});
}
resultList.Add(new
{
IsChecked = false,
PageTypeName = item.Name,
PageTypeId = item.Id,
SubMenuList
});
}
return ApiResult.Success(data: resultList);
}
/// <summary>
/// 批量添加页面到小程序
/// </summary>
/// <returns></returns>
public ApiResult SetMiniProgram_Page()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var pageList = JsonConvert.DeserializeObject<List<RB_MiniProgram_Page_Extend>>(parms.GetStringValue("setMsg"));
var deleteList = JsonConvert.DeserializeObject<List<RB_MiniProgram_Page_Extend>>(parms.GetStringValue("delMsg"));
if (deleteList != null && deleteList.Count > 0)
{
var isDeleteFlag = programPageModule.RemoveBeatchMiniprogram_Page_Module(string.Join(",", deleteList.Select(qitem => qitem.Id)));
}
var flag = programPageModule.SetMiniProgram_Page_ByListModule(pageList);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取根据小程序编号获取小程序页面列表
/// </summary>
/// <returns></returns>
public ApiResult GetMiniprogramPageListExt()
{
List<object> resultList = new List<object>();
var pageList = programPageModule.GetMiniprogram_Page_ListExtModule(new RB_MiniProgram_Page_Extend() { MallBaseId = RequestParm.MallBaseId });
var pageTypeList = Common.Plugin.EnumHelper.EnumToList(typeof(PageTypeEnum));
foreach (var item in pageTypeList)
{
resultList.Add(new
{
PageTypeName = item.Name,
PageTypeId = item.Id,
SubMenuList = pageList.Where(qitem => qitem.PageType == (PageTypeEnum)item.Id).OrderBy(qitem => qitem.PageSort)
.Select(qitem => new
{
qitem.PageId,
qitem.PageName,
qitem.PageUrl,
qitem.IsParameter,
qitem.ParameterValue,
qitem.Id,
qitem.SelfPageName
})
.ToList()
});
}
return ApiResult.Success(data: resultList);
}
/// <summary>
/// 保存小程序页面自定义标题
/// </summary>
/// <returns></returns>
public ApiResult SetMiniprogramPageTitle()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
var pageList = JsonConvert.DeserializeObject<List<RB_MiniProgram_Page_Extend>>(parms.GetStringValue("setMsg"));
var flag = programPageModule.SetMiniProgram_PageTitle_ByListModule(pageList);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
......
......@@ -96,7 +96,7 @@ namespace Mall.WebApi.Filter
string controllerName = actionContext.ActionDescriptor.RouteValues["controller"].ToString().ToLower();
string actionName = actionContext.ActionDescriptor.RouteValues["action"].ToString().ToLower();
//string areaName = actionContext.ActionDescriptor.RouteValues["area"].ToString().ToLower();
if (!actionName.Contains("get"))
if (!actionName.ToLower().Contains("get"))
{
string cachedKey = SecurityHelper.MD5(string.Format("cmd={0}&token={1}", controllerName + "/" + actionName, token));
try
......
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