kongzy
2024-09-14 f0f00e9ba8a755e4317e029d73b69a92ad9f9df1
exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExExamRecordServiceImpl.java
@@ -46,6 +46,8 @@
    @Override
    public int insertExamRecord(ExExamRecord examRecord) {
        checkUserAllowed(examRecord);
        examRecord.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId());
        examRecord.setCreateBy(SecurityUtils.getUsername());
        int row=baseMapper.insert(examRecord);
        if(row<1){
            throw new ApiException("新增登记记录失败");
@@ -56,6 +58,7 @@
    @Override
    public int updateExamRecord(ExExamRecord examRecord) {
        checkUserAllowed(examRecord);
        examRecord.setUpdateBy(SecurityUtils.getUsername());
        int row=baseMapper.updateById(examRecord);
        if(row<1){
            throw new ApiException("更新登记记录失败");
@@ -72,12 +75,12 @@
    public void checkUserAllowed(ExExamRecord examRecord) {
        SysUser currentUser= SecurityUtils.getLoginUser().getUser();
        if(currentUser.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())){
            return;
            throw new ApiException("管理员没有权限操作");
        }
        if(currentUser.getUserType().equals(UserTypeEnum.STUDENT.getCode())){
            throw new ApiException("没有权限操作");
        }
        if(!currentUser.getCompanyId().equals(examRecord.getCompanyId())){
        if(examRecord.getCompanyId()!=null&&!currentUser.getCompanyId().equals(examRecord.getCompanyId())){
            throw new ApiException("没有权限操作其他企业登记记录");
        }
    }