feat:增加查询个人朋友圈接口
This commit is contained in:
@@ -37,10 +37,16 @@ public class MomentController {
|
|||||||
return momentService.deleteMoment(id);
|
return momentService.deleteMoment(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询朋友圈")
|
@Operation(summary = "查询所有朋友圈")
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public @JsonView(ReadView.class) List<MomentDto> queryMoment() {
|
public @JsonView(ReadView.class) List<MomentDto> queryMomentList() {
|
||||||
return momentService.queryMoment();
|
return momentService.queryMomentList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询朋友圈")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public @JsonView(ReadView.class) List<MomentDto> queryMomentById(@PathVariable("id") long id) {
|
||||||
|
return momentService.queryMomentById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "新增评论")
|
@Operation(summary = "新增评论")
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import java.util.List;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MomentDao {
|
public interface MomentDao {
|
||||||
List<MomentDto> queryMoment();
|
List<MomentDto> queryMomentList();
|
||||||
|
|
||||||
|
List<MomentDto> queryMomentById(@Param("id") Long id);
|
||||||
|
|
||||||
void insertMomentImage(@Param("momentId") Long momentId,
|
void insertMomentImage(@Param("momentId") Long momentId,
|
||||||
@Param("list") List<String> imageFiles);
|
@Param("list") List<String> imageFiles);
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ public interface MomentService {
|
|||||||
|
|
||||||
Boolean deleteMoment(Long id);
|
Boolean deleteMoment(Long id);
|
||||||
|
|
||||||
List<MomentDto> queryMoment();
|
List<MomentDto> queryMomentList();
|
||||||
|
|
||||||
|
List<MomentDto> queryMomentById(Long id);
|
||||||
|
|
||||||
Boolean addComment(Long momentId, String content);
|
Boolean addComment(Long momentId, String content);
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,14 @@ public class MomentServiceImpl implements MomentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MomentDto> queryMoment() {
|
public List<MomentDto> queryMomentList() {
|
||||||
// TODO 只能查询好友的朋友圈
|
// TODO 只能查询好友的朋友圈
|
||||||
return momentDao.queryMoment();
|
return momentDao.queryMomentList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MomentDto> queryMomentById(Long id) {
|
||||||
|
return momentDao.queryMomentById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,7 +119,7 @@ public class MomentServiceImpl implements MomentService {
|
|||||||
queryWrapper.eq(MomentLike::getMomentId, momentId).eq(MomentLike::getCreateBy, StpUtil.getLoginIdAsString());
|
queryWrapper.eq(MomentLike::getMomentId, momentId).eq(MomentLike::getCreateBy, StpUtil.getLoginIdAsString());
|
||||||
MomentLike like = momentLikeMapper.selectOne(queryWrapper);
|
MomentLike like = momentLikeMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
if (like == null ) {
|
if (like == null) {
|
||||||
throw new CustomException("该朋友圈不存在");
|
throw new CustomException("该朋友圈不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
WHERE moment_id = #{id}
|
WHERE moment_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryMoment" resultMap="momentResultMap">
|
<select id="queryMomentList" resultMap="momentResultMap">
|
||||||
SELECT a.id AS id,
|
SELECT a.id AS id,
|
||||||
b.id AS userId,
|
b.id AS userId,
|
||||||
b.username AS username,
|
b.username AS username,
|
||||||
@@ -56,6 +56,19 @@
|
|||||||
ORDER BY a.update_time DESC
|
ORDER BY a.update_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryMomentById" resultMap="momentResultMap">
|
||||||
|
SELECT a.id AS id,
|
||||||
|
b.id AS userId,
|
||||||
|
b.username AS username,
|
||||||
|
b.avatar AS avatar,
|
||||||
|
a.content AS content,
|
||||||
|
a.create_time AS date
|
||||||
|
FROM moment AS a
|
||||||
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
|
WHERE a.create_by = #{id}
|
||||||
|
ORDER BY a.update_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="queryMomentImage" resultType="java.lang.String">
|
<select id="queryMomentImage" resultType="java.lang.String">
|
||||||
SELECT image_url AS imageUrl
|
SELECT image_url AS imageUrl
|
||||||
FROM moment_image
|
FROM moment_image
|
||||||
|
|||||||
Reference in New Issue
Block a user