|
|
|
@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
@ -21,44 +20,36 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP |
|
|
|
|
private PaperQuestionService paperQuestionService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> getList(int page,int num, ExamPapers entity) { |
|
|
|
|
public Map<String, Object> getList(int page, int num, ExamPapers entity) { |
|
|
|
|
int offset = (page - 1) * num; |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
List<ExamPapers> data = baseMapper.getList( |
|
|
|
|
entity.getIndustryId(), |
|
|
|
|
entity.getPaperName(), |
|
|
|
|
offset, |
|
|
|
|
num); |
|
|
|
|
num |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
int total = baseMapper.getListSize( |
|
|
|
|
int total = baseMapper.getListSize( |
|
|
|
|
entity.getIndustryId(), |
|
|
|
|
entity.getPaperName()); |
|
|
|
|
entity.getPaperName() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
map.put("data", data); |
|
|
|
|
map.put("total", total); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean deleteExamPaperById(Long id) { |
|
|
|
|
public boolean delExamPaper(List<Long> ids) { |
|
|
|
|
boolean flag = false; |
|
|
|
|
List<Long> ids = new ArrayList<>(); |
|
|
|
|
ids.add(id); |
|
|
|
|
flag = deleteLogic(ids); |
|
|
|
|
|
|
|
|
|
if(flag){ |
|
|
|
|
flag = paperQuestionService.delete(id); |
|
|
|
|
} |
|
|
|
|
return flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean deleteExamPaperListByIds(List<Long> ids) { |
|
|
|
|
boolean flag = false; |
|
|
|
|
flag = deleteLogic(ids); |
|
|
|
|
if(flag){ |
|
|
|
|
for(Long id : ids){ |
|
|
|
|
if (flag) { |
|
|
|
|
for (Long id : ids) { |
|
|
|
|
flag = paperQuestionService.delete(id); |
|
|
|
|
if(!flag){ |
|
|
|
|
if (!flag) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -67,61 +58,66 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean updatePaperStatus(InsExamPaperVO vo) { |
|
|
|
|
ExamPapers entity = baseMapper.getDetail(vo.getId()); |
|
|
|
|
if(vo.getPaperStatus()==0){ |
|
|
|
|
entity.setPaperStatus(1); |
|
|
|
|
}else if(vo.getPaperStatus()==1){ |
|
|
|
|
entity.setPaperStatus(0); |
|
|
|
|
} |
|
|
|
|
return updateById(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean batchUpdatePaperStatus(List<InsExamPaperVO> vos) { |
|
|
|
|
public boolean upPaperStatus(InsExamPaperVO vo) { |
|
|
|
|
boolean flag = false; |
|
|
|
|
for(InsExamPaperVO vo : vos){ |
|
|
|
|
flag = updatePaperStatus(vo); |
|
|
|
|
for (Long id : vo.getIds()) { |
|
|
|
|
ExamPapers entity = baseMapper.getExamPaperDetail(id); |
|
|
|
|
entity.setPaperStatus(vo.getPaperStatus()); |
|
|
|
|
flag = updateById(entity); |
|
|
|
|
if (!flag) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> getDetail(String id){ |
|
|
|
|
public Map<String, Object> getExamPaperDetail(String id) { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
ExamPapers head = baseMapper.getDetail(Long.valueOf(id)); |
|
|
|
|
ExamPapers head = baseMapper.getExamPaperDetail(Long.valueOf(id)); |
|
|
|
|
List<QuestionCategories> detail = baseMapper.getQuestions(Long.valueOf(id)); |
|
|
|
|
|
|
|
|
|
map.put("head", head); |
|
|
|
|
map.put("data", detail); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<QuestionCategories> getRandomQuestions(ExamPapers entity) { |
|
|
|
|
public List<QuestionCategories> getRandomQuestions(ExamPapers entity) { |
|
|
|
|
return baseMapper.getRandomQuestions(entity.getIndustryId(), entity.getQuestionCount()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public ExamPapers add(InsExamPaperVO vo){ |
|
|
|
|
public boolean addExamPaper(InsExamPaperVO vo) { |
|
|
|
|
// 试卷
|
|
|
|
|
ExamPapers examPapers = new ExamPapers(); |
|
|
|
|
examPapers.setPaperName(vo.getPaperName()); |
|
|
|
|
examPapers.setIndustryId(vo.getIndustryId()); |
|
|
|
|
examPapers.setQuestionCount(vo.getQuestionCount()); |
|
|
|
|
examPapers.setTotalScore(vo.getTotalScore()); |
|
|
|
|
examPapers.setExamDuration(vo.getExamDuration()); |
|
|
|
|
examPapers.setDurationType(vo.getDurationType()); |
|
|
|
|
examPapers.setPaperContent(vo.getPaperContent()); |
|
|
|
|
boolean flag = false; |
|
|
|
|
ExamPapers examPapers = voToEntity(vo); |
|
|
|
|
examPapers.setPaperStatus(1); |
|
|
|
|
save(examPapers); |
|
|
|
|
return examPapers; |
|
|
|
|
flag = save(examPapers); |
|
|
|
|
|
|
|
|
|
if (flag) { |
|
|
|
|
flag = paperQuestionService.addPaperQuestion(examPapers.getId(), vo.getQuestionIds()); |
|
|
|
|
} |
|
|
|
|
return flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public ExamPapers update(InsExamPaperVO vo) { |
|
|
|
|
public boolean editExamPaper(InsExamPaperVO vo) { |
|
|
|
|
// 试卷
|
|
|
|
|
ExamPapers examPapers = new ExamPapers(); |
|
|
|
|
boolean flag = false; |
|
|
|
|
ExamPapers examPapers = voToEntity(vo); |
|
|
|
|
examPapers.setId(vo.getId()); |
|
|
|
|
flag = updateById(examPapers); |
|
|
|
|
|
|
|
|
|
if (flag) { |
|
|
|
|
flag = paperQuestionService.editPaperQuestion(examPapers.getId(), vo.getQuestionIds()); |
|
|
|
|
} |
|
|
|
|
return flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// vo转entity
|
|
|
|
|
private ExamPapers voToEntity(InsExamPaperVO vo) { |
|
|
|
|
ExamPapers examPapers = new ExamPapers(); |
|
|
|
|
examPapers.setPaperName(vo.getPaperName()); |
|
|
|
|
examPapers.setIndustryId(vo.getIndustryId()); |
|
|
|
|
examPapers.setQuestionCount(vo.getQuestionCount()); |
|
|
|
@ -129,7 +125,6 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP |
|
|
|
|
examPapers.setExamDuration(vo.getExamDuration()); |
|
|
|
|
examPapers.setDurationType(vo.getDurationType()); |
|
|
|
|
examPapers.setPaperContent(vo.getPaperContent()); |
|
|
|
|
updateById(examPapers); |
|
|
|
|
return examPapers; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |