courseObjectivesFList);
}
diff --git a/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentKnowMapper.java b/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentKnowMapper.java
index 98d2b90..1222d1a 100644
--- a/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentKnowMapper.java
+++ b/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentKnowMapper.java
@@ -3,6 +3,8 @@ package com.teaching.backend.mapper.courses;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.courses.ObjectiveContentKnow;
+import java.util.List;
+
/**
*
* Mapper 接口
@@ -13,4 +15,5 @@ import com.teaching.backend.model.entity.courses.ObjectiveContentKnow;
*/
public interface ObjectiveContentKnowMapper extends BaseMapper {
+ void insertBatchSomeColumn(List objectiveContentKnowList);
}
diff --git a/src/main/java/com/teaching/backend/mapper/courses/StudentCoursesMapper.java b/src/main/java/com/teaching/backend/mapper/courses/StudentCoursesMapper.java
index ea9cb28..b6042f9 100644
--- a/src/main/java/com/teaching/backend/mapper/courses/StudentCoursesMapper.java
+++ b/src/main/java/com/teaching/backend/mapper/courses/StudentCoursesMapper.java
@@ -1,8 +1,11 @@
package com.teaching.backend.mapper.courses;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.teaching.backend.model.entity.courses.ObjectiveContentKnow;
import com.teaching.backend.model.entity.courses.StudentCourses;
+import java.util.List;
+
/**
*
* Mapper 接口
@@ -13,4 +16,5 @@ import com.teaching.backend.model.entity.courses.StudentCourses;
*/
public interface StudentCoursesMapper extends BaseMapper {
+ void insertBatchSomeColumn(List studentCoursesList);
}
diff --git a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java
index b49a21c..fb91204 100644
--- a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java
+++ b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java
@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -24,8 +27,13 @@ public class ObjectiveContentKnow implements Serializable {
private static final long serialVersionUID = 1L;
- @TableId(value = "id", type = IdType.ASSIGN_UUID)
- private String id;
+ @ApiModelProperty(value = "雪花算法生成的主键")
+ @JsonFormat(shape = JsonFormat.Shape.STRING)//此句为问题关键相当于吧Long转换为String
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ private Long id;
+
+// @TableId(value = "id", type = IdType.NONE)
+// private Long id;
/**
* 分项目标或内容 的 id
diff --git a/src/main/java/com/teaching/backend/model/entity/courses/StudentCourses.java b/src/main/java/com/teaching/backend/model/entity/courses/StudentCourses.java
index acc0c54..b3125f7 100644
--- a/src/main/java/com/teaching/backend/model/entity/courses/StudentCourses.java
+++ b/src/main/java/com/teaching/backend/model/entity/courses/StudentCourses.java
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -24,8 +26,9 @@ public class StudentCourses implements Serializable {
private static final long serialVersionUID = 1L;
- @TableId(value = "id", type = IdType.ASSIGN_UUID)
- private String id;
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @JsonFormat(shape = JsonFormat.Shape.STRING)//此句为问题关键相当于吧Long转换为String
+ private Long id;
/**
* 学生的username
diff --git a/src/main/java/com/teaching/backend/model/query/CourseQuery.java b/src/main/java/com/teaching/backend/model/query/CourseQuery.java
index d091993..13dbc8b 100644
--- a/src/main/java/com/teaching/backend/model/query/CourseQuery.java
+++ b/src/main/java/com/teaching/backend/model/query/CourseQuery.java
@@ -14,4 +14,16 @@ public class CourseQuery extends PageQuery {
@ApiModelProperty(value = "用户的username",required = true)
private String username;
+
+ @ApiModelProperty("课程任课教师")
+ private String teacher;
+
+ @ApiModelProperty("课程类别")
+ private String category;
+
+ @ApiModelProperty("课程性质")
+ private String nature;
+
+ @ApiModelProperty("课程考核类型")
+ private String assessmenttype;
}
diff --git a/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java b/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java
new file mode 100644
index 0000000..66a317e
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java
@@ -0,0 +1,22 @@
+package com.teaching.backend.model.vo.courses;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(description = "教师具体信息VO实体")
+public class TeacherInfVO {
+
+ /**
+ * 教师username
+ */
+ @ApiModelProperty("教师username")
+ private String username;
+ /**
+ * 课程封面
+ */
+ @ApiModelProperty("教师name")
+ private String name;
+}
diff --git a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java
index c69b060..2737450 100644
--- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java
+++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java
@@ -36,4 +36,6 @@ public interface ICoursesService extends IService {
void updateCourse(CoursesDTO coursesDTO);
void down(HttpServletResponse response, String id) throws Exception;
+
+ void populateTeacherNames(List courseList);
}
diff --git a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java
index c3a75d1..b031659 100644
--- a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java
+++ b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java
@@ -14,4 +14,6 @@ import com.teaching.backend.model.entity.courses.ObjectiveContents;
*/
public interface IObjectiveContentsService extends IService {
+
+ String deleteById(String id);
}
diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
index 88c4816..a1d58f4 100644
--- a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CourseObjectivesMapper;
+import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper;
import com.teaching.backend.mapper.courses.ObjectiveContentsMapper;
import com.teaching.backend.model.dto.courses.CourseObjectivesDTO;
import com.teaching.backend.model.entity.courses.CourseObjectives;
+import com.teaching.backend.model.entity.courses.ObjectiveContentKnow;
import com.teaching.backend.model.entity.courses.ObjectiveContents;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.service.courses.ICourseObjectivesService;
@@ -39,6 +41,8 @@ public class CourseObjectivesServiceImpl extends ServiceImpl()
+ .eq(ObjectiveContentKnow::getObjectiveOrContent, id));
+ if(count > CourseCode.KNOWS_EXIT.getValue()){
+ throw new BusinessException(ErrorCode.KNOWS_EXIT);
+ }
String pid = courseObjectives.getPid();
if (type.equals(CourseCode.SI_ZHENG_TYPE.getValue())){
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
index 23bf545..9a7d330 100644
--- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
@@ -3,6 +3,7 @@ package com.teaching.backend.service.impl.courses;
import cn.afterturn.easypoi.word.WordExportUtil;
import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -14,6 +15,7 @@ import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.courses.ObjectiveContentsMapper;
import com.teaching.backend.mapper.courses.ObjectivesTypeMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
+import com.teaching.backend.mapper.umsAdmin.UmsAdminRoleRelationMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
@@ -22,6 +24,7 @@ import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.courses.ObjectiveContents;
import com.teaching.backend.model.entity.courses.ObjectivesType;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
+import com.teaching.backend.model.entity.umsAdmin.UmsAdminRoleRelation;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
@@ -66,6 +69,8 @@ public class CoursesServiceImpl extends ServiceImpl impl
UmsAdminMapper umsAdminMapper;
@Autowired
UmsTeacherMapper umsTeacherMapper;
+ @Autowired
+ UmsAdminRoleRelationMapper umsAdminRoleRelationMapper;
@Override
@@ -73,12 +78,15 @@ public class CoursesServiceImpl extends ServiceImpl impl
public String saveCourseWithObjective(CoursesDTO coursesDTO) {
String teacher = coursesDTO.getTeacher();
if (teacher == null || teacher.equals("")) {
- throw new BusinessException(ErrorCode.TEACHER_NOT_EXIT);
+ throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT);
}
Courses courses = new Courses();
+ String courseId = UUID.randomUUID().toString().replace("-", "");
+
CourseObjectives courseObjectives = new CourseObjectives();
BeanUtils.copyProperties(coursesDTO, courses);
courses.setCreateTime(LocalDateTime.now());
+ courses.setId(courseId);
String code = coursesDTO.getCode();
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", code);
@@ -86,24 +94,27 @@ public class CoursesServiceImpl extends ServiceImpl impl
if (count == 0) {
int insert = coursesMapper.insert(courses);
if (insert > 0) {
- Courses coursesNew = coursesMapper.selectOne(queryWrapper);
- courseObjectives.setCourseId(coursesNew.getId());
+ Courses coursesNew = coursesMapper.selectById(courseId);
+ courseObjectives.setCourseId(courseId);
courseObjectives.setName(coursesNew.getName() + "课程总体目标");
int insertTotal = courseObjectivesMapper.insert(courseObjectives);
if (insertTotal>0){
CourseObjectives courseTotalObjectives = courseObjectivesMapper.selectOne
- (new LambdaQueryWrapper().eq(CourseObjectives::getCourseId, coursesNew.getId()));
+ (new LambdaQueryWrapper().eq(CourseObjectives::getCourseId, courseId));
String courseTotalObjectivesId = courseTotalObjectives.getId();
List objectivesTypes = objectivesTypeMapper.selectList(new LambdaQueryWrapper());
+ ArrayList courseObjectivesFList = new ArrayList<>();
+ CourseObjectives courseObjectivesF = null;
for (ObjectivesType objectivesType : objectivesTypes) {
Integer typeId = objectivesType.getId();
String typeName = objectivesType.getTypeName();
- CourseObjectives courseObjectivesF = new CourseObjectives();
+ courseObjectivesF = new CourseObjectives();
courseObjectivesF.setType(typeId);
courseObjectivesF.setName(typeName);
courseObjectivesF.setPid(courseTotalObjectivesId);
- courseObjectivesMapper.insert(courseObjectivesF);
+ courseObjectivesFList.add(courseObjectivesF);
}
+ courseObjectivesMapper.insertBatch(courseObjectivesFList);
courseTotalObjectives.setHasChild(1);
courseObjectivesMapper.updateById(courseTotalObjectives);
}
@@ -118,42 +129,50 @@ public class CoursesServiceImpl extends ServiceImpl impl
@Override
public PageDTO queryCourses(CourseQuery courseQuery) {
String username = courseQuery.getUsername();
- if (username==null || username.equals("")){
- throw new BusinessException(ErrorCode.TEACHER_NOT_EXIT);
+ if (username == null || username.isEmpty()) {
+ throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT);
}
- //要搜索的课程名字
- String name = courseQuery.getName();
- // 1.1构建分页条件
+
+ UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper()
+ .eq(UmsAdmin::getUsername, username));
+ UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper()
+ .eq(UmsAdminRoleRelation::getAdminId, umsAdmin.getId()));
+
+ // Determine if the user is a teacher
+ boolean isTeacher = umsAdminRoleRelation.getRoleId() == CourseCode.TEACHER_ROLE_ID.getValue();
+
Page page = courseQuery.toMpPageDefaultSortByCreateTime();
- // 2.分页查询
Page p = lambdaQuery()
- .like(name != null, Courses::getName, name)
-// .eq(Courses::getTeacher,teacherId)
-// .apply("JSON_CONTAINS(teacher, JSON_QUOTE({0}))", teacherId)
- .apply("FIND_IN_SET({0}, teacher)", username)
+ .like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
+ .apply(isTeacher, "FIND_IN_SET({0}, teacher)", username)
+ .eq(!isTeacher && courseQuery.getCategory() != null, Courses::getCategory, courseQuery.getCategory())
+ .eq(!isTeacher && courseQuery.getNature() != null, Courses::getNature, courseQuery.getNature())
+ .eq(!isTeacher && courseQuery.getAssessmenttype() != null, Courses::getAssessmenttype, courseQuery.getAssessmenttype())
+ .apply(!isTeacher && courseQuery.getTeacher() != null && !courseQuery.getTeacher().isEmpty(), "FIND_IN_SET({0}, teacher)", courseQuery.getTeacher())
.page(page);
+
PageDTO coursesVOPageDTO = PageDTO.of(p, CoursesVO.class);
- List pageDTOList = coursesVOPageDTO.getList();
- List teachers = null;
+ populateTeacherNames(coursesVOPageDTO.getList());
- for (CoursesVO coursesVO : pageDTOList) {
+ return coursesVOPageDTO;
+ }
+
+ public void populateTeacherNames(List courseList) {
+ for (CoursesVO coursesVO : courseList) {
List teacherNameList = new ArrayList<>();
- String teacherIds = coursesVO.getTeacher();
- teachers = new ArrayList<>(Arrays.asList(teacherIds.split(",")));
- for (String teacher : teachers) {
- UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper().
- eq(UmsAdmin::getUsername, teacher));
- if (umsAdmin==null){
+ String[] teacherIds = coursesVO.getTeacher().split(",");
+ for (String teacherId : teacherIds) {
+ UmsAdmin umsAdminTea = umsAdminMapper.selectOne(new LambdaQueryWrapper()
+ .eq(UmsAdmin::getUsername, teacherId));
+ if (umsAdminTea == null) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
}
- Long adminId = umsAdmin.getId();
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper()
- .eq(UmsTeacher::getUserId, adminId));
+ .eq(UmsTeacher::getUserId, umsAdminTea.getId()));
teacherNameList.add(umsTeacher.getName());
}
coursesVO.setTeacher(String.join(",", teacherNameList));
}
- return coursesVOPageDTO;
}
@Override
diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
index 6b42b66..2dac173 100644
--- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
@@ -1,5 +1,6 @@
package com.teaching.backend.service.impl.courses;
+import cn.hutool.core.lang.generator.SnowflakeGenerator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
@@ -26,6 +27,7 @@ import java.sql.SQLIntegrityConstraintViolationException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.UUID;
import java.util.stream.Collectors;
/**
@@ -49,7 +51,10 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl knowIds = new ArrayList<>(Arrays.asList(knows.split(",")));
- ObjectiveContentKnow objectiveContentKnow = null;
+ List objectiveContentKnowList = new ArrayList<>();
+ for (String knowId : knowIds) {
+ ObjectiveContentKnow objectiveContentKnow = new ObjectiveContentKnow();
+// objectiveContentKnow.setId(snowflakeGenerator.next());
+ objectiveContentKnow.setObjectiveOrContent(objectiveOrContent);
+ objectiveContentKnow.setKnow(knowId);
+ objectiveContentKnowList.add(objectiveContentKnow);
+ }
+
try {
- for (String knowId : knowIds) {
- objectiveContentKnow = new ObjectiveContentKnow();
- objectiveContentKnow.setObjectiveOrContent(objectiveOrContent);
- objectiveContentKnow.setKnow(knowId);
- objectiveContentKnowMapper.insert(objectiveContentKnow);
- }
+ objectiveContentKnowMapper.insertBatchSomeColumn(objectiveContentKnowList);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_EXIT);
}
+
return "添加成功";
}
@@ -118,7 +127,7 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl {
BigDecimal contentPercentage = calculatePercentage(contentKnowVO.getKnowsTime(), classhours);
contentKnowVO.setPersent(contentPercentage + "%");
@@ -161,8 +170,8 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl implements IObjectiveContentsService {
+ @Autowired
+ ObjectiveContentKnowMapper objectiveContentKnowMapper;
+ @Autowired
+ ObjectiveContentsMapper objectiveContentsMapper;
+ @Override
+ public String deleteById(String id) {
+ if (id == null){
+ throw new BusinessException(ErrorCode.CONTENT_NOT_EXIT);
+ }
+ Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper()
+ .eq(ObjectiveContentKnow::getObjectiveOrContent, id));
+ if(count > CourseCode.KNOWS_EXIT.getValue()){
+ throw new BusinessException(ErrorCode.KNOWS_EXIT);
+ }
+ int delete = objectiveContentsMapper.deleteById(id);
+ return delete>0 ? "删除成功!" : "删除失败!";
+ }
}
diff --git a/src/main/java/com/teaching/backend/service/impl/courses/StudentCoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/StudentCoursesServiceImpl.java
index 63e6b64..c553c44 100644
--- a/src/main/java/com/teaching/backend/service/impl/courses/StudentCoursesServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/courses/StudentCoursesServiceImpl.java
@@ -1,6 +1,7 @@
package com.teaching.backend.service.impl.courses;
+import cn.hutool.core.lang.generator.SnowflakeGenerator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -20,6 +21,7 @@ import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO;
+import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.courses.IStudentCoursesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -49,6 +51,11 @@ public class StudentCoursesServiceImpl extends ServiceImpl coursesIds = new ArrayList<>(Arrays.asList(courses.split(",")));
+ List studentCoursesList = new ArrayList<>();
StudentCourses studentCourses = null;
+
+ for (String course : coursesIds) {
+ studentCourses = new StudentCourses();
+ studentCourses.setStudent(studentId);
+ studentCourses.setCourse(course);
+ studentCoursesList.add(studentCourses);
+ }
try {
- for (String course : coursesIds) {
- studentCourses = new StudentCourses();
- studentCourses.setStudent(studentId);
- studentCourses.setCourse(course);
- studentCoursesMapper.insert(studentCourses);
- }
+ studentCoursesMapper.insertBatchSomeColumn(studentCoursesList);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_EXIT);
@@ -79,7 +89,7 @@ public class StudentCoursesServiceImpl extends ServiceImpl queryCourses(CourseQuery courseQuery) {
String username = courseQuery.getUsername();
- if (username==null || username.equals("")){
+ if (username == null || username.equals("")) {
throw new BusinessException(ErrorCode.STUDENT_NOT_EXIT);
}
List studentCourses = studentCoursesMapper.selectList(new LambdaQueryWrapper()
@@ -99,26 +109,9 @@ public class StudentCoursesServiceImpl extends ServiceImpl p = this.coursesMapper.selectPage(page, queryWrapper);
PageDTO coursesVOPageDTO = PageDTO.of(p, CoursesVO.class);
- List pageDTOList = coursesVOPageDTO.getList();
- List teachers = null;
- for (CoursesVO coursesVO : pageDTOList) {
- List teacherNameList = new ArrayList<>();
- String teacherIds = coursesVO.getTeacher();
- teachers = new ArrayList<>(Arrays.asList(teacherIds.split(",")));
- for (String teacher : teachers) {
- UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper().
- eq(UmsAdmin::getUsername, teacher));
- if (umsAdmin==null){
- throw new BusinessException(ErrorCode.OPERATION_ERROR);
- }
- Long adminId = umsAdmin.getId();
- UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper()
- .eq(UmsTeacher::getUserId, adminId));
- teacherNameList.add(umsTeacher.getName());
- }
- coursesVO.setTeacher(String.join(",", teacherNameList));
- }
+ coursesService.populateTeacherNames(coursesVOPageDTO.getList());
+
return coursesVOPageDTO;
}
}
diff --git a/src/main/java/com/teaching/backend/service/umsAdmin/UmsAdminService.java b/src/main/java/com/teaching/backend/service/umsAdmin/UmsAdminService.java
index 8e90b61..2c02b2f 100644
--- a/src/main/java/com/teaching/backend/service/umsAdmin/UmsAdminService.java
+++ b/src/main/java/com/teaching/backend/service/umsAdmin/UmsAdminService.java
@@ -6,6 +6,7 @@ import com.teaching.backend.model.dto.UpdateAdminPasswordParam;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsResource;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
+import com.teaching.backend.model.vo.courses.TeacherInfVO;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.List;
@@ -76,4 +77,6 @@ public interface UmsAdminService extends IService {
* 手机号登录
*/
String phoneLogin(String phone);
+
+ List getTeacherInfList();
}
diff --git a/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsAdminServiceImpl.java b/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsAdminServiceImpl.java
index 0eeb61f..c9dfb79 100644
--- a/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsAdminServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsAdminServiceImpl.java
@@ -4,18 +4,18 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.Gson;
import com.teaching.backend.exception.Asserts;
import com.teaching.backend.exception.LyException;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminRoleRelationMapper;
+import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.model.dto.UmsAdminParam;
import com.teaching.backend.model.dto.UpdateAdminPasswordParam;
-import com.teaching.backend.model.entity.umsAdmin.AdminUserDetails;
-import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
-import com.teaching.backend.model.entity.umsAdmin.UmsResource;
-import com.teaching.backend.model.entity.umsAdmin.UmsRole;
+import com.teaching.backend.model.entity.umsAdmin.*;
+import com.teaching.backend.model.vo.courses.TeacherInfVO;
import com.teaching.backend.service.umsAdmin.UmsAdminService;
import com.teaching.backend.utils.JwtTokenUtil;
import com.teaching.backend.utils.RegexUtils;
@@ -40,6 +40,7 @@ import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import java.time.LocalDateTime;
+import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -58,6 +59,10 @@ public class UmsAdminServiceImpl extends ServiceImpl i
private AmqpTemplate amqpTemplate;
@Autowired
private StringRedisTemplate redisTemplate;
+ @Autowired
+ UmsTeacherMapper umsTeacherMapper;
+ @Autowired
+ UmsAdminMapper umsAdminMapper;
@Override
@@ -128,6 +133,8 @@ public class UmsAdminServiceImpl extends ServiceImpl i
return token;
}
+
+
@Override
public boolean updateUms(UmsAdmin umsadmin) {
if (umsadmin.getPassword().length() > 0){
@@ -280,4 +287,20 @@ public class UmsAdminServiceImpl extends ServiceImpl i
throw new UsernameNotFoundException("用户名或密码错误");
}
+ @Override
+ public List getTeacherInfList() {
+ List umsTeachers = umsTeacherMapper.selectList(new LambdaQueryWrapper());
+ TeacherInfVO teacherInfVO = null;
+ List teacherInfList = new ArrayList<>();;
+ for (UmsTeacher umsTeacher : umsTeachers) {
+ teacherInfVO = new TeacherInfVO();
+ UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper()
+ .eq(UmsAdmin::getId, umsTeacher.getUserId()));
+ teacherInfVO.setName(umsTeacher.getName());
+ teacherInfVO.setUsername(umsAdmin.getUsername());
+ teacherInfList.add(teacherInfVO);
+ }
+ return teacherInfList;
+ }
+
}
diff --git a/src/main/java/com/teaching/backend/utils/CourseCode.java b/src/main/java/com/teaching/backend/utils/CourseCode.java
index 18f50fb..0c9fc7b 100644
--- a/src/main/java/com/teaching/backend/utils/CourseCode.java
+++ b/src/main/java/com/teaching/backend/utils/CourseCode.java
@@ -7,6 +7,8 @@ public enum CourseCode {
CONTENT_EXIT(1, "存在内容"),
SI_ZHENG_TYPE(1, "思政目标类型"),
SI_ZHENG_EXIT(1, "思政目标存在"),
+ KNOWS_EXIT(0, "存在关联的知识点"),
+ TEACHER_ROLE_ID(1, "教师的角色id是1"),
Total_EXIT(0, "课程总目标"),
COURSE_UODATING(1, "课程正在修改中");
diff --git a/src/main/resources/mapper/CourseObjectivesMapper.xml b/src/main/resources/mapper/CourseObjectivesMapper.xml
index 1204030..91dd5a0 100644
--- a/src/main/resources/mapper/CourseObjectivesMapper.xml
+++ b/src/main/resources/mapper/CourseObjectivesMapper.xml
@@ -12,4 +12,13 @@
select * from t1
order by t1.pid
+
+
+ INSERT INTO course_objectives (id, type, name, pid)
+ VALUES
+
+ (#{item.id}, #{item.type}, #{item.name},#{item.pid})
+
+
+
diff --git a/src/main/resources/mapper/ObjectiveContentKnowMapper.xml b/src/main/resources/mapper/ObjectiveContentKnowMapper.xml
index b764958..9ae17ca 100644
--- a/src/main/resources/mapper/ObjectiveContentKnowMapper.xml
+++ b/src/main/resources/mapper/ObjectiveContentKnowMapper.xml
@@ -2,4 +2,12 @@
+
+ INSERT INTO objective_content_know (objective_or_content, know)
+ VALUES
+
+ (#{item.objectiveOrContent}, #{item.know})
+
+
+
diff --git a/src/main/resources/mapper/StudentCoursesMapper.xml b/src/main/resources/mapper/StudentCoursesMapper.xml
index 6b5568e..dfd2bba 100644
--- a/src/main/resources/mapper/StudentCoursesMapper.xml
+++ b/src/main/resources/mapper/StudentCoursesMapper.xml
@@ -2,4 +2,11 @@
+
+ INSERT INTO student_courses (student, course)
+ VALUES
+
+ (#{item.student}, #{item.course})
+
+