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

master
yh 4 months ago
commit 0d1a331144
  1. 9
      pom.xml
  2. 7
      src/main/java/com/teaching/backend/constant/RoleConstants.java
  3. 48
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  4. 4
      src/main/java/com/teaching/backend/controller/courses/CoursesController2.java
  5. 47
      src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java
  6. 27
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java
  7. 13
      src/main/java/com/teaching/backend/controller/umsStudent/UmsStudentController.java
  8. 3
      src/main/java/com/teaching/backend/mapper/courses/StudentCoursesMapper.java
  9. 14
      src/main/java/com/teaching/backend/mapper/report/ReportMapper.java
  10. 2
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java
  11. 9
      src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java
  12. 21
      src/main/java/com/teaching/backend/model/dto/report/ReportDTO.java
  13. 2
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java
  14. 13
      src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java
  15. 24
      src/main/java/com/teaching/backend/model/entity/report/Report.java
  16. 4
      src/main/java/com/teaching/backend/model/query/CourseQuery.java
  17. 6
      src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java
  18. 20
      src/main/java/com/teaching/backend/model/vo/report/BrowseReportVO.java
  19. 5
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  20. 29
      src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java
  21. 56
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  22. 6
      src/main/java/com/teaching/backend/service/impl/courses/StudentCoursesServiceImpl.java
  23. 73
      src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java
  24. 3
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsRoleServiceImpl.java
  25. 13
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  26. 21
      src/main/java/com/teaching/backend/service/report/ReportService.java
  27. 18
      src/main/resources/mapper/ReportMapper.xml
  28. 8
      src/main/resources/mapper/StudentCoursesMapper.xml
  29. 1
      src/main/resources/mapper/UmsUserMapper.xml

@ -117,10 +117,6 @@
<version>4.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
@ -206,6 +202,11 @@
<artifactId>redisson</artifactId>
<version>3.13.6</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>

@ -0,0 +1,7 @@
package com.teaching.backend.constant;
public class RoleConstants {
public static final Long TEACHER_ROLE = 1L;
public static final Long STUDENT_ROLE = 2L;
public static final Long ADMIN_ROLE = 3L;
}

@ -2,6 +2,7 @@ package com.teaching.backend.controller.courses;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
@ -11,8 +12,10 @@ import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import com.teaching.backend.service.courses.ICoursesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -41,21 +44,37 @@ public class CoursesController {
// @ApiOperation("网站首页")
// @GetMapping("/index")
// public BaseResponse<Map<String,Object>> getData(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize) {
// List<CoursesVO> coursesVo = coursesService.getPagePageSize(page, pageSize);
//// System.out.println(coursesVo);
// long totalcount = coursesService.count();
// long toatlPages = (int) Math.ceil((double)totalcount / pageSize);
// Map<String,Object> objectMap = new HashMap<>();
// objectMap.put("content",coursesVo);
// objectMap.put("totalcount", totalcount);
// objectMap.put("totalPages", toatlPages);
// objectMap.put("currentPage", page);
// return ResultUtils.success(objectMap);
// }
@ApiOperation("网站首页")
@GetMapping("/index")
public BaseResponse<Map<String,Object>> getData(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize) {
List<CoursesVO> coursesVo = coursesService.getPagePageSize(page, pageSize);
// System.out.println(coursesVo);
long totalcount = coursesService.count();
long toatlPages = (int) Math.ceil((double)totalcount / pageSize);
Map<String,Object> objectMap = new HashMap<>();
objectMap.put("content",coursesVo);
objectMap.put("totalcount", totalcount);
objectMap.put("totalPages", toatlPages);
objectMap.put("currentPage", page);
Map<String, Object> result = coursesService.getPagePageSize2(page, pageSize);
// 将结果放入新的Map对象中返回
Map<String, Object> objectMap = new HashMap<>();
objectMap.put("content", result.get("courses"));
objectMap.put("totalcount", result.get("totalcount"));
objectMap.put("totalPages", result.get("totalPages"));
objectMap.put("currentPage", result.get("currentPage"));
return ResultUtils.success(objectMap);
}
@ApiOperation("新增课程--同步新增课程的总体目标并同时添加所有的分项目标")
@ValidateParams({"teacher","img", "category", "nature","name","code","credit","classhours","assessmenttype","assessmentway"}) // 需要校验的参数
@PostMapping("/addcourse")
@ -66,7 +85,7 @@ public class CoursesController {
@ApiOperation("查询课程列表")
@ValidateParams({"username"})
@ValidateParams({"userId"})
@GetMapping("/page")
// @PostMapping("/page")
public BaseResponse<PageDTO<CoursesVO>> getCourses(CourseQuery courseQuery){
@ -120,4 +139,13 @@ public class CoursesController {
String id = "de3100cad98f76be3176dd39aa748a9e";
coursesService.down(response, id);
}
@ApiOperation("查询学生列表")
// @ValidateParams({"username"})
@PostMapping("/studentList")
public CommonResult<HashSet<UmsStudent>> getStudentList(CourseQuery courseQuery){
HashSet<UmsStudent> umsStudentList = coursesService.queryStudentList(courseQuery);
return CommonResult.success(umsStudentList);
}
}

@ -6,7 +6,6 @@
//import com.teaching.backend.exception.BusinessException;
//import com.teaching.backend.filter.ValidateParams;
//import com.teaching.backend.model.dto.courses.CoursesDTO;
//import com.teaching.backend.model.entity.resource.CourseResources;
//import com.teaching.backend.model.entity.courses.Courses;
//import com.teaching.backend.service.courses.ICoursesService;
//import io.swagger.annotations.ApiOperation;
@ -32,8 +31,6 @@
//public class CoursesController2 {
// @Autowired
// ICoursesService coursesService;
// @Autowired
// ResourcesRelationshipService resourcesRelationshipService;
//
// @ApiOperation("网站首页2")
// @GetMapping("/index2")
@ -78,6 +75,7 @@
// return ResultUtils.success(relatedResources);
// }
//
//
// }
//
//

@ -0,0 +1,47 @@
package com.teaching.backend.controller.umsAdmin;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.model.dto.report.ReportDTO;
import com.teaching.backend.model.vo.report.BrowseReportVO;
import com.teaching.backend.service.report.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "ReportController")
@RequestMapping("/api/report")
@Slf4j
public class ReportController {
@Autowired
private ReportService reportService;
/**
* 浏览统计
* @return
*/
@GetMapping("/browseStatistics")
@ApiOperation("浏览统计")
public CommonResult<BrowseReportVO> browseStatistics(){
return CommonResult.success(reportService.getBrowseStatistics());
}
/**
* 接收每日浏览量
* @return
*/
@PostMapping("/receptionBrowse")
@ApiOperation("接收每日浏览量")
public CommonResult receptionBrowse(@RequestBody ReportDTO reportDTO){
boolean receptionBrowse = reportService.getReceptionBrowse(reportDTO);
if (receptionBrowse == false){
return CommonResult.failed();
}
return CommonResult.success(receptionBrowse);
}
}

@ -30,7 +30,7 @@ import java.util.Map;
* @Description:login
*/
@RestController
@Api(tags = "UmsAdminController")
@Api(tags = "UmsUserController")
@RequestMapping("/api/user")
@Slf4j
public class UmsUserController {
@ -145,17 +145,6 @@ public class UmsUserController {
return CommonResult.failed();
}
@ApiOperation("修改指定用户密码")
@PostMapping("/updatePassword")
public CommonResult updatePassword(@Validated @RequestBody UpdateUserPasswordParam updatePasswordParam) {
int status = umsUserService.updatePassword(updatePasswordParam);
if (status == 1) {
return CommonResult.success(status);
} else {
return CommonResult.failed();
}
}
@ApiOperation("获取指定个人信息")
@PostMapping("/personal/info")
public CommonResult getByIdPersonalInfo(@RequestParam String id) {
@ -179,6 +168,19 @@ public class UmsUserController {
return CommonResult.failed();
}
@ApiOperation("修改指定用户密码")
@PostMapping("/updatePassword")
public CommonResult updatePassword(@Validated @RequestBody UpdateUserPasswordParam updatePasswordParam) {
int status = umsUserService.updatePassword(updatePasswordParam);
if (status == 1) {
return CommonResult.success(status);
} else {
return CommonResult.failed();
}
}
@ApiOperation("获取教师信息列表,关联教师的username和name")
@GetMapping("/get_teacherinf_list")
public BaseResponse<List<TeacherInfVO>> getTeacherInfList(){
@ -186,4 +188,5 @@ public class UmsUserController {
return ResultUtils.success(teacherInfVO);
}
}

@ -0,0 +1,13 @@
package com.teaching.backend.controller.umsStudent;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(tags = "UmsStudentController")
@RequestMapping("/api/student")
@Slf4j
public class UmsStudentController {
}

@ -17,4 +17,7 @@ import java.util.List;
public interface StudentCoursesMapper extends BaseMapper<StudentCourses> {
void insertBatchSomeColumn(List<StudentCourses> studentCoursesList);
List<StudentCourses> selectBatchSomeStudent(String courseId);
}

@ -0,0 +1,14 @@
package com.teaching.backend.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.dto.report.ReportDTO;
import com.teaching.backend.model.entity.report.Report;
import java.time.LocalDate;
public interface ReportMapper extends BaseMapper<Report> {
String getBrowseByTime(LocalDate day);
boolean addTodayBrowse(ReportDTO reportDTO);
}

@ -1,6 +1,7 @@
package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.courses.StudentCourses;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
@ -17,4 +18,5 @@ public interface UmsUserMapper extends BaseMapper<UmsUser> {
UmsTeacher getByIdTeacher(String id);
UmsStudentVO getByIdStudent(String id);
}

@ -1,14 +1,10 @@
package com.teaching.backend.model.dto.chapter;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.xml.soap.Text;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -74,11 +70,6 @@ public class ChapterDTO implements Serializable {
@ApiModelProperty(value = "周次")
private String zc;
@ApiModelProperty(value = "资源")
private String ziyuan;
@ApiModelProperty(value = "资源文件")
private String zywj;
@ApiModelProperty(value = "内部序号显示")
private String numshow;

@ -0,0 +1,21 @@
package com.teaching.backend.model.dto.report;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
@Data
@TableName("report")
public class ReportDTO implements Serializable {
//时间
private LocalDate createTime;
//浏览量
private String pageView;
}

@ -117,7 +117,7 @@ public class UmsStudentAndTeacherDTO implements Serializable {
/**
* user_id
*/
private Integer userId;
private Long userId;
/**
* role_id

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import com.teaching.backend.model.entity.KnowGraph.Know;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -80,12 +80,6 @@ public class Chapter implements Serializable {
@ApiModelProperty(value = "周次")
private String zc;
@ApiModelProperty(value = "资源")
private String ziyuan;
@ApiModelProperty(value = "资源文件")
private String zywj;
@ApiModelProperty(value = "内部序号显示")
private String numshow;
@ -93,4 +87,9 @@ public class Chapter implements Serializable {
@TableField(exist = false)
private List<Chapter> children; // 用于存储子章节
@ApiModelProperty(value = "知识点")
@TableField(exist = false)
private List<Know> knowledgePoints; // 用于存储章节下的知识点
}

@ -0,0 +1,24 @@
package com.teaching.backend.model.entity.report;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
@Data
@TableName("report")
public class Report implements Serializable {
//主键
@TableId(type = IdType.AUTO)
private Long id;
//时间
private LocalDate createTime;
//浏览量
private String pageView;
}

@ -15,8 +15,8 @@ public class CourseQuery extends PageQuery {
@ApiModelProperty("课程名称关键字")
private String name;
@ApiModelProperty(value = "用户的username",required = true)
private String username;
@ApiModelProperty(value = "用户的userId",required = true)
private String userId;
// @ApiModelProperty(value = "用户的角色id",required = true)
// private List<String> roleId;

@ -10,10 +10,10 @@ import lombok.Data;
public class TeacherInfVO {
/**
* 教师username
* 教师userId
*/
@ApiModelProperty("教师username")
private String username;
@ApiModelProperty("教师userId")
private Long userId;
/**
* 课程封面
*/

@ -0,0 +1,20 @@
package com.teaching.backend.model.vo.report;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
@Data
@Builder
public class BrowseReportVO implements Serializable {
//日期,以逗号分隔,例如:2022-10-01,2022-10-02,2022-10-03
private String dateList;
//本月浏览量,以逗号分隔,例如:200,210,220
private String ThisMonthBrowseList;
//上月浏览量,以逗号分隔,例如:20,21,10
private String LastMonthBrowseList;
}

@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import javax.servlet.http.HttpServletResponse;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -41,4 +44,6 @@ public interface ICoursesService extends IService<Courses> {
CoursesVO getByIdCourseVo(String courseid);
Map<String, Object> getPagePageSize2(int page, int pageSize);
HashSet<UmsStudent> queryStudentList(CourseQuery courseQuery);
}

@ -8,8 +8,10 @@ import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.chapter.ChapterMapper;
import com.teaching.backend.model.dto.chapter.ChapterDTO;
import com.teaching.backend.model.entity.KnowGraph.Know;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.vo.chapter.ChapterVo;
import com.teaching.backend.service.KnowGraph.KnowService;
import com.teaching.backend.service.chapter.IChapterService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -31,6 +33,8 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
// private int count=0;
List<Chapter> list=new ArrayList<>();
@Autowired
private KnowService knowService;
@Override
public String updateNumShow(Chapter chapter) {
@ -155,7 +159,6 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
@Override
public List<Chapter> getChapterTree(String courseId) {
List<Chapter> chapters=baseMapper.selectSectionsByCourseId(courseId);
Map<String,Chapter> chapterMap=new HashMap<>();
@ -165,6 +168,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
for (Chapter chapter:chapters){
chapter.setChildren(new ArrayList<>());
chapter.setKnowledgePoints(new ArrayList<>()); // 初始化知识点列表
chapterMap.put(chapter.getId(),chapter);
}
@ -182,9 +186,23 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
}
}
return roots;
for (Chapter root : roots) {
loadKnowledgePointsRecursively(root);
}
return roots;
}
private void loadKnowledgePointsRecursively(Chapter chapter) {
for (Chapter child : chapter.getChildren()) {
Set<Know> knows = knowService.queryByChapterId(child.getId());
child.setKnowledgePoints(new ArrayList<>(knows));
loadKnowledgePointsRecursively(child);
}
}
@Override
public void saveChapter(ChapterDTO chapterDTO) {
@ -235,9 +253,16 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
lambdaQueryWrapper.eq(Chapter::getPid,id);
Long count= this.count(lambdaQueryWrapper);
if (count>0){
throw new BusinessException(ErrorCode.OPERATION_ERROR,"存在子章节,无法删除");
}
Set<Know> knows = knowService.queryByChapterId(id);
if (!knows.isEmpty()) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "子章节下存在知识点,无法删除");
}
this.remove(queryWrapper);

@ -13,6 +13,7 @@ import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.chapter.ChapterMapper;
import com.teaching.backend.mapper.courses.*;
import com.teaching.backend.mapper.records.LearningRecordsMapper;
import com.teaching.backend.mapper.umsAdmin.UmsStudentMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO;
@ -20,11 +21,13 @@ import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.courses.*;
import com.teaching.backend.model.entity.records.LearningRecords;
import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.utils.CourseCode;
import com.teaching.backend.utils.knowGraph.AddNeoKnowByCourse;
@ -43,6 +46,8 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
/**
* <p>
* 服务实现类
@ -76,6 +81,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Autowired
UmsTeacherMapper umsTeacherMapper;
@Autowired
UmsStudentMapper umsStudentMapper;
@Autowired
StudentCoursesMapper studentCoursesMapper;
@Autowired
ObjectiveContentKnowMapper objectiveContentKnowMapper;
@ -146,10 +153,14 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Override
public PageDTO<CoursesVO> queryCourses(CourseQuery courseQuery) {
int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getUsername, courseQuery.getUsername())).getRoleId());
// int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
// .eq(UmsUser::getUsername, courseQuery.getUsername())).getRoleId());
UmsUser umsUser = umsUserMapper.selectById(courseQuery.getUserId());
if (umsUser == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
int roleId = Integer.parseInt(umsUser.getRoleId());
PageDTO<CoursesVO> coursesVOPageDTO;
switch (roleId) {
//教师--也是管理员--但是只能看自己的课程,有搜索功能
case 1:
@ -174,7 +185,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime();
Page<Courses> p = lambdaQuery()
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
.apply("FIND_IN_SET({0}, teacher)", courseQuery.getUsername())
.apply("FIND_IN_SET({0}, teacher)", courseQuery.getUserId())
.eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory())
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature())
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype())
@ -184,11 +195,10 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
private PageDTO<CoursesVO> queryForStudent(CourseQuery courseQuery) {
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(new LambdaQueryWrapper<StudentCourses>()
.eq(StudentCourses::getStudent, courseQuery.getUsername()));
.eq(StudentCourses::getStudent, courseQuery.getUserId()));
List<String> coursesList = studentCourses.stream()
.map(StudentCourses::getCourse)
.collect(Collectors.toList());
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime();
Page<Courses> p = lambdaQuery()
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
@ -196,7 +206,6 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
.page(page);
return PageDTO.of(p, CoursesVO.class);
}
private PageDTO<CoursesVO> queryForAdmin(CourseQuery courseQuery) {
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime();
Page<Courses> p = lambdaQuery()
@ -212,17 +221,16 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
private void populateTeacherNames(List<CoursesVO> courseList) {
for (CoursesVO coursesVO : courseList) {
List<String> teacherNameList = new ArrayList<>();
String[] teacherIds = coursesVO.getTeacher().split(",");
for (String teacherId : teacherIds) {
UmsUser umsUserTea = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getUsername, teacherId));
if (umsUserTea == null) {
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
String[] teacherUserIds = coursesVO.getTeacher().split(",");
for (String teacherId : teacherUserIds) {
// UmsUser umsUserTea = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
// .eq(UmsUser::getUsername, teacherId));
// if (umsUserTea == null) {
// throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
// }
// System.out.println(umsAdminTea);
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper<UmsTeacher>()
.eq(UmsTeacher::getUserId, umsUserTea.getId()));
// System.out.println(umsTeacher);
.eq(UmsTeacher::getUserId,teacherId));
if (umsTeacher == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
@ -332,6 +340,22 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
}
@Override
public HashSet<UmsStudent> queryStudentList(CourseQuery courseQuery) {
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery);
List<CoursesVO> coursesList = queryCourses.getList();
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList());
HashSet<UmsStudent> studentNameList = new HashSet<>();
for (String courseId : courseIds) {
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId);
for (StudentCourses studentUsername : studentUsernames) {
UmsStudent umsStudent = umsStudentMapper.selectByUserId(Integer.valueOf(studentUsername.getStudent()));
studentNameList.add(umsStudent);
}
}
return studentNameList;
}
@Override
public List<CoursesVO> getPagePageSize(int page, int pageSize) {
int startIndex = (page-1) * pageSize;

@ -84,12 +84,12 @@ public class StudentCoursesServiceImpl extends ServiceImpl<StudentCoursesMapper,
//TODO:学生这个课程要不要整合到教师那边???
@Override
public PageDTO<CoursesVO> queryCourses(CourseQuery courseQuery) {
String username = courseQuery.getUsername();
if (username == null || username.equals("")) {
String userId = courseQuery.getUserId();
if (userId == null || userId.equals("")) {
throw new BusinessException(ErrorCode.STUDENT_NOT_EXIT);
}
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(new LambdaQueryWrapper<StudentCourses>()
.eq(StudentCourses::getStudent, username));
.eq(StudentCourses::getStudent, userId));
List<String> coursesList = studentCourses.stream()
.map(StudentCourses::getCourse)
.collect(Collectors.toList());

@ -0,0 +1,73 @@
package com.teaching.backend.service.impl.report;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.report.ReportMapper;
import com.teaching.backend.model.dto.report.ReportDTO;
import com.teaching.backend.model.entity.report.Report;
import com.teaching.backend.model.vo.report.BrowseReportVO;
import com.teaching.backend.service.report.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
@Autowired
private ReportMapper reportMapper;
@Override
public BrowseReportVO getBrowseStatistics() {
//存放访问的前一天至前七天的每天对应的日期
List<LocalDate> dateList = new ArrayList<>();
//存放这个月访问的前一天至前七天的每天对应的浏览量
List<String> ThisMonthBrowseList = new ArrayList<>();
//存放上个月访问的前一天至前七天的每天对应的浏览量
List<String> LastMonthBrowseList = new ArrayList<>();
//获取今天的日期
LocalDate end = LocalDate.now();
// 获取前七天的日期
for (int i = 1; i <= 7; i++) {
LocalDate day = end.minusDays(i);
dateList.add(day);
//查询今天对应的浏览量
String browse = reportMapper.getBrowseByTime(day);
ThisMonthBrowseList.add(browse);
//获取上个月的今天
LocalDate lastMonthToday = end.minusMonths(1);
LocalDate lastMonth = lastMonthToday.minusDays(i);
//查询上个月的今天对应的浏览量
String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth);
LastMonthBrowseList.add(lastMonthBrowse);
}
return BrowseReportVO
.builder()
.dateList(StringUtils.join(dateList,","))
.ThisMonthBrowseList(StringUtils.join(ThisMonthBrowseList,","))
.LastMonthBrowseList(StringUtils.join(LastMonthBrowseList,","))
.build();
}
@Override
public boolean getReceptionBrowse(ReportDTO reportDTO) {
if (reportDTO.getCreateTime() == null || reportDTO.getPageView() == null){
return false;
}
boolean todayBrowse = reportMapper.addTodayBrowse(reportDTO);
if (todayBrowse == false){
return false;
}
return true;
}
}

@ -1,4 +1,4 @@
package com.teaching.backend.service.umsAdmin.impl;
package com.teaching.backend.service.impl.umsAdmin;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.umsAdmin.UmsPermissionMapper;
@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**

@ -1,4 +1,4 @@
package com.teaching.backend.service.umsAdmin.impl;
package com.teaching.backend.service.impl.umsAdmin;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
@ -42,6 +42,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
@Service
@Slf4j
public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> implements UmsUserService {
@ -377,18 +379,15 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
}
throw new UsernameNotFoundException("用户名或密码错误");
}
@Override
public List<TeacherInfVO> getTeacherInfList() {
List<UmsTeacher> umsTeachers = umsTeacherMapper.selectList(new LambdaQueryWrapper<UmsTeacher>());
List<UmsTeacher> umsTeachers = umsTeacherMapper.selectList(new LambdaQueryWrapper<>(UmsTeacher.class));
TeacherInfVO teacherInfVO = null;
List<TeacherInfVO> teacherInfList = new ArrayList<>();;
List<TeacherInfVO> teacherInfList = new ArrayList<>();
for (UmsTeacher umsTeacher : umsTeachers) {
teacherInfVO = new TeacherInfVO();
UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getId, umsTeacher.getUserId()));
teacherInfVO.setName(umsTeacher.getName());
teacherInfVO.setUsername(umsUser.getUsername());
teacherInfVO.setUserId(umsTeacher.getUserId());
teacherInfList.add(teacherInfVO);
}
return teacherInfList;

@ -0,0 +1,21 @@
package com.teaching.backend.service.report;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.report.ReportDTO;
import com.teaching.backend.model.entity.report.Report;
import com.teaching.backend.model.vo.report.BrowseReportVO;
public interface ReportService extends IService<Report> {
/**
* 浏览统计
* @return
*/
BrowseReportVO getBrowseStatistics();
/**
* 接收每日浏览量
* @return
*/
boolean getReceptionBrowse(ReportDTO reportDTO);
}

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.report.ReportMapper">
<insert id="addTodayBrowse" parameterType="com.teaching.backend.model.dto.report.ReportDTO">
INSERT INTO report (create_time, page_view)
VALUES
(#{createTime}, #{pageView})
</insert>
<select id="getBrowseByTime" resultType="java.lang.String" parameterType="java.time.LocalDate">
SELECT
r.page_view pageView
FROM
report r
WHERE
r.create_time = #{day}
</select>
</mapper>

@ -9,4 +9,12 @@
(#{item.student}, #{item.course})
</foreach>
</insert>
<select id="selectBatchSomeStudent" resultType="com.teaching.backend.model.entity.courses.StudentCourses" parameterType="java.lang.String">
SELECT
sc.student student
FROM
student_courses sc
WHERE
sc.course = #{courseId}
</select>
</mapper>

@ -76,4 +76,5 @@
WHERE
s.user_id = #{id}
</select>
</mapper>

Loading…
Cancel
Save