diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/UserType.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/UserType.java index 9ca70d3..5c99312 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/UserType.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/UserType.java @@ -34,4 +34,8 @@ public enum UserType { } throw new RuntimeException("'UserType' not found By " + str); } + + public String getName() { + return this.userType; + } } diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/WebServiceImpl.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/WebServiceImpl.java index 1d3197d..a8cec5e 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/WebServiceImpl.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/WebServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import org.dromara.common.core.domain.model.LoginUser; +import org.dromara.common.core.enums.UserType; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.scale.constant.ScaleDimensionEnum; @@ -77,6 +78,10 @@ public class WebServiceImpl implements IWebService { LoginUser loginUser = getLoginUser(); Long userId = loginUser.getUserId(); Long deptId = loginUser.getDeptId(); + String userType = loginUser.getUserType(); + if (!UserType.STUDENT.getName().equals(userType)) { + throw new ServiceException("只有学生账户才能测评"); + } SysScalePublishVo sysScalePublishVo = null; if (deptId != null) { //先查询直接用户组的发布 @@ -130,6 +135,11 @@ public class WebServiceImpl implements IWebService { @Override public Boolean newRecord(Long recordId) { + LoginUser loginUser = getLoginUser(); + String userType = loginUser.getUserType(); + if (!UserType.STUDENT.getName().equals(userType)) { + throw new ServiceException("只有学生账户才能测评"); + } //LoginUser loginUser = getLoginUser(); SysEvaluationRecord evaluationRecord = recordMapper.selectById(recordId); if (evaluationRecord == null) { @@ -148,6 +158,11 @@ public class WebServiceImpl implements IWebService { @Transactional(rollbackFor = Exception.class) @Override public Map submitAnswer(SubmitAnswerBo bo) { + LoginUser loginUser = getLoginUser(); + String userType = loginUser.getUserType(); + if (!UserType.STUDENT.getName().equals(userType)) { + throw new ServiceException("只有学生账户才能测评"); + } boolean allowQueryResult = true; Long scaleId = bo.getScaleId(); Map> answerMapByQuestion = scaleAnswerService.getScaleAnswerMap(scaleId); diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml index a956da7..dc23567 100644 --- a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml +++ b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml @@ -1,9 +1,8 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -