|
@@ -3,6 +3,7 @@ package com.fs.course.controller;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.annotation.Log;
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
import com.fs.common.core.controller.BaseController;
|
|
@@ -11,16 +12,21 @@ import com.fs.common.core.domain.model.LoginUser;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
|
|
+import com.fs.config.cloud.CloudHostProper;
|
|
|
|
|
+import com.fs.course.business.FsVideoResourceBusinessService;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsUserCourseVideo;
|
|
import com.fs.course.domain.FsUserCourseVideo;
|
|
|
import com.fs.course.domain.FsVideoResource;
|
|
import com.fs.course.domain.FsVideoResource;
|
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
|
|
+import com.fs.course.service.IFsUserVideoService;
|
|
|
|
|
+import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
import com.fs.course.service.IFsVideoResourceService;
|
|
import com.fs.course.service.IFsVideoResourceService;
|
|
|
import com.fs.course.vo.FsVideoResourceVO;
|
|
import com.fs.course.vo.FsVideoResourceVO;
|
|
|
import com.fs.framework.web.service.TokenService;
|
|
import com.fs.framework.web.service.TokenService;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -32,6 +38,7 @@ import java.util.stream.Collectors;
|
|
|
/**
|
|
/**
|
|
|
* 资源库管理
|
|
* 资源库管理
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/course/videoResource")
|
|
@RequestMapping("/course/videoResource")
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
@@ -40,11 +47,16 @@ public class FsVideoResourceController extends BaseController {
|
|
|
private final IFsVideoResourceService fsVideoResourceService;
|
|
private final IFsVideoResourceService fsVideoResourceService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserCourseVideoService fsUserCourseVideoService;
|
|
private IFsUserCourseVideoService fsUserCourseVideoService;
|
|
|
- @Autowired
|
|
|
|
|
- private TokenService tokenService;
|
|
|
|
|
|
|
|
|
|
|
|
+ private final TokenService tokenService;
|
|
|
|
|
+
|
|
|
|
|
+ private final ISysConfigService configService;
|
|
|
|
|
+
|
|
|
|
|
+ private final CloudHostProper cloudHostProper;
|
|
|
|
|
+
|
|
|
|
|
+ private final FsVideoResourceBusinessService videoResourceBusinessService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private ISysConfigService configService;
|
|
|
|
|
|
|
+ private IFsUserVideoService fsUserVideoService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询视频素材库列表
|
|
* 查询视频素材库列表
|
|
@@ -56,8 +68,7 @@ public class FsVideoResourceController extends BaseController {
|
|
|
@RequestParam(required = false) Integer typeId,
|
|
@RequestParam(required = false) Integer typeId,
|
|
|
@RequestParam(required = false) Integer typeSubId,
|
|
@RequestParam(required = false) Integer typeSubId,
|
|
|
@RequestParam(required = false, defaultValue = "1") Integer pageNum,
|
|
@RequestParam(required = false, defaultValue = "1") Integer pageNum,
|
|
|
- @RequestParam(required = false, defaultValue = "10") Integer pageSize)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("resourceName", resourceName);
|
|
params.put("resourceName", resourceName);
|
|
|
params.put("fileName", fileName);
|
|
params.put("fileName", fileName);
|
|
@@ -66,7 +77,7 @@ public class FsVideoResourceController extends BaseController {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
- if (ObjectUtil.isNotEmpty(config.getIsBound())&&config.getIsBound()){
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(config.getIsBound()) && config.getIsBound()) {
|
|
|
params.put("userId", loginUser.getUser().getUserId());
|
|
params.put("userId", loginUser.getUser().getUserId());
|
|
|
}
|
|
}
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
@@ -80,8 +91,7 @@ public class FsVideoResourceController extends BaseController {
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('course:videoResource:query')")
|
|
@PreAuthorize("@ss.hasPermi('course:videoResource:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return AjaxResult.success(fsVideoResourceService.getById(id));
|
|
return AjaxResult.success(fsVideoResourceService.getById(id));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -91,17 +101,25 @@ public class FsVideoResourceController extends BaseController {
|
|
|
@PreAuthorize("@ss.hasPermi('course:videoResource:add')")
|
|
@PreAuthorize("@ss.hasPermi('course:videoResource:add')")
|
|
|
@Log(title = "视频素材库", businessType = BusinessType.INSERT)
|
|
@Log(title = "视频素材库", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody FsVideoResource fsVideoResource)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody FsVideoResource fsVideoResource) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long userId = loginUser.getUser().getUserId();
|
|
Long userId = loginUser.getUser().getUserId();
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
- if (ObjectUtil.isNotEmpty(config.getIsBound())&&config.getIsBound()){
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(config.getIsBound()) && config.getIsBound()) {
|
|
|
fsVideoResource.setUserId(userId);
|
|
fsVideoResource.setUserId(userId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
fsVideoResource.setCreateTime(LocalDateTime.now());
|
|
fsVideoResource.setCreateTime(LocalDateTime.now());
|
|
|
- fsVideoResourceService.save(fsVideoResource);
|
|
|
|
|
|
|
+ boolean save = fsVideoResourceService.save(fsVideoResource);
|
|
|
|
|
+ if (save&&StringUtils.isNotEmpty(fsVideoResource.getHsyVid())){
|
|
|
|
|
+ try {
|
|
|
|
|
+ fsUserCourseVideoService.updateMediaPublishStatus(fsVideoResource.getHsyVid());
|
|
|
|
|
+ log.info("更新视频发布状态成功,hsyVid: {}", fsVideoResource.getHsyVid());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("更新视频发布状态失败,hsyVid: {}, 错误: {}", fsVideoResource.getHsyVid(), e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -118,6 +136,11 @@ public class FsVideoResourceController extends BaseController {
|
|
|
fsVideoResource.setUpdateTime(LocalDateTime.now());
|
|
fsVideoResource.setUpdateTime(LocalDateTime.now());
|
|
|
//12.10要求素材名称跟着视频名称走
|
|
//12.10要求素材名称跟着视频名称走
|
|
|
fsVideoResource.setResourceName(fsVideoResource.getFileName());
|
|
fsVideoResource.setResourceName(fsVideoResource.getFileName());
|
|
|
|
|
+ if (("今正科技".equals(cloudHostProper.getCompanyName()))) {
|
|
|
|
|
+ // 同步资源到课程
|
|
|
|
|
+ videoResourceBusinessService.edit(fsVideoResource);
|
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
|
+ }
|
|
|
fsVideoResourceService.updateById(fsVideoResource);
|
|
fsVideoResourceService.updateById(fsVideoResource);
|
|
|
fsUserCourseVideoService.updateVideoByVideoUrl(fsVideoResource.getVideoUrl(),fsVideoResourceResult.getOldVideoUrl(),fsVideoResource.getThumbnail(),fsVideoResource.getFileName());
|
|
fsUserCourseVideoService.updateVideoByVideoUrl(fsVideoResource.getVideoUrl(),fsVideoResourceResult.getOldVideoUrl(),fsVideoResource.getThumbnail(),fsVideoResource.getFileName());
|
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
@@ -129,8 +152,7 @@ public class FsVideoResourceController extends BaseController {
|
|
|
@PreAuthorize("@ss.hasPermi('course:videoResource:remove')")
|
|
@PreAuthorize("@ss.hasPermi('course:videoResource:remove')")
|
|
|
@Log(title = "视频素材库", businessType = BusinessType.DELETE)
|
|
@Log(title = "视频素材库", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
@DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
Wrapper<FsVideoResource> updateWrapper = Wrappers.<FsVideoResource>lambdaUpdate()
|
|
Wrapper<FsVideoResource> updateWrapper = Wrappers.<FsVideoResource>lambdaUpdate()
|
|
|
.set(FsVideoResource::getIsDel, 1)
|
|
.set(FsVideoResource::getIsDel, 1)
|
|
|
.in(FsVideoResource::getId, Arrays.asList(ids));
|
|
.in(FsVideoResource::getId, Arrays.asList(ids));
|
|
@@ -140,6 +162,7 @@ public class FsVideoResourceController extends BaseController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 批量修改视频分类
|
|
* 批量修改视频分类
|
|
|
|
|
+ *
|
|
|
* @param typeId
|
|
* @param typeId
|
|
|
* @param typeSubId
|
|
* @param typeSubId
|
|
|
* @param ids
|
|
* @param ids
|
|
@@ -151,13 +174,13 @@ public class FsVideoResourceController extends BaseController {
|
|
|
public AjaxResult batchUpdateClass(@RequestParam("typeId") Long typeId,
|
|
public AjaxResult batchUpdateClass(@RequestParam("typeId") Long typeId,
|
|
|
@RequestParam("typeSubId") Long typeSubId,
|
|
@RequestParam("typeSubId") Long typeSubId,
|
|
|
@RequestParam("ids") String ids) {
|
|
@RequestParam("ids") String ids) {
|
|
|
- if(typeId == null || typeId <= 0){
|
|
|
|
|
|
|
+ if (typeId == null || typeId <= 0) {
|
|
|
return AjaxResult.error("请选择分类");
|
|
return AjaxResult.error("请选择分类");
|
|
|
}
|
|
}
|
|
|
- if(typeSubId == null || typeSubId <= 0){
|
|
|
|
|
|
|
+ if (typeSubId == null || typeSubId <= 0) {
|
|
|
return AjaxResult.error("请选择子分类");
|
|
return AjaxResult.error("请选择子分类");
|
|
|
}
|
|
}
|
|
|
- if(ids == null || ids.isEmpty()){
|
|
|
|
|
|
|
+ if (ids == null || ids.isEmpty()) {
|
|
|
return AjaxResult.error("请选择要修改的分类");
|
|
return AjaxResult.error("请选择要修改的分类");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -187,13 +210,26 @@ public class FsVideoResourceController extends BaseController {
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
|
|
|
|
|
- list.forEach(v ->{
|
|
|
|
|
|
|
+ list.forEach(v -> {
|
|
|
v.setCreateTime(LocalDateTime.now());
|
|
v.setCreateTime(LocalDateTime.now());
|
|
|
- if (ObjectUtil.isNotEmpty(config.getIsBound())&&config.getIsBound()){
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(config.getIsBound()) && config.getIsBound()) {
|
|
|
v.setUserId(userId);
|
|
v.setUserId(userId);
|
|
|
}
|
|
}
|
|
|
- } );
|
|
|
|
|
- fsVideoResourceService.saveBatch(list);
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ boolean saveStatus = fsVideoResourceService.saveBatch(list);
|
|
|
|
|
+ if (saveStatus) {
|
|
|
|
|
+ list.forEach(fsVideoResource -> {
|
|
|
|
|
+ // 检查hsyVid是否存在且不为空
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(fsVideoResource.getHsyVid())) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ fsUserCourseVideoService.updateMediaPublishStatus(fsVideoResource.getHsyVid());
|
|
|
|
|
+ log.info("更新视频发布状态成功,hsyVid: {}", fsVideoResource.getHsyVid());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("更新视频发布状态失败,hsyVid: {}, 错误: {}", fsVideoResource.getHsyVid(), e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|