parent
b9a36ce057
commit
d3f6fb7f51
13 changed files with 287 additions and 82 deletions
@ -0,0 +1,24 @@ |
|||||||
|
package com.ccic.safeliab.dao; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ccic.safeliab.entity.PaperQuestion; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper 接口 |
||||||
|
* |
||||||
|
* @author Chill |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface PaperQuestionMapper extends BaseMapper<PaperQuestion> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除试卷的所有试题 |
||||||
|
* |
||||||
|
* @param id 试卷id |
||||||
|
* @return 删除件数 |
||||||
|
*/ |
||||||
|
boolean deletePaperALlQuestion(@Param("id") Long id); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.ccic.safeliab.service; |
||||||
|
|
||||||
|
import com.ccic.safeliab.entity.PaperQuestion; |
||||||
|
import com.ccic.safeliab.support.BaseService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Service |
||||||
|
public interface PaperQuestionService extends BaseService<PaperQuestion> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加试卷试题关系 |
||||||
|
* @param paperID 试卷ID |
||||||
|
* @param QuestionIds 题目ID集合 |
||||||
|
* @return 添加是否成功 |
||||||
|
*/ |
||||||
|
int add(Long paperID, List<String> QuestionIds); |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除试卷试题关系 |
||||||
|
* @param paperID 试卷ID |
||||||
|
* @return 添加是否成功 |
||||||
|
*/ |
||||||
|
boolean delete(Long paperID); |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新试卷试题关系 |
||||||
|
* @param paperID 试卷ID |
||||||
|
* @param QuestionIds 题目ID集合 |
||||||
|
* @return 添加是否成功 |
||||||
|
*/ |
||||||
|
int update(Long paperID, List<String> QuestionIds); |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.ccic.safeliab.service; |
||||||
|
|
||||||
|
import com.ccic.safeliab.dao.PaperQuestionMapper; |
||||||
|
import com.ccic.safeliab.entity.*; |
||||||
|
import com.ccic.safeliab.support.BaseServiceImpl; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Service |
||||||
|
@Transactional |
||||||
|
public class PaperQuestionServiceImpl extends BaseServiceImpl<PaperQuestionMapper, PaperQuestion> implements PaperQuestionService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int add(Long paperID, List<String> QuestionIds){ |
||||||
|
int number = 0; |
||||||
|
for(String QuestionId : QuestionIds){ |
||||||
|
number++; |
||||||
|
PaperQuestion paperQuestion = new PaperQuestion(); |
||||||
|
paperQuestion.setPaperId(paperID); |
||||||
|
paperQuestion.setQuestionId(Long.valueOf(QuestionId)); |
||||||
|
paperQuestion.setQuestionNumber(number); |
||||||
|
save(paperQuestion); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return number; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean delete(Long paperID){ |
||||||
|
return baseMapper.deletePaperALlQuestion(paperID); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int update(Long paperID, List<String> QuestionIds){ |
||||||
|
baseMapper.deletePaperALlQuestion(paperID); |
||||||
|
int number = 0; |
||||||
|
for(String QuestionId : QuestionIds){ |
||||||
|
number++; |
||||||
|
PaperQuestion paperQuestion = new PaperQuestion(); |
||||||
|
paperQuestion.setPaperId(paperID); |
||||||
|
paperQuestion.setQuestionId(Long.valueOf(QuestionId)); |
||||||
|
paperQuestion.setQuestionNumber(number); |
||||||
|
save(paperQuestion); |
||||||
|
|
||||||
|
} |
||||||
|
return number; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.ccic.safeliab.dao.PaperQuestionMapper"> |
||||||
|
<delete id="deletePaperALlQuestion"> |
||||||
|
DELETE FROM ex_paper_questions |
||||||
|
WHERE paper_id = #{id} |
||||||
|
</delete> |
||||||
|
</mapper> |
Loading…
Reference in new issue