Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EduSpider
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
viitto
EduSpider
Commits
7b31c066
Commit
7b31c066
authored
May 25, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api修改
parent
7acb0792
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
8 deletions
+143
-8
ICourseRepository.cs
EduSpider.IRepository/ICourseRepository.cs
+19
-1
ICourseService.cs
EduSpider.IServices/ICourseService.cs
+18
-1
CourseRepository.cs
EduSpider.Repository/CourseRepository.cs
+64
-1
CourseService.cs
EduSpider.Services/CourseService.cs
+31
-0
CourseController.cs
EduSpider.WebApi/Controllers/CourseController.cs
+7
-2
EduSpider.WebApi.csproj
EduSpider.WebApi/EduSpider.WebApi.csproj
+1
-0
appsettings.json
EduSpider.WebApi/appsettings.json
+1
-1
CourseManager.cs
EduSpider/Spiders/ClassInRule/CourseManager.cs
+2
-2
No files found.
EduSpider.IRepository/ICourseRepository.cs
View file @
7b31c066
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
...
@@ -19,6 +20,23 @@ namespace EduSpider.Repository
...
@@ -19,6 +20,23 @@ namespace EduSpider.Repository
/// </summary>
/// </summary>
/// <param name="courses"></param>
/// <param name="courses"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
BatchSetCourse
(
List
<
RB_Course
>
courses
);
public
bool
BatchSetCourseRepository
(
List
<
RB_Course
>
courses
);
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePageRepository
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
);
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseListRepository
(
CourseQuery
query
);
}
}
}
}
EduSpider.IServices/ICourseService.cs
View file @
7b31c066
using
System
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
...
@@ -12,6 +14,21 @@ namespace EduSpider.IServices
...
@@ -12,6 +14,21 @@ namespace EduSpider.IServices
/// </summary>
/// </summary>
public
interface
ICourseService
:
IDependency
public
interface
ICourseService
:
IDependency
{
{
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePage
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
);
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseList
(
CourseQuery
query
);
}
}
}
}
EduSpider.Repository/CourseRepository.cs
View file @
7b31c066
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
EduSpider.Repository.Base
;
using
EduSpider.Repository.Base
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
VTX.FW.DB.Dapper
;
namespace
EduSpider.Repository
namespace
EduSpider.Repository
{
{
...
@@ -18,11 +20,72 @@ namespace EduSpider.Repository
...
@@ -18,11 +20,72 @@ namespace EduSpider.Repository
/// </summary>
/// </summary>
/// <param name="courses"></param>
/// <param name="courses"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
BatchSetCourse
(
List
<
RB_Course
>
courses
)
public
bool
BatchSetCourse
Repository
(
List
<
RB_Course
>
courses
)
{
{
bool
flag
;
bool
flag
;
flag
=
base
.
BatchInsert
(
courses
,
isReplace
:
true
);
flag
=
base
.
BatchInsert
(
courses
,
isReplace
:
true
);
return
flag
;
return
flag
;
}
}
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseListRepository
(
CourseQuery
query
)
{
var
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@"
SELECT A.*
FROM RB_Course AS A
WHERE 1=1
"
);
if
(
query
!=
null
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
query
.
courseName
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @courseName "
,
nameof
(
RB_Course
.
courseName
));
parameters
.
Add
(
"courseName"
,
"%"
+
query
.
courseName
.
Trim
()
+
"%"
);
}
if
(
query
.
courseId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Course
.
courseId
),
query
.
courseId
);
}
}
return
base
.
Get
<
RB_Course
>(
builder
.
ToString
(),
parameters
).
ToList
();
}
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePageRepository
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
)
{
var
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@"
SELECT A.*
FROM RB_Course AS A
WHERE 1=1
"
);
if
(
query
!=
null
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
query
.
courseName
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @courseName "
,
nameof
(
RB_Course
.
courseName
));
parameters
.
Add
(
"courseName"
,
"%"
+
query
.
courseName
.
Trim
()
+
"%"
);
}
if
(
query
.
courseId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Course
.
courseId
),
query
.
courseId
);
}
}
return
base
.
GetPage
<
RB_Course
>(
pageIndex
,
pageSize
,
out
rowsCount
,
builder
.
ToString
(),
parameters
).
ToList
();
}
}
}
}
}
EduSpider.Services/CourseService.cs
View file @
7b31c066
using
EduSpider.IServices
;
using
EduSpider.IServices
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
EduSpider.Repository
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
VTX.FW.Attr
;
namespace
EduSpider.Services
namespace
EduSpider.Services
{
{
...
@@ -13,6 +17,33 @@ namespace EduSpider.Services
...
@@ -13,6 +17,33 @@ namespace EduSpider.Services
/// </summary>
/// </summary>
public
class
CourseService
:
ICourseService
public
class
CourseService
:
ICourseService
{
{
/// <summary>
/// 课程仓储接口
/// </summary>
[
Autowired
]
public
ICourseRepository
CourseRepository
{
get
;
set
;
}
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseList
(
CourseQuery
query
)
{
return
CourseRepository
.
GetCourseListRepository
(
query
);
}
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePage
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
)
{
return
CourseRepository
.
GetCoursePageRepository
(
pageIndex
,
pageSize
,
out
rowsCount
,
query
);
}
}
}
}
}
EduSpider.WebApi/Controllers/CourseController.cs
View file @
7b31c066
...
@@ -13,6 +13,11 @@ namespace EduSpider.WebApi.Controllers
...
@@ -13,6 +13,11 @@ namespace EduSpider.WebApi.Controllers
public
class
CourseController
:
BaseController
public
class
CourseController
:
BaseController
{
{
/// <summary>
/// 课程仓储接口
/// </summary>
[
Autowired
]
public
ICourseService
CourseService
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 获取课程列表
/// 获取课程列表
...
@@ -23,8 +28,8 @@ namespace EduSpider.WebApi.Controllers
...
@@ -23,8 +28,8 @@ namespace EduSpider.WebApi.Controllers
public
ApiResult
GetCoursePage
()
public
ApiResult
GetCoursePage
()
{
{
var
list
=
CourseService
.
GetCoursePage
(
1
,
1000
,
out
_
,
new
Model
.
Query
.
CourseQuery
());
return
ApiResult
.
Success
(
data
:
""
,
message
:
"成功!"
);
return
ApiResult
.
Success
(
data
:
list
,
message
:
"成功!"
);
}
}
}
}
}
}
EduSpider.WebApi/EduSpider.WebApi.csproj
View file @
7b31c066
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCore" Version="5.0.8.3" />
<PackageReference Include="SqlSugarCore" Version="5.0.8.3" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="VTX.FW" Version="1.0.0" />
<PackageReference Include="VTX.FW" Version="1.0.0" />
</ItemGroup>
</ItemGroup>
...
...
EduSpider.WebApi/appsettings.json
View file @
7b31c066
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
],
],
//ַ
//ַ
"ConnectionStrings"
:
{
"ConnectionStrings"
:
{
"DefaultConnection"
:
"server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_
user
;CharSet=utf8mb4; Convert Zero Datetime=true; "
,
"DefaultConnection"
:
"server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_
think
;CharSet=utf8mb4; Convert Zero Datetime=true; "
,
"DefaultConnectionPName"
:
"MySql.Data.MySqlClient"
"DefaultConnectionPName"
:
"MySql.Data.MySqlClient"
}
}
}
}
EduSpider/Spiders/ClassInRule/CourseManager.cs
View file @
7b31c066
...
@@ -45,7 +45,7 @@ namespace EduSpider.Spiders.ClassInRule
...
@@ -45,7 +45,7 @@ namespace EduSpider.Spiders.ClassInRule
var
tempList
=
ParseJson
(
dataObj
.
GetString
(
"courseList"
));
var
tempList
=
ParseJson
(
dataObj
.
GetString
(
"courseList"
));
if
(
tempList
!=
null
&&
tempList
.
Count
>
0
)
if
(
tempList
!=
null
&&
tempList
.
Count
>
0
)
{
{
courseRepository
.
BatchSetCourse
(
tempList
);
courseRepository
.
BatchSetCourse
Repository
(
tempList
);
totalCount
+=
tempList
.
Count
();
totalCount
+=
tempList
.
Count
();
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
pageCount
,
totalCount
));
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
pageCount
,
totalCount
));
}
}
...
@@ -78,7 +78,7 @@ namespace EduSpider.Spiders.ClassInRule
...
@@ -78,7 +78,7 @@ namespace EduSpider.Spiders.ClassInRule
var
subtempList
=
ParseJson
(
sub_dataObj
.
GetString
(
"courseList"
));
var
subtempList
=
ParseJson
(
sub_dataObj
.
GetString
(
"courseList"
));
if
(
subtempList
!=
null
&&
subtempList
.
Count
>
0
)
if
(
subtempList
!=
null
&&
subtempList
.
Count
>
0
)
{
{
courseRepository
.
BatchSetCourse
(
subtempList
);
courseRepository
.
BatchSetCourse
Repository
(
subtempList
);
totalCount
+=
subtempList
.
Count
();
totalCount
+=
subtempList
.
Count
();
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
i
,
totalCount
));
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
i
,
totalCount
));
}
}
...
...
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