kongzy
2024-09-14 f0f00e9ba8a755e4317e029d73b69a92ad9f9df1
exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExCourseServiceImpl.java
@@ -10,6 +10,7 @@
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;
@@ -78,7 +79,7 @@
            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){
@@ -112,8 +113,11 @@
            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("已审批的课程不能再操作");
            }
        }
    }
@@ -139,8 +143,9 @@
    @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;
        }
@@ -149,8 +154,22 @@
    @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("审批失败");