Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
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
黄奎
Education
Commits
703f4246
Commit
703f4246
authored
Feb 21, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/education
parents
1dbae8f2
299eaa95
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
16 deletions
+74
-16
RB_Course_Chapter_ViewModel.cs
Edu.Model/ViewModel/Course/RB_Course_Chapter_ViewModel.cs
+6
-0
CourseModule.cs
Edu.Module.Course/CourseModule.cs
+57
-16
RB_Course_WordsRepository.cs
Edu.Repository/Course/RB_Course_WordsRepository.cs
+11
-0
No files found.
Edu.Model/ViewModel/Course/RB_Course_Chapter_ViewModel.cs
View file @
703f4246
using
System
;
using
System.Collections.Generic
;
namespace
Edu.Model.ViewModel.Course
{
...
...
@@ -38,5 +39,10 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public
string
QCreateTime
{
get
;
set
;
}
/// <summary>
/// 章节单词列表
/// </summary>
public
List
<
RB_Course_Words_Extend
>
WordsList
{
get
;
set
;
}
}
}
Edu.Module.Course/CourseModule.cs
View file @
703f4246
...
...
@@ -486,9 +486,23 @@ namespace Edu.Module.Course
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course_Chapter_ViewModel
>
GetChapterListModule
(
RB_Course_Chapter_ViewModel
query
)
public
List
<
RB_Course_Chapter_ViewModel
>
GetChapterListModule
(
RB_Course_Chapter_ViewModel
query
,
bool
isQueryWords
=
false
)
{
return
chapterRepository
.
GetChapterListRepository
(
query
);
var
list
=
chapterRepository
.
GetChapterListRepository
(
query
);
if
(
isQueryWords
)
{
List
<
RB_Course_Words_Extend
>
courseWordsList
=
new
List
<
RB_Course_Words_Extend
>();
if
(
query
.
CourseId
>
0
)
{
courseWordsList
=
course_WordsRepository
.
GetCourseWordsListRepository
(
new
RB_Course_Words_Extend
()
{
CourseId
=
query
.
CourseId
}).
OrderBy
(
qitem
=>
qitem
.
ChapterId
).
ToList
();
}
foreach
(
var
item
in
list
)
{
Int32
.
TryParse
(
item
.
ChapterNo
,
out
int
ChapterNo
);
item
.
WordsList
=
courseWordsList
?.
Where
(
qitem
=>
qitem
.
ChapterId
==
ChapterNo
).
ToList
();
}
}
return
list
;
}
/// <summary>
...
...
@@ -1098,39 +1112,39 @@ namespace Edu.Module.Course
{
foreach
(
var
item
in
courseList
)
{
if
(
item
.
CourseId
!=
215
)
{
continue
;
}
//item.CourseId == 285||
//if ( item.CourseId == 285)
//{
//}
//else
//{
// continue;
//}
List
<
RB_Course_Chapter_ViewModel
>
result
=
new
List
<
RB_Course_Chapter_ViewModel
>();
//课程单词列表
var
courseWordsList
=
course_WordsRepository
.
GetCourseWordsListRepository
(
new
RB_Course_Words_Extend
()
{
CourseId
=
item
.
CourseId
}).
OrderBy
(
qitem
=>
qitem
.
ChapterId
).
ToList
();
var
chapterQuery
=
new
RB_Course_Chapter_ViewModel
()
{
CourseId
=
item
.
CourseId
};
var
sourceList
=
GetChapterListModule
(
chapterQuery
);
var
sourceList
=
GetChapterListModule
(
chapterQuery
,
isQueryWords
:
true
);
var
treeList
=
GetChapterTreeListModule
(
chapterQuery
);
if
(
treeList
!=
null
&&
treeList
.
Count
>
0
)
{
foreach
(
var
tItem
in
treeList
)
{
var
rootModel
=
sourceList
.
Where
(
qitem
=>
qitem
.
ChapterId
==
tItem
.
ChapterId
).
FirstOrDefault
();
rootModel
.
ChapterId
=
0
;
if
(
tItem
.
ChildList
==
null
||
(
tItem
.
ChildList
!=
null
&&
tItem
.
ChildList
.
Count
==
0
))
{
var
rootModel1
=
JsonHelper
.
DeserializeObject
<
RB_Course_Chapter_ViewModel
>(
JsonHelper
.
Serialize
(
rootModel
));
rootModel1
.
ChapterName
+=
"(1)"
;
rootModel1
.
StudyHours
=
2
;
rootModel1
.
StudyMinutes
=
90
;
rootModel1
.
ChapterId
=
0
;
result
.
Add
(
rootModel1
);
var
rootModel2
=
JsonHelper
.
DeserializeObject
<
RB_Course_Chapter_ViewModel
>(
JsonHelper
.
Serialize
(
rootModel
));
rootModel2
.
ChapterName
+=
"(2)"
;
rootModel2
.
StudyHours
=
2
;
rootModel2
.
StudyMinutes
=
90
;
rootModel
1
.
ChapterId
=
0
;
rootModel
.
WordsList
=
new
List
<
RB_Course_Words_Extend
>()
;
result
.
Add
(
rootModel2
);
}
else
{
...
...
@@ -1147,20 +1161,39 @@ namespace Edu.Module.Course
if
(
result
!=
null
&&
result
.
Count
>
0
)
{
int
index
=
1
;
List
<
RB_Course_Words_Extend
>
wordsList
=
new
List
<
RB_Course_Words_Extend
>();
foreach
(
var
sItem
in
result
)
{
sItem
.
ChapterId
=
0
;
sItem
.
SortNum
=
index
;
sItem
.
ChapterNo
=
index
.
ToString
();
string
pattern
=
@"第[一二三四五六七八九十]次课"
;
string
newStr
=
Regex
.
Replace
(
sItem
.
ChapterName
,
pattern
,
""
);
string
newTitle
=
string
.
Format
(
"第{0}次课"
,
new
WordToNumHelper
().
NumToChinese
(
index
.
ToString
()))
+
" "
+
newStr
.
Trim
();
sItem
.
ChapterName
=
newTitle
;
foreach
(
var
subItem
in
sItem
.
WordsList
)
{
subItem
.
Id
=
0
;
subItem
.
ChapterId
=
index
;
}
if
(
sItem
.
WordsList
!=
null
&&
sItem
.
WordsList
.
Count
>
0
)
{
wordsList
.
AddRange
(
sItem
.
WordsList
);
}
index
++;
}
chapterRepository
.
DeleteByCourseIdRepository
(
item
.
CourseId
);
course_WordsRepository
.
DeleteWordsByCourseIdRepository
(
item
.
CourseId
);
chapterRepository
.
SetBatchInsertCourseChapterRepository
(
result
);
if
(
wordsList
!=
null
&&
wordsList
.
Count
>
0
)
{
course_WordsRepository
.
BatchInsertCourseWordsRepository
(
wordsList
);
}
}
//
string str = Common.Plugin.JsonHelper.Serialize(result);
string
str
=
Common
.
Plugin
.
JsonHelper
.
Serialize
(
result
);
}
}
}
...
...
@@ -1176,11 +1209,12 @@ namespace Edu.Module.Course
{
if
(
item
.
ChildList
!=
null
&&
item
.
ChildList
.
Count
>
0
)
{
int
index
=
0
;
foreach
(
var
subItem
in
item
.
ChildList
)
{
var
tempModel
=
sourceList
?.
Where
(
qitem
=>
qitem
.
ChapterId
==
subItem
.
ChapterId
)?.
FirstOrDefault
();
if
(
subItem
.
ChildList
==
null
||
(
subItem
.
ChildList
!=
null
&&
subItem
.
ChildList
.
Count
==
0
))
{
var
tempModel
=
sourceList
?.
Where
(
qitem
=>
qitem
.
ChapterId
==
subItem
.
ChapterId
)?.
FirstOrDefault
();
if
(
tempModel
!=
null
)
{
string
newName
=
item
.
ChapterName
+
" "
+
tempModel
.
ChapterName
;
...
...
@@ -1188,16 +1222,23 @@ namespace Edu.Module.Course
newName
=
Regex
.
Replace
(
newName
,
pattern
,
""
);
string
pattern2
=
@"第[一二三四五六七八九十]*课"
;
newName
=
Regex
.
Replace
(
newName
,
pattern2
,
""
);
if
(
index
==
0
)
{
tempModel
.
WordsList
=
sourceList
?.
Where
(
qitem
=>
qitem
.
ChapterId
==
tempModel
.
ParentId
)?.
FirstOrDefault
()?.
WordsList
??
new
List
<
RB_Course_Words_Extend
>();
}
tempModel
.
ChapterName
=
newName
;
tempModel
.
StudyHours
=
2
;
tempModel
.
StudyMinutes
=
90
;
tempModel
.
ParentId
=
0
;
tempModel
.
ChapterId
=
0
;
resultList
.
Add
(
tempModel
);
index
++;
}
}
else
{
tempModel
.
WordsList
=
new
List
<
RB_Course_Words_Extend
>();
GetCourseChildList
(
subItem
,
sourceList
,
resultList
);
}
}
...
...
Edu.Repository/Course/RB_Course_WordsRepository.cs
View file @
703f4246
...
...
@@ -120,6 +120,17 @@ WHERE 1=1
return
flag
;
}
/// <summary>
/// 根据课程编号删除课程单词
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
DeleteWordsByCourseIdRepository
(
int
CourseId
)
{
string
sql
=
"DELETE FROM RB_Course_Words WHERE CourseId="
+
CourseId
;
return
base
.
Execute
(
sql
)
>
0
;
}
/// <summary>
/// 获取章节单词数量
/// </summary>
...
...
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