wangliang %!s(int64=4) %!d(string=hai) anos
pai
achega
163932e564

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java

@@ -680,7 +680,7 @@ public class TBUserController {
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length())
                         .replaceAll("'", "");
-                if (Objects.nonNull(columnStr) && columnStr.contains("#23000")) {
+                if (Objects.nonNull(columnStr) && columnStr.contains(SystemConstant.SQL_UNIQUE_ERROR)) {
                     throw new BusinessException(
                             "机构id[" + orgId + "]下的" + FieldUniqueEnum.org_login_name.getCode() + "数据不允许重复插入");
                 } else {

+ 2 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -298,6 +298,8 @@ public class SystemConstant {
     public static final String studentOauth = "student:oauth:cache::";
 
     public static final String configCache = "config:cache::";
+
+    public static final String SQL_UNIQUE_ERROR = "#23000";
     //    /**
     //     * ehcache配置
     //     */

+ 8 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -6,6 +6,7 @@ import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
+import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dao.TEExamActivityMapper;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.response.MonitorStreamDto;
@@ -332,8 +333,13 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length())
                         .replaceAll("'", "");
-                throw new BusinessException("机构id[" + teExamActivityList.get(0).getExamId() + "]下的" + FieldUniqueEnum
-                        .convertToCode(columnStr) + "数据不允许重复插入");
+                if (Objects.nonNull(columnStr) && columnStr.contains(SystemConstant.SQL_UNIQUE_ERROR)) {
+                    throw new BusinessException(
+                            "机构id[" + teExamActivityList.get(0).getExamId() + "]下的" + FieldUniqueEnum.t_e_exam_activity_examId_code_Idx.getCode() + "数据不允许重复插入");
+                } else {
+                    throw new BusinessException(
+                            "机构id[" + teExamActivityList.get(0).getExamId() + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
+                }
             } else if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
             } else {