|
@@ -51,50 +51,21 @@ public class BasicUserCourseServiceImpl extends ServiceImpl<BasicUserCourseMappe
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void updateByCourseIdAndClazzList(Long courseId, List<String> clazzList, SysUser sysUser) {
|
|
|
- List<BasicUserCourse> basicUserCourseList = this.list(new QueryWrapper<BasicUserCourse>().lambda()
|
|
|
- .eq(BasicUserCourse::getCourseId, courseId));
|
|
|
-
|
|
|
- // 寻找要删除的目标(1.班级不为空 2.老班级不被新班级集合包含)
|
|
|
- List<BasicUserCourse> willUpdateList = new ArrayList<>();
|
|
|
- List<Long> willDeleteIdList = new ArrayList<>();
|
|
|
- List<String> willAddClazz = new ArrayList<>(clazzList);
|
|
|
+ public void updateByCourseIdAndClazzList(Long courseId, List<String> clazzList, SysUser sysUser, Long orgId) {
|
|
|
List<BasicUserCourse> willAddList = new ArrayList<>();
|
|
|
|
|
|
- for (BasicUserCourse old : basicUserCourseList) {
|
|
|
- String clazz = old.getClazz();
|
|
|
- Long id = old.getId();
|
|
|
- if (SystemConstant.strNotNull(clazz)){
|
|
|
- if (clazzList.contains(clazz)){
|
|
|
- // 要更新时间的旧关系
|
|
|
- old.setOrgId(sysUser.getOrgId());
|
|
|
- old.setUpdateId(sysUser.getUpdateId());
|
|
|
- willUpdateList.add(old);
|
|
|
- willAddClazz.remove(clazz);
|
|
|
- }else {
|
|
|
- // 要被删除的旧关系
|
|
|
- willDeleteIdList.add(id);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 删掉全部
|
|
|
- if (willDeleteIdList.size() > 0) {
|
|
|
- this.removeByIds(willDeleteIdList);
|
|
|
- }
|
|
|
-
|
|
|
- // 更新
|
|
|
- this.updateBatchById(willUpdateList);
|
|
|
+ // 删除原有的全部
|
|
|
+ this.remove(new QueryWrapper<BasicUserCourse>().lambda().eq(BasicUserCourse::getCourseId,courseId).gt(BasicUserCourse::getId,0));
|
|
|
|
|
|
// 新增
|
|
|
- for (String addClazz : willAddClazz) {
|
|
|
+ for (String clazz : clazzList) {
|
|
|
BasicUserCourse basicUserCourse = new BasicUserCourse();
|
|
|
basicUserCourse.setId(SystemConstant.getDbUuid());
|
|
|
basicUserCourse.setSchoolId(sysUser.getSchoolId());
|
|
|
- basicUserCourse.setOrgId(sysUser.getOrgId());
|
|
|
+ basicUserCourse.setOrgId(orgId);
|
|
|
basicUserCourse.setCourseId(courseId);
|
|
|
- basicUserCourse.setClazz(addClazz);
|
|
|
- basicUserCourse.setCreateId(sysUser.getId());
|
|
|
+ basicUserCourse.setClazz(clazz);
|
|
|
+ basicUserCourse.setUpdateId(sysUser.getId());
|
|
|
willAddList.add(basicUserCourse);
|
|
|
}
|
|
|
this.saveBatch(willAddList);
|