Parcourir la source

更新视频观看进度 接口

tags/V1.8.0^2
wanghaoran il y a 1 an
Parent
révision
7881455609
5 fichiers modifiés avec 140 ajouts et 10 suppressions
  1. +16
    -1
      tuoheng-api/src/main/java/com/tuoheng/api/constants/DictConstants.java
  2. +13
    -3
      tuoheng-api/src/main/java/com/tuoheng/api/controller/WestreamVideoController.java
  3. +15
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/request/WestreamVideoQuery.java
  4. +2
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/service/IWestreamVideoService.java
  5. +94
    -6
      tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamVideoServiceImpl.java

+ 16
- 1
tuoheng-api/src/main/java/com/tuoheng/api/constants/DictConstants.java Voir le fichier

@@ -14,9 +14,24 @@ public class DictConstants {
public static final String POINTS_RULE_FEEDBACK = "submit_feedback";
//积分规则-上传美拍并通过
public static final String POINTS_RULE_PICTURE = "submit_scenery";
//积分规则-上报问题每日上限积分
public static final String POINTS_RULE_DAILYLIMIT_FEEDBACK = "daily_limit_feedback";
//积分规则-上传美拍每日上限积分
public static final String POINTS_RULE_DAILYLIMIT_PICTURE = "daily_limit_picture";
//积分规则-注册小程序账号
public static final String APP_REGISTRY = "app_registry";
//积分规则-关注抖音并通过
public static final String TIKTOK = "tiktok";
//积分规则-观看学习视频
public static final String VIDEO = "video";
//积分规则-报名志愿者活动
public static final String VOLUNTEER_ACTIVITY = "volunteer_activity";
//积分规则-提交护河建议
public static final String PROTECT_RIVER_SUGGESTION = "protect_river_suggestion";
//积分规则-提交护河建议每日积分上限
public static final String POINTS_RULE_DAILYlIMIT_SUGGESTION = "daily_limit_suggestion";
//积分规则-每日上限积分
public static final String POINTS_RULE_DAILYLIMIT = "daily_limit";

//短信规则code
public static final String MSG_RULE_CODE = "msg_rule";
//短信规则name描述

+ 13
- 3
tuoheng-api/src/main/java/com/tuoheng/api/controller/WestreamVideoController.java Voir le fichier

@@ -1,14 +1,13 @@
package com.tuoheng.api.controller;

import com.tuoheng.api.entity.domain.WestreamVideo;
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;
import org.springframework.web.bind.annotation.*;

/**
* 全民护河学习视频 前端控制器
@@ -33,4 +32,15 @@ public class WestreamVideoController {
public JsonResult index(WestreamVideoQuery query) {
return westreamVideoService.queryPage(query);
}

/**
* 更新视频观看进度
*
* @param query
* @return
*/
@PutMapping("/updateProgress")
public JsonResult updateProgress(@RequestBody WestreamVideoQuery query) {
return westreamVideoService.updateProgress(query);
}
}

+ 15
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/request/WestreamVideoQuery.java Voir le fichier

@@ -14,4 +14,19 @@ public class WestreamVideoQuery extends BaseQuery {
* 用户openid
*/
private String openid;

/**
* 视频ID
*/
private Integer videoId;

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

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

+ 2
- 0
tuoheng-api/src/main/java/com/tuoheng/api/service/IWestreamVideoService.java Voir le fichier

@@ -7,4 +7,6 @@ import com.tuoheng.common.utils.JsonResult;

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

JsonResult updateProgress(WestreamVideoQuery query);
}

+ 94
- 6
tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamVideoServiceImpl.java Voir le fichier

@@ -3,22 +3,26 @@ 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.core.toolkit.ObjectUtils;
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.constants.DictConstants;
import com.tuoheng.api.entity.domain.*;
import com.tuoheng.api.entity.request.WestreamVideoQuery;
import com.tuoheng.api.mapper.WestreamVideoMapper;
import com.tuoheng.api.mapper.WestreamVideoUserMapper;
import com.tuoheng.api.mapper.*;
import com.tuoheng.api.service.IWestreamVideoService;
import com.tuoheng.api.utils.SmsUtil;
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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
* 全民护河学习视频表 服务实现类
*
@@ -34,6 +38,18 @@ public class WestreamVideoServiceImpl extends BaseServiceImpl<WestreamVideoMappe
@Autowired
private WestreamVideoUserMapper westreamVideoUserMapper;

@Autowired
private WestreamUserMapper westreamUserMapper;

@Autowired
private ThDictMapper thDictMapper;

@Autowired
private ThDictDataMapper thDictDataMapper;

@Autowired
private UserPointsDetailMapper userPointsDetailMapper;

@Override
public JsonResult queryPage(WestreamVideoQuery query) {
if(null == query.getTenantId() || StringUtils.isEmpty(query.getOpenid())){
@@ -66,4 +82,76 @@ public class WestreamVideoServiceImpl extends BaseServiceImpl<WestreamVideoMappe

return JsonResult.success(pageData);
}

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

if(null == query.getVideoId()){
return JsonResult.error("视频ID为空!");
}


WestreamVideoUser westreamVideoUser = westreamVideoUserMapper.selectOne(new LambdaQueryWrapper<WestreamVideoUser>()
.eq(WestreamVideoUser::getTenantId, query.getTenantId())
.eq(WestreamVideoUser::getOpenid, query.getOpenid())
.eq(WestreamVideoUser::getVideoId, query.getVideoId())
.eq(WestreamVideoUser::getMark, 1));

if(ObjectUtil.isNull(westreamVideoUser)){
WestreamVideoUser westreamVideoUserAdd = new WestreamVideoUser();
BeanUtils.copyProperties(query, westreamVideoUserAdd);
westreamVideoUserAdd.setCreateTime(new Date());
westreamVideoUserMapper.insert(westreamVideoUserAdd);
}else {
westreamVideoUser.setVideoProgress(query.getVideoProgress());
westreamVideoUser.setStatus(query.getStatus());
westreamVideoUserMapper.updateById(westreamVideoUser);
//视频学习完成,开始计算积分
if(2 == query.getStatus()){

//查询学习视频 积分设置
//发送短信
ThDict thDict = thDictMapper.selectOne(new LambdaQueryWrapper<ThDict>()
.eq(ThDict::getTenantId, query.getTenantId())
.eq(ThDict::getCode, DictConstants.POINTS_RULE_CODE)
.eq(ThDict::getMark, 1));
if(ObjectUtils.isNotNull(thDict)){
ThDictData thDictData = thDictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>()
.eq(ThDictData::getDictId, thDict.getId())
.eq(ThDictData::getName, DictConstants.VIDEO));
if(ObjectUtils.isNotNull(thDictData)){
if(StringUtils.isNotEmpty(thDictData.getValue())){
//查询用户昵称
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>()
.eq(WestreamUser::getTenantId, query.getTenantId())
.eq(WestreamUser::getOpenid, query.getOpenid())
.eq(WestreamUser::getMark, 1));


//积分明细表入库
UserPointsDetail userPointsDetail = new UserPointsDetail();
BeanUtils.copyProperties(query,userPointsDetail);
userPointsDetail.setNickname(westreamUser.getNickname());
userPointsDetail.setPointsChange(Integer.parseInt(thDictData.getValue()));
userPointsDetail.setPointsTime(new Date());
userPointsDetail.setChangeName("观看学习视频"+query.getVideoId());
userPointsDetail.setType(1);
userPointsDetailMapper.insert(userPointsDetail);

//TODO 对接商城
}
}
}
}




}

return JsonResult.success();
}
}

Chargement…
Annuler
Enregistrer