Compare commits

..

No commits in common. "e0f6ccace8e3e07df1e58958dff6263479503608" and "593fac40442ea9b689c864a9d020a86b3acd47dc" have entirely different histories.

5 changed files with 68 additions and 158 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,7 +1,5 @@
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;
@ -11,13 +9,11 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@AutoMapper(target = Vlog.class)
public class IndexVlogVO {
private String Id;
private String memberId;
private String avatar;
private String nickname;
private String title;
private String vlogId;
private String vlogerId;
private String vlogerFace;
private String vlogerName;
private String content;
private String url;
private String cover;

View File

@ -44,7 +44,6 @@ 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;
@ -82,6 +81,8 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Autowired
private MemberMapper memberMapper;
@Autowired
private VlogConvert vlogConvert;
@Autowired
private ISysMessageService sysMessageService;
@Autowired
private ISysMessageTemplateService templateService;
@ -135,7 +136,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
@Override
public void createVlog(VlogBO vlogBO) {
String vid = sid.nextShort();
Vlog vlog = MapstructUtils.convert(vlogBO, Vlog.class);
Vlog vlog = vlogConvert.toEntity(vlogBO);
vlog.setId(vid);
vlog.setLikeCounts(0);
vlog.setCommentsCounts(0);
@ -195,8 +196,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 memberId = (String) reportMap.get("MemberId");
blockUserList.add(memberId);
String vlogerId = (String) reportMap.get("vlogerId");
blockUserList.add(vlogerId);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
@ -209,7 +210,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 = MapstructUtils.convert(v, IndexVlogVO.class);
IndexVlogVO vo = vlogConvert.toVO(v);
if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, v.getMemberId()));
vo.setDoILikeThisVlog(doILikeVlog(userId, v.getId()));
@ -219,26 +220,6 @@ 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); // 当前页数据列表
@ -280,7 +261,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return null;
}
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
IndexVlogVO vo = vlogConvert.toVO(vlog);
if (StringUtils.isNotBlank(userId)) {
vo.setDoIFollowVloger(fansService.queryDoIFollowVloger(userId, vlog.getMemberId()));
@ -290,13 +271,6 @@ 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;
}
@ -339,7 +313,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
List<Vlog> vlogList = vlogPage.getRecords();
List<IndexVlogVO> voList = vlogList.stream().map(vlog -> {
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
IndexVlogVO vo = vlogConvert.toVO(vlog);
String uid = bo.getUserId();
if (StringUtils.isBlank(uid)) {
LoginUser user = LoginHelper.getLoginUser();
@ -351,14 +325,6 @@ 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());
@ -466,21 +432,13 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
if (vlog == null) {
return null;
}
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
IndexVlogVO vo = vlogConvert.toVO(vlog);
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)
@ -494,68 +452,28 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
return gridResult;
}
@Override
public PagedGridResult getMyFollowVlogList(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.getMyFollowVlogList(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
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);
// 补充用户信息头像/昵称
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;
// 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;
}
@Override
@ -616,7 +534,7 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
// } else {
// result.put("vodDetail", vodDetail);
// }
IndexVlogVO vo = MapstructUtils.convert(vlog, IndexVlogVO.class);
IndexVlogVO vo = vlogConvert.toVO(vlog);
// 添加评论信息
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 ,
v.member_id ,
m.avatar ,
m.nickname ,
v.id as vlogId,
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,

View File

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