|
@@ -316,22 +316,25 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
parentId = kmtExerciseQuestion.getParentId();
|
|
|
}
|
|
|
List<String> tempList = kmtExerciseMapper.findQuestionIdByParentId(parentId);
|
|
|
- if (tempList != null && tempList.size() > 0){
|
|
|
- if (kmtExerciseQuestion.getId().equals(tempList.get(0))){
|
|
|
- return responseEntity.failure(ResponseConstant.CODE_000, "已移动到第一小题");
|
|
|
- }
|
|
|
- if (kmtExerciseQuestion.getId().equals(tempList.get(tempList.size() - 1))){
|
|
|
- return responseEntity.failure(ResponseConstant.CODE_000, "已移动到最后一个小题的位置");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
//移动小题
|
|
|
if (request.getType() == 1){
|
|
|
+ //第一个小题不能往上移
|
|
|
+ if (tempList != null && tempList.size() > 0){
|
|
|
+ if (kmtExerciseQuestion.getId().equals(tempList.get(0))){
|
|
|
+ return responseEntity.failure(ResponseConstant.CODE_000, "已移动到第一小题");
|
|
|
+ }
|
|
|
+ }
|
|
|
//上移
|
|
|
kmtExerciseMapper.updateByBookIdAndNum(kmtExerciseQuestion.getBookId(), kmtExerciseQuestion.getNum(),kmtExerciseQuestion.getNum() - 1);
|
|
|
kmtExerciseMapper.updateQuestionNumByQuestionId(kmtExerciseQuestion.getId(), kmtExerciseQuestion.getNum() - 1);
|
|
|
} else if (request.getType() == 2){
|
|
|
+ //最后一个小题不能往下移
|
|
|
+ if (tempList != null && tempList.size() > 0){
|
|
|
+ if (kmtExerciseQuestion.getId().equals(tempList.get(tempList.size() - 1))){
|
|
|
+ return responseEntity.failure(ResponseConstant.CODE_000, "已移动到最后一个小题的位置");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //下移
|
|
|
kmtExerciseMapper.updateByBookIdAndNum(kmtExerciseQuestion.getBookId(), kmtExerciseQuestion.getNum(), kmtExerciseQuestion.getNum() + 1);
|
|
|
kmtExerciseMapper.updateQuestionNumByQuestionId(kmtExerciseQuestion.getId(), kmtExerciseQuestion.getNum() + 1);
|
|
|
}
|