| | |
| | | import com.gkhy.exam.common.api.CommonPage; |
| | | import com.gkhy.exam.common.constant.UserConstant; |
| | | import com.gkhy.exam.common.domain.entity.SysUser; |
| | | import com.gkhy.exam.common.enums.ApproveStatusEnum; |
| | | import com.gkhy.exam.common.enums.CodeTypeEnum; |
| | | import com.gkhy.exam.common.enums.UserTypeEnum; |
| | | import com.gkhy.exam.common.exception.ApiException; |
| | | import com.gkhy.exam.common.utils.PageUtils; |
| | | import com.gkhy.exam.common.utils.SecurityUtils; |
| | | import com.gkhy.exam.system.domain.ExCourse; |
| | | import com.gkhy.exam.system.domain.ExCoursePhase; |
| | | import com.gkhy.exam.system.mapper.ExCourseMapper; |
| | | import com.gkhy.exam.system.mapper.ExCoursePhaseMapper; |
| | | import com.gkhy.exam.system.mapper.ExPhaseStudentMapper; |
| | | import com.gkhy.exam.system.service.ExCoursePhaseService; |
| | |
| | | public class ExCoursePhaseServiceImpl extends ServiceImpl<ExCoursePhaseMapper, ExCoursePhase> implements ExCoursePhaseService { |
| | | @Autowired |
| | | private ExPhaseStudentMapper phaseStudentMapper; |
| | | @Autowired |
| | | private ExCourseMapper courseMapper; |
| | | |
| | | |
| | | |
| | |
| | | @Override |
| | | public int insertCoursePhase(ExCoursePhase coursePhase) { |
| | | checkUserAllowed(coursePhase); |
| | | checkCourseStatus(coursePhase); |
| | | if(!checkNameUnique(coursePhase)){ |
| | | throw new ApiException("批次名称已存在"); |
| | | } |
| | |
| | | @Override |
| | | public int updateCoursePhase(ExCoursePhase coursePhase) { |
| | | checkUserAllowed(coursePhase); |
| | | checkCourseStatus(coursePhase); |
| | | if(!checkNameUnique(coursePhase)){ |
| | | throw new ApiException("批次名称已存在"); |
| | | } |
| | |
| | | if(currentUser.getUserType().equals(UserTypeEnum.STUDENT.getCode())){ |
| | | throw new ApiException("没有权限操作"); |
| | | } |
| | | if(!currentUser.getCompanyId().equals(coursePhase.getCompanyId())){ |
| | | if(coursePhase.getCompanyId()!=null&&!currentUser.getCompanyId().equals(coursePhase.getCompanyId())){ |
| | | throw new ApiException("没有权限操作其他企业批次"); |
| | | } |
| | | int level=coursePhase.getLevel(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private void checkCourseStatus(ExCoursePhase coursePhase){ |
| | | Long courseId=coursePhase.getCourseId(); |
| | | ExCourse course= courseMapper.selectById(courseId); |
| | | if(course.getStatus().equals(UserConstant.DISENABLE)){ |
| | | throw new ApiException("课程已禁用,不能分配"); |
| | | } |
| | | if(!course.getState().equals(ApproveStatusEnum.APPROVED.getCode())){ |
| | | throw new ApiException("课程审批未通过,不能分配"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int deleteCoursePhaseById(Long phaseId) { |
| | | checkUserAllowed(baseMapper.selectById(phaseId)); |