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
9e75dc21
Commit
9e75dc21
authored
Jan 06, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/education
parents
37f468dd
57786fad
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
419 additions
and
121 deletions
+419
-121
CourseWordsHelper.cs
Edu.Common/Data/CourseWordsHelper.cs
+64
-8
NPOIHelper.cs
Edu.Common/Plugin/NPOIHelper.cs
+40
-1
RB_Course_Words.cs
Edu.Model/Entity/Course/RB_Course_Words.cs
+8
-0
RB_Course_Words_Extend.cs
Edu.Model/ViewModel/Course/RB_Course_Words_Extend.cs
+4
-1
CourseModule.cs
Edu.Module.Course/CourseModule.cs
+116
-108
CourseWordsModule.cs
Edu.Module.Course/CourseWordsModule.cs
+11
-0
StudentModule.cs
Edu.Module.User/StudentModule.cs
+23
-0
RB_Course_WordsRepository.cs
Edu.Repository/Course/RB_Course_WordsRepository.cs
+29
-0
CourseController.cs
Edu.WebApi/Controllers/Course/CourseController.cs
+10
-1
CourseWordsController.cs
Edu.WebApi/Controllers/Course/CourseWordsController.cs
+112
-2
UserController.cs
Edu.WebApi/Controllers/User/UserController.cs
+2
-0
No files found.
Edu.Common/Data/CourseWordsHelper.cs
View file @
9e75dc21
...
...
@@ -15,12 +15,16 @@ namespace Edu.Common.Data
public
static
List
<
WordsItem
>
GetXlsWordsData
(
string
filePath
)
{
List
<
WordsItem
>
xlsItems
=
new
List
<
WordsItem
>();
var
d
t
=
Common
.
Plugin
.
NPOIHelper
.
ImportExcelToDatatable
(
filePath
,
0
,
0
,
true
);
if
(
d
t
!=
null
&&
dt
.
Row
s
.
Count
>
0
)
var
d
s
=
Common
.
Plugin
.
NPOIHelper
.
ExcelToDataSet
(
filePath
);
if
(
d
s
!=
null
&&
ds
.
Table
s
.
Count
>
0
)
{
for
each
(
DataRow
item
in
dt
.
Rows
)
for
(
var
i
=
0
;
i
<
ds
.
Tables
.
Count
;
i
++
)
{
xlsItems
.
Add
(
DataRowToModel
(
item
));
var
dataRow
=
ds
.
Tables
[
i
].
Rows
;
for
(
var
j
=
0
;
j
<
ds
.
Tables
[
i
].
Rows
.
Count
;
j
++)
{
xlsItems
.
Add
(
DataRowToModel
((
i
+
1
),
ds
.
Tables
[
i
].
Rows
[
j
]));
}
}
}
return
xlsItems
;
...
...
@@ -29,21 +33,73 @@ namespace Edu.Common.Data
/// <summary>
/// DataRow转实体
/// </summary>
/// <param name="tableName"></param>
/// <param name="dr"></param>
/// <returns></returns>
private
static
WordsItem
DataRowToModel
(
DataRow
dr
)
private
static
WordsItem
DataRowToModel
(
int
ChapterId
,
DataRow
dr
)
{
WordsItem
model
=
new
WordsItem
();
model
.
ChapterId
=
ChapterId
;
if
(
dr
!=
null
)
{
if
(
dr
.
Table
.
Columns
.
Contains
(
"品詞名"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"品詞名"
].
ToString
()))
{
model
.
WordType
=
dr
[
"品詞名"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"語彙・表現"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"語彙・表現"
].
ToString
()))
{
model
.
WordContent
=
dr
[
"語彙・表現"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"声调"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"声调"
].
ToString
()))
{
model
.
WordTone
=
dr
[
"声调"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"日文书写"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"日文书写"
].
ToString
()))
{
model
.
WordWrite
=
dr
[
"日文书写"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"中文意思"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"中文意思"
].
ToString
()))
{
model
.
ChineseMean
=
dr
[
"中文意思"
].
ToString
();
}
}
return
model
;
}
}
/// <summary>
/// 单词项
/// </summary>
public
class
WordsItem
{
{
/// <summary>
/// 章节编号
/// </summary>
public
int
ChapterId
{
get
;
set
;
}
/// <summary>
/// 单词类型(名词、动词、形容词等)
/// </summary>
public
string
WordType
{
get
;
set
;
}
/// <summary>
/// 单词内容
/// </summary>
public
string
WordContent
{
get
;
set
;
}
/// <summary>
/// 单词声调
/// </summary>
public
string
WordTone
{
get
;
set
;
}
/// <summary>
/// 单词书写
/// </summary>
public
string
WordWrite
{
get
;
set
;
}
/// <summary>
/// 中文意思
/// </summary>
public
string
ChineseMean
{
get
;
set
;
}
}
}
Edu.Common/Plugin/NPOIHelper.cs
View file @
9e75dc21
...
...
@@ -586,6 +586,45 @@ namespace Edu.Common.Plugin
return
table
;
}
/// <summary>
/// Excel转DataSet
/// </summary>
/// <param name="excelPath"></param>
/// <returns></returns>
public
static
DataSet
ExcelToDataSet
(
string
excelPath
)
{
int
sheetCount
;
return
ExcelToDataSet
(
excelPath
,
true
,
out
sheetCount
);
}
/// <summary>
/// Excel转DataSet
/// </summary>
/// <param name="excelPath"></param>
/// <param name="firstRowAsHeader"></param>
/// <param name="sheetCount"></param>
/// <returns></returns>
static
DataSet
ExcelToDataSet
(
string
excelPath
,
bool
firstRowAsHeader
,
out
int
sheetCount
)
{
using
(
DataSet
ds
=
new
DataSet
())
{
using
(
FileStream
fileStream
=
new
FileStream
(
excelPath
,
FileMode
.
Open
,
FileAccess
.
Read
))
{
HSSFWorkbook
workbook
=
new
HSSFWorkbook
(
fileStream
);
HSSFFormulaEvaluator
evaluator
=
new
HSSFFormulaEvaluator
(
workbook
);
sheetCount
=
workbook
.
NumberOfSheets
;
for
(
int
i
=
0
;
i
<
sheetCount
;
++
i
)
{
HSSFSheet
sheet
=
workbook
.
GetSheetAt
(
i
)
as
HSSFSheet
;
DataTable
dt
=
ImportDataTable
(
sheet
,
0
,
firstRowAsHeader
);
dt
.
TableName
=
workbook
.
GetSheetName
(
i
);
ds
.
Tables
.
Add
(
dt
);
}
return
ds
;
}
}
}
#
endregion
/// <summary>
...
...
@@ -785,7 +824,7 @@ namespace Edu.Common.Plugin
{
XSSFCell
newCell
=
dataRow
.
CreateCell
(
column
.
Ordinal
)
as
XSSFCell
;
newCell
.
CellStyle
=
cellSource
.
CellStyle
;
String
drValue
=
row
[
column
].
ToString
();
newCell
.
SetCellValue
(
drValue
);
}
...
...
Edu.Model/Entity/Course/RB_Course_Words.cs
View file @
9e75dc21
...
...
@@ -2,12 +2,15 @@
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.Course
{
/// <summary>
/// 课程章节单词实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Course_Words
{
/// <summary>
...
...
@@ -50,6 +53,11 @@ namespace Edu.Model.Entity.Course
/// </summary>
public
string
ChineseMean
{
get
;
set
;
}
/// <summary>
/// 文件路径
/// </summary>
public
string
FileUrl
{
get
;
set
;
}
/// <summary>
/// 状态
/// </summary>
...
...
Edu.Model/ViewModel/Course/RB_Course_Words_Extend.cs
View file @
9e75dc21
...
...
@@ -10,6 +10,9 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public
class
RB_Course_Words_Extend
:
RB_Course_Words
{
/// <summary>
/// 课程编号
/// </summary>
public
string
QCourseIds
{
get
;
set
;
}
}
}
Edu.Module.Course/CourseModule.cs
View file @
9e75dc21
This diff is collapsed.
Click to expand it.
Edu.Module.Course/CourseWordsModule.cs
View file @
9e75dc21
...
...
@@ -29,6 +29,16 @@ namespace Edu.Module.Course
return
list
;
}
/// <summary>
/// 批量添加课程单词
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchInsertCourseWordsModule
(
List
<
RB_Course_Words_Extend
>
list
)
{
return
course_WordsRepository
.
BatchInsertCourseWordsRepository
(
list
);
}
/// <summary>
/// 新增修改课程单词
/// </summary>
...
...
@@ -47,6 +57,7 @@ namespace Edu.Module.Course
{
nameof
(
RB_Course_Words_Extend
.
WordTone
),
model
.
WordTone
},
{
nameof
(
RB_Course_Words_Extend
.
WordWrite
),
model
.
WordWrite
},
{
nameof
(
RB_Course_Words_Extend
.
ChineseMean
),
model
.
ChineseMean
},
{
nameof
(
RB_Course_Words_Extend
.
FileUrl
),
model
.
FileUrl
},
{
nameof
(
RB_Course_Words_Extend
.
UpdateBy
),
model
.
UpdateBy
},
{
nameof
(
RB_Course_Words_Extend
.
UpdateTime
),
model
.
UpdateTime
},
};
...
...
Edu.Module.User/StudentModule.cs
View file @
9e75dc21
...
...
@@ -437,6 +437,29 @@ namespace Edu.Module.User
extModel
.
StuPurposeName
=
learningGoalsRepository
.
GetLearningGoalsExtEntityRepository
(
extModel
.
StuPurpose
)?.
Name
??
""
;
extModel
.
StuChannelName
=
channelRepository
.
GetChannelExtEntityRepository
(
extModel
.
StuChannel
)?.
Name
??
""
;
extModel
.
StuNeedsName
=
needsRepository
.
GetNeedsExtEntityRepository
(
extModel
.
StuNeeds
)?.
Name
??
""
;
if
(
extModel
.
CustomerId
>
0
)
{
extModel
.
CustomerName
=
customerRepository
.
GetEntity
(
extModel
.
CustomerId
)?.
CustomerName
??
""
;
}
if
(
extModel
.
StuSourceId
>
0
)
{
if
(
extModel
.
CreateType
==
StuCreateTypeEnum
.
CustomerInput
)
{
extModel
.
StuSourceIdName
=
customerRepository
.
GetEntity
(
extModel
.
StuSourceId
)?.
CustomerName
??
""
;
}
else
if
(
extModel
.
CreateType
==
StuCreateTypeEnum
.
EmployeeInput
)
{
extModel
.
StuSourceIdName
=
accountModule
.
GetEmployeeInfo
(
extModel
.
StuSourceId
)?.
EmployeeName
??
""
;
}
else
if
(
extModel
.
CreateType
==
StuCreateTypeEnum
.
InternalIntroduction
)
{
extModel
.
StuSourceIdName
=
accountModule
.
GetEmployeeInfo
(
extModel
.
StuSourceId
)?.
EmployeeName
??
""
;
}
else
if
(
extModel
.
CreateType
==
StuCreateTypeEnum
.
TransIntroduction
)
{
extModel
.
StuSourceIdName
=
studentRepository
.
GetEntity
(
extModel
.
StuSourceId
)?.
StuName
??
""
;
}
}
}
return
extModel
;
}
...
...
Edu.Repository/Course/RB_Course_WordsRepository.cs
View file @
9e75dc21
...
...
@@ -37,8 +37,37 @@ WHERE 1=1
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Course_Words_Extend
.
CourseId
),
query
.
CourseId
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
QCourseIds
))
{
builder
.
AppendFormat
(
" AND A.{0} IN({1}) "
,
nameof
(
RB_Course_Words_Extend
.
CourseId
),
query
.
QCourseIds
);
}
}
return
Get
<
RB_Course_Words_Extend
>(
builder
.
ToString
()).
ToList
();
}
/// <summary>
/// 批量添加课程单词
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchInsertCourseWordsRepository
(
List
<
RB_Course_Words_Extend
>
list
)
{
bool
flag
=
true
;
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
" INSERT INTO RB_Course_Words(CourseId,ChapterId,WordType,WordContent,WordTone,WordWrite,ChineseMean,Status,Group_Id,CreateBy,CreateTime,UpdateBy,UpdateTime) "
);
builder
.
AppendFormat
(
" VALUES "
);
string
tempStr
=
""
;
foreach
(
var
item
in
list
)
{
tempStr
+=
$",(
{
item
.
CourseId
}
,
{
item
.
ChapterId
}
,'
{
item
.
WordType
}
','
{
item
.
WordContent
}
','
{
item
.
WordTone
}
','
{
item
.
WordWrite
}
','
{
item
.
ChineseMean
}
',0,
{
item
.
Group_Id
}
,
{
item
.
CreateBy
}
,'
{
item
.
CreateTime
}
',
{
item
.
UpdateBy
}
,'
{
item
.
UpdateTime
}
') "
;
}
builder
.
Append
(
tempStr
.
TrimStart
(
','
));
flag
=
base
.
Execute
(
builder
.
ToString
())
>
0
;
}
return
flag
;
}
}
}
Edu.WebApi/Controllers/Course/CourseController.cs
View file @
9e75dc21
...
...
@@ -582,10 +582,19 @@ namespace Edu.WebApi.Controllers.Course
#
region
课程章节管理
/// <summary>
/// 导入课程章节到新课程
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetImportCourseChapter
()
{
var
query
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
RB_Course_Chapter_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
var
query
=
new
RB_Course_Chapter_ViewModel
()
{
CourseIds
=
base
.
ParmJObj
.
GetStringValue
(
"CourseIds"
),
NewCourseId
=
base
.
ParmJObj
.
GetInt
(
"NewCourseId"
),
MaxLength
=
base
.
ParmJObj
.
GetInt
(
"MaxLength"
)
};
query
.
Group_Id
=
base
.
UserInfo
.
Group_Id
;
query
.
School_Id
=
base
.
UserInfo
.
School_Id
;
query
.
CreateBy
=
base
.
UserInfo
.
Id
;
...
...
Edu.WebApi/Controllers/Course/CourseWordsController.cs
View file @
9e75dc21
using
Edu.Common.API
;
using
Edu.Common.Plugin
;
using
Edu.Model.ViewModel.Course
;
using
Edu.Module.Course
;
using
Edu.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
...
...
@@ -16,6 +19,11 @@ namespace Edu.WebApi.Controllers.Course
[
EnableCors
(
"AllowCors"
)]
public
class
CourseWordsController
:
BaseController
{
/// <summary>
/// 课程单词处理类对象
/// </summary>
private
readonly
CourseWordsModule
courseWordsModule
=
new
CourseWordsModule
();
/// <summary>
/// 导入Excel单词
/// </summary>
...
...
@@ -24,7 +32,109 @@ namespace Edu.WebApi.Controllers.Course
{
var
userInfo
=
base
.
GetUserInfo
(
Uid
);
var
dataList
=
Common
.
Data
.
CourseWordsHelper
.
GetXlsWordsData
(
filePath
);
return
ApiResult
.
Success
(
data
:
dataList
);
List
<
RB_Course_Words_Extend
>
result
=
new
List
<
RB_Course_Words_Extend
>();
if
(
dataList
!=
null
&&
dataList
.
Count
>
0
)
{
foreach
(
var
item
in
dataList
)
{
var
model
=
new
RB_Course_Words_Extend
()
{
Id
=
0
,
CourseId
=
CourseId
,
ChapterId
=
item
.
ChapterId
,
WordType
=
item
.
WordType
,
WordContent
=
item
.
WordContent
,
WordTone
=
item
.
WordTone
,
WordWrite
=
item
.
WordWrite
,
ChineseMean
=
item
.
ChineseMean
,
Status
=
Common
.
Enum
.
DateStateEnum
.
Normal
,
Group_Id
=
userInfo
.
Group_Id
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
UpdateBy
=
userInfo
.
Id
,
UpdateTime
=
DateTime
.
Now
};
if
(!
string
.
IsNullOrEmpty
(
model
.
WordContent
))
{
result
.
Add
(
model
);
}
}
}
bool
flag
=
false
;
if
(
result
!=
null
&&
result
.
Count
>
0
)
{
flag
=
courseWordsModule
.
BatchInsertCourseWordsModule
(
result
);
}
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
/// <summary>
/// 获取课程单词列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetCourseWordsList
()
{
var
query
=
new
RB_Course_Words_Extend
()
{
CourseId
=
base
.
ParmJObj
.
GetInt
(
"CourseId"
),
ChapterId
=
base
.
ParmJObj
.
GetInt
(
"ChapterId"
),
};
query
.
Group_Id
=
base
.
UserInfo
.
Group_Id
;
var
list
=
courseWordsModule
.
GetCourseWordsListModule
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
}
/// <summary>
/// 添加修改课程单词
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetCourseWords
()
{
var
extModel
=
new
RB_Course_Words_Extend
()
{
Id
=
base
.
ParmJObj
.
GetInt
(
"Id"
),
CourseId
=
base
.
ParmJObj
.
GetInt
(
"CourseId"
),
ChapterId
=
base
.
ParmJObj
.
GetInt
(
"ChapterId"
),
WordType
=
base
.
ParmJObj
.
GetStringValue
(
"WordType"
),
WordContent
=
base
.
ParmJObj
.
GetStringValue
(
"WordContent"
),
WordTone
=
base
.
ParmJObj
.
GetStringValue
(
"WordTone"
),
WordWrite
=
base
.
ParmJObj
.
GetStringValue
(
"WordWrite"
),
ChineseMean
=
base
.
ParmJObj
.
GetStringValue
(
"ChineseMean"
),
FileUrl
=
base
.
ParmJObj
.
GetStringValue
(
"FileUrl"
),
};
extModel
.
CreateTime
=
DateTime
.
Now
;
extModel
.
CreateBy
=
UserInfo
.
Id
;
extModel
.
UpdateBy
=
UserInfo
.
Id
;
extModel
.
UpdateTime
=
DateTime
.
Now
;
extModel
.
Group_Id
=
this
.
UserInfo
.
Group_Id
;
bool
flag
=
courseWordsModule
.
SetCourseWordsModule
(
extModel
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
/// <summary>
/// 根据编号获取单词详情
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetCourseWords
()
{
var
Id
=
base
.
ParmJObj
.
GetInt
(
"Id"
,
0
);
var
extModel
=
courseWordsModule
.
GetCourseWordsModule
(
Id
);
return
ApiResult
.
Success
(
data
:
extModel
);
}
/// <summary>
/// 根据编号删除单词
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
RemoveCourseWords
()
{
var
Id
=
base
.
ParmJObj
.
GetInt
(
"Id"
,
0
);
var
flag
=
courseWordsModule
.
RemoveCourseWordsModule
(
Id
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
}
}
}
\ No newline at end of file
Edu.WebApi/Controllers/User/UserController.cs
View file @
9e75dc21
...
...
@@ -1223,6 +1223,7 @@ namespace Edu.WebApi.Controllers.User
extModel
.
PlatformName
,
AssistList
=
extModel
?.
AssistList
??
new
List
<
RB_Student_Assist_Extend
>(),
extModel
.
StuSourceId
,
extModel
.
StuSourceIdName
,
extModel
.
QQ
,
extModel
.
WeChatNo
,
extModel
.
StuType
,
...
...
@@ -1230,6 +1231,7 @@ namespace Edu.WebApi.Controllers.User
extModel
.
StuNeeds
,
extModel
.
StuNeedsName
,
extModel
.
StuRealMobile
,
extModel
.
CustomerName
,
};
return
ApiResult
.
Success
(
data
:
obj
);
}
...
...
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