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);
return R.ok(pages);
}
@GetMapping("detail")
@GetMapping("/detail")
public R<Object> detail(@RequestParam(defaultValue = "") String userId,
@RequestParam String vlogId) {
return R.ok(vlogService.getVlogDetailById(userId, vlogId));

View File

@ -1,5 +1,7 @@
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.Data;
import lombok.NoArgsConstructor;
@ -9,11 +11,13 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@AutoMapper(target = Vlog.class)
public class IndexVlogVO {
private String vlogId;
private String vlogerId;
private String vlogerFace;
private String vlogerName;
private String Id;
private String memberId;
private String avatar;
private String nickname;
private String title;
private String content;
private String url;
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.domain.bo.SysMessageBo;
import org.dromara.system.domain.vo.SysMessageTemplateVo;
import org.dromara.common.core.utils.MapstructUtils;
import java.time.Instant;
import java.time.LocalDateTime;
@ -81,8 +82,6 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Autowired
private MemberMapper memberMapper;
@Autowired
private VlogConvert vlogConvert;
@Autowired
private ISysMessageService sysMessageService;
@Autowired
private ISysMessageTemplateService templateService;
@ -136,7 +135,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Override
public void createVlog(VlogBO vlogBO) {
String vid = sid.nextShort();
Vlog vlog = vlogConvert.toEntity(vlogBO);
Vlog vlog = MapstructUtils.convert(vlogBO, Vlog.class);
vlog.setId(vid);
vlog.setLikeCounts(0);
vlog.setCommentsCounts(0);
@ -196,8 +195,8 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
for (String report : reports) {
try {
Map<String, Object> reportMap = objectMapper.readValue(report, new TypeReference<Map<String, Object>>() {});
String vlogerId = (String) reportMap.get("vlogerId");
blockUserList.add(vlogerId);
String memberId = (String) reportMap.get("MemberId");
blockUserList.add(memberId);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
@ -210,7 +209,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
Page<Vlog> vlogPage = vlogMapper.selectPage(pageParam, queryWrapper);
List<Vlog> vlogList = vlogPage.getRecords();
List<IndexVlogVO> voList = vlogList.stream().map(v -> {
IndexVlogVO vo = vlogConvert.toVO(v);
IndexVlogVO vo = MapstructUtils.convert(v, IndexVlogVO.class);
if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, v.getMemberId()));
vo.setDoILikeThisVlog(doILikeVlog(userId, v.getId()));
@ -220,6 +219,26 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return vo;
}).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();
gridResult.setRows(voList); // 当前页数据列表
@ -261,7 +280,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return null;
}
IndexVlogVO vo = vlogConvert.toVO(vlog);
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, vlog.getMemberId()));
@ -271,6 +290,13 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
vo.setLikeCounts(getVlogBeLikedCounts(vlogId));
vo.setCommentsCounts(getVlogComment(vlogId));
// 补充作者信息头像/昵称
Member author = memberMapper.selectById(vlog.getMemberId());
if (author != null) {
vo.setAvatar(author.getAvatar());
vo.setNickname(author.getNickname());
}
return vo;
}
@ -313,7 +339,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
List<Vlog> vlogList = vlogPage.getRecords();
List<IndexVlogVO> voList = vlogList.stream().map(vlog -> {
IndexVlogVO vo = vlogConvert.toVO(vlog);
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
String uid = bo.getUserId();
if (StringUtils.isBlank(uid)) {
LoginUser user = LoginHelper.getLoginUser();
@ -325,6 +351,14 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
}
vo.setLikeCounts(getVlogBeLikedCounts(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;
}).collect(Collectors.toList());
@ -432,13 +466,21 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
if (vlog == null) {
return null;
}
IndexVlogVO vo = vlogConvert.toVO(vlog);
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
if (StringUtils.isNotBlank(finalUid)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(finalUid, vlog.getMemberId()));
vo.setDoILikeThisVlog(true);
}
vo.setLikeCounts(getVlogBeLikedCounts(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;
})
.filter(Objects::nonNull)
@ -452,28 +494,68 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
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
public PagedGridResult getMyFollowVlogList(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.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
@ -534,7 +616,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
// } else {
// 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());
result.put("comments", comments);

View File

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

View File

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