wangwei hace 5 años
padre
commit
3a9b6f5765

+ 32 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -95,6 +95,7 @@ import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.ExamOrgPropertyCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamOrgSettingsCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.task.api.request.SyncExamReq;
@@ -1316,4 +1317,35 @@ public class ExamController extends ControllerSupport {
 		return map;
 	}
 
+	@ApiOperation(value = "是否可以微信作答", notes = "")
+	@GetMapping("weixinAnswerEnabled/{examId}")
+	public Boolean weixinAnswerEnabled(@PathVariable Long examId) {
+		User accessUser = getAccessUser();
+		OrgPropertyCacheBean orgConf = CacheHelper.getOrgProperty(accessUser.getRootOrgId(),
+				"WEIXIN_ANSWER_ENABLED");
+		StudentCacheBean student = CacheHelper.getStudent(accessUser.getUserId());
+		ExamOrgPropertyCacheBean examConf = CacheHelper.getExamOrgProperty(examId,
+				student.getOrgId(), "WEIXIN_ANSWER_ENABLED");
+
+		Object orgValue = orgConf.getValue();
+		String examValue = examConf.getValue();
+
+		if (!orgConf.getHasValue()) {
+			return false;
+		}
+		if (null == orgValue) {
+			return false;
+		}
+
+		if (StringUtils.isBlank(examValue)) {
+			return false;
+		}
+
+		if (StringUtil.isTrue(orgValue.toString()) && StringUtil.isTrue(examValue)) {
+			return true;
+		}
+
+		return false;
+	}
+
 }