|
|
@@ -19,6 +19,7 @@ import com.njuzr.eaibackend.utils.PageMapperUtil;
|
|
|
import com.njuzr.eaibackend.vo.CourseVO;
|
|
|
import com.njuzr.eaibackend.vo.UserVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.bouncycastle.jcajce.provider.symmetric.TEA;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
@@ -29,6 +30,7 @@ import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.net.StandardSocketOptions;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
@@ -103,8 +105,25 @@ public class CourseServiceImpl implements CourseService {
|
|
|
wrapper.eq("course_id", courseQueryDTO.getCourseId());
|
|
|
}
|
|
|
|
|
|
- if (courseQueryDTO.getTeacherPid() != null) { // courseId直接判断是否相等
|
|
|
- wrapper.eq("teacher_portal_id", courseQueryDTO.getTeacherPid());
|
|
|
+ // 兼容两种id的查询方式
|
|
|
+ if(courseQueryDTO.getTeacherId() != null && courseQueryDTO.getTeacherPid() != null){
|
|
|
+ wrapper.and(wq -> wq
|
|
|
+ .eq(courseQueryDTO.getTeacherPid() != null,
|
|
|
+ "teacher_portal_id", courseQueryDTO.getTeacherPid())
|
|
|
+ .or()
|
|
|
+ .eq(courseQueryDTO.getTeacherId() != null,
|
|
|
+ "teacher_ids", courseQueryDTO.getTeacherId().toString())
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ if (courseQueryDTO.getTeacherPid() != null ) { // courseId直接判断是否相等
|
|
|
+ System.out.println(courseQueryDTO.getTeacherPid());
|
|
|
+ wrapper.eq("teacher_portal_id", courseQueryDTO.getTeacherPid());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(courseQueryDTO.getTeacherId() != null){
|
|
|
+ System.out.println(courseQueryDTO.getTeacherPid());
|
|
|
+ wrapper.eq("teacher_ids", courseQueryDTO.getTeacherId());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// if (courseQueryDTO.getTeacherId() != null) { // 模糊匹配teacherIds中是否包含这个字段
|
|
|
@@ -164,8 +183,8 @@ public class CourseServiceImpl implements CourseService {
|
|
|
|
|
|
if (targetCourse == null)
|
|
|
throw MyException.create(HttpStatus.BAD_REQUEST, "课程不存在");
|
|
|
-
|
|
|
- if (targetUser.getRole() != Role.ADMIN && !targetCourse.getTeacherIds().contains(String.valueOf(userId)))
|
|
|
+ // 兼容两种id的权限判断方式
|
|
|
+ if (targetUser.getRole() != Role.ADMIN && !Objects.equals(targetCourse.getTeacherPid(), targetUser.getPid()) && !targetCourse.getTeacherIds().contains(String.valueOf(userId)))
|
|
|
throw MyException.create(HttpStatus.BAD_REQUEST, "无权限更新");
|
|
|
|
|
|
Course opeCourse = convertToPO(courseUpdateDTO);
|