commit
36b479dd25
@ -7,6 +7,7 @@ import com.stdiet.common.utils.DateUtils;
|
|||||||
import com.stdiet.common.utils.StringUtils;
|
import com.stdiet.common.utils.StringUtils;
|
||||||
import com.stdiet.common.utils.sign.AesUtils;
|
import com.stdiet.common.utils.sign.AesUtils;
|
||||||
import com.stdiet.custom.domain.SysOrderPause;
|
import com.stdiet.custom.domain.SysOrderPause;
|
||||||
|
import com.stdiet.custom.domain.SysVideoComment;
|
||||||
import com.stdiet.custom.domain.SysWxAdLog;
|
import com.stdiet.custom.domain.SysWxAdLog;
|
||||||
import com.stdiet.custom.service.*;
|
import com.stdiet.custom.service.*;
|
||||||
import com.stdiet.custom.utils.CookieUtils;
|
import com.stdiet.custom.utils.CookieUtils;
|
||||||
@ -45,6 +46,9 @@ public class SysWapController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
ISysSmsConfirmServie iSysSmsConfirmServie;
|
ISysSmsConfirmServie iSysSmsConfirmServie;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ISysNutritionalVideoService iSysNutritionalVideoService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户食谱详情
|
* 客户食谱详情
|
||||||
@ -159,6 +163,12 @@ public class SysWapController extends BaseController {
|
|||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取验证码
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping(value = "/checkCookie")
|
@GetMapping(value = "/checkCookie")
|
||||||
public AjaxResult checkCookie(HttpServletRequest request) {
|
public AjaxResult checkCookie(HttpServletRequest request) {
|
||||||
JSONObject resultObj = CookieUtils.checkCookieValida(request, "token");
|
JSONObject resultObj = CookieUtils.checkCookieValida(request, "token");
|
||||||
@ -169,6 +179,12 @@ public class SysWapController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码校验
|
||||||
|
*
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping(value = "/getCode")
|
@GetMapping(value = "/getCode")
|
||||||
public AjaxResult getCode(@RequestParam String phone) {
|
public AjaxResult getCode(@RequestParam String phone) {
|
||||||
|
|
||||||
@ -200,8 +216,6 @@ public class SysWapController extends BaseController {
|
|||||||
String tokenStr = phone + "_" + new Date().getTime() + "_" + RandomStringUtils.randomAlphanumeric(8);
|
String tokenStr = phone + "_" + new Date().getTime() + "_" + RandomStringUtils.randomAlphanumeric(8);
|
||||||
Cookie cookie = new Cookie("token", AesUtils.encrypt(tokenStr));
|
Cookie cookie = new Cookie("token", AesUtils.encrypt(tokenStr));
|
||||||
cookie.setMaxAge(24 * 60 * 60);
|
cookie.setMaxAge(24 * 60 * 60);
|
||||||
// cookie.setSecure(true);
|
|
||||||
// cookie.setHttpOnly(true);
|
|
||||||
cookie.setPath("/");
|
cookie.setPath("/");
|
||||||
response.addCookie(cookie);
|
response.addCookie(cookie);
|
||||||
return new AjaxResult(20000, "登录成功");
|
return new AjaxResult(20000, "登录成功");
|
||||||
@ -214,4 +228,53 @@ public class SysWapController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/video/comment")
|
||||||
|
public AjaxResult getVideoComment(SysVideoComment videoComment, HttpServletRequest request) {
|
||||||
|
JSONObject result = CookieUtils.checkCookieValida(request, "token");
|
||||||
|
|
||||||
|
String phone = result.getString("phone");
|
||||||
|
List<SysVideoComment> comments = iSysNutritionalVideoService.selectVideoCommentByTopicId(videoComment, phone == null ? "" : phone);
|
||||||
|
|
||||||
|
return AjaxResult.success(comments);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/video/post/comment")
|
||||||
|
public AjaxResult insertVideoComment(@RequestBody SysVideoComment videoComment, HttpServletRequest request) {
|
||||||
|
JSONObject result = CookieUtils.checkCookieValida(request, "token");
|
||||||
|
if (result.getInteger("code") != 200) {
|
||||||
|
return AjaxResult.error(result.getInteger("code"), result.getString("msg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
videoComment.setFromUid(result.getString("phone"));
|
||||||
|
videoComment.setFromRole("phone");
|
||||||
|
|
||||||
|
SysVideoComment comment = iSysNutritionalVideoService.insertVideoComment(videoComment);
|
||||||
|
|
||||||
|
if (StringUtils.isNull(comment)) {
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/video/post/reply")
|
||||||
|
public AjaxResult insertVideoCommentReply(@RequestBody SysVideoComment videoComment, HttpServletRequest request) {
|
||||||
|
JSONObject result = CookieUtils.checkCookieValida(request, "token");
|
||||||
|
if (result.getInteger("code") != 200) {
|
||||||
|
return AjaxResult.error(result.getInteger("code"), result.getString("msg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
videoComment.setFromUid(result.getString("phone"));
|
||||||
|
videoComment.setFromRole("phone");
|
||||||
|
|
||||||
|
SysVideoComment reply = iSysNutritionalVideoService.insertVideoCommentReply(videoComment);
|
||||||
|
|
||||||
|
if (StringUtils.isNull(reply)) {
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,6 @@ public class VideoWebInterfaceController extends BaseController {
|
|||||||
|
|
||||||
JSONObject result = CookieUtils.checkCookieValida(request, "token");
|
JSONObject result = CookieUtils.checkCookieValida(request, "token");
|
||||||
if (result.getInteger("code") != 200) {
|
if (result.getInteger("code") != 200) {
|
||||||
// TableDataInfo errInfo = new TableDataInfo();
|
|
||||||
// errInfo.setCode(result.getInteger("code"));
|
|
||||||
// errInfo.setMsg(result.getString("msg"));
|
|
||||||
// return errInfo;
|
|
||||||
|
|
||||||
Cookie cookie = new Cookie("token", "");
|
Cookie cookie = new Cookie("token", "");
|
||||||
cookie.setMaxAge(24 * 60 * 60);
|
cookie.setMaxAge(24 * 60 * 60);
|
||||||
cookie.setPath("/");
|
cookie.setPath("/");
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.stdiet.custom.domain;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class SysVideoComment {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题id
|
||||||
|
*/
|
||||||
|
String topicId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题类型
|
||||||
|
*/
|
||||||
|
Integer topicType;
|
||||||
|
|
||||||
|
String commentId;
|
||||||
|
|
||||||
|
String replyId;
|
||||||
|
|
||||||
|
Integer replyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
*/
|
||||||
|
String uid;
|
||||||
|
|
||||||
|
String fromUid;
|
||||||
|
|
||||||
|
String toUid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题内容
|
||||||
|
*/
|
||||||
|
String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片地址
|
||||||
|
*/
|
||||||
|
JSONArray img;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0-未读 1-已读
|
||||||
|
*/
|
||||||
|
Integer read;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
*/
|
||||||
|
String role;
|
||||||
|
|
||||||
|
String fromRole;
|
||||||
|
|
||||||
|
String toRole;
|
||||||
|
|
||||||
|
// 非持久化字段
|
||||||
|
/**
|
||||||
|
* 角色名字
|
||||||
|
*/
|
||||||
|
String fromName;
|
||||||
|
String toName;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
String avatar;
|
||||||
|
String fromAvatar;
|
||||||
|
String toAvatar;
|
||||||
|
|
||||||
|
|
||||||
|
List<SysVideoComment> comments;
|
||||||
|
|
||||||
|
List<SysVideoComment> replys;
|
||||||
|
|
||||||
|
Integer count;
|
||||||
|
|
||||||
|
Boolean owner;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.stdiet.custom.mapper;
|
||||||
|
|
||||||
|
import com.stdiet.custom.domain.SysVideoComment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysVideoCommentMapper {
|
||||||
|
List<SysVideoComment> selectVideoCommentByTopicId(SysVideoComment videoComment);
|
||||||
|
|
||||||
|
int insertVideoComment(SysVideoComment videoComment);
|
||||||
|
|
||||||
|
int insertVideoCommentReply(SysVideoComment videoComment);
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.stdiet.custom.domain.SysNutritionalVideo;
|
import com.stdiet.custom.domain.SysNutritionalVideo;
|
||||||
import com.stdiet.custom.domain.SysVideoClassify;
|
import com.stdiet.custom.domain.SysVideoClassify;
|
||||||
|
import com.stdiet.custom.domain.SysVideoComment;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,4 +90,25 @@ public interface ISysNutritionalVideoService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int updateVideoPlayNum(String videoId);
|
public int updateVideoPlayNum(String videoId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取评论
|
||||||
|
* @param videoComment
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<SysVideoComment> selectVideoCommentByTopicId(SysVideoComment videoComment, String phone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加评论
|
||||||
|
* @param videoComment
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SysVideoComment insertVideoComment(SysVideoComment videoComment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加回复
|
||||||
|
* @param videoComment
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SysVideoComment insertVideoCommentReply(SysVideoComment videoComment);
|
||||||
}
|
}
|
@ -1,22 +1,24 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.aliyun.vod20170321.models.SearchMediaResponse;
|
import com.aliyun.vod20170321.models.SearchMediaResponse;
|
||||||
import com.aliyun.vod20170321.models.SearchMediaResponseBody;
|
import com.aliyun.vod20170321.models.SearchMediaResponseBody;
|
||||||
import com.stdiet.common.utils.AliyunVideoUtils;
|
import com.stdiet.common.utils.AliyunVideoUtils;
|
||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
import com.stdiet.common.utils.StringUtils;
|
import com.stdiet.common.utils.StringUtils;
|
||||||
import com.stdiet.common.utils.oss.AliyunOSSUtils;
|
import com.stdiet.common.utils.oss.AliyunOSSUtils;
|
||||||
|
import com.stdiet.custom.domain.SysNutritionalVideo;
|
||||||
|
import com.stdiet.custom.domain.SysVideoComment;
|
||||||
|
import com.stdiet.custom.mapper.SysNutritionalVideoMapper;
|
||||||
|
import com.stdiet.custom.mapper.SysVideoCommentMapper;
|
||||||
|
import com.stdiet.custom.service.ISysNutritionalVideoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.stdiet.custom.mapper.SysNutritionalVideoMapper;
|
|
||||||
import com.stdiet.custom.domain.SysNutritionalVideo;
|
import java.util.ArrayList;
|
||||||
import com.stdiet.custom.service.ISysNutritionalVideoService;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 营养视频Service业务层处理
|
* 营养视频Service业务层处理
|
||||||
@ -25,11 +27,13 @@ import com.stdiet.custom.service.ISysNutritionalVideoService;
|
|||||||
* @date 2021-04-29
|
* @date 2021-04-29
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoService
|
public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysNutritionalVideoMapper sysNutritionalVideoMapper;
|
private SysNutritionalVideoMapper sysNutritionalVideoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysVideoCommentMapper sysVideoCommentMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询营养视频
|
* 查询营养视频
|
||||||
*
|
*
|
||||||
@ -37,8 +41,7 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
* @return 营养视频
|
* @return 营养视频
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysNutritionalVideo selectSysNutritionalVideoById(Long id)
|
public SysNutritionalVideo selectSysNutritionalVideoById(Long id) {
|
||||||
{
|
|
||||||
return sysNutritionalVideoMapper.selectSysNutritionalVideoById(id);
|
return sysNutritionalVideoMapper.selectSysNutritionalVideoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,35 +52,34 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
* @return 营养视频
|
* @return 营养视频
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysNutritionalVideo> selectSysNutritionalVideoList(SysNutritionalVideo sysNutritionalVideo, boolean flag)
|
public List<SysNutritionalVideo> selectSysNutritionalVideoList(SysNutritionalVideo sysNutritionalVideo, boolean flag) {
|
||||||
{
|
|
||||||
List<SysNutritionalVideo> list = sysNutritionalVideoMapper.selectSysNutritionalVideoList(sysNutritionalVideo);
|
List<SysNutritionalVideo> list = sysNutritionalVideoMapper.selectSysNutritionalVideoList(sysNutritionalVideo);
|
||||||
if(flag && list != null && list.size() > 0){
|
if (flag && list != null && list.size() > 0) {
|
||||||
List<String> fileUrl = new ArrayList<>();
|
List<String> fileUrl = new ArrayList<>();
|
||||||
List<String> videoIdList = new ArrayList<>();
|
List<String> videoIdList = new ArrayList<>();
|
||||||
for (SysNutritionalVideo video : list) {
|
for (SysNutritionalVideo video : list) {
|
||||||
if(StringUtils.isNotEmpty(video.getCoverUrl())){
|
if (StringUtils.isNotEmpty(video.getCoverUrl())) {
|
||||||
fileUrl.add(video.getCoverUrl());
|
fileUrl.add(video.getCoverUrl());
|
||||||
}else{
|
} else {
|
||||||
videoIdList.add(video.getVideoId());
|
videoIdList.add(video.getVideoId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fileUrl.size() > 0){
|
if (fileUrl.size() > 0) {
|
||||||
List<String> downUrlList = AliyunOSSUtils.generatePresignedUrl(fileUrl);
|
List<String> downUrlList = AliyunOSSUtils.generatePresignedUrl(fileUrl);
|
||||||
if(downUrlList != null && downUrlList.size() > 0){
|
if (downUrlList != null && downUrlList.size() > 0) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (SysNutritionalVideo video : list) {
|
for (SysNutritionalVideo video : list) {
|
||||||
if (StringUtils.isNotEmpty(video.getCoverUrl())) {
|
if (StringUtils.isNotEmpty(video.getCoverUrl())) {
|
||||||
video.setCoverUrl(downUrlList.get(index));
|
video.setCoverUrl(downUrlList.get(index));
|
||||||
index++;
|
index++;
|
||||||
if(index == downUrlList.size()){
|
if (index == downUrlList.size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(videoIdList.size() > 0) {
|
if (videoIdList.size() > 0) {
|
||||||
List<String> coverUrlList = AliyunVideoUtils.getVideoCoverUrl(videoIdList);
|
List<String> coverUrlList = AliyunVideoUtils.getVideoCoverUrl(videoIdList);
|
||||||
if (coverUrlList != null && coverUrlList.size() > 0) {
|
if (coverUrlList != null && coverUrlList.size() > 0) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -85,7 +87,7 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
if (StringUtils.isEmpty(video.getCoverUrl())) {
|
if (StringUtils.isEmpty(video.getCoverUrl())) {
|
||||||
video.setCoverUrl(coverUrlList.get(index));
|
video.setCoverUrl(coverUrlList.get(index));
|
||||||
index++;
|
index++;
|
||||||
if(index == coverUrlList.size()){
|
if (index == coverUrlList.size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,15 +105,14 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo)
|
public int insertSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) {
|
||||||
{
|
|
||||||
sysNutritionalVideo.setCreateTime(DateUtils.getNowDate());
|
sysNutritionalVideo.setCreateTime(DateUtils.getNowDate());
|
||||||
//判断封面是上传的还是阿里云视频截图封面
|
//判断封面是上传的还是阿里云视频截图封面
|
||||||
if(isSnapshot(sysNutritionalVideo.getCoverUrl())){
|
if (isSnapshot(sysNutritionalVideo.getCoverUrl())) {
|
||||||
//更新阿里云视频封面
|
//更新阿里云视频封面
|
||||||
try{
|
try {
|
||||||
AliyunVideoUtils.updateVideoCoverUrl(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getCoverUrl());
|
AliyunVideoUtils.updateVideoCoverUrl(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getCoverUrl());
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -127,15 +128,14 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo)
|
public int updateSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) {
|
||||||
{
|
|
||||||
sysNutritionalVideo.setUpdateTime(DateUtils.getNowDate());
|
sysNutritionalVideo.setUpdateTime(DateUtils.getNowDate());
|
||||||
sysNutritionalVideo.setCoverUrl(sysNutritionalVideo.getCoverUrl() == null ? "" : sysNutritionalVideo.getCoverUrl());
|
sysNutritionalVideo.setCoverUrl(sysNutritionalVideo.getCoverUrl() == null ? "" : sysNutritionalVideo.getCoverUrl());
|
||||||
String coverUrl = sysNutritionalVideo.getCoverUrl();
|
String coverUrl = sysNutritionalVideo.getCoverUrl();
|
||||||
//判断封面是上传的还是阿里云视频截图封面
|
//判断封面是上传的还是阿里云视频截图封面
|
||||||
sysNutritionalVideo.setCoverUrl(isSnapshot(coverUrl) ? "" : coverUrl);
|
sysNutritionalVideo.setCoverUrl(isSnapshot(coverUrl) ? "" : coverUrl);
|
||||||
int row = sysNutritionalVideoMapper.updateSysNutritionalVideo(sysNutritionalVideo);
|
int row = sysNutritionalVideoMapper.updateSysNutritionalVideo(sysNutritionalVideo);
|
||||||
if(row > 0){
|
if (row > 0) {
|
||||||
sysNutritionalVideo.setCoverUrl(isSnapshot(coverUrl) ? coverUrl : null);
|
sysNutritionalVideo.setCoverUrl(isSnapshot(coverUrl) ? coverUrl : null);
|
||||||
updateAliyunVideo(sysNutritionalVideo);
|
updateAliyunVideo(sysNutritionalVideo);
|
||||||
}
|
}
|
||||||
@ -143,12 +143,12 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void updateAliyunVideo(SysNutritionalVideo sysNutritionalVideo){
|
public void updateAliyunVideo(SysNutritionalVideo sysNutritionalVideo) {
|
||||||
try{
|
try {
|
||||||
if(sysNutritionalVideo != null && sysNutritionalVideo.getVideoId() != null){
|
if (sysNutritionalVideo != null && sysNutritionalVideo.getVideoId() != null) {
|
||||||
AliyunVideoUtils.updateVideo(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getTitle(), sysNutritionalVideo.getTags(), sysNutritionalVideo.getDescription(), null, sysNutritionalVideo.getCoverUrl());
|
AliyunVideoUtils.updateVideo(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getTitle(), sysNutritionalVideo.getTags(), sysNutritionalVideo.getDescription(), null, sysNutritionalVideo.getCoverUrl());
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,10 +160,9 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteSysNutritionalVideoByIds(Long[] ids)
|
public int deleteSysNutritionalVideoByIds(Long[] ids) {
|
||||||
{
|
|
||||||
int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoByIds(ids);
|
int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoByIds(ids);
|
||||||
if(row > 0){
|
if (row > 0) {
|
||||||
updateAliyunVideoCateId(ids);
|
updateAliyunVideoCateId(ids);
|
||||||
}
|
}
|
||||||
return row;
|
return row;
|
||||||
@ -176,10 +175,9 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteSysNutritionalVideoById(Long id)
|
public int deleteSysNutritionalVideoById(Long id) {
|
||||||
{
|
|
||||||
int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoById(id);
|
int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoById(id);
|
||||||
if(row > 0){
|
if (row > 0) {
|
||||||
Long[] ids = {id};
|
Long[] ids = {id};
|
||||||
updateAliyunVideoCateId(ids);
|
updateAliyunVideoCateId(ids);
|
||||||
}
|
}
|
||||||
@ -188,30 +186,32 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取视频
|
* 获取视频
|
||||||
|
*
|
||||||
* @param videoId
|
* @param videoId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public SysNutritionalVideo selectSysNutritionalVideByVideoId(String videoId){
|
public SysNutritionalVideo selectSysNutritionalVideByVideoId(String videoId) {
|
||||||
return sysNutritionalVideoMapper.selectSysNutritionalVideByVideoId(videoId);
|
return sysNutritionalVideoMapper.selectSysNutritionalVideByVideoId(videoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云视频查询检索
|
* 阿里云视频查询检索
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<String,Object> searchVideo(String key, Integer showFlag, Integer pageNo, Integer pageSize, String scrollToken){
|
public Map<String, Object> searchVideo(String key, Integer showFlag, Integer pageNo, Integer pageSize, String scrollToken) {
|
||||||
pageSize = pageSize.intValue() > 100 ? 10 : pageSize;
|
pageSize = pageSize.intValue() > 100 ? 10 : pageSize;
|
||||||
long total = 0;
|
long total = 0;
|
||||||
String newScrollToken = null;
|
String newScrollToken = null;
|
||||||
List<SysNutritionalVideo> nutritionalVideoList = new ArrayList<>();
|
List<SysNutritionalVideo> nutritionalVideoList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
SearchMediaResponse response = AliyunVideoUtils.searchVideo(key, getStatusString(showFlag), pageNo, pageSize, scrollToken);
|
SearchMediaResponse response = AliyunVideoUtils.searchVideo(key, getStatusString(showFlag), pageNo, pageSize, scrollToken);
|
||||||
if(response != null){
|
if (response != null) {
|
||||||
SearchMediaResponseBody body = response.body;
|
SearchMediaResponseBody body = response.body;
|
||||||
total = body.total;
|
total = body.total;
|
||||||
newScrollToken = body.scrollToken;
|
newScrollToken = body.scrollToken;
|
||||||
List<SearchMediaResponseBody.SearchMediaResponseBodyMediaList> mediaList = body.mediaList;
|
List<SearchMediaResponseBody.SearchMediaResponseBodyMediaList> mediaList = body.mediaList;
|
||||||
if(mediaList != null && mediaList.size() > 0){
|
if (mediaList != null && mediaList.size() > 0) {
|
||||||
for (SearchMediaResponseBody.SearchMediaResponseBodyMediaList media : mediaList) {
|
for (SearchMediaResponseBody.SearchMediaResponseBodyMediaList media : mediaList) {
|
||||||
SysNutritionalVideo sysNutritionalVideo = new SysNutritionalVideo();
|
SysNutritionalVideo sysNutritionalVideo = new SysNutritionalVideo();
|
||||||
sysNutritionalVideo.setTitle(media.video.title);
|
sysNutritionalVideo.setTitle(media.video.title);
|
||||||
@ -225,7 +225,7 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
@ -235,65 +235,125 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStatusString(Integer status){
|
private String getStatusString(Integer status) {
|
||||||
if(status == null){
|
if (status == null) {
|
||||||
return "Normal,Blocked";
|
return "Normal,Blocked";
|
||||||
}
|
}
|
||||||
return status.intValue() == 1 ? "Normal" : "Blocked";
|
return status.intValue() == 1 ? "Normal" : "Blocked";
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getStatus(String status){
|
private Integer getStatus(String status) {
|
||||||
if(status == null){
|
if (status == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return "Normal".equals(status) ? 1 : 0;
|
return "Normal".equals(status) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新微信展示状态
|
* 更新微信展示状态
|
||||||
|
*
|
||||||
* @param wxShow
|
* @param wxShow
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int updateWxshowByIds(Integer wxShow, Long[] ids){
|
public int updateWxshowByIds(Integer wxShow, Long[] ids) {
|
||||||
return sysNutritionalVideoMapper.updateWxshowByIds(wxShow, ids);
|
return sysNutritionalVideoMapper.updateWxshowByIds(wxShow, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将删除的阿里云视频放入回收站
|
* 将删除的阿里云视频放入回收站
|
||||||
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void updateAliyunVideoCateId(Long[] ids){
|
public void updateAliyunVideoCateId(Long[] ids) {
|
||||||
try {
|
try {
|
||||||
List<String> videoIdList = sysNutritionalVideoMapper.getVideoIdByIds(ids);
|
List<String> videoIdList = sysNutritionalVideoMapper.getVideoIdByIds(ids);
|
||||||
if(videoIdList != null && videoIdList.size() > 0){
|
if (videoIdList != null && videoIdList.size() > 0) {
|
||||||
for (String videoId : videoIdList) {
|
for (String videoId : videoIdList) {
|
||||||
AliyunVideoUtils.delVideo(videoId);
|
AliyunVideoUtils.delVideo(videoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新视频播放量
|
* 更新视频播放量
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int updateVideoPlayNum(String videoId){
|
public int updateVideoPlayNum(String videoId) {
|
||||||
return sysNutritionalVideoMapper.updateVideoPlayNum(videoId);
|
return sysNutritionalVideoMapper.updateVideoPlayNum(videoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysVideoComment> selectVideoCommentByTopicId(SysVideoComment videoComment, String uid) {
|
||||||
|
List<SysVideoComment> comments = sysVideoCommentMapper.selectVideoCommentByTopicId(videoComment);
|
||||||
|
for (SysVideoComment comment : comments) {
|
||||||
|
if(comment.getFromUid().equals(uid)){
|
||||||
|
comment.setOwner(true);
|
||||||
|
} else {
|
||||||
|
comment.setOwner(false);
|
||||||
|
}
|
||||||
|
if (comment.getFromRole().equals("phone")) {
|
||||||
|
comment.setFromUid(StringUtils.hiddenPhoneNumber(comment.getFromUid()));
|
||||||
|
}
|
||||||
|
if (comment.getToRole().equals("phone")) {
|
||||||
|
comment.setToUid(StringUtils.hiddenPhoneNumber(comment.getToUid()));
|
||||||
|
}
|
||||||
|
List<SysVideoComment> replys = comment.getReplys();
|
||||||
|
for (SysVideoComment reply : replys) {
|
||||||
|
if(reply.getFromUid().equals(uid)){
|
||||||
|
reply.setOwner(true);
|
||||||
|
} else {
|
||||||
|
reply.setOwner(false);
|
||||||
|
}
|
||||||
|
if (reply.getFromRole().equals("phone")) {
|
||||||
|
reply.setFromUid(StringUtils.hiddenPhoneNumber(reply.getFromUid()));
|
||||||
|
}
|
||||||
|
if (reply.getToRole().equals("phone")) {
|
||||||
|
reply.setToUid(StringUtils.hiddenPhoneNumber(reply.getToUid()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysVideoComment insertVideoComment(SysVideoComment videoComment) {
|
||||||
|
String uuid = java.util.UUID.randomUUID().toString().replace("-", "");
|
||||||
|
videoComment.setId(uuid);
|
||||||
|
int rows = sysVideoCommentMapper.insertVideoComment(videoComment);
|
||||||
|
if (rows > 0) {
|
||||||
|
return videoComment;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysVideoComment insertVideoCommentReply(SysVideoComment videoComment) {
|
||||||
|
String id = java.util.UUID.randomUUID().toString().replace("-", "");
|
||||||
|
videoComment.setId(id);
|
||||||
|
String uuid = java.util.UUID.randomUUID().toString().replace("-", "");
|
||||||
|
videoComment.setReplyId(uuid);
|
||||||
|
int rows = sysVideoCommentMapper.insertVideoCommentReply(videoComment);
|
||||||
|
if (rows > 0) {
|
||||||
|
return videoComment;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否为阿里点播的截图
|
* 判断是否为阿里点播的截图
|
||||||
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isSnapshot(String url){
|
private boolean isSnapshot(String url) {
|
||||||
return StringUtils.isNotEmpty(url) && url.startsWith("http://outin");
|
return StringUtils.isNotEmpty(url) && url.startsWith("http://outin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.stdiet.custom.mapper.SysVideoCommentMapper">
|
||||||
|
|
||||||
|
<resultMap id="SysVideoCommentResult" type="SysVideoComment">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="topic_id" property="topicId"/>
|
||||||
|
<result column="content" property="content"/>
|
||||||
|
<result column="from_uid" property="fromUid"/>
|
||||||
|
<result column="from_role" property="fromRole"/>
|
||||||
|
<result column="to_uid" property="toUid"/>
|
||||||
|
<result column="to_role" property="toRole"/>
|
||||||
|
<!-- <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/>-->
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<!-- <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/>-->
|
||||||
|
<!-- <association property="fromAvatar" column="{uid=from_uid,role=from_role}" select="selectUserAvatar"/>-->
|
||||||
|
<!-- <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/>-->
|
||||||
|
<association property="replys" column="id"
|
||||||
|
select="selectVideoCommentReplyByCommentId"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="SysVideoCommentReplyResult" type="SysVideoComment">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="topic_id" property="topicId"/>
|
||||||
|
<result column="comment_id" property="commentId"/>
|
||||||
|
<result column="content" property="content"/>
|
||||||
|
<result column="from_uid" property="fromUid"/>
|
||||||
|
<result column="from_role" property="fromRole"/>
|
||||||
|
<result column="to_uid" property="toUid"/>
|
||||||
|
<result column="to_role" property="toRole"/>
|
||||||
|
<result column="reply_id" property="replyId"/>
|
||||||
|
<!-- <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/>-->
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<!-- <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/>-->
|
||||||
|
<!-- <association property="fromAvatar" column="{uid=from_uid,role=from_role}" select="selectUserAvatar"/>-->
|
||||||
|
<!-- <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/>-->
|
||||||
|
<!-- <association property="toAvatar" column="{uid=to_uid,role=to_role}" select="selectUserAvatar"/>-->
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectVideoCommentByTopicId" resultMap="SysVideoCommentResult">
|
||||||
|
select * from sys_nutritional_video_comment where topic_id = #{topicId} and del_flag = 0
|
||||||
|
order by create_time asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectVideoCommentReplyByCommentId" resultMap="SysVideoCommentReplyResult">
|
||||||
|
select * from sys_nutritional_video_reply where comment_id = #{id} and del_flag = 0
|
||||||
|
order by create_time asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询人名-->
|
||||||
|
<select id="selectUserInfo" parameterType="java.util.Map" resultType="String">
|
||||||
|
<choose>
|
||||||
|
<when test="_parameter.get('role') == 'customer'">
|
||||||
|
select name from sys_customer where id = #{uid}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
select nick_name from sys_user where user_id = #{uid}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询头像-->
|
||||||
|
<select id="selectUserAvatar" parameterType="java.util.Map" resultType="String">
|
||||||
|
<choose>
|
||||||
|
<when test="_parameter.get('role') == 'customer'">
|
||||||
|
select avatar_url from sys_wx_user_info where cus_id = #{uid}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
select IF(avatar != '', CONCAT("https://api.stdiet.top/prod-api", avatar), '') as avatar from sys_user
|
||||||
|
where user_id = #{uid}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 插入问题回复-->
|
||||||
|
<insert id="insertVideoComment" parameterType="SysVideoComment">
|
||||||
|
insert into sys_nutritional_video_comment
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="topicId != null">topic_id,</if>
|
||||||
|
<if test="fromUid != null">from_uid,</if>
|
||||||
|
<if test="fromRole != null">from_role,</if>
|
||||||
|
<if test="toUid != null">to_uid,</if>
|
||||||
|
<if test="toRole != null">to_role,</if>
|
||||||
|
<if test="content != null">content,</if>
|
||||||
|
<if test="img != null">img,</if>
|
||||||
|
<if test="topicId != null">create_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="topicId != null">#{topicId},</if>
|
||||||
|
<if test="fromUid != null">#{fromUid},</if>
|
||||||
|
<if test="fromRole != null">#{fromRole},</if>
|
||||||
|
<if test="toUid != null">#{toUid},</if>
|
||||||
|
<if test="toRole != null">#{toRole},</if>
|
||||||
|
<if test="content != null">#{content},</if>
|
||||||
|
<if test="img != null">
|
||||||
|
#{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},
|
||||||
|
</if>
|
||||||
|
<if test="topicId != null">now(),</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 插入问题回复-->
|
||||||
|
<insert id="insertVideoCommentReply" parameterType="SysVideoComment" useGeneratedKeys="true" keyColumn="id"
|
||||||
|
keyProperty="id">
|
||||||
|
insert into sys_nutritional_video_reply
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="commentId != null">comment_id,</if>
|
||||||
|
<if test="replyId != null">reply_id,</if>
|
||||||
|
<if test="content != null">content,</if>
|
||||||
|
<if test="fromUid != null">from_uid,</if>
|
||||||
|
<if test="toUid != null">to_uid,</if>
|
||||||
|
<if test="img != null">img,</if>
|
||||||
|
<if test="fromRole != null">from_role,</if>
|
||||||
|
<if test="toRole != null">to_role,</if>
|
||||||
|
<if test="content != null">create_time,</if>
|
||||||
|
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="commentId != null">#{commentId},</if>
|
||||||
|
<if test="replyId != null">#{replyId},</if>
|
||||||
|
<if test="content != null">#{content},</if>
|
||||||
|
<if test="fromUid != null">#{fromUid},</if>
|
||||||
|
<if test="toUid != null">#{toUid},</if>
|
||||||
|
<if test="img != null">
|
||||||
|
#{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},
|
||||||
|
</if>
|
||||||
|
<if test="fromRole != null">#{fromRole},</if>
|
||||||
|
<if test="toRole != null">#{toRole},</if>
|
||||||
|
<if test="content != null">now(),</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user