Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zhengyuan-danger-chemistry-manage
Project
Project
Details
Activity
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
耿迪迪
zhengyuan-danger-chemistry-manage
Commits
f62d76ec
Commit
f62d76ec
authored
Dec 27, 2022
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
从题库批量新增 gengdidi
parent
e867b9be
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
164 additions
and
5 deletions
+164
-5
TBankSubjectController.java
.../zehong/web/controller/system/TBankSubjectController.java
+1
-0
TTrainCourseTopicController.java
...ong/web/controller/train/TTrainCourseTopicController.java
+11
-0
BatchTopicVo.java
...c/main/java/com/zehong/system/domain/vo/BatchTopicVo.java
+66
-0
TTrainCourseTopicMapper.java
...ava/com/zehong/system/mapper/TTrainCourseTopicMapper.java
+7
-0
ITTrainCourseTopicService.java
.../com/zehong/system/service/ITTrainCourseTopicService.java
+10
-1
TTrainCourseTopicServiceImpl.java
...ong/system/service/impl/TTrainCourseTopicServiceImpl.java
+50
-4
TTrainCourseTopicMapper.xml
.../main/resources/mapper/system/TTrainCourseTopicMapper.xml
+7
-0
lessonsProgram.js
...er-manage-web/src/api/educationPlanExam/lessonsProgram.js
+12
-0
No files found.
danger-manage-admin/src/main/java/com/zehong/web/controller/system/TBankSubjectController.java
View file @
f62d76ec
package
com
.
zehong
.
web
.
controller
.
system
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
danger-manage-admin/src/main/java/com/zehong/web/controller/train/TTrainCourseTopicController.java
View file @
f62d76ec
...
...
@@ -2,6 +2,7 @@ package com.zehong.web.controller.train;
import
java.util.List
;
import
com.zehong.system.domain.vo.BatchTopicVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.security.access.prepost.PreAuthorize
;
...
...
@@ -122,4 +123,14 @@ public class TTrainCourseTopicController extends BaseController
{
return
toAjax
(
tTrainCourseTopicService
.
deleteTTrainCourseTopicById
(
topicId
));
}
/**
* 题库批量导入试题
* @param batchTopicVo 试题实体
* @return AjaxResult
*/
@PostMapping
(
"/bachAddTopic"
)
public
AjaxResult
bachAddTopic
(
@RequestBody
BatchTopicVo
batchTopicVo
){
return
toAjax
(
tTrainCourseTopicService
.
bachAddTopic
(
batchTopicVo
));
}
}
danger-manage-system/src/main/java/com/zehong/system/domain/vo/BatchTopicVo.java
0 → 100644
View file @
f62d76ec
package
com
.
zehong
.
system
.
domain
.
vo
;
import
java.util.List
;
/**
* @author geng
* 批量导入试题
*/
public
class
BatchTopicVo
{
/**
* 所属考试id
*/
private
Long
courseId
;
private
List
<
TopicInfos
>
topicInfos
;
public
Long
getCourseId
()
{
return
courseId
;
}
public
void
setCourseId
(
Long
courseId
)
{
this
.
courseId
=
courseId
;
}
public
List
<
TopicInfos
>
getTopicInfos
()
{
return
topicInfos
;
}
public
void
setTopicInfos
(
List
<
TopicInfos
>
topicInfos
)
{
this
.
topicInfos
=
topicInfos
;
}
/**
* @author geng
* 题库批量导入试题实体
*/
public
static
class
TopicInfos
{
/**
* 题库id
*/
private
Long
bankId
;
/**
* 随机抽取题数量
*/
private
int
quan
;
public
Long
getBankId
()
{
return
bankId
;
}
public
void
setBankId
(
Long
bankId
)
{
this
.
bankId
=
bankId
;
}
public
int
getQuan
()
{
return
quan
;
}
public
void
setQuan
(
int
quan
)
{
this
.
quan
=
quan
;
}
}
}
danger-manage-system/src/main/java/com/zehong/system/mapper/TTrainCourseTopicMapper.java
View file @
f62d76ec
...
...
@@ -60,4 +60,11 @@ public interface TTrainCourseTopicMapper
* @return 结果
*/
public
int
deleteTTrainCourseTopicByIds
(
Long
[]
topicIds
);
/**
* 批量新增
* @param topics 试题试题
* @return
*/
int
batchInsertTTrainCourseTopic
(
List
<
TTrainCourseTopic
>
topics
);
}
danger-manage-system/src/main/java/com/zehong/system/service/ITTrainCourseTopicService.java
View file @
f62d76ec
package
com
.
zehong
.
system
.
service
;
import
java.util.List
;
import
com.zehong.system.domain.TTrainCourseTopic
;
import
com.zehong.system.domain.vo.BatchTopicVo
;
import
java.util.List
;
/**
* 培训课程题库Service接口
...
...
@@ -59,4 +61,11 @@ public interface ITTrainCourseTopicService
* @return 结果
*/
public
int
deleteTTrainCourseTopicById
(
Long
topicId
);
/**
* 题库批量导入试题
* @param batchTopicVo 试题实体
* @return int
*/
int
bachAddTopic
(
BatchTopicVo
batchTopicVo
);
}
danger-manage-system/src/main/java/com/zehong/system/service/impl/TTrainCourseTopicServiceImpl.java
View file @
f62d76ec
package
com
.
zehong
.
system
.
service
.
impl
;
import
java.util.List
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.common.utils.StringUtils
;
import
com.zehong.system.domain.TBankSubject
;
import
com.zehong.system.domain.TTrainCourse
;
import
com.zehong.system.domain.TTrainCourseTopic
;
import
com.zehong.system.domain.vo.BatchTopicVo
;
import
com.zehong.system.mapper.TBankSubjectMapper
;
import
com.zehong.system.mapper.TTrainCourseMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zehong.system.mapper.TTrainCourseTopicMapper
;
import
com.zehong.system.domain.TTrainCourseTopic
;
import
com.zehong.system.service.ITTrainCourseTopicService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
/**
* 培训课程题库Service业务层处理
*
...
...
@@ -24,6 +35,8 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
private
TTrainCourseTopicMapper
tTrainCourseTopicMapper
;
@Autowired
private
TTrainCourseMapper
tTrainCourseMapper
;
@Resource
private
TBankSubjectMapper
tBankSubjectMapper
;
/**
* 查询培训课程题库
...
...
@@ -118,4 +131,37 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
}
return
tTrainCourseTopicMapper
.
deleteTTrainCourseTopicById
(
topicId
);
}
/**
* 题库批量导入试题
* @param batchTopicVo 试题实体
* @return int
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
bachAddTopic
(
BatchTopicVo
batchTopicVo
){
if
(
CollectionUtil
.
isEmpty
(
batchTopicVo
.
getTopicInfos
())
||
StringUtils
.
isEmpty
(
String
.
valueOf
(
batchTopicVo
.
getCourseId
()))){
return
0
;
}
List
<
TTrainCourseTopic
>
topics
=
new
ArrayList
<>();
for
(
BatchTopicVo
.
TopicInfos
topic
:
batchTopicVo
.
getTopicInfos
()){
//获取题库试题
TBankSubject
tBankSubject
=
new
TBankSubject
();
tBankSubject
.
setBankId
(
topic
.
getBankId
());
List
<
TBankSubject
>
bankSubjects
=
tBankSubjectMapper
.
selectTBankSubjectList
(
tBankSubject
);
//获取随机试题
Collections
.
shuffle
(
bankSubjects
);
for
(
int
i
=
0
;
i
<
topic
.
getQuan
();
i
++){
TTrainCourseTopic
courseTopic
=
new
TTrainCourseTopic
();
courseTopic
.
setCourseId
(
batchTopicVo
.
getCourseId
());
courseTopic
.
setTopicTitle
(
bankSubjects
.
get
(
i
).
getTopicTitle
());
courseTopic
.
setTopicOption
(
bankSubjects
.
get
(
i
).
getTopicOption
());
courseTopic
.
setAnswer
(
bankSubjects
.
get
(
i
).
getAnswer
());
courseTopic
.
setCreateTime
(
new
Date
());
topics
.
add
(
courseTopic
);
}
}
//批量新增试题
return
tTrainCourseTopicMapper
.
batchInsertTTrainCourseTopic
(
topics
);
}
}
danger-manage-system/src/main/resources/mapper/system/TTrainCourseTopicMapper.xml
View file @
f62d76ec
...
...
@@ -77,4 +77,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{topicId}
</foreach>
</delete>
<insert
id=
"batchInsertTTrainCourseTopic"
parameterType=
"java.util.List"
>
insert into t_train_course_topic(course_id,topic_title,topic_option,answer,create_time) values
<foreach
collection=
"list"
item=
"topic"
index=
"index"
separator=
","
>
(#{topic.courseId},#{topic.topicTitle},#{topic.topicOption},#{topic.answer},#{topic.createTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
danger-manage-web/src/api/educationPlanExam/lessonsProgram.js
View file @
f62d76ec
...
...
@@ -159,3 +159,15 @@ export function testPersonDetailByCourseId(query) {
})
}
/**
* 从题库导入试题
* @param data
*/
export
function
bachAddTopic
(
data
)
{
return
request
({
url
:
'/system/course/bachAddTopic'
,
method
:
'post'
,
data
:
data
})
}
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