@@ -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); | |||
} | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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> { | |||
} |
@@ -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> { | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} | |||
/** | |||
* 获取到图片域名的地址 | |||
* |