|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
import com.qmth.teachcloud.common.bean.dto.BasicCourseExportDto;
|
|
import com.qmth.teachcloud.common.bean.dto.BasicCourseExportDto;
|
|
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
@@ -23,9 +24,11 @@ import com.qmth.teachcloud.common.enums.RoleTypeEnum;
|
|
import com.qmth.teachcloud.common.mapper.BasicCourseMapper;
|
|
import com.qmth.teachcloud.common.mapper.BasicCourseMapper;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
|
+import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.dao.DataIntegrityViolationException;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -171,7 +174,31 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
List<BasicCourseParams> basicCourseParamsList = new ArrayList<>();
|
|
List<BasicCourseParams> basicCourseParamsList = new ArrayList<>();
|
|
basicCourseParamsList.add(basicCourseParams);
|
|
basicCourseParamsList.add(basicCourseParams);
|
|
BasicCourse editBasicCourse = this.editEntityHelp(basicCourseParamsList, sysUser).get(0);
|
|
BasicCourse editBasicCourse = this.editEntityHelp(basicCourseParamsList, sysUser).get(0);
|
|
- this.saveOrUpdate(editBasicCourse);
|
|
|
|
|
|
+ try {
|
|
|
|
+ this.saveOrUpdate(editBasicCourse);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ if (e instanceof DataIntegrityViolationException) {
|
|
|
|
+ String error = e.getCause().toString();
|
|
|
|
+ String tooLongColumn = error.substring(error.lastIndexOf("column") + 7);
|
|
|
|
+ tooLongColumn = tooLongColumn.substring(0, tooLongColumn.lastIndexOf("at") - 1);
|
|
|
|
+ tooLongColumn = tooLongColumn.replaceAll("'", "");
|
|
|
|
+ String columnName = "";
|
|
|
|
+ switch (tooLongColumn) {
|
|
|
|
+ case "name":
|
|
|
|
+ columnName = "基础课程名称";
|
|
|
|
+ break;
|
|
|
|
+ case "code":
|
|
|
|
+ columnName = "基础课程编号";
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ String content = SystemConstant.strNotNull(columnName) ? columnName : tooLongColumn;
|
|
|
|
+ throw ExceptionResultEnum.SQL_ERROR.exception("[" + content + "]超过长度限制");
|
|
|
|
+ } else if (e instanceof ApiException) {
|
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return editBasicCourse.getId();
|
|
return editBasicCourse.getId();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -385,7 +412,31 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
addBasicCourseParamsList.add(basicCourseParams);
|
|
addBasicCourseParamsList.add(basicCourseParams);
|
|
}
|
|
}
|
|
List<BasicCourse> editBasicCourse = this.editEntityHelp(addBasicCourseParamsList, sysUser);
|
|
List<BasicCourse> editBasicCourse = this.editEntityHelp(addBasicCourseParamsList, sysUser);
|
|
- this.saveOrUpdateBatch(editBasicCourse);
|
|
|
|
|
|
+ try {
|
|
|
|
+ this.saveOrUpdateBatch(editBasicCourse);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ if (e instanceof DataIntegrityViolationException) {
|
|
|
|
+ String error = e.getCause().toString();
|
|
|
|
+ String tooLongColumn = error.substring(error.lastIndexOf("column") + 7);
|
|
|
|
+ tooLongColumn = tooLongColumn.substring(0, tooLongColumn.lastIndexOf("at") - 1);
|
|
|
|
+ tooLongColumn = tooLongColumn.replaceAll("'", "");
|
|
|
|
+ String columnName = "";
|
|
|
|
+ switch (tooLongColumn) {
|
|
|
|
+ case "name":
|
|
|
|
+ columnName = "基础课程名称";
|
|
|
|
+ break;
|
|
|
|
+ case "code":
|
|
|
|
+ columnName = "基础课程编号";
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ String content = SystemConstant.strNotNull(columnName) ? columnName : tooLongColumn;
|
|
|
|
+ throw ExceptionResultEnum.SQL_ERROR.exception("[" + content + "]超过长度限制");
|
|
|
|
+ } else if (e instanceof ApiException) {
|
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return addBasicCourseParamsList;
|
|
return addBasicCourseParamsList;
|
|
}
|
|
}
|