Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java
master
Alan 4 months ago
commit 309b6cb6c9
  1. 9
      pom.xml
  2. 12
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  3. 47
      src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java
  4. 29
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java
  5. 13
      src/main/java/com/teaching/backend/controller/umsStudent/UmsStudentController.java
  6. 3
      src/main/java/com/teaching/backend/mapper/courses/StudentCoursesMapper.java
  7. 14
      src/main/java/com/teaching/backend/mapper/report/ReportMapper.java
  8. 2
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java
  9. 21
      src/main/java/com/teaching/backend/model/dto/report/ReportDTO.java
  10. 2
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java
  11. 24
      src/main/java/com/teaching/backend/model/entity/report/Report.java
  12. 20
      src/main/java/com/teaching/backend/model/vo/report/BrowseReportVO.java
  13. 5
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  14. 21
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  15. 73
      src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java
  16. 3
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsRoleServiceImpl.java
  17. 2
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  18. 21
      src/main/java/com/teaching/backend/service/report/ReportService.java
  19. 18
      src/main/resources/mapper/ReportMapper.xml
  20. 8
      src/main/resources/mapper/StudentCoursesMapper.xml
  21. 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>

@ -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;
@ -120,4 +123,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);
}
}

@ -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,11 +168,25 @@ public class UmsUserController {
return CommonResult.failed();
}
@ApiOperation("获取教师信息列表,关联教师的userId和name")
@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(){
List<TeacherInfVO> teacherInfVO = umsUserService.getTeacherInfList();
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);
}

@ -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

@ -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;
}

@ -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);
}

@ -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 org.apache.poi.xwpf.usermodel.*;
@ -77,6 +80,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Autowired
UmsTeacherMapper umsTeacherMapper;
@Autowired
UmsStudentMapper umsStudentMapper;
@Autowired
StudentCoursesMapper studentCoursesMapper;
@Autowired
ObjectiveContentKnowMapper objectiveContentKnowMapper;
@ -329,6 +334,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;

@ -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;

@ -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