| | |
| | | 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.common.utils.StringUtils; |
| | | import com.gkhy.exam.system.domain.ExCourse; |
| | | import com.gkhy.exam.system.mapper.ExCourseChapterMapper; |
| | | import com.gkhy.exam.system.mapper.ExCourseMapper; |
| | |
| | | course.setState(ApproveStatusEnum.APPROVED.getCode()); |
| | | course.setPrivatize(PrivatizeEnum.PUBLIC.getCode()); |
| | | }else{ |
| | | course.setState(ApproveStatusEnum.APPROVING.getCode()); |
| | | course.setState(ApproveStatusEnum.TEMPORARY.getCode()); |
| | | } |
| | | int row =baseMapper.insert(course); |
| | | if(row<1){ |
| | |
| | | throw new ApiException("没有权限操作其他企业课程"); |
| | | } |
| | | if(course.getId()!=null){ |
| | | if(course.getState().equals(ApproveStatusEnum.APPROVING.getCode())){ |
| | | throw new ApiException("课程待审批状态不能再操作"); |
| | | } |
| | | if(course.getState().equals(ApproveStatusEnum.APPROVED.getCode())){ |
| | | throw new ApiException("已审批的课程不能再修改"); |
| | | throw new ApiException("已审批的课程不能再操作"); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public boolean checkNameUnique(ExCourse course) { |
| | | SysUser user=SecurityUtils.getLoginUser().getUser(); |
| | | Long courseId=course.getId()==null?-1L:course.getId(); |
| | | ExCourse cou= baseMapper.checkNameUnique(course.getName()); |
| | | ExCourse cou= baseMapper.checkNameUnique(course.getName(),user.getCompanyId()); |
| | | if(cou!=null&&cou.getId().longValue()!=courseId.longValue()){ |
| | | return UserConstant.NOT_UNIQUE; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public int doApprove(ExCourse course) { |
| | | ExCourse existCourse=baseMapper.selectById(course.getId()); |
| | | checkUserAllowed(existCourse); |
| | | SysUser currentUser= SecurityUtils.getLoginUser().getUser(); |
| | | ExCourse dbCourse=getById(course.getId()); |
| | | if(!currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())){ |
| | | if(currentUser.getUserType().equals(UserTypeEnum.STUDENT.getCode())){ |
| | | throw new ApiException("没有权限操作"); |
| | | } |
| | | if(!currentUser.getCompanyId().equals(dbCourse.getCompanyId())){ |
| | | throw new ApiException("没有权限操作其他企业课程"); |
| | | } |
| | | if(dbCourse.getState().equals(ApproveStatusEnum.APPROVED.getCode())){ |
| | | throw new ApiException("已审批的课程不能再操作"); |
| | | } |
| | | } |
| | | if(StringUtils.isBlank(course.getMessage())){ |
| | | course.setMessage(""); |
| | | } |
| | | int row=baseMapper.updateById(course); |
| | | if(row<1){ |
| | | throw new ApiException("审批失败"); |