Merge remote-tracking branch 'origin/wzj-main' into wzj-main

This commit is contained in:
fxh 2025-08-15 16:55:32 +08:00
commit 2c4ea0c22c
17 changed files with 562 additions and 388 deletions

View File

@ -0,0 +1,130 @@
package org.dromara.app;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzj.soopin.content.domain.base.BaseInfoProperties;
import com.wzj.soopin.content.domain.bo.CommentBO;
import com.wzj.soopin.content.domain.po.Comment;
import com.wzj.soopin.content.domain.vo.CommentVO;
import com.wzj.soopin.content.enums.MessageEnum;
import com.wzj.soopin.content.service.CommentService;
import com.wzj.soopin.content.service.MsgService;
import com.wzj.soopin.content.utils.RedisOperator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.common.satoken.utils.LoginHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Api(tags = "管理端-评论管理接口")
@RequestMapping("/app/comment")
@RestController
public class AppCommentController {
@Autowired
private CommentService commentService;
@Autowired
private RedisOperator redis;
@Autowired
private MsgService msgService;
@ApiOperation("查询视频评论列表")
@PostMapping("/vlogComments")
public R<Page<CommentVO>> queryVlogComments(
@RequestBody CommentBO bo,
@RequestBody Page<Comment> page) {
try {
Page<CommentVO> commentPage = commentService.pageComment(page, bo);
return R.ok(commentPage);
} catch (Exception e) {
log.error("查询视频评论列表失败", e);
return R.fail("查询视频评论列表失败: " + e.getMessage());
}
}
@ApiOperation("发布评论")
@PostMapping("/publish")
public R<Void> publishComment(@RequestBody CommentBO bo) {
try {
// 鉴权评论人从登录上下文获取覆盖入参
Long loginUserId = LoginHelper.getUserId();
if (loginUserId == null) {
return R.fail("未登录或登录已过期");
}
bo.setCommentUserId(String.valueOf(loginUserId));
// 父评论为空时按根评论处理约定使用"0"作为无父评论标记
if (bo.getFatherCommentId() == null || bo.getFatherCommentId().isEmpty()) {
bo.setFatherCommentId("0");
}
// 1) 创建评论
commentService.createComment(bo);
// 2) 短视频评论总数 +1Redis 优先
redis.increment(BaseInfoProperties.REDIS_VLOG_COMMENT_COUNTS + ":" + bo.getVlogId(), 1);
// 3) 发送站内消息根评论 -> 通知视频作者回复评论 -> 通知被回复用户
if ("0".equals(bo.getFatherCommentId())) {
// 评论视频通知视频作者
if (bo.getVlogerId() != null && !bo.getVlogerId().isEmpty()
&& !String.valueOf(loginUserId).equals(bo.getVlogerId())) {
msgService.createMsg(String.valueOf(loginUserId), bo.getVlogerId(), MessageEnum.COMMENT_VLOG.type, null);
}
} else {
// 回复评论通知父评论作者
Comment father = commentService.getCommentDetail(bo.getFatherCommentId());
if (father != null && father.getCommentUserId() != null
&& !String.valueOf(loginUserId).equals(father.getCommentUserId())) {
msgService.createMsg(String.valueOf(loginUserId), father.getCommentUserId(), MessageEnum.REPLY_YOU.type, null);
}
}
return R.ok();
} catch (Exception e) {
log.error("发布评论失败", e);
return R.fail("发布评论失败: " + e.getMessage());
}
}
@ApiOperation("删除评论")
@PostMapping("/delete")
public R<Void> deleteComment(
@ApiParam(value = "评论ID") @RequestParam String commentId) {
try {
String username = LoginHelper.getUsername();
commentService.deleteComment(commentId, username);
return R.ok();
} catch (Exception e) {
log.error("删除评论失败", e);
return R.fail("删除评论失败: " + e.getMessage());
}
}
@ApiOperation("获取评论详情")
@GetMapping("/detail")
public R<Map<String, Object>> getCommentDetail(@ApiParam(value = "评论ID") @RequestParam String commentId) {
try {
Comment comment = commentService.getCommentDetail(commentId);
if (comment == null) {
return R.fail("评论不存在");
}
// 获取子评论
List<Comment> childComments = commentService.getChildComments(commentId);
Map<String, Object> result = new HashMap<>();
result.put("comment", comment);
result.put("childComments", childComments);
return R.ok(result);
} catch (Exception e) {
log.error("获取评论详情失败", e);
return R.fail("获取评论详情失败: " + e.getMessage());
}
}
}

View File

@ -0,0 +1,219 @@
package org.dromara.app;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wzj.soopin.content.domain.bo.IndexListBO;
import com.wzj.soopin.content.domain.bo.MyListBO;
import com.wzj.soopin.content.domain.bo.SimpleListBO;
import com.wzj.soopin.content.domain.bo.VlogBO;
import com.wzj.soopin.content.service.VlogService;
import com.wzj.soopin.content.service.VlogUploadService;
import com.wzj.soopin.content.utils.PagedGridResult;
import com.wzj.soopin.content.utils.QcCloud;
import com.wzj.soopin.content.utils.RedisOperator;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.dromara.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.wzj.soopin.content.domain.base.BaseInfoProperties.*;
@Slf4j
@Api(tags = "VlogController 短视频相关业务功能的接口")
@RequestMapping("/app/vlog")
@RestController
public class AppVlogController {
@Autowired
private VlogService vlogService;
@Autowired
private QcCloud qcCloud;
@Autowired
private VlogUploadService vlogUploadService;
@Autowired
public RedisOperator redis;
@Tag(name = "首页视频列表")
@PostMapping("/indexList")
public R<PagedGridResult> indexList(@RequestBody IndexListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getIndexVlogList(bo, page);
return R.ok(pages);
}
@GetMapping("detail")
public R<Object> detail(@RequestParam(defaultValue = "") String userId,
@RequestParam String vlogId) {
return R.ok(vlogService.getVlogDetailById(userId, vlogId));
}
@Tag(name = "我的私密视频列表")
@PostMapping("/myPrivateList")
public R<PagedGridResult> myPrivateList(@RequestBody MyListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.queryMyVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "我点赞的视频列表")
@PostMapping("/myLikedList")
public R<PagedGridResult> myLikedList(@RequestBody MyListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getMyLikedVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "我关注的视频列表")
@PostMapping("/followList")
public R<PagedGridResult> followList(@RequestBody SimpleListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getMyFollowVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "好友视频列表")
@PostMapping("/friendList")
public R<PagedGridResult> friendList(@RequestBody SimpleListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getMyFriendVlogList(bo, page);
return R.ok(pages);
}
@PostMapping("publish")
public R<Void> publish(@RequestBody VlogBO vlogBO) throws Exception {
String url = vlogBO.getUrl();
log.info("未审核视频地址:"+url);
String fileName = url.substring(url.lastIndexOf("/") + 1);
log.info("视频文件名称:"+fileName);
log.info("开始上传腾讯云点播:"+fileName);
String fileId = qcCloud.uploadViaTempFile(fileName);
log.info("视频发布ID:"+fileId);
vlogBO.setFileId(fileId);
// 删除minio文件
// MinIOUtils.removeFile(minIOConfig.getBucketName(),fileName);
// log.info("删除minio文件"+fileName);
// FIXME 校验VlogBO
vlogService.createVlog(vlogBO);
return R.ok();
}
@Tag(name = "我的公开视频列表")
@PostMapping("/myPublicList")
public R<PagedGridResult> myPublicList(@RequestBody MyListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.queryMyVlogList(bo, page);
return R.ok(pages);
}
private Integer nacosConuts=0;
@PostMapping("like")
public R<Void> like(@RequestParam String userId,
@RequestParam String vlogerId,
@RequestParam String vlogId) {
// 我点赞的视频关联关系保存到数据库
vlogService.userLikeVlog(userId, vlogId);
// 点赞后视频和视频发布者的获赞都会 +1
redis.increment(REDIS_VLOGER_BE_LIKED_COUNTS + ":" + vlogerId, 1);
redis.increment(REDIS_VLOG_BE_LIKED_COUNTS + ":" + vlogId, 1);
// 我点赞的视频需要在redis中保存关联关系
redis.set(REDIS_USER_LIKE_VLOG + ":" + userId + ":" + vlogId, "1");
log.info("nacosConuts="+nacosConuts);
String countsStr = redis.get(REDIS_VLOG_BE_LIKED_COUNTS + ":" + vlogId);
Integer counts=0;
if (StringUtils.isNotBlank(countsStr)){
counts=Integer.valueOf(countsStr);
if (counts>=nacosConuts){
vlogService.flushCounts(vlogId, counts);
}
}
return R.ok();
}
@PostMapping("unlike")
public R<Void> unlike(@RequestParam String userId,
@RequestParam String vlogerId,
@RequestParam String vlogId) {
// 我取消点赞的视频关联关系删除
vlogService.userUnLikeVlog(userId, vlogId);
redis.decrement(REDIS_VLOGER_BE_LIKED_COUNTS + ":" + vlogerId, 1);
redis.decrement(REDIS_VLOG_BE_LIKED_COUNTS + ":" + vlogId, 1);
redis.del(REDIS_USER_LIKE_VLOG + ":" + userId + ":" + vlogId);
return R.ok();
}
@Tag(name = "手动触发缓存点赞最多视频")
@PostMapping("/cacheTopLikedVlogs")
public R<Void> cacheTopLikedVlogs(@RequestParam(defaultValue = "100") int limit) {
try {
vlogService.cacheTopLikedVlogs(limit);
return R.ok();
} catch (Exception e) {
log.error("手动触发缓存点赞最多视频失败", e);
return R.fail("缓存失败: " + e.getMessage());
}
}
@Tag(name = "获取缓存中的点赞最多视频")
@GetMapping("/getTopLikedVlogs")
public R<Object> getTopLikedVlogs(@RequestParam(defaultValue = "") String date,
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "0") int pageNum) {
try {
String redisKey;
if (StringUtils.isBlank(date)) {
// 如果没有指定日期使用今天的日期
redisKey = "top_liked_vlogs:" + java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"));
} else {
redisKey = "top_liked_vlogs:" + date;
}
String cachedData = redis.get(redisKey);
List<Map<String, Object>> resultList = new ArrayList<>();
if (StringUtils.isNotBlank(cachedData)) {
// 解析JSON数据
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, Object>> vlogList = objectMapper.readValue(cachedData, new com.fasterxml.jackson.core.type.TypeReference<List<Map<String, Object>>>() {});
// 计算分页
int startIndex = pageNum * pageSize;
int endIndex = Math.min(startIndex + pageSize, vlogList.size());
if (startIndex < vlogList.size()) {
// 从Redis缓存中获取指定页的数据
resultList = vlogList.subList(startIndex, endIndex);
log.info("从Redis缓存中获取了{}条视频数据", resultList.size());
}
}
// 如果Redis中的数据不足从数据库随机查询补充
if (resultList.size() < pageSize) {
int needMore = pageSize - resultList.size();
log.info("Redis缓存数据不足需要从数据库随机查询{}条视频", needMore);
// 从数据库随机查询视频
List<Map<String, Object>> randomVlogs = vlogService.getRandomVlogs(needMore);
resultList.addAll(randomVlogs);
log.info("从数据库随机查询了{}条视频", randomVlogs.size());
}
return R.ok(resultList);
} catch (Exception e) {
log.error("获取缓存中的点赞最多视频失败", e);
return R.fail("获取缓存失败: " + e.getMessage());
}
}
}

View File

@ -33,7 +33,7 @@ import java.util.ArrayList;
@Slf4j
@Api(tags = "VlogController 短视频相关业务功能的接口")
@RequestMapping("vlog")
@RequestMapping("/vlog")
@RestController
public class VlogController extends BaseInfoProperties {
@ -155,38 +155,11 @@ public class VlogController extends BaseInfoProperties {
}
}
@PostMapping("publish")
public R<Void> publish(@RequestBody VlogBO vlogBO) throws Exception {
String url = vlogBO.getUrl();
log.info("未审核视频地址:"+url);
String fileName = url.substring(url.lastIndexOf("/") + 1);
log.info("视频文件名称:"+fileName);
log.info("开始上传腾讯云点播:"+fileName);
String fileId = qcCloud.uploadViaTempFile(fileName);
log.info("视频发布ID:"+fileId);
vlogBO.setFileId(fileId);
// 删除minio文件
// MinIOUtils.removeFile(minIOConfig.getBucketName(),fileName);
// log.info("删除minio文件"+fileName);
// FIXME 校验VlogBO
vlogService.createVlog(vlogBO);
return R.ok();
}
@Tag(name = "首页视频列表")
@PostMapping("/indexList")
public R<PagedGridResult> indexList(@RequestBody IndexListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getIndexVlogList(bo, page);
return R.ok(pages);
}
@GetMapping("detail")
public R<Object> detail(@RequestParam(defaultValue = "") String userId,
@RequestParam String vlogId) {
return R.ok(vlogService.getVlogDetailById(userId, vlogId));
}
@PostMapping("changeVlogStatus")
public R<Void> changeVlogStatus(@RequestParam String userId,
@RequestParam String vlogId,
@ -215,157 +188,13 @@ public class VlogController extends BaseInfoProperties {
@Tag(name = "我的公开视频列表")
@PostMapping("/myPublicList")
public R<PagedGridResult> myPublicList(@RequestBody MyListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.queryMyVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "我的私密视频列表")
@PostMapping("/myPrivateList")
public R<PagedGridResult> myPrivateList(@RequestBody MyListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.queryMyVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "我点赞的视频列表")
@PostMapping("/myLikedList")
public R<PagedGridResult> myLikedList(@RequestBody MyListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getMyLikedVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "我关注的视频列表")
@PostMapping("/followList")
public R<PagedGridResult> followList(@RequestBody SimpleListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getMyFollowVlogList(bo, page);
return R.ok(pages);
}
@Tag(name = "好友视频列表")
@PostMapping("/friendList")
public R<PagedGridResult> friendList(@RequestBody SimpleListBO bo, @RequestBody Page page) {
PagedGridResult pages = vlogService.getMyFriendVlogList(bo, page);
return R.ok(pages);
}
private Integer nacosConuts=0;
@PostMapping("like")
public R<Void> like(@RequestParam String userId,
@RequestParam String vlogerId,
@RequestParam String vlogId) {
// 我点赞的视频关联关系保存到数据库
vlogService.userLikeVlog(userId, vlogId);
// 点赞后视频和视频发布者的获赞都会 +1
redis.increment(REDIS_VLOGER_BE_LIKED_COUNTS + ":" + vlogerId, 1);
redis.increment(REDIS_VLOG_BE_LIKED_COUNTS + ":" + vlogId, 1);
// 我点赞的视频需要在redis中保存关联关系
redis.set(REDIS_USER_LIKE_VLOG + ":" + userId + ":" + vlogId, "1");
log.info("nacosConuts="+nacosConuts);
String countsStr = redis.get(REDIS_VLOG_BE_LIKED_COUNTS + ":" + vlogId);
Integer counts=0;
if (StringUtils.isNotBlank(countsStr)){
counts=Integer.valueOf(countsStr);
if (counts>=nacosConuts){
vlogService.flushCounts(vlogId, counts);
}
}
return R.ok();
}
@PostMapping("unlike")
public R<Void> unlike(@RequestParam String userId,
@RequestParam String vlogerId,
@RequestParam String vlogId) {
// 我取消点赞的视频关联关系删除
vlogService.userUnLikeVlog(userId, vlogId);
redis.decrement(REDIS_VLOGER_BE_LIKED_COUNTS + ":" + vlogerId, 1);
redis.decrement(REDIS_VLOG_BE_LIKED_COUNTS + ":" + vlogId, 1);
redis.del(REDIS_USER_LIKE_VLOG + ":" + userId + ":" + vlogId);
return R.ok();
}
@PostMapping("totalLikedCounts")
public R<Integer> totalLikedCounts(@RequestParam String vlogId) {
return R.ok(vlogService.getVlogBeLikedCounts(vlogId));
}
@Tag(name = "手动触发缓存点赞最多视频")
@PostMapping("/cacheTopLikedVlogs")
public R<Void> cacheTopLikedVlogs(@RequestParam(defaultValue = "100") int limit) {
try {
vlogService.cacheTopLikedVlogs(limit);
return R.ok();
} catch (Exception e) {
log.error("手动触发缓存点赞最多视频失败", e);
return R.fail("缓存失败: " + e.getMessage());
}
}
@Tag(name = "获取缓存中的点赞最多视频")
@GetMapping("/getTopLikedVlogs")
public R<Object> getTopLikedVlogs(@RequestParam(defaultValue = "") String date,
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "0") int pageNum) {
try {
String redisKey;
if (StringUtils.isBlank(date)) {
// 如果没有指定日期使用今天的日期
redisKey = "top_liked_vlogs:" + java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"));
} else {
redisKey = "top_liked_vlogs:" + date;
}
String cachedData = redis.get(redisKey);
List<Map<String, Object>> resultList = new ArrayList<>();
if (StringUtils.isNotBlank(cachedData)) {
// 解析JSON数据
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, Object>> vlogList = objectMapper.readValue(cachedData, new com.fasterxml.jackson.core.type.TypeReference<List<Map<String, Object>>>() {});
// 计算分页
int startIndex = pageNum * pageSize;
int endIndex = Math.min(startIndex + pageSize, vlogList.size());
if (startIndex < vlogList.size()) {
// 从Redis缓存中获取指定页的数据
resultList = vlogList.subList(startIndex, endIndex);
log.info("从Redis缓存中获取了{}条视频数据", resultList.size());
}
}
// 如果Redis中的数据不足从数据库随机查询补充
if (resultList.size() < pageSize) {
int needMore = pageSize - resultList.size();
log.info("Redis缓存数据不足需要从数据库随机查询{}条视频", needMore);
// 从数据库随机查询视频
List<Map<String, Object>> randomVlogs = vlogService.getRandomVlogs(needMore);
resultList.addAll(randomVlogs);
log.info("从数据库随机查询了{}条视频", randomVlogs.size());
}
return R.ok(resultList);
} catch (Exception e) {
log.error("获取缓存中的点赞最多视频失败", e);
return R.fail("获取缓存失败: " + e.getMessage());
}
}
}

View File

@ -58,101 +58,7 @@ public class CommentController extends BaseController {
return R.ok(commentPage);
}
@ApiOperation("查询视频评论列表")
@PostMapping("/vlogComments")
public R<Page<CommentVO>> queryVlogComments(
@RequestBody CommentBO bo,
@RequestBody Page<Comment> page) {
try {
Page<CommentVO> commentPage = commentService.pageComment(page, bo);
return R.ok(commentPage);
} catch (Exception e) {
log.error("查询视频评论列表失败", e);
return R.fail("查询视频评论列表失败: " + e.getMessage());
}
}
@ApiOperation("发布评论")
@PostMapping("/publish")
public R<Void> publishComment(@RequestBody CommentBO bo) {
try {
// 鉴权评论人从登录上下文获取覆盖入参
Long loginUserId = LoginHelper.getUserId();
if (loginUserId == null) {
return R.fail("未登录或登录已过期");
}
bo.setCommentUserId(String.valueOf(loginUserId));
// 父评论为空时按根评论处理约定使用"0"作为无父评论标记
if (bo.getFatherCommentId() == null || bo.getFatherCommentId().isEmpty()) {
bo.setFatherCommentId("0");
}
// 1) 创建评论
commentService.createComment(bo);
// 2) 短视频评论总数 +1Redis 优先
redis.increment(BaseInfoProperties.REDIS_VLOG_COMMENT_COUNTS + ":" + bo.getVlogId(), 1);
// 3) 发送站内消息根评论 -> 通知视频作者回复评论 -> 通知被回复用户
if ("0".equals(bo.getFatherCommentId())) {
// 评论视频通知视频作者
if (bo.getVlogerId() != null && !bo.getVlogerId().isEmpty()
&& !String.valueOf(loginUserId).equals(bo.getVlogerId())) {
msgService.createMsg(String.valueOf(loginUserId), bo.getVlogerId(), MessageEnum.COMMENT_VLOG.type, null);
}
} else {
// 回复评论通知父评论作者
Comment father = commentService.getCommentDetail(bo.getFatherCommentId());
if (father != null && father.getCommentUserId() != null
&& !String.valueOf(loginUserId).equals(father.getCommentUserId())) {
msgService.createMsg(String.valueOf(loginUserId), father.getCommentUserId(), MessageEnum.REPLY_YOU.type, null);
}
}
return R.ok();
} catch (Exception e) {
log.error("发布评论失败", e);
return R.fail("发布评论失败: " + e.getMessage());
}
}
@ApiOperation("删除评论")
@PostMapping("/delete")
public R<Void> deleteComment(
@ApiParam(value = "评论ID") @RequestParam String commentId) {
try {
String username = LoginHelper.getUsername();
commentService.deleteComment(commentId, username);
return R.ok();
} catch (Exception e) {
log.error("删除评论失败", e);
return R.fail("删除评论失败: " + e.getMessage());
}
}
@ApiOperation("获取评论详情")
@GetMapping("/detail")
public R<Map<String, Object>> getCommentDetail(@ApiParam(value = "评论ID") @RequestParam String commentId) {
try {
Comment comment = commentService.getCommentDetail(commentId);
if (comment == null) {
return R.fail("评论不存在");
}
// 获取子评论
List<Comment> childComments = commentService.getChildComments(commentId);
Map<String, Object> result = new HashMap<>();
result.put("comment", comment);
result.put("childComments", childComments);
return R.ok(result);
} catch (Exception e) {
log.error("获取评论详情失败", e);
return R.fail("获取评论详情失败: " + e.getMessage());
}
}
@ApiOperation("获取子评论列表")
@GetMapping("/childList")

View File

@ -9,12 +9,11 @@ import com.wzj.soopin.content.domain.bo.VlogBO;
import com.wzj.soopin.content.service.VlogService;
import com.wzj.soopin.content.service.VlogUploadService;
import com.wzj.soopin.content.utils.RedisOperator;
import org.dromara.common.redis.utils.RedisUtils;
import com.wzj.soopin.content.utils.TencentCloudUtil;
import com.wzj.soopin.member.domain.vo.FansVO;
import com.wzj.soopin.member.service.IFansService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,10 +21,6 @@ import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.ZonedDateTime;
@Slf4j
@Api(tags = "管理端-视频")
@ -120,6 +115,77 @@ public class VlogUploadController extends BaseInfoProperties {
result.put("size", vlogBO.getSize());
result.put("pages", (resp.getTotalCount() + vlogBO.getSize() - 1) / vlogBO.getSize()); // 总页数
// 批量获取所有视频的统计信息避免重复查询
Map<String, String> fileIdToVlogIdMap = new HashMap<>();
List<String> allVlogIds = new ArrayList<>();
if (resp.getMediaInfoSet() != null) {
for (MediaInfo mediaInfo : resp.getMediaInfoSet()) {
String fileId = mediaInfo.getFileId();
Map<String, Object> statistics = vlogService.getVlogStatistics(fileId);
String vlogId = (String) statistics.get("vlogId");
if (StringUtils.isNotBlank(vlogId)) {
fileIdToVlogIdMap.put(fileId, vlogId);
allVlogIds.add(vlogId);
}
}
}
// 批量获取所有点赞数据
Map<String, Integer> vlogLikeCounts = new HashMap<>();
Map<String, Integer> vlogCommentCounts = new HashMap<>();
long totalLikeCounts = 0;
long totalCommentCounts = 0;
if (!allVlogIds.isEmpty()) {
// 批量获取所有点赞键
String likePattern = REDIS_USER_LIKE_VLOG + ":*";
Collection<String> allLikeKeys = RedisUtils.keys(likePattern);
if (allLikeKeys != null && !allLikeKeys.isEmpty()) {
// 逐个获取点赞值由于RedisUtils没有批量方法
Map<String, String> likeKeyValueMap = new HashMap<>();
for (String likeKey : allLikeKeys) {
String likeValue = RedisUtils.getCacheObject(likeKey);
if ("1".equals(likeValue)) {
likeKeyValueMap.put(likeKey, likeValue);
}
}
// 按vlogId分组统计点赞数
for (String vlogId : allVlogIds) {
int likeCount = 0;
for (String likeKey : likeKeyValueMap.keySet()) {
if (likeKey.endsWith(":" + vlogId)) {
likeCount++;
}
}
vlogLikeCounts.put(vlogId, likeCount);
totalLikeCounts += likeCount;
}
}
// 批量获取所有评论数
for (String vlogId : allVlogIds) {
String commentKey = REDIS_VLOG_COMMENT_COUNTS + ":" + vlogId;
String commentCountsStr = RedisUtils.getCacheObject(commentKey);
int commentCount = 0;
if (StringUtils.isNotBlank(commentCountsStr)) {
try {
commentCount = Integer.valueOf(commentCountsStr);
} catch (NumberFormatException e) {
log.warn("Redis中视频{}的评论数格式错误: {}", vlogId, commentCountsStr);
}
}
vlogCommentCounts.put(vlogId, commentCount);
totalCommentCounts += commentCount;
}
}
// 将总的点赞数和评论数添加到结果中
result.put("totalLikeCounts", totalLikeCounts);
result.put("totalCommentCounts", totalCommentCounts);
List<Map<String, Object>> mediaList = new ArrayList<>();
if (resp.getMediaInfoSet() != null) {
for (MediaInfo mediaInfo : resp.getMediaInfoSet()) {
@ -148,6 +214,20 @@ public class VlogUploadController extends BaseInfoProperties {
Map<String, Object> statistics = vlogService.getVlogStatistics(mediaInfo.getFileId());
mediaMap.putAll(statistics);
// 从statistics中获取vlogId用于Redis查询
String vlogId = (String) statistics.get("vlogId");
log.info("处理视频 fileId: {}, vlogId: {}", mediaInfo.getFileId(), vlogId);
// 使用批量获取的数据避免重复查询Redis
int videoLikeCounts = 0;
int videoCommentCounts = 0;
if (StringUtils.isNotBlank(vlogId)) {
videoLikeCounts = vlogLikeCounts.getOrDefault(vlogId, 0);
videoCommentCounts = vlogCommentCounts.getOrDefault(vlogId, 0);
}
mediaMap.put("likeCounts", videoLikeCounts);
mediaMap.put("commentCounts", videoCommentCounts);
// 获取视频上传者信息
Map<String, String> uploaderInfo = vlogService.getVlogUploaderInfo(mediaInfo.getFileId());
if (uploaderInfo != null) {

View File

@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
public class IndexListBO {
@Schema(description = "用户ID")
private String userId;
private String memberId;
@Schema(description = "搜索关键字")
private String search;
@Schema(description = "城市编码")
@ -12,8 +12,8 @@ public class IndexListBO {
@Schema(description = "状态")
private String status;
// getter/setter
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public String getMemberId() { return memberId; }
public void setUserId(String userId) { this.memberId = userId; }
public String getSearch() { return search; }
public void setSearch(String search) { this.search = search; }
public String getCityCode() { return cityCode; }

View File

@ -3,6 +3,7 @@ package com.wzj.soopin.content.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.time.LocalDateTime;
@ -15,8 +16,9 @@ public class Comment {
private String id;
/**
* 评论的视频是哪个作者(vloger)的关联id
* 评论的视频是哪个作者(member)的关联id
*/
@TableField("member_id")
private String vlogerId;
/**

View File

@ -18,8 +18,8 @@ public class Vlog extends BaseAudit {
/**
* 对应用户表idvlog视频发布者
*/
@TableField("vloger_id")
private String vlogerId;
@TableField("member_id")
private String memberId;
/**
* 视频播放地址

View File

@ -38,9 +38,9 @@ public interface CommentMapper extends BaseMapper<Comment> {
/**
* 根据视频ID查询评论列表
*/
@Select("SELECT c.*, u.nickname as userNickname, u.face as userFace " +
@Select("SELECT c.*, m.nickname as userNickname, m.avatar as userFace " +
"FROM cont_comment c " +
"LEFT JOIN cont_users u ON c.comment_user_id = u.id " +
"LEFT JOIN ums_member m ON c.comment_user_id = m.id " +
"WHERE c.vlog_id = #{vlogId} " +
"ORDER BY c.create_time DESC")
List<Map<String, Object>> selectCommentsByVlogId(@Param("vlogId") String vlogId);

View File

@ -18,6 +18,6 @@ public interface MyLikedVlogMapper extends BaseMapperPlus<MyLikedVlog,MyLikedVlo
@Select("SELECT COUNT(*) FROM cont_my_liked_vlog WHERE vlog_id = #{vlogId}")
int countLikesByVlogId(@Param("vlogId") String vlogId);
@Select("SELECT u.nickname, u.face, l.create_time FROM cont_my_liked_vlog l LEFT JOIN cont_users u ON l.user_id = u.id WHERE l.vlog_id = #{vlogId} ORDER BY l.create_time DESC")
@Select("SELECT m.nickname, m.avatar as face, l.create_time FROM cont_my_liked_vlog l LEFT JOIN ums_member m ON l.user_id = m.id WHERE l.vlog_id = #{vlogId} ORDER BY l.create_time DESC")
List<Map<String, Object>> selectLikedUsersByVlogId(@Param("vlogId") String vlogId);
}

View File

@ -8,6 +8,7 @@ import com.wzj.soopin.content.domain.bo.CommentBO;
import com.wzj.soopin.content.domain.po.Comment;
import com.wzj.soopin.content.domain.po.Vlog;
import com.wzj.soopin.content.domain.po.Users;
import com.wzj.soopin.member.domain.po.Member;
import com.wzj.soopin.content.domain.vo.ChildCommentVO;
import com.wzj.soopin.content.domain.vo.CommentVO;
import com.wzj.soopin.content.enums.MessageEnum;
@ -15,6 +16,7 @@ import com.wzj.soopin.content.enums.YesOrNo;
import com.wzj.soopin.content.mapper.CommentMapper;
import com.wzj.soopin.content.mapper.CommentMapperCustom;
import com.wzj.soopin.content.mapper.UsersMapper;
import com.wzj.soopin.member.mapper.MemberMapper;
import com.wzj.soopin.content.mapper.VlogMapper;
import com.wzj.soopin.content.service.CommentService;
import com.wzj.soopin.content.service.MsgService;
@ -54,6 +56,8 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
@Autowired
private UsersMapper usersMapper;
@Autowired
private MemberMapper memberMapper;
@Autowired
private VlogMapper vlogMapper;
@Override
@ -184,13 +188,13 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
// 手机号查视频
if (bo != null && org.springframework.util.StringUtils.hasText(bo.getMobile())) {
Users user = usersMapper.selectOne(new LambdaQueryWrapper<Users>().eq(Users::getMobile, bo.getMobile()));
Member user = memberMapper.selectOne(new LambdaQueryWrapper<Member>().eq(Member::getPhoneHidden, bo.getMobile()));
if (user == null) {
Page<CommentVO> emptyPage = new Page<>(page.getCurrent(), page.getSize(), 0);
emptyPage.setRecords(new ArrayList<>());
return emptyPage;
}
List<Vlog> vlogList = vlogMapper.selectList(new LambdaQueryWrapper<Vlog>().eq(Vlog::getVlogerId, user.getId()));
List<Vlog> vlogList = vlogMapper.selectList(new LambdaQueryWrapper<Vlog>().eq(Vlog::getMemberId, user.getId()));
if (vlogList.isEmpty()) {
Page<CommentVO> emptyPage = new Page<>(page.getCurrent(), page.getSize(), 0);
emptyPage.setRecords(new ArrayList<>());
@ -211,17 +215,17 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
BeanUtils.copyProperties(comment, vo);
vo.setCommentId(comment.getId());
// 查评论用户信息
Users user = usersMapper.selectById(comment.getCommentUserId());
Member user = memberMapper.selectById(comment.getCommentUserId());
if (user != null) {
vo.setCommentUserFace(user.getFace());
vo.setCommentUserFace(user.getAvatar());
vo.setCommentUserNickname(user.getNickname());
}
// 查视频作者手机号和视频播放地址
Vlog vlog = vlogMapper.selectById(comment.getVlogId());
if (vlog != null) {
Users vloger = usersMapper.selectById(vlog.getVlogerId());
Member vloger = memberMapper.selectById(vlog.getMemberId());
if (vloger != null) {
vo.setVlogerMobile(vloger.getMobile());
vo.setVlogerMobile(vloger.getPhoneHidden());
}
vo.setVlogUrl(vlog.getUrl()); // 假设Vlog实体有getUrl()方法
}
@ -245,7 +249,7 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
Comment fatherComment = commentMapper.selectById(fatherCommentId);
String replyedUserNickname = null;
if (fatherComment != null) {
Users replyedUser = usersMapper.selectById(fatherComment.getCommentUserId());
Member replyedUser = memberMapper.selectById(fatherComment.getCommentUserId());
if (replyedUser != null) {
replyedUserNickname = replyedUser.getNickname();
}
@ -263,10 +267,10 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
vo.setCreateTime(child.getCreateTime());
vo.setReplyedUserNickname(replyedUserNickname);
// 回复人昵称和头像
Users replyUser = usersMapper.selectById(child.getCommentUserId());
Member replyUser = memberMapper.selectById(child.getCommentUserId());
if (replyUser != null) {
vo.setReplyUserNickname(replyUser.getNickname());
vo.setReplyUserFace(replyUser.getFace());
vo.setReplyUserFace(replyUser.getAvatar());
}
voList.add(vo);
}
@ -286,7 +290,7 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
Comment fatherComment = commentMapper.selectById(fatherCommentId);
String replyedUserNickname;
if (fatherComment != null) {
Users replyedUser = usersMapper.selectById(fatherComment.getCommentUserId());
Member replyedUser = memberMapper.selectById(fatherComment.getCommentUserId());
if (replyedUser != null) {
replyedUserNickname = replyedUser.getNickname();
} else {
@ -310,10 +314,10 @@ public class CommentServiceImpl extends BaseInfoProperties implements CommentSer
vo.setCreateTime(child.getCreateTime());
vo.setReplyedUserNickname(replyedUserNickname);
// 回复人昵称和头像
Users replyUser = usersMapper.selectById(child.getCommentUserId());
Member replyUser = memberMapper.selectById(child.getCommentUserId());
if (replyUser != null) {
vo.setReplyUserNickname(replyUser.getNickname());
vo.setReplyUserFace(replyUser.getFace());
vo.setReplyUserFace(replyUser.getAvatar());
}
return vo;
}).collect(java.util.stream.Collectors.toList());

View File

@ -16,11 +16,13 @@ import com.wzj.soopin.content.domain.bo.IndexListBO;
import com.wzj.soopin.content.domain.po.MyLikedVlog;
import com.wzj.soopin.content.domain.po.Vlog;
import com.wzj.soopin.content.domain.po.Users;
import com.wzj.soopin.member.domain.po.Member;
import com.wzj.soopin.content.domain.vo.IndexVlogVO;
import com.wzj.soopin.content.enums.YesOrNo;
import com.wzj.soopin.content.mapper.CommentMapper;
import com.wzj.soopin.content.mapper.MyLikedVlogMapper;
import com.wzj.soopin.content.mapper.UsersMapper;
import com.wzj.soopin.member.mapper.MemberMapper;
import com.wzj.soopin.content.mapper.VlogMapper;
import com.wzj.soopin.content.mapper.VlogMapperCustom;
import com.wzj.soopin.content.service.MsgService;
@ -77,6 +79,8 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Autowired
private UsersMapper usersMapper;
@Autowired
private MemberMapper memberMapper;
@Autowired
private VlogConvert vlogConvert;
@Autowired
private ISysMessageService sysMessageService;
@ -95,7 +99,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
// 1. 获取视频信息找到上传者
Vlog vlog = vlogMapper.selectByFileId(fileId);
if (vlog == null) return;
String uploaderId = vlog.getVlogerId();
String uploaderId = vlog.getMemberId();
// 2. 选择模板假设你有模板ID实际可配置到常量或数据库
Long templateId = (status == 1) ? 1938491493736902658L : 1938491899007332353L; // 1001=审核通过模板1002=驳回模板
@ -144,7 +148,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Override
public PagedGridResult getIndexVlogList(IndexListBO bo, Page page) {
String userId = bo.getUserId();
String userId = bo.getMemberId();
String search = bo.getSearch();
String cityCode = bo.getCityCode();
String status = bo.getStatus();
@ -199,7 +203,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
}
}
if (!blockUserList.isEmpty()) {
queryWrapper.notIn(Vlog::getVlogerId, blockUserList);
queryWrapper.notIn(Vlog::getMemberId, blockUserList);
}
}
}
@ -208,7 +212,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
List<IndexVlogVO> voList = vlogList.stream().map(v -> {
IndexVlogVO vo = vlogConvert.toVO(v);
if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, v.getVlogerId()));
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, v.getMemberId()));
vo.setDoILikeThisVlog(doILikeVlog(userId, v.getId()));
}
vo.setLikeCounts(getVlogBeLikedCounts(v.getId()));
@ -260,7 +264,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
IndexVlogVO vo = vlogConvert.toVO(vlog);
if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, vlog.getVlogerId()));
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, vlog.getMemberId()));
vo.setDoILikeThisVlog(doILikeVlog(userId, vlogId));
}
@ -275,7 +279,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
public void changeToPrivateOrPublic(String userId, String vlogId, Integer yesOrNo) {
LambdaUpdateWrapper<Vlog> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Vlog::getId, vlogId)
.eq(Vlog::getVlogerId, userId)
.eq(Vlog::getMemberId, userId)
.set(Vlog::getIsPrivate, yesOrNo);
vlogMapper.update(null, updateWrapper);
}
@ -285,7 +289,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
public void changeVlogStatus(String userId, String vlogId, Integer status) {
LambdaUpdateWrapper<Vlog> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Vlog::getId, vlogId)
.eq(Vlog::getVlogerId, userId)
.eq(Vlog::getMemberId, userId)
.set(Vlog::getStatus, status);
vlogMapper.update(null, updateWrapper);
}
@ -299,9 +303,9 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
if(bo.getUserId()==null){
LoginUser user= LoginHelper.getLoginUser();
queryWrapper.eq(Vlog::getVlogerId, user.getUserId());
queryWrapper.eq(Vlog::getMemberId, user.getUserId());
}else{
queryWrapper.eq(Vlog::getVlogerId, bo.getUserId());
queryWrapper.eq(Vlog::getMemberId, bo.getUserId());
}
queryWrapper.eq(Vlog::getIsPrivate, bo.getYesOrNo());
@ -316,7 +320,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
uid = user != null ? String.valueOf(user.getUserId()) : null;
}
if (StringUtils.isNotBlank(uid)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(uid, vlog.getVlogerId()));
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(uid, vlog.getMemberId()));
vo.setDoILikeThisVlog(doILikeVlog(uid, vlog.getId()));
}
vo.setLikeCounts(getVlogBeLikedCounts(vlog.getId()));
@ -352,13 +356,13 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
// 发送点赞通知
Vlog vlog = vlogMapper.selectById(vlogId);
if (vlog != null) {
String vlogerId = vlog.getVlogerId();
String vlogerId = vlog.getMemberId();
if (!userId.equals(vlogerId)) {
Long templateId = 1938491299175723009L;
SysMessageTemplateVo template = templateService.selectTemplateById(templateId);
if (template != null) {
// 查询点赞用户昵称
Users liker = usersMapper.selectById(userId);
Member liker = memberMapper.selectById(userId);
String likerNickname = liker != null && liker.getNickname() != null ? liker.getNickname() : "";
String content = template.getTemplateContent()
@ -430,7 +434,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
}
IndexVlogVO vo = vlogConvert.toVO(vlog);
if (StringUtils.isNotBlank(finalUid)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(finalUid, vlog.getVlogerId()));
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(finalUid, vlog.getMemberId()));
vo.setDoILikeThisVlog(true);
}
vo.setLikeCounts(getVlogBeLikedCounts(vlog.getId()));
@ -496,7 +500,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
// 这里不再统计避免重复计算
// 获取粉丝数量优先 Redis无则 MySQL
String fansCountsStr = redis.get(REDIS_MY_FANS_COUNTS + ":" + vlog.getVlogerId());
String fansCountsStr = redis.get(REDIS_MY_FANS_COUNTS + ":" + vlog.getMemberId());
Integer fansCounts = 0;
if (StringUtils.isNotBlank(fansCountsStr)) {
fansCounts = Integer.valueOf(fansCountsStr);
@ -608,20 +612,20 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
}
// 获取上传者ID
String uploaderId = vlog.getVlogerId();
String uploaderId = vlog.getMemberId();
if (uploaderId == null) {
return null;
}
// t_users 表获取用户信息
Users user = usersMapper.selectById(uploaderId);
// ums_member 表获取用户信息
Member user = memberMapper.selectById(uploaderId);
if (user == null) {
return null;
}
Map<String, String> result = new HashMap<>();
result.put("name", user.getNickname());
result.put("phone", user.getMobile());
result.put("phone", user.getPhoneHidden());
return result;
}

View File

@ -6,7 +6,7 @@
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="vloger_id" property="vlogerId" jdbcType="VARCHAR" />
<result column="member_id" property="vlogerId" jdbcType="VARCHAR" />
<result column="father_comment_id" property="fatherCommentId" jdbcType="VARCHAR" />
<result column="vlog_id" property="vlogId" jdbcType="VARCHAR" />
<result column="comment_user_id" property="commentUserId" jdbcType="VARCHAR" />

View File

@ -12,24 +12,24 @@
SELECT
c.id,
c.id as commentId,
c.vloger_id as vlogerId,
c.member_id as vlogerId,
c.status,
c.father_comment_id as fatherCommentId,
c.vlog_id as vlogId,
c.comment_user_id as commentUserId,
u.nickname as commentUserNickname,
u.face as commentUserFace,
m.nickname as commentUserNickname,
m.avatar as commentUserFace,
c.content,
c.like_counts as likeCounts,
c.create_time as createTime
FROM cont_comment c
LEFT JOIN cont_users u ON c.comment_user_id = u.id
LEFT JOIN ums_member m ON c.comment_user_id = m.id
<where>
<if test="paramMap.vlogId != null and paramMap.vlogId != ''">
AND c.vlog_id = #{paramMap.vlogId}
</if>
<if test="paramMap.mobile != null and paramMap.mobile != ''">
AND u.mobile LIKE CONCAT('%', #{paramMap.mobile}, '%')
AND m.phone_hidden LIKE CONCAT('%', #{paramMap.mobile}, '%')
</if>
<if test="true">
AND (c.father_comment_id = '0' OR c.father_comment_id IS NULL)
@ -42,25 +42,25 @@
SELECT
c.id,
c.id as commentId,
c.vloger_id as vlogerId,
c.member_id as vlogerId,
c.father_comment_id as fatherCommentId,
c.vlog_id as vlogId,
c.comment_user_id as commentUserId,
c.status,
u.nickname as commentUserNickname,
u.face as commentUserFace,
m.nickname as commentUserNickname,
m.avatar as commentUserFace,
c.content,
c.like_counts as likeCounts,
c.create_time as createTime
FROM cont_comment c
LEFT JOIN cont_users u ON c.comment_user_id = u.id
LEFT JOIN ums_member m ON c.comment_user_id = m.id
<where>
c.father_comment_id = '0'
<if test="vlogId != null and vlogId != ''">
AND c.vlog_id = #{vlogId}
</if>
<if test="mobile != null and mobile != ''">
AND u.mobile LIKE CONCAT('%', #{mobile}, '%')
AND m.phone_hidden LIKE CONCAT('%', #{mobile}, '%')
</if>
</where>
ORDER BY c.create_time DESC

View File

@ -5,17 +5,17 @@
<select id="queryMyFollows" resultType="com.wzj.soopin.content.domain.vo.VlogerVO" parameterType="map">
SELECT
u.id as vlogerId,
u.nickname as nickname,
u.face as face,
m.id as vlogerId,
m.nickname as nickname,
m.avatar as face,
f.is_fan_friend_of_mine as bothFriend,
f.created_time as createdTime
FROM
ums_fans f
LEFT JOIN
cont_users u
ums_member m
ON
f.vloger_id = u.id
f.vloger_id = m.id
WHERE
f.fan_id = #{paramMap.myId}
ORDER BY
@ -27,21 +27,21 @@
<select id="queryMyFans" resultType="com.wzj.soopin.member.domain.vo.FansVO" parameterType="map">
SELECT
u.id as fanId,
u.nickname as nickname,
u.face as face,
m.id as fanId,
m.nickname as nickname,
m.avatar as face,
f.is_fan_friend_of_mine as bothFriend,
f.created_time as createdTime
FROM
ums_fans f
LEFT JOIN
cont_users u
ums_member m
ON
f.fan_id = u.id
f.fan_id = m.id
WHERE
f.vloger_id = #{paramMap.myId}
ORDER BY
u.nickname
m.nickname
ASC
</select>

View File

@ -73,9 +73,9 @@
<select id="selectMyPublic" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
u.face as vlogerFace,
u.nickname as vlogerName,
v.member_id as vlogerId,
m.avatar as vlogerFace,
m.nickname as vlogerName,
v.title as content,
v.url as mediaUrl,
v.cover as cover,
@ -93,12 +93,12 @@
FROM
cont_vlog v
LEFT JOIN
cont_users u
ums_member m
ON
v.vloger_id = u.id
v.member_id = m.id
WHERE
v.is_private = 0
AND v.vloger_id = #{paramMap.vlogerId}
AND v.member_id = #{paramMap.vlogerId}
<choose>
<when test="paramMap.status != null and paramMap.status!=''">
AND v.status = #{paramMap.status}
@ -128,9 +128,9 @@
<select id="getVlogDetailFromId" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
u.face as vlogerFace,
u.nickname as vlogerName,
v.member_id as vlogerId,
m.avatar as vlogerFace,
m.nickname as vlogerName,
v.title as content,
v.url as mediaUrl,
v.cover as cover,
@ -148,9 +148,9 @@
FROM
cont_vlog v
LEFT JOIN
cont_users u
ums_member m
ON
v.vloger_id = u.id
v.member_id = m.id
WHERE
v.id = #{paramMap.vlogId}
AND v.status = 1
@ -176,24 +176,24 @@
SELECT
c.id,
c.id as commentId,
c.vloger_id as vlogerId,
c.member_id as vlogerId,
c.father_comment_id as fatherCommentId,
c.vlog_id as vlogId,
c.comment_user_id as commentUserId,
u.nickname as commentUserNickname,
u.face as commentUserFace,
m.nickname as commentUserNickname,
m.avatar as commentUserFace,
c.content,
c.like_counts as likeCounts,
c.create_time as createTime
FROM cont_comment c
LEFT JOIN cont_users u ON c.comment_user_id = u.id
LEFT JOIN ums_member m ON c.comment_user_id = m.id
<where>
c.father_comment_id = '0'
<if test="vlogId != null and vlogId != ''">
AND c.vlog_id = #{vlogId}
</if>
<if test="mobile != null and mobile != ''">
AND u.mobile LIKE CONCAT('%', #{mobile}, '%')
AND m.phone_hidden LIKE CONCAT('%', #{mobile}, '%')
</if>
</where>
ORDER BY c.create_time DESC
@ -202,7 +202,7 @@
<select id="selectVlogListWithAggregatedData" resultType="java.util.Map">
SELECT
v.id,
v.vloger_id,
v.member_id,
v.url as mediaUrl,
v.cover,
v.title,
@ -219,22 +219,22 @@
v.update_time,
v.create_by,
v.update_by,
u.nickname,
u.mobile
m.nickname,
m.phone_hidden as mobile
FROM
cont_vlog v
LEFT JOIN
cont_users u ON v.vloger_id = u.id
ums_member m ON v.member_id = m.id
LEFT JOIN
cont_my_liked_vlog mlv ON v.id = mlv.vlog_id
LEFT JOIN
cont_comment c ON v.id = c.vlog_id AND (c.father_comment_id = '0' OR c.father_comment_id IS NULL)
<where>
<if test="vlogBO.mobile != null and vlogBO.mobile != ''">
AND u.mobile LIKE CONCAT('%', #{vlogBO.mobile}, '%')
AND m.phone_hidden LIKE CONCAT('%', #{vlogBO.mobile}, '%')
</if>
<if test="vlogBO.nickname != null and vlogBO.nickname != ''">
AND u.nickname LIKE CONCAT('%', #{vlogBO.nickname}, '%')
AND m.nickname LIKE CONCAT('%', #{vlogBO.nickname}, '%')
</if>
<if test="vlogBO.titleQuery != null and vlogBO.titleQuery != ''">
AND v.title LIKE CONCAT('%', #{vlogBO.titleQuery}, '%')
@ -248,7 +248,7 @@
</where>
GROUP BY
v.id,
v.vloger_id,
v.member_id,
v.url,
v.cover,
v.title,
@ -263,8 +263,8 @@
v.update_time,
v.create_by,
v.update_by,
u.nickname,
u.mobile
m.nickname,
m.phone_hidden as mobile
ORDER BY
<choose>
<when test="vlogBO.column == 'likeCounts'">

View File

@ -5,9 +5,9 @@
<select id="getIndexVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
u.face as vlogerFace,
u.nickname as vlogerName,
v.member_id as vlogerId,
m.avatar as vlogerFace,
m.nickname as vlogerName,
v.title as content,
v.url as url,
v.cover as cover,
@ -25,9 +25,9 @@
FROM
cont_vlog v
LEFT JOIN
cont_users u
ums_member m
ON
v.vloger_id = u.id
v.member_id = m.id
WHERE
v.is_private = 0
<choose>
@ -52,7 +52,7 @@
</foreach>
</if>
<if test="paramMap.blockUser != null and paramMap.blockUser.size() > 0">
AND v.vloger_id NOT IN
AND v.member_id NOT IN
<foreach collection="paramMap.blockUser" item="vlogerId" open="(" separator="," close=")">
#{vlogerId}
</foreach>
@ -66,9 +66,9 @@
<select id="getVlogDetailById" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
u.face as vlogerFace,
u.nickname as vlogerName,
v.member_id as vlogerId,
m.avatar as vlogerFace,
m.nickname as vlogerName,
v.title as content,
v.url as url,
v.cover as cover,
@ -86,9 +86,9 @@
FROM
cont_vlog v
LEFT JOIN
cont_users u
ums_member m
ON
v.vloger_id = u.id
v.member_id = m.id
WHERE
v.id = #{paramMap.vlogId}
AND v.status = 1
@ -98,7 +98,7 @@
<select id="getMyLikedVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
v.member_id as vlogerId,
-- u.face as vlogerFace,
-- u.nickname as vlogerName,
v.title as content,
@ -122,11 +122,11 @@
ON
v.id = mlv.vlog_id
LEFT JOIN
cont_users u
ums_member m
ON
mlv.user_id = u.id
mlv.user_id = m.id
WHERE
u.id = #{paramMap.userId}
m.id = #{paramMap.userId}
AND v.status = 1
AND v.first_frame_img IS NOT NULL
AND v.is_private = 0
@ -137,7 +137,7 @@
</foreach>
</if>
<if test="paramMap.blockUser != null and paramMap.blockUser.size() > 0">
AND v.vloger_id NOT IN
AND v.member_id NOT IN
<foreach collection="paramMap.blockUser" item="vlogerId" open="(" separator="," close=")">
#{vlogerId}
</foreach>
@ -150,9 +150,9 @@
<select id="getMyFollowVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
u.face as vlogerFace,
u.nickname as vlogerName,
v.member_id as vlogerId,
m.avatar as vlogerFace,
m.nickname as vlogerName,
v.title as content,
v.url as url,
v.cover as cover,
@ -172,11 +172,11 @@
LEFT JOIN
cont_fans f
ON
v.vloger_id = f.vloger_id
v.member_id = f.vloger_id
LEFT JOIN
cont_users u
ums_member m
ON
f.vloger_id = u.id
f.vloger_id = m.id
WHERE
v.is_private = 0
AND v.status = 1
@ -191,9 +191,9 @@
<select id="getMyFriendVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT
v.id as vlogId,
v.vloger_id as vlogerId,
u.face as vlogerFace,
u.nickname as vlogerName,
v.member_id as vlogerId,
m.avatar as vlogerFace,
m.nickname as vlogerName,
v.title as content,
v.url as url,
v.cover as cover,
@ -213,11 +213,11 @@
LEFT JOIN
ums_fans f
ON
v.vloger_id = f.fan_id
v.member_id = f.fan_id
LEFT JOIN
cont_users u
ums_member m
ON
f.fan_id = u.id
f.fan_id = m.id
WHERE
v.is_private = 0
AND v.status = 1