Merge branch 'master' of https://gitee.com/Cxx0822/food-hub-service
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.cxx.food.controller;
|
package com.cxx.food.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cxx.food.dto.*;
|
import com.cxx.food.dto.*;
|
||||||
import com.cxx.food.service.MomentService;
|
import com.cxx.food.service.MomentService;
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
@@ -43,6 +44,13 @@ public class MomentController {
|
|||||||
return momentService.queryMomentList();
|
return momentService.queryMomentList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询所有朋友圈")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public IPage<MomentDto> queryMomentByPage(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
|
return momentService.queryMomentByPage(currentPage, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询朋友圈")
|
@Operation(summary = "查询朋友圈")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public @JsonView(ReadView.class) List<MomentDto> queryMomentById(@PathVariable("id") long id) {
|
public @JsonView(ReadView.class) List<MomentDto> queryMomentById(@PathVariable("id") long id) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.cxx.food.dao;
|
package com.cxx.food.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.cxx.food.dto.*;
|
import com.cxx.food.dto.*;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@@ -10,6 +12,8 @@ import java.util.List;
|
|||||||
public interface MomentDao {
|
public interface MomentDao {
|
||||||
List<MomentDto> queryMomentList();
|
List<MomentDto> queryMomentList();
|
||||||
|
|
||||||
|
IPage<MomentDto> queryMomentByPage(Page<MomentDto> page);
|
||||||
|
|
||||||
List<MomentDto> queryMomentById(@Param("id") Long id);
|
List<MomentDto> queryMomentById(@Param("id") Long id);
|
||||||
|
|
||||||
void insertMomentImage(@Param("momentId") Long momentId,
|
void insertMomentImage(@Param("momentId") Long momentId,
|
||||||
|
|||||||
41
src/main/java/com/cxx/food/dto/MomentPageDto.java
Normal file
41
src/main/java/com/cxx/food/dto/MomentPageDto.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package com.cxx.food.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class MomentPageDto {
|
||||||
|
@Schema(description = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "姓名")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(description = "头像")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
@Schema(description = "朋友圈内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "朋友圈图片")
|
||||||
|
private List<String> imageList;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
@Schema(description = "点赞用户")
|
||||||
|
private List<Long> likeList;
|
||||||
|
|
||||||
|
@Schema(description = "评论内容")
|
||||||
|
private List<CommentDto> commentList;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.cxx.food.service;
|
package com.cxx.food.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cxx.food.dto.*;
|
import com.cxx.food.dto.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -14,6 +15,8 @@ public interface MomentService {
|
|||||||
|
|
||||||
List<MomentDto> queryMomentList();
|
List<MomentDto> queryMomentList();
|
||||||
|
|
||||||
|
IPage<MomentDto> queryMomentByPage(int currentPage, int pageSize);
|
||||||
|
|
||||||
List<MomentDto> queryMomentById(Long id);
|
List<MomentDto> queryMomentById(Long id);
|
||||||
|
|
||||||
Boolean addComment(Long momentId, String content);
|
Boolean addComment(Long momentId, String content);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.cxx.food.service.impl;
|
package com.cxx.food.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.cxx.food.constant.BizType;
|
import com.cxx.food.constant.BizType;
|
||||||
import com.cxx.food.dao.MomentDao;
|
import com.cxx.food.dao.MomentDao;
|
||||||
import com.cxx.food.dto.MomentDto;
|
import com.cxx.food.dto.MomentDto;
|
||||||
@@ -74,6 +76,12 @@ public class MomentServiceImpl implements MomentService {
|
|||||||
return momentDao.queryMomentList();
|
return momentDao.queryMomentList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<MomentDto> queryMomentByPage(int currentPage, int pageSize) {
|
||||||
|
Page<MomentDto> page = new Page<>(currentPage, pageSize);
|
||||||
|
return momentDao.queryMomentByPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MomentDto> queryMomentById(Long id) {
|
public List<MomentDto> queryMomentById(Long id) {
|
||||||
return momentDao.queryMomentById(id);
|
return momentDao.queryMomentById(id);
|
||||||
|
|||||||
@@ -18,6 +18,23 @@
|
|||||||
</collection>
|
</collection>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="momentPageResultMap" type="com.cxx.food.dto.MomentPageDto">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="userId" column="userId"/>
|
||||||
|
<result property="username" column="username"/>
|
||||||
|
<result property="avatar" column="avatar"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
<result property="date" column="date"/>
|
||||||
|
<collection property="imageList" ofType="java.lang.String"
|
||||||
|
column="id" select="queryMomentImage"/>
|
||||||
|
<collection property="likeList" ofType="long"
|
||||||
|
column="id" select="queryMomentLike">
|
||||||
|
</collection>
|
||||||
|
<collection property="commentList" ofType="com.cxx.food.dto.CommentDto"
|
||||||
|
column="id" select="queryMomentComment">
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="commentResultMap" type="com.cxx.food.dto.CommentDto">
|
<resultMap id="commentResultMap" type="com.cxx.food.dto.CommentDto">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="username" column="username"/>
|
<result property="username" column="username"/>
|
||||||
@@ -33,11 +50,11 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryMomentComment" resultMap="commentResultMap">
|
<select id="queryMomentComment" resultMap="commentResultMap">
|
||||||
SELECT a.id AS id,
|
SELECT a.id AS id,
|
||||||
b.username AS username,
|
b.username AS username,
|
||||||
b.avatar AS avatar,
|
COALESCE(b.avatar, '') AS avatar,
|
||||||
a.content AS content,
|
a.content AS content,
|
||||||
a.create_time AS date
|
a.create_time AS date
|
||||||
FROM comment_record AS a
|
FROM comment_record AS a
|
||||||
LEFT JOIN user AS b ON a.create_by = b.id
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
WHERE subject_id = #{id}
|
WHERE subject_id = #{id}
|
||||||
@@ -45,12 +62,24 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryMomentList" 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,
|
||||||
b.avatar AS avatar,
|
COALESCE(b.avatar, '') AS avatar,
|
||||||
a.content AS content,
|
a.content AS content,
|
||||||
a.create_time AS date
|
a.create_time AS date
|
||||||
|
FROM moment AS a
|
||||||
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
|
ORDER BY a.create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryMomentByPage" resultMap="momentPageResultMap">
|
||||||
|
SELECT a.id AS id,
|
||||||
|
b.id AS userId,
|
||||||
|
b.username AS username,
|
||||||
|
COALESCE(b.avatar, '') AS avatar,
|
||||||
|
a.content AS content,
|
||||||
|
a.create_time AS date
|
||||||
FROM moment AS a
|
FROM moment AS a
|
||||||
LEFT JOIN user AS b ON a.create_by = b.id
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
ORDER BY a.create_time DESC
|
ORDER BY a.create_time DESC
|
||||||
@@ -60,7 +89,7 @@
|
|||||||
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,
|
||||||
b.avatar AS avatar,
|
COALESCE(b.avatar, '') AS avatar,
|
||||||
a.content AS content,
|
a.content AS content,
|
||||||
a.create_time AS date
|
a.create_time AS date
|
||||||
FROM moment AS a
|
FROM moment AS a
|
||||||
|
|||||||
Reference in New Issue
Block a user