ExamSongServiceImpl.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.keao.edu.user.service.impl;
  2. import com.keao.edu.auth.api.client.SysUserFeignService;
  3. import com.keao.edu.auth.api.entity.SysUser;
  4. import com.keao.edu.common.dal.BaseDAO;
  5. import com.keao.edu.common.exception.BizException;
  6. import com.keao.edu.common.page.PageInfo;
  7. import com.keao.edu.common.page.QueryInfo;
  8. import com.keao.edu.common.service.impl.BaseServiceImpl;
  9. import com.keao.edu.user.dao.ExamRegistrationDao;
  10. import com.keao.edu.user.dao.ExamSongDao;
  11. import com.keao.edu.user.entity.ExamSong;
  12. import com.keao.edu.user.page.ExamSongQueryInfo;
  13. import com.keao.edu.user.service.ExamSongService;
  14. import com.keao.edu.util.collection.MapUtil;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.stereotype.Service;
  18. import java.util.*;
  19. @Service
  20. public class ExamSongServiceImpl extends BaseServiceImpl<Integer, ExamSong> implements ExamSongService {
  21. @Autowired
  22. private ExamSongDao examSongDao;
  23. @Autowired
  24. private ExamRegistrationDao examRegistrationDao;
  25. @Autowired
  26. private SysUserFeignService sysUserFeignService;
  27. @Override
  28. public BaseDAO<Integer, ExamSong> getDAO() {
  29. return examSongDao;
  30. }
  31. @Override
  32. public long insert(ExamSong examSong) {
  33. if(StringUtils.isBlank(examSong.getSubjectList())){
  34. throw new BizException("请选择专业");
  35. }
  36. if(Objects.isNull(examSong.getType())){
  37. throw new BizException("请选择曲库类别");
  38. }
  39. // List<ExamSong> existsExamSongs = examSongDao.getWithLevelAndType(examSong.getTenantId(), examSong.getLevelList(), examSong.getType());
  40. // if(!CollectionUtils.isEmpty(existsExamSongs)){
  41. // throw new BizException("{}级别的{}已存在",examSong.getLevelList(), examSong.getType().getMsg());
  42. // }
  43. return super.insert(examSong);
  44. }
  45. @Override
  46. public PageInfo<ExamSong> queryPage(QueryInfo queryInfo) {
  47. PageInfo<ExamSong> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
  48. Map<String, Object> params = new HashMap<String, Object>();
  49. MapUtil.populateMap(params, queryInfo);
  50. List<ExamSong> dataList = new ArrayList<>();
  51. int count = this.findCount(params);
  52. if (count > 0) {
  53. pageInfo.setTotal(count);
  54. params.put("offset", pageInfo.getOffset());
  55. dataList = this.getDAO().queryPage(params);
  56. }
  57. pageInfo.setRows(dataList);
  58. return pageInfo;
  59. }
  60. @Override
  61. public List<ExamSong> getWithSubject(Integer subjectId) {
  62. if(Objects.isNull(subjectId)){
  63. throw new BizException("请选择专业");
  64. }
  65. return examSongDao.getWithSubject(subjectId);
  66. }
  67. @Override
  68. public PageInfo<ExamSong> querySongPage(ExamSongQueryInfo queryInfo) {
  69. PageInfo<ExamSong> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
  70. //获取学员所在机构
  71. SysUser sysUser = sysUserFeignService.queryUserInfo();
  72. List<Integer> tenantIds = examRegistrationDao.queryStudentTenantId(sysUser.getId());
  73. if(tenantIds == null || tenantIds.size() == 0){
  74. return pageInfo;
  75. }
  76. Map<String, Object> params = new HashMap<String, Object>();
  77. MapUtil.populateMap(params, queryInfo);
  78. // params.put("tenantIds",tenantIds);
  79. List<ExamSong> dataList = new ArrayList<>();
  80. int count = examSongDao.countSongPage(params);
  81. if (count > 0) {
  82. pageInfo.setTotal(count);
  83. params.put("offset", pageInfo.getOffset());
  84. dataList = examSongDao.querySongPage(params);
  85. }
  86. pageInfo.setRows(dataList);
  87. return pageInfo;
  88. }
  89. }