Merge branch 'master' of 39.106.16.162:/home/git/teaching-backend/teaching-backend

master
yh 4 months ago
commit 4a05b3671d
  1. 21
      src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java
  2. 11
      src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java
  3. 17
      src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java
  4. 17
      src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
  5. 17
      src/main/java/com/teaching/backend/mapper/records/ResourceLearningRecordMapper.java
  6. 9
      src/main/java/com/teaching/backend/model/entity/CourseResources.java
  7. 57
      src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java
  8. 57
      src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java
  9. 12
      src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java
  10. 73
      src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java
  11. 8
      src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java
  12. 22
      src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java
  13. 22
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  14. 43
      src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java
  15. 21
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java
  16. 17
      src/main/java/com/teaching/backend/service/records/ICourseLearningRecordService.java
  17. 17
      src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
  18. 17
      src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java
  19. 2
      src/main/java/com/teaching/backend/service/resource/CourseResourcesService.java

@ -72,13 +72,26 @@ public class CourseResourceController {
/** /**
* 编辑 * 编辑
* @param resourceId * @param resources
* @return * @return
*/ */
@ApiOperation("编辑课程资源") @ApiOperation("编辑课程资源")
@PostMapping("/edit") @PutMapping("/edit")
public BaseResponse<CourseResources> editCourseResource(@RequestParam String resourceId){ public BaseResponse<String> editCourseResource(@RequestBody CourseResources resources){
System.out.println(resources);
courseResourcesService.updateById(resources);
return ResultUtils.success("编辑成功");
}
/**
* 根据id查询课程资源
* @param resourceId
* @return
*/
@ApiOperation("根据id查询课程资源")
@PostMapping("/getone")
public BaseResponse<CourseResources> getOne(@RequestParam String resourceId){
System.out.println(resourceId); System.out.println(resourceId);
return ResultUtils.success(courseResourcesService.editCourseResource(resourceId)); return ResultUtils.success(courseResourcesService.getById(resourceId));
} }
} }

@ -47,20 +47,15 @@ public class LearningRecordsController {
long total = cs.size(); // 总记录数 long total = cs.size(); // 总记录数
Page<LearningRecordsVo> pageInfo = new Page<>(pagenum,pagesize,total); Page<LearningRecordsVo> pageInfo = new Page<>(pagenum,pagesize,total);
pageInfo.setRecords(pageCs); pageInfo.setRecords(pageCs);
// System.out.println("总记录数"+pageInfo.getTotal());
// System.out.println("当前页面:"+pagenum);
// System.out.println("当前页面大小:"+pagesize);
// System.out.println("当前页面内容:"+pageCs);
// System.out.println("页面数:"+pageInfo.getPages());
pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数 pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数
// System.out.println(pageInfo.getPages());
return ResultUtils.success(pageInfo); return ResultUtils.success(pageInfo);
} }
@ApiOperation("查询所有") @ApiOperation("查询所有")
@GetMapping("/all") @GetMapping("/all")
public BaseResponse<List<LearningRecords>> All(){ public BaseResponse<List<LearningRecords>> All(){
System.out.println("学习记录:"+learningRecordsService.list()); // System.out.println("学习记录:"+learningRecordsService.list());
return ResultUtils.success(learningRecordsService.list()); return ResultUtils.success(learningRecordsService.list());
} }
@ -74,7 +69,7 @@ public class LearningRecordsController {
@ValidateParams({"userId","type","coursesId"}) @ValidateParams({"userId","type","coursesId"})
@PostMapping("/saverecords") @PostMapping("/saverecords")
public BaseResponse<String> saveRecords(@RequestBody LearningRecords learningRecords){ public BaseResponse<String> saveRecords(@RequestBody LearningRecords learningRecords){
System.out.println(learningRecords); // System.out.println(learningRecords);
return ResultUtils.success(learningRecordsService.saveRecords(learningRecords)); return ResultUtils.success(learningRecordsService.saveRecords(learningRecords));
} }

@ -0,0 +1,17 @@
package com.teaching.backend.mapper.records;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.records.CourseLearningRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-07-24
*/
public interface CourseLearningRecordMapper extends BaseMapper<CourseLearningRecord> {
}

@ -0,0 +1,17 @@
package com.teaching.backend.mapper.records;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-07-24
*/
public interface KnowledgeLearningRecordMapper extends BaseMapper<KnowledgeLearningRecord> {
}

@ -0,0 +1,17 @@
package com.teaching.backend.mapper.records;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-07-24
*/
public interface ResourceLearningRecordMapper extends BaseMapper<ResourceLearningRecord> {
}

@ -25,8 +25,13 @@ import java.util.stream.Stream;
@AllArgsConstructor @AllArgsConstructor
@TableName("Resource") @TableName("Resource")
public class CourseResources { public class CourseResources {
@TableId(value = "id", type = IdType.AUTO) private static final long serialVersionUID = 1L;
private int id;
/**
* 内部编号
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
private String name; private String name;
private int type; private int type;
private int status; private int status;

@ -0,0 +1,57 @@
package com.teaching.backend.model.entity.records;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author author
* @since 2024-07-24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("course_learning_record")
@ApiModel(value="CourseLearningRecord对象", description="")
public class CourseLearningRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = " 课程记录id")
@TableId(value = "id", type = IdType.AUTO)
private String id;
@ApiModelProperty(value = "课程id")
@TableField("course_id")
private String courseId;
@ApiModelProperty(value = "用户id")
@TableField("user_id")
private String userId;
@ApiModelProperty(value = "观看人数")
@TableField("number")
private Integer number;
@ApiModelProperty(value = "记录封面")
@TableField("img")
private String img;
@ApiModelProperty(value = "最近学习时间")
@TableField("time")
private LocalDateTime time;
}

@ -0,0 +1,57 @@
package com.teaching.backend.model.entity.records;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author author
* @since 2024-07-24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("knowledge_learning_record")
@ApiModel(value="KnowledgeLearningRecord对象", description="")
public class KnowledgeLearningRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "知识点学习记录id")
@TableId(value = "id", type = IdType.AUTO)
private String id;
@ApiModelProperty(value = "知识点id")
@TableField("knowledge_id")
private String knowledgeId;
@ApiModelProperty(value = "用户id")
@TableField("user_id")
private String userId;
@ApiModelProperty(value = "观看人数")
@TableField("number")
private Integer number;
@ApiModelProperty(value = "记录封面")
@TableField("img")
private String img;
@ApiModelProperty(value = "最近访问时间")
@TableField("time")
private LocalDateTime time;
}

@ -33,18 +33,6 @@ public class LearningRecords {
* 课程id * 课程id
*/ */
private String coursesId; private String coursesId;
/**
* 章节id
*/
private String chapterId;
/**
* 知识点id
*/
private String knowledgePointId;
/**
* 资源id
*/
private String resourceId;
/** /**
* 访问时间 * 访问时间
*/ */

@ -0,0 +1,73 @@
package com.teaching.backend.model.entity.records;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author author
* @since 2024-07-24
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("resource_learning_record")
@ApiModel(value="ResourceLearningRecord对象", description="")
public class ResourceLearningRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "资源学习记录id")
@TableId(value = "id", type = IdType.AUTO)
private String id;
@ApiModelProperty(value = "资源id")
@TableField("resource_id")
private String resourceId;
@ApiModelProperty(value = "用户id")
@TableField("user_id")
private String userId;
@ApiModelProperty(value = "观看人数")
@TableField("number")
private Integer number;
@ApiModelProperty(value = "是否打开, 1:开打了; 2:未打开;")
@TableField("open")
private Integer open;
@ApiModelProperty(value = "是否下载, 1:下载了; 2:未下载;")
@TableField(" download")
private Integer download;
@ApiModelProperty(value = "学习时长")
@TableField("duration")
private Integer duration;
@ApiModelProperty(value = "是否完成观看")
@TableField("finish")
private Integer finish;
@ApiModelProperty(value = "记录封面")
@TableField("img")
private String img;
@ApiModelProperty(value = "最近学习时间")
@TableField("time")
private LocalDateTime time;
}

@ -57,7 +57,7 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe
this.save(courseResources); this.save(courseResources);
int resourceId=courseResources.getId(); String resourceId=courseResources.getId();
System.out.println(resourceId); System.out.println(resourceId);
ResourceRelationship resourcesRelationship=new ResourceRelationship(); ResourceRelationship resourcesRelationship=new ResourceRelationship();
@ -159,6 +159,8 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe
public void saveCourseResource(CourseResources courseResources) { public void saveCourseResource(CourseResources courseResources) {
//将状态设置为1 //将状态设置为1
courseResources.setStatus(1); courseResources.setStatus(1);
//设置文件路径
courseResources.setPath(courseResources.getImg());
//设置默认图片 //设置默认图片
switch (courseResources.getType()){ switch (courseResources.getType()){
case 1 : courseResources.setImg("src\\assets\\icons\\ppt (2).png");//ppt的默认图片 case 1 : courseResources.setImg("src\\assets\\icons\\ppt (2).png");//ppt的默认图片
@ -179,10 +181,8 @@ public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMappe
} }
@Override @Override
public CourseResources editCourseResource(String resourceId) { public void editCourseResource(String resourceId) {
//根据id查数据 //根据id查数据
return this.getById(resourceId);
} }

@ -0,0 +1,22 @@
package com.teaching.backend.service.impl.records;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.records.CourseLearningRecordMapper;
import com.teaching.backend.model.entity.records.CourseLearningRecord;
import com.teaching.backend.service.records.ICourseLearningRecordService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-07-24
*/
@Service
public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningRecordMapper, CourseLearningRecord> implements ICourseLearningRecordService {
}

@ -0,0 +1,22 @@
package com.teaching.backend.service.impl.records;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.service.records.IKnowledgeLearningRecordService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-07-24
*/
@Service
public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLearningRecordMapper, KnowledgeLearningRecord> implements IKnowledgeLearningRecordService {
}

@ -18,6 +18,7 @@ import com.teaching.backend.service.records.LearningRecordsService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -35,8 +36,6 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
private LearningRecordsMapper learningRecordsMapper; private LearningRecordsMapper learningRecordsMapper;
@Autowired @Autowired
private CourseResourcesServiceImpl courseResourcesService; private CourseResourcesServiceImpl courseResourcesService;
// @Autowired
// private KnowServiceimpl knowledgePointService;
@Autowired @Autowired
private ChapterServiceImpl chapterService; private ChapterServiceImpl chapterService;
@ -74,7 +73,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
.orderByDesc(LearningRecords::getAccessTime) .orderByDesc(LearningRecords::getAccessTime)
.eq(LearningRecords::getUserId, userId) .eq(LearningRecords::getUserId, userId)
.eq(LearningRecords::getStatus, "1"); .eq(LearningRecords::getStatus, "1");
System.out.println(this.list(lambdaQueryWrapper1)); // System.out.println("查询数据库结果为:"+this.list(lambdaQueryWrapper1));
//如果为空-------------------????? //如果为空-------------------?????
for (LearningRecords learningRecords : this.list(lambdaQueryWrapper1)) { for (LearningRecords learningRecords : this.list(lambdaQueryWrapper1)) {
//查找该用户的学习记录 //查找该用户的学习记录
@ -94,15 +93,10 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
//添加课程名称 //添加课程名称
switch (learningRecords.getType()) { switch (learningRecords.getType()) {
case "4": //如果是资源学习 case "4": //如果是资源学习
// if (courseResourcesService.getById(learningRecords.getCoursesId()) != null){
// name=courseResourcesService.getById(learningRecords.getCoursesId()).getName();
// }else {
// name = "查无次记录";
// }
//如果对应的资源不存在
learningRecordsVo.setCoursesName(courseResourcesService.getById(learningRecords.getCoursesId()).getName());//设置名称 --------------------------------------------待完善 learningRecordsVo.setCoursesName(courseResourcesService.getById(learningRecords.getCoursesId()).getName());//设置名称 --------------------------------------------待完善
break; break;
case "3": //如果是知识点学习记录 case "3": //如果是知识点学习记录
// learningRecordsVo.setCoursesName(knowledgePointService.getById(learningRecords.getCoursesId()).get());
// if (knowledgePointService.getById(learningRecords.getCoursesId()) != null){ // if (knowledgePointService.getById(learningRecords.getCoursesId()) != null){
// name=knowledgePointService.getById(learningRecords.getCoursesId()).getName(); // name=knowledgePointService.getById(learningRecords.getCoursesId()).getName();
// }else { // }else {
@ -112,22 +106,11 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
//如果对应的资源不存在 //如果对应的资源不存在
break; break;
case "2": //如果是章节学习记录 case "2": //如果是章节学习记录
// if (chapterService.getById(learningRecords.getCoursesId()) != null){
// name=chapterService.getById(learningRecords.getCoursesId()).getName();
// }else {
// name = "查无次记录";
// }
learningRecordsVo.setCoursesName(chapterService.getById(learningRecords.getCoursesId()).getName()); learningRecordsVo.setCoursesName(chapterService.getById(learningRecords.getCoursesId()).getName());
//如果对应的资源不存在 //如果对应的资源不存在
break; break;
case "1": //如果是课程学习记录 case "1": //如果是课程学习记录
// if (coursesService.getById(learningRecords.getCoursesId()) != null){
// name=coursesService.getById(learningRecords.getCoursesId()).getName();
// }else {
// name = "查无次记录";
// }
learningRecordsVo.setCoursesName(coursesService.getById(learningRecords.getCoursesId()).getName()); learningRecordsVo.setCoursesName(coursesService.getById(learningRecords.getCoursesId()).getName());
//如果对应的资源不存在
break; break;
} }
//添加观看人数 //添加观看人数
@ -138,7 +121,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
list.add(learningRecordsVo); list.add(learningRecordsVo);
// } // }
} }
System.out.println(list); // System.out.println("查询后结果:"+list);
return list; return list;
} }
@ -148,6 +131,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
* @return * @return
*/ */
@Override @Override
@Transactional
public String saveRecords(LearningRecords learningRecords) { public String saveRecords(LearningRecords learningRecords) {
String userId = learningRecords.getUserId(); String userId = learningRecords.getUserId();
String coursesId = learningRecords.getCoursesId(); String coursesId = learningRecords.getCoursesId();
@ -172,23 +156,6 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
if (learningRecords.getContent() == null || learningRecords.getContent().equals("")){ if (learningRecords.getContent() == null || learningRecords.getContent().equals("")){
learningRecords.setContent("img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png"); learningRecords.setContent("img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png");
} }
// //添加记录封面
// switch (learningRecords.getType()) {
// case "4": //如果是资源学习
// learningRecords.setContent(learningResourceService.getById(learningRecords.getCoursesId()).getContent());//设置封面
// break;
// case "3": //如果是知识点学习记录
// learningRecords.setContent(knowledgePointService.getById(learningRecords.getCoursesId()).getContent());//设置封面
//
// break;
// case "2": //如果是章节学习记录
// learningRecords.setContent(chapterService.getById(learningRecords.getCoursesId()).getContent());//设置封面
//
// break;
// case "1": //如果是课程学习记录
// learningRecords.setContent(coursesService.getById(learningRecords.getCoursesId()).getImg());//设置封面
// break;
// }
if (count == 0){//如果没有就新增并记录学习方式是打开还是下载 if (count == 0){//如果没有就新增并记录学习方式是打开还是下载
//根据传上来的type设置 //根据传上来的type设置
// learningRecords.setType(learningRecords.getType()); // learningRecords.setType(learningRecords.getType());

@ -0,0 +1,21 @@
package com.teaching.backend.service.impl.records;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.records.ResourceLearningRecordMapper;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
import com.teaching.backend.service.records.IResourceLearningRecordService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-07-24
*/
@Service
public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearningRecordMapper, ResourceLearningRecord> implements IResourceLearningRecordService {
}

@ -0,0 +1,17 @@
package com.teaching.backend.service.records;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.records.CourseLearningRecord;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-07-24
*/
public interface ICourseLearningRecordService extends IService<CourseLearningRecord> {
}

@ -0,0 +1,17 @@
package com.teaching.backend.service.records;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-07-24
*/
public interface IKnowledgeLearningRecordService extends IService<KnowledgeLearningRecord> {
}

@ -0,0 +1,17 @@
package com.teaching.backend.service.records;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-07-24
*/
public interface IResourceLearningRecordService extends IService<ResourceLearningRecord> {
}

@ -31,5 +31,5 @@ public interface CourseResourcesService extends IService<CourseResources> {
public void saveCourseResource(CourseResources courseResources); public void saveCourseResource(CourseResources courseResources);
public CourseResources editCourseResource(String resourceId); public void editCourseResource(String resourceId);
} }

Loading…
Cancel
Save