Commit 7236ae3a authored by 黄奎's avatar 黄奎

页面修改

parent c90a12b5
...@@ -86,4 +86,33 @@ namespace Mall.Model.Extend.BaseSetUp ...@@ -86,4 +86,33 @@ namespace Mall.Model.Extend.BaseSetUp
public List<RB_Destination_Extend> Children { get; set; } public List<RB_Destination_Extend> Children { get; set; }
} }
/// <summary>
/// 地区树形结构
/// </summary>
public class DestinationViewModel
{
/// <summary>
/// 主键
/// </summary>
public int ID
{
get;
set;
}
/// <summary>
/// 名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 下级地区列表
/// </summary>
public List<DestinationViewModel> Children { get; set; }
}
} }
...@@ -29,7 +29,70 @@ namespace Mall.Module.BaseSetUp ...@@ -29,7 +29,70 @@ namespace Mall.Module.BaseSetUp
{ {
ParentID = ParentID ParentID = ParentID
}; };
return rb_DestinationRepository.GetListExt(where); var list= rb_DestinationRepository.GetListExt(where);
return list;
}
/// <summary>
/// 根据父节点编号获取子列表
/// </summary>
/// <param name="ParentID">父节点编号</param>
/// <returns></returns>
public List<DestinationViewModel> GetChildListModule_V2(int ParentID)
{
List<DestinationViewModel> list = new List<DestinationViewModel>();
var dataList = rb_DestinationRepository.GetAllDestinationList();
if (dataList != null && dataList.Count > 0)
{
var tempList= dataList.Where(qitem => qitem.ParentID == ParentID)?.ToList();
if (tempList != null && tempList.Count > 0)
{
foreach (var item in tempList)
{
var model = new DestinationViewModel()
{
ID=item.ID,
Name=item.Name,
Children=new List<DestinationViewModel> ()
};
GetChildDestinationListModule(model,item.ID, dataList);
list.Add(model);
}
}
}
return list;
}
/// <summary>
/// 遍历下级地区
/// </summary>
/// <param name="currentModel"></param>
/// <param name="sourceList"></param>
private void GetChildDestinationListModule(DestinationViewModel currentModel,int ParentId,List<RB_Destination_Extend> sourceList)
{
if (sourceList != null && sourceList.Count > 0)
{
if (currentModel != null)
{
var tempList = sourceList.Where(qitem => qitem.ParentID == ParentId)?.ToList();
if (tempList != null && tempList.Count > 0)
{
currentModel.Children = new List<DestinationViewModel>();
foreach (var item in tempList)
{
var cModel = new DestinationViewModel()
{
ID = item.ID,
Name = item.Name,
Children = new List<DestinationViewModel>()
};
GetChildDestinationListModule(cModel, item.ID, sourceList);
currentModel.Children.Add(cModel);
}
}
}
}
} }
/// <summary> /// <summary>
...@@ -51,6 +114,35 @@ namespace Mall.Module.BaseSetUp ...@@ -51,6 +114,35 @@ namespace Mall.Module.BaseSetUp
return rb_DestinationRepository.GetAllDestinationList(); return rb_DestinationRepository.GetAllDestinationList();
} }
/// <summary>
/// 获取中国下面的所有数据
/// </summary>
/// <returns></returns>
public List<DestinationViewModel> GetAllListModule_V2()
{
List<DestinationViewModel> list = new List<DestinationViewModel>();
var dataList= rb_DestinationRepository.GetAllDestinationList();
if (dataList != null && dataList.Count > 0)
{
var templist = dataList.Where(qitem => qitem.ParentID == 1)?.ToList();
if (templist != null && templist.Count > 0)
{
foreach (var item in templist)
{
var model = new DestinationViewModel()
{
ID = item.ID,
Name = item.Name,
Children = new List<DestinationViewModel>()
};
GetChildDestinationListModule(model, item.ID, dataList);
list.Add(model);
}
}
}
return list;
}
/// <summary> /// <summary>
/// 新增修改地区 /// 新增修改地区
/// </summary> /// </summary>
......
...@@ -33,18 +33,14 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -33,18 +33,14 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary> /// </summary>
/// <param name="ParentID">父节点编号</param> /// <param name="ParentID">父节点编号</param>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous] [RateValve(Policy = Policy.Ip, Limit = 10, Duration = 60)] [AllowAnonymous]
[RateValve(Policy = Policy.Ip, Limit = 10, Duration = 60)]
public ApiResult GetChildList() public ApiResult GetChildList()
{ {
JObject parm = JObject.Parse(RequestParm.msg.ToString()); JObject parm = JObject.Parse(RequestParm.msg.ToString());
int ID = parm.GetInt("Id"); int ID = parm.GetInt("Id");
if (ID > 0) if (ID > 0)
{ {
//var CommonList = Mall.Common.Data.AreaDataHelper.GetAreaList();
//if (CommonList != null && CommonList.Count > 0)
//{
// return ApiResult.Success("", CommonList.Where(qitem => qitem.P == ID).Select(qitem => new { ID = qitem.I, Name = qitem.N }));
//}
var list = destinationModule.GetChildList(ID).Select(item => new { item.ID, item.Name }); var list = destinationModule.GetChildList(ID).Select(item => new { item.ID, item.Name });
return ApiResult.Success("", list); return ApiResult.Success("", list);
} }
...@@ -54,6 +50,28 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -54,6 +50,28 @@ namespace Mall.WebApi.Controllers.MallBase
} }
} }
/// <summary>
/// 根据父节点编号获取子列表
/// </summary>
/// <param name="ParentID">父节点编号</param>
/// <returns></returns>
[AllowAnonymous]
[RateValve(Policy = Policy.Ip, Limit = 10, Duration = 60)]
public ApiResult GetChildList_V2()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int ID = parm.GetInt("Id");
if (ID > 0)
{
var list = destinationModule.GetChildListModule_V2(ID);
return ApiResult.Success("", list);
}
else
{
return ApiResult.Failed("未找到相关数据!");
}
}
[HttpPost] [HttpPost]
public ApiResult GetAllList() public ApiResult GetAllList()
...@@ -62,10 +80,20 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -62,10 +80,20 @@ namespace Mall.WebApi.Controllers.MallBase
var list = destinationModule.GetAllList(); var list = destinationModule.GetAllList();
var result = GetData(list); var result = GetData(list);
return ApiResult.Success("", result); return ApiResult.Success("", result);
} }
/// <summary>
/// 获取所有地区信息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAllList_V2()
{
var list = destinationModule.GetAllListModule_V2();
return ApiResult.Success("", list);
}
public static List<RB_Destination_Extend> GetData(List<RB_Destination_Extend> nodeList) public static List<RB_Destination_Extend> GetData(List<RB_Destination_Extend> nodeList)
{ {
...@@ -76,6 +104,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -76,6 +104,7 @@ namespace Mall.WebApi.Controllers.MallBase
} }
return nodes; return nodes;
} }
//递归获取子节点 //递归获取子节点
public static List<RB_Destination_Extend> GetChildrens(List<RB_Destination_Extend> nodeList, RB_Destination_Extend node) public static List<RB_Destination_Extend> GetChildrens(List<RB_Destination_Extend> nodeList, RB_Destination_Extend node)
{ {
......
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