UserPaperService.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package com.qxgmat.service;
  2. import com.github.pagehelper.Page;
  3. import com.nuliji.tools.AbstractService;
  4. import com.nuliji.tools.PageResult;
  5. import com.nuliji.tools.exception.ParameterException;
  6. import com.nuliji.tools.exception.SystemException;
  7. import com.qxgmat.data.constants.enums.QuestionType;
  8. import com.qxgmat.data.constants.enums.module.PaperModule;
  9. import com.qxgmat.data.constants.enums.module.QuestionModule;
  10. import com.qxgmat.data.constants.enums.status.DirectionStatus;
  11. import com.qxgmat.data.dao.UserPaperMapper;
  12. import com.qxgmat.data.dao.entity.UserPaper;
  13. import com.qxgmat.data.relation.UserPaperRelationMapper;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.stereotype.Service;
  17. import javax.annotation.Resource;
  18. import java.util.Collection;
  19. import java.util.List;
  20. @Service
  21. public class UserPaperService extends AbstractService {
  22. private static final Logger logger = LoggerFactory.getLogger(UserPaperService.class);
  23. @Resource
  24. private UserPaperMapper userPaperMapper;
  25. @Resource
  26. private UserPaperRelationMapper userPaperRelationMapper;
  27. public PageResult<UserPaper> list(int page, int size, Integer userId, PaperModule module, QuestionType type, String startTime, String endTime, String order, DirectionStatus direction){
  28. return new PageResult<>(null, 0);
  29. }
  30. public UserPaper add(UserPaper paper){
  31. int result = insert(userPaperMapper, paper);
  32. paper = one(userPaperMapper, paper.getId());
  33. if(paper == null){
  34. throw new SystemException("组卷添加失败");
  35. }
  36. return paper;
  37. }
  38. public UserPaper edit(UserPaper paper){
  39. UserPaper in = one(userPaperMapper, paper.getId());
  40. if(in == null){
  41. throw new ParameterException("组卷不存在");
  42. }
  43. int result = update(userPaperMapper, paper);
  44. return paper;
  45. }
  46. public boolean delete(Number id){
  47. UserPaper in = one(userPaperMapper, id);
  48. if(in == null){
  49. throw new ParameterException("组卷不存在");
  50. }
  51. int result = delete(userPaperMapper, id);
  52. return result > 0;
  53. }
  54. public UserPaper get(Number id){
  55. UserPaper in = one(userPaperMapper, id);
  56. if(in == null){
  57. throw new ParameterException("组卷不存在");
  58. }
  59. return in;
  60. }
  61. public Page<UserPaper> select(int page, int pageSize){
  62. return select(userPaperMapper, page, pageSize);
  63. }
  64. public List<UserPaper> select(Collection ids){
  65. return select(userPaperMapper, ids);
  66. }
  67. }