视频查看量更新

This commit is contained in:
Liuyang 2025-01-13 09:09:56 +08:00
parent d63f4abbcd
commit 58154fa8d0
3 changed files with 40 additions and 10 deletions

View File

@ -118,4 +118,11 @@ public class LearningResourcesController {
return success(aLong);
}
@PutMapping("/videoViewsUpdate")
@Operation(summary = "视频查看量更新")
// @PreAuthorize("@ss.hasPermission('llm:learning-resources:update')")
public CommonResult<Boolean> videoViewsUpdate(@Valid @RequestBody LearningResourcesSaveReqVO updateReqVO) {
learningResourcesService.videoViewsUpdate(updateReqVO);
return success(true);
}
}

View File

@ -54,4 +54,11 @@ public interface LearningResourcesService {
PageResult<LearningResourcesDO> getLearningResourcesPage(LearningResourcesPageReqVO pageReqVO);
String downLearningResources(Long id);
}
/**
* 视频查看量更新
* @param updateReqVO 更新信息
*/
void videoViewsUpdate (@Valid LearningResourcesSaveReqVO updateReqVO);
}

View File

@ -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();
}
}
/**
* 视频查看量更新
*
* @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);
}
}