|
@@ -1,9 +1,11 @@
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
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.qmth.distributed.print.business.bean.params.TeachClazzParams;
|
|
import com.qmth.distributed.print.business.bean.result.TeachClazzResult;
|
|
import com.qmth.distributed.print.business.bean.result.TeachClazzResult;
|
|
import com.qmth.distributed.print.business.entity.TeachClazz;
|
|
import com.qmth.distributed.print.business.entity.TeachClazz;
|
|
import com.qmth.distributed.print.business.entity.TeachCourse;
|
|
import com.qmth.distributed.print.business.entity.TeachCourse;
|
|
@@ -52,39 +54,50 @@ public class TeachClazzServiceImpl extends ServiceImpl<TeachClazzMapper,TeachCla
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
- public Boolean createTeachClazz(String teachClazzName, Long teachCourseId, SysUser requestUser) {
|
|
|
|
|
|
+ public Boolean editTeachClazz(TeachClazzParams teachClazzParams, SysUser requestUser) {
|
|
|
|
+ Long id = teachClazzParams.getId();
|
|
|
|
+ Long teachCourseId = teachClazzParams.getTeachCourseId();
|
|
|
|
+ String teachClazzName = teachClazzParams.getTeachClazzName();
|
|
|
|
+ boolean result;
|
|
|
|
+
|
|
if (SystemConstant.isOneNull(teachClazzName, teachCourseId)) {
|
|
if (SystemConstant.isOneNull(teachClazzName, teachCourseId)) {
|
|
throw ExceptionResultEnum.ERROR.exception("参数异常");
|
|
throw ExceptionResultEnum.ERROR.exception("参数异常");
|
|
}
|
|
}
|
|
- TeachCourse teachCourse = teachCourseService.getById(teachCourseId);
|
|
|
|
- if (Objects.isNull(teachCourse)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("教学课程不存在");
|
|
|
|
- }
|
|
|
|
- if (!Objects.equals(teachCourse.getUserId(), requestUser.getId())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("用户身份信息异常");
|
|
|
|
- }
|
|
|
|
|
|
+ if (SystemConstant.longNotNull(id)){
|
|
|
|
+ // 重命名课程
|
|
|
|
+ result = this.update(new UpdateWrapper<TeachClazz>().lambda().eq(TeachClazz::getId,id).set(TeachClazz::getTeachClazzName,teachClazzName));
|
|
|
|
+ }else {
|
|
|
|
+ TeachCourse teachCourse = teachCourseService.getById(teachCourseId);
|
|
|
|
+ if (Objects.isNull(teachCourse)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("教学课程不存在");
|
|
|
|
+ }
|
|
|
|
+ if (!Objects.equals(teachCourse.getUserId(), requestUser.getId())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("用户身份信息异常");
|
|
|
|
+ }
|
|
|
|
|
|
- Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
- TeachClazz check = this.getOne(new QueryWrapper<TeachClazz>()
|
|
|
|
- .lambda()
|
|
|
|
- .eq(TeachClazz::getSchoolId, schoolId)
|
|
|
|
- .eq(TeachClazz::getTeachClazzName, teachClazzName)
|
|
|
|
- .eq(TeachClazz::getTeachCourseId, teachCourseId));
|
|
|
|
|
|
+ Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
+ TeachClazz check = this.getOne(new QueryWrapper<TeachClazz>()
|
|
|
|
+ .lambda()
|
|
|
|
+ .eq(TeachClazz::getSchoolId, schoolId)
|
|
|
|
+ .eq(TeachClazz::getTeachClazzName, teachClazzName)
|
|
|
|
+ .eq(TeachClazz::getTeachCourseId, teachCourseId));
|
|
|
|
|
|
- if (Objects.nonNull(check)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("教学课程【" + check.getTeachCourseName() + "】中已存在班级名称为【" + check.getTeachClazzName() + "】的班级");
|
|
|
|
- }
|
|
|
|
|
|
+ if (Objects.nonNull(check)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("教学课程【" + check.getTeachCourseName() + "】中已存在班级名称为【" + check.getTeachClazzName() + "】的班级");
|
|
|
|
+ }
|
|
|
|
|
|
- TeachClazz teachClazz = new TeachClazz();
|
|
|
|
- teachClazz.setSchoolId(schoolId);
|
|
|
|
- teachClazz.setTeachClazzName(teachClazzName);
|
|
|
|
- teachClazz.setUserId(teachCourse.getUserId());
|
|
|
|
- teachClazz.setUserName(teachCourse.getUserName());
|
|
|
|
- teachClazz.setTeachCourseId(teachCourseId);
|
|
|
|
- teachClazz.setTeachCourseCode(teachCourse.getBasicCourseCode());
|
|
|
|
- teachClazz.setTeachCourseName(teachCourse.getBasicCourseName());
|
|
|
|
- teachClazz.insertInfo(requestUser.getId());
|
|
|
|
- return this.save(teachClazz);
|
|
|
|
|
|
+ TeachClazz teachClazz = new TeachClazz();
|
|
|
|
+ teachClazz.setSchoolId(schoolId);
|
|
|
|
+ teachClazz.setTeachClazzName(teachClazzName);
|
|
|
|
+ teachClazz.setUserId(teachCourse.getUserId());
|
|
|
|
+ teachClazz.setUserName(teachCourse.getUserName());
|
|
|
|
+ teachClazz.setTeachCourseId(teachCourseId);
|
|
|
|
+ teachClazz.setTeachCourseCode(teachCourse.getBasicCourseCode());
|
|
|
|
+ teachClazz.setTeachCourseName(teachCourse.getBasicCourseName());
|
|
|
|
+ teachClazz.insertInfo(requestUser.getId());
|
|
|
|
+ result = this.save(teachClazz);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|