Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzksxtfw
Overview
Overview
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
常超
xzksxtfw
Commits
5db4a0a8
Commit
5db4a0a8
authored
Dec 28, 2023
by
yangyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
题库删除、修改提交
parent
fb4831ec
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
6 deletions
+70
-6
src/main/java/com/exam/controller/AnswerController.java
+21
-3
src/main/java/com/exam/mapper/AnswerMapper.java
+14
-3
src/main/java/com/exam/service/AnswerService.java
+4
-0
src/main/java/com/exam/serviceimpl/AnswerServiceImpl.java
+31
-0
No files found.
src/main/java/com/exam/controller/AnswerController.java
View file @
5db4a0a8
...
...
@@ -7,9 +7,7 @@ import com.exam.serviceimpl.AnswerServiceImpl;
import
com.exam.util.ApiResultHandler
;
import
com.exam.vo.AnswerVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
@RestController
...
...
@@ -25,4 +23,24 @@ public class AnswerController {
return
ApiResultHandler
.
buildApiResult
(
200
,
"查询所有题库"
,
answerVOIPage
);
}
@GetMapping
(
"/deleteAnswers/{questionid}/{tablename}/{subject}"
)
public
ApiResult
deleteQuestion
(
@PathVariable
(
"questionid"
)
String
questionid
,
@PathVariable
(
"tablename"
)
String
tablename
,
@PathVariable
(
"subject"
)
String
subject
){
int
res
=
answerService
.
deleteQuestion
(
questionid
,
tablename
,
subject
);
if
(
res
==
0
)
{
return
ApiResultHandler
.
buildApiResult
(
400
,
"删除失败"
,
res
);
}
else
{
return
ApiResultHandler
.
buildApiResult
(
200
,
"删除成功"
,
res
);
}
}
@PostMapping
(
"/updateAnswers"
)
public
ApiResult
updateAnswers
(
@RequestBody
AnswerVO
answerVO
){
int
res
=
answerService
.
updateAnswers
(
answerVO
);
if
(
res
==
0
)
{
return
ApiResultHandler
.
buildApiResult
(
400
,
"修改失败"
,
res
);
}
else
{
return
ApiResultHandler
.
buildApiResult
(
200
,
"修改成功"
,
res
);
}
}
}
src/main/java/com/exam/mapper/AnswerMapper.java
View file @
5db4a0a8
...
...
@@ -3,9 +3,7 @@ package com.exam.mapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.exam.vo.AnswerVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.*
;
@Mapper
...
...
@@ -20,4 +18,17 @@ public interface AnswerMapper {
+
"</if>"
+
"</script>"
)
IPage
<
AnswerVO
>
findAll
(
Page
page
,
@Param
(
"question"
)
String
question
);
@Delete
(
"delete from ${tablename} where questionid = #{questionid}"
)
int
deleteQuestion
(
@Param
(
"questionid"
)
String
questionid
,
@Param
(
"tablename"
)
String
tablename
);
@Delete
(
"delete from paper_manage where questionid = #{questionid} and questionType = #{questionType} and paperid = (select paperid from exam_manage where type = #{subject})"
)
int
deletePaperManage
(
@Param
(
"questionid"
)
String
questionid
,
@Param
(
"questionType"
)
String
questionType
,
@Param
(
"subject"
)
String
subject
);
@Update
(
"update multi_question set question = #{question},answerA = #{answerA},answerB = #{answerB},answerC = #{answerC},answerD = #{answerD},rightAnswer = #{rightAnswer},analysis = #{analysis} where questionid = #{questionid}"
)
int
updateMultiQuestionByQuestionid
(
AnswerVO
answerVO
);
@Update
(
"update judge_question set question = #{question},answer = #{rightAnswer},analysis = #{analysis} where questionid = #{questionid}"
)
int
updatejudgeQuestionByQuestionid
(
AnswerVO
answerVO
);
}
src/main/java/com/exam/service/AnswerService.java
View file @
5db4a0a8
...
...
@@ -7,4 +7,8 @@ import com.exam.vo.AnswerVO;
public
interface
AnswerService
{
IPage
<
AnswerVO
>
findAll
(
Page
<
AnswerVO
>
page
,
String
question
);
int
deleteQuestion
(
String
questionid
,
String
tablename
,
String
subject
);
int
updateAnswers
(
AnswerVO
answerVO
);
}
src/main/java/com/exam/serviceimpl/AnswerServiceImpl.java
View file @
5db4a0a8
...
...
@@ -18,4 +18,35 @@ public class AnswerServiceImpl implements AnswerService {
public
IPage
<
AnswerVO
>
findAll
(
Page
<
AnswerVO
>
page
,
String
question
)
{
return
answerMapper
.
findAll
(
page
,
question
);
}
@Override
public
int
deleteQuestion
(
String
questionid
,
String
tablename
,
String
subject
)
{
int
flag
=
answerMapper
.
deleteQuestion
(
questionid
,
tablename
);
if
(
flag
>
0
){
answerMapper
.
deletePaperManage
(
questionid
,
getQuestionType
(
tablename
),
subject
);
return
1
;
}
return
0
;
}
@Override
public
int
updateAnswers
(
AnswerVO
answerVO
)
{
int
update
=
0
;
if
(
"multi_question"
.
equals
(
answerVO
.
getTablename
())){
update
=
answerMapper
.
updateMultiQuestionByQuestionid
(
answerVO
);
}
else
if
(
"judge_question"
.
equals
(
answerVO
.
getTablename
())){
update
=
answerMapper
.
updatejudgeQuestionByQuestionid
(
answerVO
);
}
return
update
;
}
public
String
getQuestionType
(
String
tablename
){
String
questionType
=
""
;
if
(
"multi_question"
.
equals
(
tablename
)){
questionType
=
"1"
;
}
else
if
(
"judge_question"
.
equals
(
tablename
)){
questionType
=
"3"
;
}
return
questionType
;
}
}
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