package com.qxgmat.service; import com.github.pagehelper.Page; import com.nuliji.tools.AbstractService; import com.nuliji.tools.PageResult; import com.nuliji.tools.exception.ParameterException; import com.nuliji.tools.exception.SystemException; import com.qxgmat.data.constants.enums.QuestionType; import com.qxgmat.data.constants.enums.module.PaperModule; import com.qxgmat.data.constants.enums.module.QuestionModule; import com.qxgmat.data.constants.enums.status.DirectionStatus; import com.qxgmat.data.dao.UserPaperMapper; import com.qxgmat.data.dao.entity.UserPaper; import com.qxgmat.data.relation.UserPaperRelationMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Collection; import java.util.List; @Service public class UserPaperService extends AbstractService { private static final Logger logger = LoggerFactory.getLogger(UserPaperService.class); @Resource private UserPaperMapper userPaperMapper; @Resource private UserPaperRelationMapper userPaperRelationMapper; public PageResult list(int page, int size, Integer userId, PaperModule module, QuestionType type, String startTime, String endTime, String order, DirectionStatus direction){ return new PageResult<>(null, 0); } public UserPaper add(UserPaper paper){ int result = insert(userPaperMapper, paper); paper = one(userPaperMapper, paper.getId()); if(paper == null){ throw new SystemException("组卷添加失败"); } return paper; } public UserPaper edit(UserPaper paper){ UserPaper in = one(userPaperMapper, paper.getId()); if(in == null){ throw new ParameterException("组卷不存在"); } int result = update(userPaperMapper, paper); return paper; } public boolean delete(Number id){ UserPaper in = one(userPaperMapper, id); if(in == null){ throw new ParameterException("组卷不存在"); } int result = delete(userPaperMapper, id); return result > 0; } public UserPaper get(Number id){ UserPaper in = one(userPaperMapper, id); if(in == null){ throw new ParameterException("组卷不存在"); } return in; } public Page select(int page, int pageSize){ return select(userPaperMapper, page, pageSize); } public List select(Collection ids){ return select(userPaperMapper, ids); } }