Browse Source

获取学习视频列表(分页) 接口

tags/V1.8.0^2
wanghaoran 1 year ago
parent
commit
e1e140171b
10 changed files with 279 additions and 4 deletions
  1. +36
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/controller/WestreamVideoController.java
  2. +56
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/WestreamVideo.java
  3. +51
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/WestreamVideoUser.java
  4. +17
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/request/WestreamVideoQuery.java
  5. +13
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/mapper/WestreamVideoMapper.java
  6. +13
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/mapper/WestreamVideoUserMapper.java
  7. +10
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/service/IWestreamVideoService.java
  8. +69
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamVideoServiceImpl.java
  9. +4
    -4
      tuoheng-common/src/main/java/com/tuoheng/common/common/BaseQuery.java
  10. +10
    -0
      tuoheng-common/src/main/java/com/tuoheng/common/utils/CommonUtils.java

+ 36
- 0
tuoheng-api/src/main/java/com/tuoheng/api/controller/WestreamVideoController.java View File

@@ -0,0 +1,36 @@
package com.tuoheng.api.controller;

import com.tuoheng.api.entity.request.StreamQuery;
import com.tuoheng.api.entity.request.WestreamVideoQuery;
import com.tuoheng.api.service.IWestreamUserService;
import com.tuoheng.api.service.IWestreamVideoService;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 全民护河学习视频 前端控制器
*
* @author WangHaoran
* @since 2023-06-07
*/
@RestController
@RequestMapping("/westreamVideo")
public class WestreamVideoController {

@Autowired
IWestreamVideoService westreamVideoService;

/**
* 获取学习视频列表(分页)
*
* @param query 查询条件
* @return
*/
@GetMapping("/index")
public JsonResult index(WestreamVideoQuery query) {
return westreamVideoService.queryPage(query);
}
}

+ 56
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/WestreamVideo.java View File

@@ -0,0 +1,56 @@
package com.tuoheng.api.entity.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
* 全民护河学习视频表
*
* @author WangHaoran
* @since 2023-06-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("th_westream_video")
public class WestreamVideo extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 租户ID
*/
private Integer tenantId;

/**
* 视频标题
*/
private String videoTitle;

/**
* 视频简介
*/
private String videoBrief;

/**
* 视频地址
*/
private String videoUrl;

/**
* 封面图片地址
*/
private String imageUrl;

/**
* 视频学习状态 0待学习 1学习中 2已学习
*/
@TableField(exist = false)
private Integer status;
}

+ 51
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/WestreamVideoUser.java View File

@@ -0,0 +1,51 @@
package com.tuoheng.api.entity.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;


/**
* 全民护河学习视频用户表
*
* @author WangHaoran
* @since 2023-06-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("th_westream_video_user")
public class WestreamVideoUser extends BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 租户ID
*/
private Integer tenantId;

/**
* 视频标题
*/
private Integer videoId;

/**
* 视频标题
*/
private String openid;

/**
* 视频观看进度
*/
private String videoProgress;

/**
* 视频学习状态 1学习中 2已学习
*/
private Integer status;

}

+ 17
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/request/WestreamVideoQuery.java View File

@@ -0,0 +1,17 @@
package com.tuoheng.api.entity.request;

import com.tuoheng.common.common.BaseQuery;
import lombok.Data;

@Data
public class WestreamVideoQuery extends BaseQuery {
/**
* 租户ID
*/
private Integer tenantId;

/**
* 用户openid
*/
private String openid;
}

+ 13
- 0
tuoheng-api/src/main/java/com/tuoheng/api/mapper/WestreamVideoMapper.java View File

@@ -0,0 +1,13 @@
package com.tuoheng.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.api.entity.domain.WestreamVideo;

/**
* 全民护河学习视频表 Mapper 接口
*
* @author WangHaoran
* @since 2023-06-07
*/
public interface WestreamVideoMapper extends BaseMapper<WestreamVideo> {
}

+ 13
- 0
tuoheng-api/src/main/java/com/tuoheng/api/mapper/WestreamVideoUserMapper.java View File

@@ -0,0 +1,13 @@
package com.tuoheng.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.api.entity.domain.WestreamVideoUser;

/**
* 全民护河学习视频用户表 Mapper 接口
*
* @author WangHaoran
* @since 2023-06-07
*/
public interface WestreamVideoUserMapper extends BaseMapper<WestreamVideoUser> {
}

+ 10
- 0
tuoheng-api/src/main/java/com/tuoheng/api/service/IWestreamVideoService.java View File

@@ -0,0 +1,10 @@
package com.tuoheng.api.service;

import com.tuoheng.api.entity.domain.WestreamVideo;
import com.tuoheng.api.entity.request.WestreamVideoQuery;
import com.tuoheng.common.common.IBaseService;
import com.tuoheng.common.utils.JsonResult;

public interface IWestreamVideoService extends IBaseService<WestreamVideo> {
JsonResult queryPage(WestreamVideoQuery query);
}

+ 69
- 0
tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamVideoServiceImpl.java View File

@@ -0,0 +1,69 @@
package com.tuoheng.api.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.api.entity.domain.WestreamScenery;
import com.tuoheng.api.entity.domain.WestreamVideo;
import com.tuoheng.api.entity.domain.WestreamVideoUser;
import com.tuoheng.api.entity.request.WestreamVideoQuery;
import com.tuoheng.api.mapper.WestreamVideoMapper;
import com.tuoheng.api.mapper.WestreamVideoUserMapper;
import com.tuoheng.api.service.IWestreamVideoService;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.config.CommonConfig;
import com.tuoheng.common.utils.CommonUtils;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 全民护河学习视频表 服务实现类
*
* @author WangHaoran
* @since 2023-06-07
*/
@Service
public class WestreamVideoServiceImpl extends BaseServiceImpl<WestreamVideoMapper, WestreamVideo> implements IWestreamVideoService {

@Autowired
private WestreamVideoMapper westreamVideoMapper;

@Autowired
private WestreamVideoUserMapper westreamVideoUserMapper;

@Override
public JsonResult queryPage(WestreamVideoQuery query) {
if(null == query.getTenantId() || StringUtils.isEmpty(query.getOpenid())){
return JsonResult.error("参数为空!");
}

// 获取分页数据
IPage<WestreamVideo> page = new Page<>(query.getPage(), query.getLimit());
IPage<WestreamVideo> pageData = westreamVideoMapper.selectPage(page, new LambdaQueryWrapper<WestreamVideo>()
.eq(WestreamVideo::getMark, 1)
.eq(WestreamVideo::getTenantId, query.getTenantId())
.orderByDesc(WestreamVideo::getCreateTime));

for (WestreamVideo record : pageData.getRecords()) {
//替换图片域名
record.setImageUrl(CommonUtils.getImageURL(record.getImageUrl()));
//替换视频域名
record.setVideoUrl(CommonUtils.getVideoURL(record.getVideoUrl()));
//查询该视频对应用户观看状态
WestreamVideoUser westreamVideoUser = westreamVideoUserMapper.selectOne(new LambdaQueryWrapper<WestreamVideoUser>()
.eq(WestreamVideoUser::getVideoId, record.getId())
.eq(WestreamVideoUser::getTenantId, query.getTenantId())
.eq(WestreamVideoUser::getMark, 1));
if(ObjectUtil.isNull(westreamVideoUser)){
record.setStatus(0);
}else {
record.setStatus(westreamVideoUser.getStatus());
}
}

return JsonResult.success(pageData);
}
}

+ 4
- 4
tuoheng-common/src/main/java/com/tuoheng/common/common/BaseQuery.java View File

@@ -8,12 +8,12 @@ import lombok.Data;
@Data
public class BaseQuery {
/**
* 页码
* 页码(默认1)
*/
private Integer page;
private Integer page = 1;

/**
* 每页数
* 每页数(默认10)
*/
private Integer limit;
private Integer limit = 10;
}

+ 10
- 0
tuoheng-common/src/main/java/com/tuoheng/common/utils/CommonUtils.java View File

@@ -17,6 +17,16 @@ import java.util.stream.Collectors;
*/
public class CommonUtils {

/**
* 获取到视频域名的地址
*
* @param videoUrl
* @return
*/
public static String getVideoURL(String videoUrl) {
return CommonConfig.videoURL + videoUrl;
}

/**
* 获取到图片域名的地址
*

Loading…
Cancel
Save