Commit 8a4c72c4 authored by 黄奎's avatar 黄奎

页面修改

parent 995dabd5
...@@ -844,6 +844,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -844,6 +844,7 @@ namespace Mall.WebApi.Controllers.User
public ApiResult GetMenuList() public ApiResult GetMenuList()
{ {
List<object> resultList = new List<object>(); List<object> resultList = new List<object>();
var menuList = menuModule.GetMenuListModule(new RB_Menu_Extend() { });
var list = new List<RB_Menu_Extend>(); var list = new List<RB_Menu_Extend>();
if (RequestParm.EmpId > 0) if (RequestParm.EmpId > 0)
{ {
...@@ -851,11 +852,48 @@ namespace Mall.WebApi.Controllers.User ...@@ -851,11 +852,48 @@ namespace Mall.WebApi.Controllers.User
if (roleList != null && roleList.Count > 0) if (roleList != null && roleList.Count > 0)
{ {
list = menuModule.GetMenuListModule(new RB_Menu_Extend() { QMenuIds = roleList?.FirstOrDefault()?.RoleAuth }); list = menuModule.GetMenuListModule(new RB_Menu_Extend() { QMenuIds = roleList?.FirstOrDefault()?.RoleAuth });
var superList = new List<RB_Menu_Extend>();
foreach (var item in list)
{
if (item.MenuLevel == 3)
{
var secondMenuList = menuList.Where(qitem => qitem.MenuId == item.ParentId).ToList();
foreach (var secondItem in secondMenuList)
{
if (!(superList.Where(qitem => qitem.MenuId == secondItem.MenuId).Count() > 0))
{
superList.Add(secondItem);
}
var firstMenuList= menuList.Where(qitem => qitem.MenuId == secondItem.ParentId).ToList();
foreach (var firstItem in firstMenuList)
{
if (!(superList.Where(qitem => qitem.MenuId == firstItem.MenuId).Count() > 0))
{
superList.Add(firstItem);
}
}
}
}
if (item.MenuLevel == 2)
{
var firstMenuList = menuList.Where(qitem => qitem.MenuId == item.ParentId).ToList();
foreach (var firstItem in firstMenuList)
{
if (!(superList.Where(qitem => qitem.MenuId == firstItem.MenuId).Count() > 0))
{
superList.Add(firstItem);
}
}
}
}
list.AddRange(superList);
} }
} }
else else
{ {
list = menuModule.GetMenuListModule(new RB_Menu_Extend() { }); list = menuList;
} }
var rootList = list.Where(qitem => qitem.MenuLevel == 1).OrderBy(qitem => qitem.SortNum).ToList(); var rootList = list.Where(qitem => qitem.MenuLevel == 1).OrderBy(qitem => qitem.SortNum).ToList();
......
...@@ -23,9 +23,92 @@ namespace Test.Helper ...@@ -23,9 +23,92 @@ namespace Test.Helper
public static void GetData() public static void GetData()
{ {
string cookie = "__login_route=%2Fadmin%2Fpassport%2Flogin; __login_role=admin; HJ_SESSION_ID=4t7hlqga7scesoid63ln4gbv3n; _csrf=7e088e7a563fba6d8b51b65eebea11468c0c2ea43c8e99199be24320e3e86c94a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22D9rE0_dOz8RHzW5y695GOQPTWJZgT8Sk%22%3B%7D"; string cookie = "__login_route=%2Fadmin%2Fpassport%2Flogin; __login_role=admin; HJ_SESSION_ID=4t7hlqga7scesoid63ln4gbv3n; _csrf=7e088e7a563fba6d8b51b65eebea11468c0c2ea43c8e99199be24320e3e86c94a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22D9rE0_dOz8RHzW5y695GOQPTWJZgT8Sk%22%3B%7D";
GetTemplate(cookie); GetPage(cookie);
} }
public static void GetPage(string cookie)
{
var list = GetPageList(cookie);
if (list != null && list.Count > 0)
{
var index = 1;
foreach (var item in list)
{
Console.WriteLine(index + "/" + list.Count + item.title + "分类Start");
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" INSERT INTO RB_Miniprogram_Page_Templ(PageName,IsUse,IsShowNav,IsHome,TenantId,MallBaseId,CreateDate,CreateBy,Status)");
builder.AppendFormat(" VALUES('{0}',{1},{2},{3},1,1,'{4}',1,0);SELECT LAST_INSERT_ID()", item.title,item.is_disable,item.show_navs,item.is_home_page, DateTime.Now);
List<MySqlParameter> paramsList = new List<MySqlParameter>();
try
{
var res = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder.ToString(), paramsList.ToArray());
if (res != null && Convert.ToInt32(res) > 0)
{
string updateSql = string.Format("UPDATE RB_Miniprogram_Page_Templ SET Id={0} WHERE Id={1}", item.id, Convert.ToInt32(res));
var res1 = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, updateSql, null);
}
if (item.navs != null && item.navs.Count > 0)
{
foreach (var subItem in item.navs)
{
StringBuilder builder2 = new StringBuilder();
builder2.AppendFormat(" INSERT INTO rb_miniprogram_page_templ_details(PageTemplID,NavName,TemplateId,TemplateShowName)");
builder2.AppendFormat(" VALUES({0},'{1}',{2},'{3}');SELECT LAST_INSERT_ID()", item.id, subItem.template, subItem.template_id, string.Format("#{0}:{1}",subItem.template_id,subItem.template));
var res2 = DBHelper.MySqlHelper.ExecuteScalar(DBHelper.MySqlHelper.defaultConnection, System.Data.CommandType.Text, builder2.ToString(), null);
}
}
}
catch (Exception ex)
{
Console.WriteLine(index + "/" + ex.Message);
}
index++;
Console.WriteLine(index + "/" + list.Count + item.title + "分类End");
}
}
}
/// <summary>
/// 获取页面数据
/// </summary>
/// <param name="cookie"></param>
/// <returns></returns>
public static List<PageData> GetPageList(string cookie)
{
List<PageData> list = new List<PageData>();
string ApiUrl = "https://wx.weibaoge.cn/web/index.php?r=plugin%2Fdiy%2Fmall%2Fpage%2Findex&page={0}";
string url1 = string.Format(ApiUrl, "1");
string jsonData = HttpGet(url1, cookie);
if (jsonData != null && !string.IsNullOrEmpty(jsonData))
{
JObject obj = JObject.Parse(jsonData);
JObject dataObj = JObject.Parse(obj["data"].ToString());
list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PageData>>(dataObj["list"].ToString());
}
if (list == null)
{
list = new List<PageData>();
}
Thread.Sleep(1000 * 5);
string url2 = string.Format(ApiUrl, "2");
string jsonData2 = HttpGet(url2, cookie);
if (jsonData2 != null && !string.IsNullOrEmpty(jsonData2))
{
JObject obj = JObject.Parse(jsonData2);
JObject dataObj = JObject.Parse(obj["data"].ToString());
var list2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PageData>>(dataObj["list"].ToString());
if (list2 != null && list2.Count > 0)
{
list.AddRange(list2);
}
}
return list;
}
/// <summary> /// <summary>
/// 获取模板 /// 获取模板
/// </summary> /// </summary>
......
...@@ -6,6 +6,69 @@ using System.Threading.Tasks; ...@@ -6,6 +6,69 @@ using System.Threading.Tasks;
namespace Test.Model namespace Test.Model
{ {
/// <summary>
/// 页面实体类
/// </summary>
public class PageData
{
/// <summary>
/// 页面编号
/// </summary>
public int id { get; set; }
/// <summary>
/// 页面标题
/// </summary>
public string title { get; set;}
/// <summary>
/// 是否显示导航
/// </summary>
public int show_navs { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public int is_disable { get; set; }
/// <summary>
/// 是否首页
/// </summary>
public int is_home_page { get; set; }
/// <summary>
/// 导航模板
/// </summary>
public List<navsData> navs { get; set; }
}
/// <summary>
/// 导航数据
/// </summary>
public class navsData
{
/// <summary>
/// 导航编号
/// </summary>
// public int navs { get; set; }
/// <summary>
/// 导航编号
/// </summary>
public int navs_id { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string template { get; set; }
/// <summary>
/// 模板编号
/// </summary>
public int template_id { get; set; }
}
/// <summary> /// <summary>
/// 模板实体类 /// 模板实体类
/// </summary> /// </summary>
......
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