Compare commits

...

2 Commits

Author SHA1 Message Date
曹佳豪
e0f6ccace8 Merge remote-tracking branch 'origin/wzj-main' into wzj-main 2025-08-15 19:06:17 +08:00
曹佳豪
af2e269e71 修改bug 2025-08-15 19:05:25 +08:00
5 changed files with 158 additions and 68 deletions

View File

@ -45,7 +45,7 @@ public class AppVlogController {
PagedGridResult pages = vlogService.getIndexVlogList(bo, page); PagedGridResult pages = vlogService.getIndexVlogList(bo, page);
return R.ok(pages); return R.ok(pages);
} }
@GetMapping("detail") @GetMapping("/detail")
public R<Object> detail(@RequestParam(defaultValue = "") String userId, public R<Object> detail(@RequestParam(defaultValue = "") String userId,
@RequestParam String vlogId) { @RequestParam String vlogId) {
return R.ok(vlogService.getVlogDetailById(userId, vlogId)); return R.ok(vlogService.getVlogDetailById(userId, vlogId));

View File

@ -1,5 +1,7 @@
package com.wzj.soopin.content.domain.vo; package com.wzj.soopin.content.domain.vo;
import com.wzj.soopin.content.domain.po.Vlog;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -9,11 +11,13 @@ import lombok.ToString;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@AutoMapper(target = Vlog.class)
public class IndexVlogVO { public class IndexVlogVO {
private String vlogId; private String Id;
private String vlogerId; private String memberId;
private String vlogerFace; private String avatar;
private String vlogerName; private String nickname;
private String title;
private String content; private String content;
private String url; private String url;
private String cover; private String cover;

View File

@ -44,6 +44,7 @@ import org.dromara.system.service.ISysMessageService;
import org.dromara.system.service.ISysMessageTemplateService; import org.dromara.system.service.ISysMessageTemplateService;
import org.dromara.system.domain.bo.SysMessageBo; import org.dromara.system.domain.bo.SysMessageBo;
import org.dromara.system.domain.vo.SysMessageTemplateVo; import org.dromara.system.domain.vo.SysMessageTemplateVo;
import org.dromara.common.core.utils.MapstructUtils;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -81,8 +82,6 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Autowired @Autowired
private MemberMapper memberMapper; private MemberMapper memberMapper;
@Autowired @Autowired
private VlogConvert vlogConvert;
@Autowired
private ISysMessageService sysMessageService; private ISysMessageService sysMessageService;
@Autowired @Autowired
private ISysMessageTemplateService templateService; private ISysMessageTemplateService templateService;
@ -136,7 +135,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Override @Override
public void createVlog(VlogBO vlogBO) { public void createVlog(VlogBO vlogBO) {
String vid = sid.nextShort(); String vid = sid.nextShort();
Vlog vlog = vlogConvert.toEntity(vlogBO); Vlog vlog = MapstructUtils.convert(vlogBO, Vlog.class);
vlog.setId(vid); vlog.setId(vid);
vlog.setLikeCounts(0); vlog.setLikeCounts(0);
vlog.setCommentsCounts(0); vlog.setCommentsCounts(0);
@ -196,8 +195,8 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
for (String report : reports) { for (String report : reports) {
try { try {
Map<String, Object> reportMap = objectMapper.readValue(report, new TypeReference<Map<String, Object>>() {}); Map<String, Object> reportMap = objectMapper.readValue(report, new TypeReference<Map<String, Object>>() {});
String vlogerId = (String) reportMap.get("vlogerId"); String memberId = (String) reportMap.get("MemberId");
blockUserList.add(vlogerId); blockUserList.add(memberId);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -210,7 +209,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
Page<Vlog> vlogPage = vlogMapper.selectPage(pageParam, queryWrapper); Page<Vlog> vlogPage = vlogMapper.selectPage(pageParam, queryWrapper);
List<Vlog> vlogList = vlogPage.getRecords(); List<Vlog> vlogList = vlogPage.getRecords();
List<IndexVlogVO> voList = vlogList.stream().map(v -> { List<IndexVlogVO> voList = vlogList.stream().map(v -> {
IndexVlogVO vo = vlogConvert.toVO(v); IndexVlogVO vo = MapstructUtils.convert(v, IndexVlogVO.class);
if (StringUtils.isNotBlank(userId)) { if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, v.getMemberId())); vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, v.getMemberId()));
vo.setDoILikeThisVlog(doILikeVlog(userId, v.getId())); vo.setDoILikeThisVlog(doILikeVlog(userId, v.getId()));
@ -220,6 +219,26 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return vo; return vo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 批量补充作者信息头像/昵称
if (!vlogList.isEmpty()) {
List<String> memberIds = vlogList.stream()
.map(Vlog::getMemberId)
.filter(StringUtils::isNotBlank)
.distinct()
.collect(Collectors.toList());
if (!memberIds.isEmpty()) {
List<Member> members = memberMapper.selectList(new LambdaQueryWrapper<Member>().in(Member::getId, memberIds));
Map<String, Member> memberMap = members.stream().collect(Collectors.toMap(m -> String.valueOf(m.getId()), m -> m, (a, b) -> a));
voList.forEach(vo -> {
Member m = memberMap.get(vo.getMemberId());
if (m != null) {
vo.setAvatar(m.getAvatar());
vo.setNickname(m.getNickname());
}
});
}
}
// 封装分页结果 // 封装分页结果
PagedGridResult gridResult = new PagedGridResult(); PagedGridResult gridResult = new PagedGridResult();
gridResult.setRows(voList); // 当前页数据列表 gridResult.setRows(voList); // 当前页数据列表
@ -261,7 +280,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return null; return null;
} }
IndexVlogVO vo = vlogConvert.toVO(vlog); IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
if (StringUtils.isNotBlank(userId)) { if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, vlog.getMemberId())); vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, vlog.getMemberId()));
@ -271,6 +290,13 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
vo.setLikeCounts(getVlogBeLikedCounts(vlogId)); vo.setLikeCounts(getVlogBeLikedCounts(vlogId));
vo.setCommentsCounts(getVlogComment(vlogId)); vo.setCommentsCounts(getVlogComment(vlogId));
// 补充作者信息头像/昵称
Member author = memberMapper.selectById(vlog.getMemberId());
if (author != null) {
vo.setAvatar(author.getAvatar());
vo.setNickname(author.getNickname());
}
return vo; return vo;
} }
@ -313,7 +339,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
List<Vlog> vlogList = vlogPage.getRecords(); List<Vlog> vlogList = vlogPage.getRecords();
List<IndexVlogVO> voList = vlogList.stream().map(vlog -> { List<IndexVlogVO> voList = vlogList.stream().map(vlog -> {
IndexVlogVO vo = vlogConvert.toVO(vlog); IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
String uid = bo.getUserId(); String uid = bo.getUserId();
if (StringUtils.isBlank(uid)) { if (StringUtils.isBlank(uid)) {
LoginUser user = LoginHelper.getLoginUser(); LoginUser user = LoginHelper.getLoginUser();
@ -325,6 +351,14 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
} }
vo.setLikeCounts(getVlogBeLikedCounts(vlog.getId())); vo.setLikeCounts(getVlogBeLikedCounts(vlog.getId()));
vo.setCommentsCounts(getVlogComment(vlog.getId())); vo.setCommentsCounts(getVlogComment(vlog.getId()));
// 补充用户信息头像/昵称
Member author = memberMapper.selectById(vlog.getMemberId());
if (author != null) {
vo.setAvatar(author.getAvatar());
vo.setNickname(author.getNickname());
}
return vo; return vo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -432,13 +466,21 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
if (vlog == null) { if (vlog == null) {
return null; return null;
} }
IndexVlogVO vo = vlogConvert.toVO(vlog); IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
if (StringUtils.isNotBlank(finalUid)) { if (StringUtils.isNotBlank(finalUid)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(finalUid, vlog.getMemberId())); vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(finalUid, vlog.getMemberId()));
vo.setDoILikeThisVlog(true); vo.setDoILikeThisVlog(true);
} }
vo.setLikeCounts(getVlogBeLikedCounts(vlog.getId())); vo.setLikeCounts(getVlogBeLikedCounts(vlog.getId()));
vo.setCommentsCounts(getVlogComment(vlog.getId())); vo.setCommentsCounts(getVlogComment(vlog.getId()));
// 补充用户信息头像/昵称
Member author = memberMapper.selectById(vlog.getMemberId());
if (author != null) {
vo.setAvatar(author.getAvatar());
vo.setNickname(author.getNickname());
}
return vo; return vo;
}) })
.filter(Objects::nonNull) .filter(Objects::nonNull)
@ -452,28 +494,68 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return gridResult; return gridResult;
} }
@Override
public PagedGridResult getMyFriendVlogList(SimpleListBO bo, Page page) {
int current = (int) page.getCurrent();
int size = (int) page.getSize();
Page<Vlog> pageParam = new Page<>(current, size);
Map<String, Object> map = new HashMap<>();
map.put("myId", bo.getMyId());
List<IndexVlogVO> voList = vlogMapperCustom.getMyFriendVlogList(map);
// TODO: 组装PagedGridResult返回
return null;
}
@Override @Override
public PagedGridResult getMyFollowVlogList(SimpleListBO bo, Page page) { public PagedGridResult getMyFollowVlogList(SimpleListBO bo, Page page) {
int current = (int) page.getCurrent(); int current = (int) page.getCurrent();
int size = (int) page.getSize(); int size = (int) page.getSize();
Page<Vlog> pageParam = new Page<>(current, size);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("myId", bo.getMyId()); map.put("myId", bo.getMyId());
List<IndexVlogVO> voList = vlogMapperCustom.getMyFollowVlogList(map); List<IndexVlogVO> voList = vlogMapperCustom.getMyFollowVlogList(map);
// TODO: 组装PagedGridResult返回
return null; // 补充用户信息头像/昵称
voList.forEach(vo -> {
if (StringUtils.isNotBlank(vo.getMemberId())) {
Member author = memberMapper.selectById(vo.getMemberId());
if (author != null) {
vo.setAvatar(author.getAvatar());
vo.setNickname(author.getNickname());
}
}
});
// 手动分页
int startIndex = (current - 1) * size;
int endIndex = Math.min(startIndex + size, voList.size());
List<IndexVlogVO> pagedList = voList.subList(startIndex, endIndex);
PagedGridResult gridResult = new PagedGridResult();
gridResult.setRows(pagedList);
gridResult.setPage(current);
gridResult.setRecords(voList.size());
gridResult.setTotal((int) Math.ceil((double) voList.size() / size));
return gridResult;
}
@Override
public PagedGridResult getMyFriendVlogList(SimpleListBO bo, Page page) {
int current = (int) page.getCurrent();
int size = (int) page.getSize();
Map<String, Object> map = new HashMap<>();
map.put("myId", bo.getMyId());
List<IndexVlogVO> voList = vlogMapperCustom.getMyFriendVlogList(map);
// 补充用户信息头像/昵称
voList.forEach(vo -> {
if (StringUtils.isNotBlank(vo.getMemberId())) {
Member author = memberMapper.selectById(vo.getMemberId());
if (author != null) {
vo.setAvatar(author.getAvatar());
vo.setNickname(author.getNickname());
}
}
});
// 手动分页
int startIndex = (current - 1) * size;
int endIndex = Math.min(startIndex + size, voList.size());
List<IndexVlogVO> pagedList = voList.subList(startIndex, endIndex);
PagedGridResult gridResult = new PagedGridResult();
gridResult.setRows(pagedList);
gridResult.setPage(current);
gridResult.setRecords(voList.size());
gridResult.setTotal((int) Math.ceil((double) voList.size() / size));
return gridResult;
} }
@Override @Override
@ -534,7 +616,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
// } else { // } else {
// result.put("vodDetail", vodDetail); // result.put("vodDetail", vodDetail);
// } // }
IndexVlogVO vo = vlogConvert.toVO(vlog); IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
// 添加评论信息 // 添加评论信息
List<Map<String, Object>> comments = commentMapper.selectCommentsByVlogId(vlog.getId()); List<Map<String, Object>> comments = commentMapper.selectCommentsByVlogId(vlog.getId());
result.put("comments", comments); result.put("comments", comments);

View File

@ -127,10 +127,10 @@
<select id="getVlogDetailFromId" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO"> <select id="getVlogDetailFromId" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT SELECT
v.id as vlogId, v.id ,
v.member_id as vlogerId, v.member_id ,
m.avatar as vlogerFace, m.avatar ,
m.nickname as vlogerName, m.nickname ,
v.title as content, v.title as content,
v.url as mediaUrl, v.url as mediaUrl,
v.cover as cover, v.cover as cover,

View File

@ -4,13 +4,14 @@
<select id="getIndexVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO"> <select id="getIndexVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT SELECT
v.id as vlogId, v.id,
v.member_id as vlogerId, v.member_id,
m.avatar as vlogerFace, m.avatar,
m.nickname as vlogerName, m.nickname,
v.title as content, v.title as content,
v.url as url, v.url as url,
v.cover as cover, v.cover as cover,
v.title,
v.width as width, v.width as width,
v.height as height, v.height as height,
v.like_counts as likeCounts, v.like_counts as likeCounts,
@ -53,8 +54,8 @@
</if> </if>
<if test="paramMap.blockUser != null and paramMap.blockUser.size() > 0"> <if test="paramMap.blockUser != null and paramMap.blockUser.size() > 0">
AND v.member_id NOT IN AND v.member_id NOT IN
<foreach collection="paramMap.blockUser" item="vlogerId" open="(" separator="," close=")"> <foreach collection="paramMap.blockUser" item="memberId" open="(" separator="," close=")">
#{vlogerId} #{memberId}
</foreach> </foreach>
</if> </if>
ORDER BY ORDER BY
@ -98,9 +99,8 @@
<select id="getMyLikedVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO"> <select id="getMyLikedVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT SELECT
v.id as vlogId, v.id as vlogId,
v.member_id as vlogerId, v.member_id as memberId,
-- u.face as vlogerFace, v.title as title,
-- u.nickname as vlogerName,
v.title as content, v.title as content,
v.url as url, v.url as url,
v.cover as cover, v.cover as cover,
@ -114,7 +114,9 @@
v.status as status, v.status as status,
v.file_id as fileId, v.file_id as fileId,
v.first_frame_img as firstFrameImg, v.first_frame_img as firstFrameImg,
v.id as vlogId v.id as Id,
m.avatar as avatar,
m.nickname as nickname
FROM FROM
cont_vlog v cont_vlog v
LEFT JOIN LEFT JOIN
@ -124,9 +126,9 @@
LEFT JOIN LEFT JOIN
ums_member m ums_member m
ON ON
mlv.user_id = m.id v.member_id = m.id
WHERE WHERE
m.id = #{paramMap.userId} mlv.user_id = #{paramMap.userId}
AND v.status = 1 AND v.status = 1
AND v.first_frame_img IS NOT NULL AND v.first_frame_img IS NOT NULL
AND v.is_private = 0 AND v.is_private = 0
@ -150,9 +152,8 @@
<select id="getMyFollowVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO"> <select id="getMyFollowVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT SELECT
v.id as vlogId, v.id as vlogId,
v.member_id as vlogerId, v.member_id as memberId,
m.avatar as vlogerFace, v.title as title,
m.nickname as vlogerName,
v.title as content, v.title as content,
v.url as url, v.url as url,
v.cover as cover, v.cover as cover,
@ -166,34 +167,35 @@
v.status as status, v.status as status,
v.file_id as fileId, v.file_id as fileId,
v.first_frame_img as firstFrameImg, v.first_frame_img as firstFrameImg,
v.id as vlogId v.id as Id,
m.avatar as avatar,
m.nickname as nickname
FROM FROM
cont_vlog v cont_vlog v
LEFT JOIN LEFT JOIN
cont_fans f cont_fans f
ON ON
v.member_id = f.vloger_id v.member_id = f.vloger_id
LEFT JOIN LEFT JOIN
ums_member m ums_member m
ON ON
f.vloger_id = m.id v.member_id = m.id
WHERE WHERE
v.is_private = 0 v.is_private = 0
AND v.status = 1 AND v.status = 1
AND v.first_frame_img IS NOT NULL AND v.first_frame_img IS NOT NULL
AND AND
f.fan_id = #{paramMap.myId} f.fan_id = #{paramMap.myId}
ORDER BY ORDER BY
v.created_time v.created_time
DESC DESC
</select> </select>
<select id="getMyFriendVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO"> <select id="getMyFriendVlogList" parameterType="map" resultType="com.wzj.soopin.content.domain.vo.IndexVlogVO">
SELECT SELECT
v.id as vlogId, v.id as vlogId,
v.member_id as vlogerId, v.member_id as memberId,
m.avatar as vlogerFace, v.title as title,
m.nickname as vlogerName,
v.title as content, v.title as content,
v.url as url, v.url as url,
v.cover as cover, v.cover as cover,
@ -207,19 +209,21 @@
v.status as status, v.status as status,
v.file_id as fileId, v.file_id as fileId,
v.first_frame_img as firstFrameImg, v.first_frame_img as firstFrameImg,
v.id as vlogId v.id as Id,
m.avatar as avatar,
m.nickname as nickname
FROM FROM
cont_vlog v cont_vlog v
LEFT JOIN LEFT JOIN
ums_fans f ums_fans f
ON ON
v.member_id = f.fan_id v.member_id = f.fan_id
LEFT JOIN LEFT JOIN
ums_member m ums_member m
ON ON
f.fan_id = m.id v.member_id = m.id
WHERE WHERE
v.is_private = 0 v.is_private = 0
AND v.status = 1 AND v.status = 1
AND v.first_frame_img IS NOT NULL AND v.first_frame_img IS NOT NULL
AND AND
@ -227,7 +231,7 @@
AND AND
f.is_fan_friend_of_mine = 1 f.is_fan_friend_of_mine = 1
ORDER BY ORDER BY
v.created_time v.created_time
DESC DESC
</select> </select>