Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
7236ae3a
Commit
7236ae3a
authored
Sep 29, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
c90a12b5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
8 deletions
+158
-8
RB_Destination_Extend.cs
Mall.Model/Extend/BaseSetUp/RB_Destination_Extend.cs
+29
-0
DestinationModule.cs
Mall.Module.BaseSetUp/DestinationModule.cs
+93
-1
DestinationController.cs
Mall.WebApi/Controllers/MallBase/DestinationController.cs
+36
-7
No files found.
Mall.Model/Extend/BaseSetUp/RB_Destination_Extend.cs
View file @
7236ae3a
...
...
@@ -86,4 +86,33 @@ namespace Mall.Model.Extend.BaseSetUp
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
;
}
}
}
Mall.Module.BaseSetUp/DestinationModule.cs
View file @
7236ae3a
...
...
@@ -29,7 +29,70 @@ namespace Mall.Module.BaseSetUp
{
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>
...
...
@@ -51,6 +114,35 @@ namespace Mall.Module.BaseSetUp
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>
...
...
Mall.WebApi/Controllers/MallBase/DestinationController.cs
View file @
7236ae3a
...
...
@@ -33,18 +33,14 @@ namespace Mall.WebApi.Controllers.MallBase
/// </summary>
/// <param name="ParentID">父节点编号</param>
/// <returns></returns>
[
AllowAnonymous
]
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
[
AllowAnonymous
]
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
public
ApiResult
GetChildList
()
{
JObject
parm
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
int
ID
=
parm
.
GetInt
(
"Id"
);
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
});
return
ApiResult
.
Success
(
""
,
list
);
}
...
...
@@ -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
]
public
ApiResult
GetAllList
()
...
...
@@ -62,10 +80,20 @@ namespace Mall.WebApi.Controllers.MallBase
var
list
=
destinationModule
.
GetAllList
();
var
result
=
GetData
(
list
);
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
)
{
...
...
@@ -76,6 +104,7 @@ namespace Mall.WebApi.Controllers.MallBase
}
return
nodes
;
}
//递归获取子节点
public
static
List
<
RB_Destination_Extend
>
GetChildrens
(
List
<
RB_Destination_Extend
>
nodeList
,
RB_Destination_Extend
node
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment