|
|
@@ -0,0 +1,181 @@
|
|
|
+/*
|
|
|
+ * Copyright [2022] [https://www.xiaonuo.vip]
|
|
|
+ *
|
|
|
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
|
|
+ *
|
|
|
+ * 1.请不要删除和修改根目录下的LICENSE文件。
|
|
|
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
|
|
|
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
|
|
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
|
|
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
|
|
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
|
|
+ */
|
|
|
+package vip.xiaonuo.disk.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollStreamUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
+import vip.xiaonuo.common.annotation.CommonLog;
|
|
|
+import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
+import vip.xiaonuo.common.pojo.CommonValidList;
|
|
|
+import vip.xiaonuo.disk.domain.CourseStudentProgress;
|
|
|
+import vip.xiaonuo.disk.param.courseclasshourfilerelate.CourseRelateIdParam;
|
|
|
+import vip.xiaonuo.disk.param.coursestudentprogress.CourseStudentProgressAddParam;
|
|
|
+import vip.xiaonuo.disk.param.coursestudentprogress.CourseStudentProgressEditParam;
|
|
|
+import vip.xiaonuo.disk.param.coursestudentprogress.CourseStudentProgressIdParam;
|
|
|
+import vip.xiaonuo.disk.param.coursestudentprogress.CourseStudentProgressPageParam;
|
|
|
+import vip.xiaonuo.disk.service.CourseStudentProgressService;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 课程学生-学习进度表控制器
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+@Api(tags = "课程学生-学习进度表控制器")
|
|
|
+@ApiSupport(author = "SNOWY_TEAM", order = 1)
|
|
|
+@RestController
|
|
|
+@Validated
|
|
|
+public class CourseStudentProgressController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CourseStudentProgressService courseStudentProgressService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取课程学生-学习进度表分页
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation("获取课程学生-学习进度表分页")
|
|
|
+ @SaCheckPermission("/disk/coursestudentprogress/page")
|
|
|
+ @GetMapping("/disk/coursestudentprogress/page")
|
|
|
+ public CommonResult<Page<CourseStudentProgress>> page(CourseStudentProgressPageParam courseStudentProgressPageParam) {
|
|
|
+ return CommonResult.data(courseStudentProgressService.page(courseStudentProgressPageParam));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 课程学生学习进度表-添加
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation("课程学生学习进度表-添加")
|
|
|
+ @CommonLog("课程学生学习进度表-添加")
|
|
|
+ @PostMapping("/disk/coursestudentprogress/add")
|
|
|
+ public CommonResult<String> add(@RequestBody @Valid CourseStudentProgressAddParam courseStudentProgressAddParam) {
|
|
|
+ Map param=new HashMap();
|
|
|
+ CourseStudentProgress courseStudentProgress=BeanUtil.toBean(courseStudentProgressAddParam, CourseStudentProgress.class);
|
|
|
+ String userId =StpLoginUserUtil.getLoginUser().getId();
|
|
|
+ courseStudentProgress.setUserId(userId);
|
|
|
+ //进度不能覆盖,查询该学生该课程上一次的学习进度,如果本次进度不大于最高的进度,就只存最高的进度
|
|
|
+ param.put("userId", userId);
|
|
|
+ param.put("hourId", courseStudentProgress.getHourId());
|
|
|
+ List<CourseStudentProgress> alreadyList=courseStudentProgressService.wrapperList(param);
|
|
|
+ List<String> alreadyProgressList=CollStreamUtil.toList(alreadyList, CourseStudentProgress::getProgress);
|
|
|
+ //将String转为Long
|
|
|
+ List<Long> alreadyProgressLongList=alreadyProgressList.stream().map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ //取出最大的进度
|
|
|
+ Long maxProgress=alreadyProgressLongList.stream().max(Long::compareTo).orElse(0L);
|
|
|
+ if(Long.valueOf(courseStudentProgressAddParam.getProgress()).longValue()<maxProgress.longValue())courseStudentProgress.setProgress(String.valueOf(maxProgress));
|
|
|
+
|
|
|
+ courseStudentProgressService.addOne(courseStudentProgress);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 课程学生学习进度-查询最近一次进度
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation("课程学生学习进度-查询最近一次进度")
|
|
|
+ @GetMapping("/disk/coursestudentprogress/theLastDetail")
|
|
|
+ public CommonResult<CourseStudentProgress> theLastDetail(@Valid CourseStudentProgressPageParam courseStudentProgressPageParam, HttpServletRequest req) {
|
|
|
+ Map param=new HashMap();
|
|
|
+ param.put("userId", StpLoginUserUtil.getLoginUser().getId());
|
|
|
+ param.put("hourId", req.getParameter("hourId"));
|
|
|
+ //是否查询最近一次进度,0否1是
|
|
|
+ param.put("isLast", "1");
|
|
|
+ List<CourseStudentProgress> alreadyList=courseStudentProgressService.wrapperList(param);
|
|
|
+ CourseStudentProgress courseStudentProgress=null;
|
|
|
+ if(alreadyList.size()>0)
|
|
|
+ {
|
|
|
+ courseStudentProgress=alreadyList.get(0);
|
|
|
+ }
|
|
|
+ return CommonResult.data(courseStudentProgress);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑课程学生-学习进度表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation("编辑课程学生-学习进度表")
|
|
|
+ @CommonLog("编辑课程学生-学习进度表")
|
|
|
+ @PostMapping("/disk/coursestudentprogress/edit")
|
|
|
+ public CommonResult<String> edit(@RequestBody @Valid CourseStudentProgressEditParam courseStudentProgressEditParam) {
|
|
|
+ CourseStudentProgress courseStudentProgress=BeanUtil.toBean(courseStudentProgressEditParam, CourseStudentProgress.class);
|
|
|
+ courseStudentProgressService.editOne(courseStudentProgress);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除课程学生-学习进度表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation("删除课程学生-学习进度表")
|
|
|
+ @CommonLog("删除课程学生-学习进度表")
|
|
|
+ @SaCheckPermission("/disk/coursestudentprogress/delete")
|
|
|
+ @PostMapping("/disk/coursestudentprogress/delete")
|
|
|
+ public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
|
|
|
+ CommonValidList<CourseStudentProgressIdParam> courseStudentProgressIdParamList) {
|
|
|
+ courseStudentProgressService.delete(courseStudentProgressIdParamList);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取课程学生-学习进度表详情
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/30 14:57
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation("获取课程学生-学习进度表详情")
|
|
|
+ @SaCheckPermission("/disk/coursestudentprogress/detail")
|
|
|
+ @GetMapping("/disk/coursestudentprogress/detail")
|
|
|
+ public CommonResult<CourseStudentProgress> detail(@Valid CourseStudentProgressIdParam courseStudentProgressIdParam) {
|
|
|
+ return CommonResult.data(courseStudentProgressService.detail(courseStudentProgressIdParam));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|