You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.5 KiB

package com.ccic.safeliab.service;
import com.ccic.safeliab.dao.ExamPaperMapper;
import com.ccic.safeliab.entity.*;
import com.ccic.safeliab.support.BaseServiceImpl;
import com.ccic.safeliab.vo.InsExamPaperVO;
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;
@Service
public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamPapers> implements ExamPaperService {
@Override
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);
int total = baseMapper.getListSize(
entity.getIndustryId(),
entity.getPaperName());
map.put("data", data);
map.put("total", total);
return map;
}
@Override
public boolean deleteExamPaperById(Long id) {
List<Long> ids = new ArrayList<>();
ids.add(id);
return deleteLogic(ids);
}
@Override
public boolean deleteExamPaperListByIds(List<Long> ids) {
return deleteLogic(ids);
}
@Override
@Transactional
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
@Transactional
public boolean batchUpdatePaperStatus(List<InsExamPaperVO> vos) {
boolean flag = false;
for(InsExamPaperVO vo : vos){
flag = updatePaperStatus(vo);
}
return flag;
}
@Override
public int add(List<InsExamPaperVO> vo) {
return 0;
}
@Override
public boolean update(InsExamPaperVO vo) {
return true;
}
@Override
public ExamPapers getDetail(String id){
return baseMapper.getDetail(Long.valueOf(id));
}
@Override
public List<QuestionCategories> getRandomQuestions(ExamPapers entity) {
return baseMapper.getRandomQuestions(entity.getIndustryId(), entity.getQuestionCount());
}
}