package com.keao.edu.user.service.impl; import com.keao.edu.auth.api.client.SysUserFeignService; import com.keao.edu.auth.api.entity.SysUser; import com.keao.edu.common.dal.BaseDAO; import com.keao.edu.common.exception.BizException; import com.keao.edu.common.page.PageInfo; import com.keao.edu.common.page.QueryInfo; import com.keao.edu.common.service.impl.BaseServiceImpl; import com.keao.edu.user.dao.ExamRegistrationDao; import com.keao.edu.user.dao.ExamSongDao; import com.keao.edu.user.entity.ExamSong; import com.keao.edu.user.page.ExamSongQueryInfo; import com.keao.edu.user.service.ExamSongService; import com.keao.edu.util.collection.MapUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @Service public class ExamSongServiceImpl extends BaseServiceImpl implements ExamSongService { @Autowired private ExamSongDao examSongDao; @Autowired private ExamRegistrationDao examRegistrationDao; @Autowired private SysUserFeignService sysUserFeignService; @Override public BaseDAO getDAO() { return examSongDao; } @Override public long insert(ExamSong examSong) { if(StringUtils.isBlank(examSong.getSubjectList())){ throw new BizException("请选择专业"); } if(Objects.isNull(examSong.getType())){ throw new BizException("请选择曲库类别"); } // List existsExamSongs = examSongDao.getWithLevelAndType(examSong.getTenantId(), examSong.getLevelList(), examSong.getType()); // if(!CollectionUtils.isEmpty(existsExamSongs)){ // throw new BizException("{}级别的{}已存在",examSong.getLevelList(), examSong.getType().getMsg()); // } return super.insert(examSong); } @Override public PageInfo queryPage(QueryInfo queryInfo) { PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows()); Map params = new HashMap(); MapUtil.populateMap(params, queryInfo); List dataList = new ArrayList<>(); int count = this.findCount(params); if (count > 0) { pageInfo.setTotal(count); params.put("offset", pageInfo.getOffset()); dataList = this.getDAO().queryPage(params); } pageInfo.setRows(dataList); return pageInfo; } @Override public List getWithSubject(Integer subjectId) { if(Objects.isNull(subjectId)){ throw new BizException("请选择专业"); } return examSongDao.getWithSubject(subjectId); } @Override public PageInfo querySongPage(ExamSongQueryInfo queryInfo) { PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows()); //获取学员所在机构 SysUser sysUser = sysUserFeignService.queryUserInfo(); List tenantIds = examRegistrationDao.queryStudentTenantId(sysUser.getId()); if(tenantIds == null || tenantIds.size() == 0){ return pageInfo; } Map params = new HashMap(); MapUtil.populateMap(params, queryInfo); // params.put("tenantIds",tenantIds); List dataList = new ArrayList<>(); int count = examSongDao.countSongPage(params); if (count > 0) { pageInfo.setTotal(count); params.put("offset", pageInfo.getOffset()); dataList = examSongDao.querySongPage(params); } pageInfo.setRows(dataList); return pageInfo; } }