From 58154fa8d0c9b1de41eb06d36d086913079704ed Mon Sep 17 00:00:00 2001 From: Liuyang <2746366019@qq.com> Date: Mon, 13 Jan 2025 09:09:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=9F=A5=E7=9C=8B=E9=87=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LearningResourcesController.java | 7 ++++ .../LearningResourcesService.java | 9 ++++- .../LearningResourcesServiceImpl.java | 34 ++++++++++++++----- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/learningresources/LearningResourcesController.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/learningresources/LearningResourcesController.java index ff734491e..b53d67ab0 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/learningresources/LearningResourcesController.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/learningresources/LearningResourcesController.java @@ -118,4 +118,11 @@ public class LearningResourcesController { return success(aLong); } + @PutMapping("/videoViewsUpdate") + @Operation(summary = "视频查看量更新") + // @PreAuthorize("@ss.hasPermission('llm:learning-resources:update')") + public CommonResult videoViewsUpdate(@Valid @RequestBody LearningResourcesSaveReqVO updateReqVO) { + learningResourcesService.videoViewsUpdate(updateReqVO); + return success(true); + } } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesService.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesService.java index e3b3d75ce..fd0da06ef 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesService.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesService.java @@ -54,4 +54,11 @@ public interface LearningResourcesService { PageResult getLearningResourcesPage(LearningResourcesPageReqVO pageReqVO); String downLearningResources(Long id); -} \ No newline at end of file + + + /** + * 视频查看量更新 + * @param updateReqVO 更新信息 + */ + void videoViewsUpdate (@Valid LearningResourcesSaveReqVO updateReqVO); +} diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesServiceImpl.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesServiceImpl.java index 5647e964f..057b12332 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesServiceImpl.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/learningresources/LearningResourcesServiceImpl.java @@ -1,30 +1,22 @@ package cn.iocoder.yudao.module.llm.service.learningresources; -import cn.hutool.core.util.StrUtil; -import cn.hutool.core.util.URLUtil; -import cn.iocoder.yudao.module.llm.dal.dataobject.dataset.DatasetDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; import java.util.*; import cn.iocoder.yudao.module.llm.controller.admin.learningresources.vo.*; import cn.iocoder.yudao.module.llm.dal.dataobject.learningresources.LearningResourcesDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.llm.dal.mysql.learningresources.LearningResourcesMapper; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*; -import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; /** * 学习资源 Service 实现类 @@ -101,4 +93,28 @@ public class LearningResourcesServiceImpl implements LearningResourcesService { learningResourcesMapper.updateDownCount(learningResourcesDO); return learningResourcesDO.getFileUrl(); } -} \ No newline at end of file + + + /** + * 视频查看量更新 + * + * @param updateReqVO 更新信息 + */ + @Override + public void videoViewsUpdate(LearningResourcesSaveReqVO updateReqVO) { + if (updateReqVO == null) { + throw new IllegalArgumentException("传入的LearningResourcesSaveReqVO对象不能为空"); + } + + Integer downCount = updateReqVO.getDownCount(); + + // 如果downCount为空或者小于等于0,则将downCount设置为0 + if (downCount == null|| downCount <= 0) { + updateReqVO.setDownCount(0); + }else { + updateReqVO.setDownCount(downCount + 1); + } + + updateLearningResources(updateReqVO); + } +}