최신 게시물 불러오기 api 구현 완료 :push
This commit is contained in:
@ -10,11 +10,12 @@ import com.eogns.board_back.dto.response.board.PostBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PostCommentResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PutFavoriteResponseDto;
|
||||
import com.eogns.board_back.service.BoardService;
|
||||
import com.mysql.cj.x.protobuf.MysqlxCrud.Delete;
|
||||
//import com.mysql.cj.x.protobuf.MysqlxCrud.Delete;
|
||||
import com.eogns.board_back.dto.response.board.DeleteBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetCommentListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetFavoriteListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetLatestBoardListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.IncreaseViewCountResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PatchBoardResponseDto;
|
||||
|
||||
@ -22,7 +23,7 @@ import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authorization.method.AuthorizeReturnObject;
|
||||
//import org.springframework.security.authorization.method.AuthorizeReturnObject;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@ -78,6 +79,12 @@ public class BoardController {
|
||||
return response;
|
||||
}
|
||||
|
||||
@GetMapping("/latest-list")
|
||||
public ResponseEntity<? super GetLatestBoardListResponseDto> getLatestBoardList(){
|
||||
ResponseEntity<? super GetLatestBoardListResponseDto> response = boardService.getLatestBoardList();
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("")
|
||||
public ResponseEntity<? super PostBoardResponseDto> postBoard(
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.eogns.board_back.dto.object;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.eogns.board_back.entity.BoardListViewEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -15,7 +20,33 @@ public class BoardListItem {
|
||||
private int favoriteCount;
|
||||
private int commentCount;
|
||||
private int viewCount;
|
||||
private String writeDateTime;
|
||||
private String writerNickName;
|
||||
private String writeDatetime;
|
||||
private String writerNickname;
|
||||
private String writerProfileImage;
|
||||
|
||||
public BoardListItem(BoardListViewEntity boardListViewEntity) {
|
||||
this.BoardNumber = boardListViewEntity.getBoardNumber();
|
||||
this.title = boardListViewEntity.getTitle();
|
||||
this.content = boardListViewEntity.getContent();
|
||||
this.boardTitleImage = boardListViewEntity.getTitleImage();
|
||||
this.favoriteCount = boardListViewEntity.getFavoriteCount();
|
||||
this.commentCount = boardListViewEntity.getCommentCount();
|
||||
this.viewCount = boardListViewEntity.getViewCount();
|
||||
this.writeDatetime = boardListViewEntity.getWriteDatetime();
|
||||
this.writerNickname = boardListViewEntity.getWriterNickname();
|
||||
this.writerProfileImage = boardListViewEntity.getWriterProfileImage();
|
||||
}
|
||||
|
||||
|
||||
public static List<BoardListItem> getList(List<BoardListViewEntity> boardListViewEntites) {
|
||||
List<BoardListItem> list = new ArrayList<>();
|
||||
for (BoardListViewEntity boardListViewEntity: boardListViewEntites){
|
||||
BoardListItem boardListItem = new BoardListItem(boardListViewEntity);
|
||||
list.add(boardListItem);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.eogns.board_back.dto.response.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import com.eogns.board_back.common.ResponseCode;
|
||||
import com.eogns.board_back.common.ResponseMessage;
|
||||
import com.eogns.board_back.dto.object.BoardListItem;
|
||||
import com.eogns.board_back.dto.response.ResponseDto;
|
||||
import com.eogns.board_back.entity.BoardListViewEntity;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GetLatestBoardListResponseDto extends ResponseDto{
|
||||
private List<BoardListItem> latestList;
|
||||
|
||||
private GetLatestBoardListResponseDto(List<BoardListViewEntity> boardEntities){
|
||||
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS);
|
||||
this.latestList = BoardListItem.getList(boardEntities);
|
||||
}
|
||||
|
||||
public static ResponseEntity<GetLatestBoardListResponseDto> success(List<BoardListViewEntity> boardEntities){
|
||||
GetLatestBoardListResponseDto result = new GetLatestBoardListResponseDto(boardEntities);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
||||
@Entity(name="board_list_view")
|
||||
@Table(name="board_list_view")
|
||||
|
||||
public class BoardListVeiwEntity {
|
||||
public class BoardListViewEntity {
|
||||
@Id
|
||||
private int boardNumber;
|
||||
private String title;
|
||||
@ -25,5 +25,5 @@ public class BoardListVeiwEntity {
|
||||
private String writeDatetime;
|
||||
private String writerEmail;
|
||||
private String writerNickname;
|
||||
private String writerProFileImage;
|
||||
private String writerProfileImage;
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
package com.eogns.board_back.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.eogns.board_back.entity.BoardListVeiwEntity;
|
||||
import com.eogns.board_back.entity.BoardListViewEntity;
|
||||
|
||||
@Repository
|
||||
public interface BoardListViewRepository extends JpaRepository<BoardListVeiwEntity, Integer>{
|
||||
public interface BoardListViewRepository extends JpaRepository<BoardListViewEntity, Integer>{
|
||||
|
||||
List<BoardListViewEntity> findByOrderByWriteDatetimeDesc();
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public interface BoardRepository extends JpaRepository<BoardEntity, Integer>{
|
||||
"B.board_number AS board_number, "+
|
||||
"B.title AS title, "+
|
||||
"B.content AS content, "+
|
||||
"B.write_datetime AS writerdatetime, "+
|
||||
"B.write_datetime AS writeDatetime, "+
|
||||
"B.writer_email AS writeremail, "+
|
||||
"U.nickname AS writernickname, "+
|
||||
"U.profile_image AS writerprofileimage "+
|
||||
|
@ -12,14 +12,15 @@ import com.eogns.board_back.dto.response.board.PostBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PostCommentResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PutFavoriteResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetFavoriteListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetLatestBoardListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.IncreaseViewCountResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PatchBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PatchBoardResponseDto;
|
||||
|
||||
public interface BoardService {
|
||||
ResponseEntity<? super GetBoardResponseDto> getBoard(Integer boardNumber);
|
||||
ResponseEntity<? super GetFavoriteListResponseDto> getFavoriteList(Integer boardNumber);
|
||||
ResponseEntity<? super GetCommentListResponseDto> getCommentList(Integer boardNumber);
|
||||
ResponseEntity<? super GetLatestBoardListResponseDto> getLatestBoardList();
|
||||
ResponseEntity<? super PostBoardResponseDto> postBoard(PostBoardRequestDto dto, String email);
|
||||
ResponseEntity<? super PostCommentResponseDto> postComment(PostCommentRequestDto Dto, Integer boardNumber, String email);
|
||||
ResponseEntity<? super PutFavoriteResponseDto> putFavorite(Integer boardNumber, String email);
|
||||
|
@ -14,15 +14,18 @@ import com.eogns.board_back.dto.response.board.DeleteBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetCommentListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetFavoriteListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.GetLatestBoardListResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.IncreaseViewCountResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PatchBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PostBoardResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PostCommentResponseDto;
|
||||
import com.eogns.board_back.dto.response.board.PutFavoriteResponseDto;
|
||||
import com.eogns.board_back.entity.BoardEntity;
|
||||
import com.eogns.board_back.entity.BoardListViewEntity;
|
||||
import com.eogns.board_back.entity.CommentEntity;
|
||||
import com.eogns.board_back.entity.FavoriteEntity;
|
||||
import com.eogns.board_back.entity.ImageEntity;
|
||||
import com.eogns.board_back.repository.BoardListViewRepository;
|
||||
import com.eogns.board_back.repository.BoardRepository;
|
||||
import com.eogns.board_back.repository.CommentRepository;
|
||||
import com.eogns.board_back.repository.FavoriteRepository;
|
||||
@ -32,7 +35,7 @@ import com.eogns.board_back.repository.resultSet.GetBoardResultSet;
|
||||
import com.eogns.board_back.repository.resultSet.GetCommentListResultSet;
|
||||
import com.eogns.board_back.repository.resultSet.GetFavoriteListResultSet;
|
||||
import com.eogns.board_back.service.BoardService;
|
||||
import com.mysql.cj.x.protobuf.MysqlxCrud.Delete;
|
||||
//import com.mysql.cj.x.protobuf.MysqlxCrud.Delete;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -45,6 +48,7 @@ public class BoardServiceImplement implements BoardService{
|
||||
private final ImageRepository imageRepository;
|
||||
private final CommentRepository commentRepository;
|
||||
private final FavoriteRepository favoriteRepository;
|
||||
private final BoardListViewRepository boardListViewRepository;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<? super GetBoardResponseDto> getBoard(Integer boardNumber) {
|
||||
@ -103,6 +107,21 @@ public class BoardServiceImplement implements BoardService{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<? super GetLatestBoardListResponseDto> getLatestBoardList() {
|
||||
List<BoardListViewEntity> boardListViewEntities = new ArrayList<>();
|
||||
|
||||
try {
|
||||
boardListViewEntities = boardListViewRepository.findByOrderByWriteDatetimeDesc();
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
|
||||
return ResponseDto.databaseError();
|
||||
}
|
||||
return GetLatestBoardListResponseDto.success(boardListViewEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<? super PostBoardResponseDto> postBoard(PostBoardRequestDto dto, String email) {
|
||||
try {
|
||||
@ -262,12 +281,4 @@ public class BoardServiceImplement implements BoardService{
|
||||
return DeleteBoardResponseDto.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,13 +4,13 @@
|
||||
"settings": {
|
||||
"width": 2000,
|
||||
"height": 2000,
|
||||
"scrollTop": -531.1411,
|
||||
"scrollLeft": -363,
|
||||
"zoomLevel": 0.9,
|
||||
"scrollTop": -620.5229,
|
||||
"scrollLeft": -322.1664,
|
||||
"zoomLevel": 0.8,
|
||||
"show": 431,
|
||||
"database": 4,
|
||||
"databaseName": "test_DB",
|
||||
"canvasType": "ERD",
|
||||
"canvasType": "@dineug/erd-editor/builtin-schema-sql",
|
||||
"language": 1,
|
||||
"tableNameCase": 4,
|
||||
"columnNameCase": 2,
|
||||
@ -74,15 +74,15 @@
|
||||
"IZ-XyQJ5BhJGcyRobsmca"
|
||||
],
|
||||
"ui": {
|
||||
"x": 118.1311,
|
||||
"y": 791.9049,
|
||||
"x": 121.6033,
|
||||
"y": 637.1827,
|
||||
"zIndex": 2,
|
||||
"widthName": 60,
|
||||
"widthComment": 77,
|
||||
"color": "#DEFF00"
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1724305510910,
|
||||
"updateAt": 1725949410555,
|
||||
"createAt": 1724302951608
|
||||
}
|
||||
},
|
||||
@ -111,15 +111,15 @@
|
||||
"iq0gGorB_IK4qxTFxYfJn"
|
||||
],
|
||||
"ui": {
|
||||
"x": 771.6548,
|
||||
"y": 779.3214,
|
||||
"x": 628.0437,
|
||||
"y": 636.127,
|
||||
"zIndex": 119,
|
||||
"widthName": 60,
|
||||
"widthComment": 77,
|
||||
"color": "#0072FF"
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1724304610193,
|
||||
"updateAt": 1725949437921,
|
||||
"createAt": 1724303521988
|
||||
}
|
||||
},
|
||||
@ -137,15 +137,15 @@
|
||||
"1uMXJT_u-apo92VSJebdL"
|
||||
],
|
||||
"ui": {
|
||||
"x": 1479.4999,
|
||||
"y": 851,
|
||||
"x": 1155.7499,
|
||||
"y": 705,
|
||||
"zIndex": 150,
|
||||
"widthName": 60,
|
||||
"widthComment": 117,
|
||||
"color": "#007CFF"
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1724304612372,
|
||||
"updateAt": 1725949448118,
|
||||
"createAt": 1724303642740
|
||||
}
|
||||
},
|
||||
@ -165,15 +165,15 @@
|
||||
"Cnotkxe-ecAoyfjrbJEx9"
|
||||
],
|
||||
"ui": {
|
||||
"x": 471.0675,
|
||||
"y": 498.548,
|
||||
"x": 408.5675,
|
||||
"y": 492.298,
|
||||
"zIndex": 276,
|
||||
"widthName": 60,
|
||||
"widthComment": 77,
|
||||
"color": "#00FF06"
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1724305514454,
|
||||
"updateAt": 1725949436819,
|
||||
"createAt": 1724304175986
|
||||
}
|
||||
},
|
||||
@ -196,15 +196,15 @@
|
||||
"hNbULkxqIsGqzvohT_wQr"
|
||||
],
|
||||
"ui": {
|
||||
"x": 415.3727,
|
||||
"y": 1160.25,
|
||||
"x": 360.3727,
|
||||
"y": 937.75,
|
||||
"zIndex": 299,
|
||||
"widthName": 60,
|
||||
"widthComment": 65,
|
||||
"color": "#6CFF00"
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1724304618473,
|
||||
"updateAt": 1725949443065,
|
||||
"createAt": 1724304332193
|
||||
}
|
||||
},
|
||||
@ -225,15 +225,15 @@
|
||||
"pYDg6JbatIM5D1FHS-Zjj"
|
||||
],
|
||||
"ui": {
|
||||
"x": 1346.343,
|
||||
"y": 1179.1855,
|
||||
"x": 942.843,
|
||||
"y": 920.4355,
|
||||
"zIndex": 364,
|
||||
"widthName": 60,
|
||||
"widthComment": 93,
|
||||
"color": "#FF0D00"
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1724304782771,
|
||||
"updateAt": 1725949444231,
|
||||
"createAt": 1724304620674
|
||||
}
|
||||
}
|
||||
@ -891,8 +891,8 @@
|
||||
"columnIds": [
|
||||
"T_l8NWwFvW6cE_JEkJL6q"
|
||||
],
|
||||
"x": 1281.6548,
|
||||
"y": 903.3214,
|
||||
"x": 1138.0437,
|
||||
"y": 760.127,
|
||||
"direction": 2
|
||||
},
|
||||
"end": {
|
||||
@ -900,8 +900,8 @@
|
||||
"columnIds": [
|
||||
"WSSBKHeYT3A8y6Hi9MRRb"
|
||||
],
|
||||
"x": 1479.4999,
|
||||
"y": 903,
|
||||
"x": 1155.7499,
|
||||
"y": 757,
|
||||
"direction": 1
|
||||
},
|
||||
"meta": {
|
||||
@ -919,8 +919,8 @@
|
||||
"columnIds": [
|
||||
"4mXeeKYgmIqlM2eUoJFzE"
|
||||
],
|
||||
"x": 550.1311000000001,
|
||||
"y": 903.9049,
|
||||
"x": 553.6033,
|
||||
"y": 749.1827,
|
||||
"direction": 2
|
||||
},
|
||||
"end": {
|
||||
@ -928,8 +928,8 @@
|
||||
"columnIds": [
|
||||
"iq0gGorB_IK4qxTFxYfJn"
|
||||
],
|
||||
"x": 771.6548,
|
||||
"y": 903.3214,
|
||||
"x": 628.0437,
|
||||
"y": 760.127,
|
||||
"direction": 1
|
||||
},
|
||||
"meta": {
|
||||
@ -947,8 +947,8 @@
|
||||
"columnIds": [
|
||||
"4mXeeKYgmIqlM2eUoJFzE"
|
||||
],
|
||||
"x": 334.1311,
|
||||
"y": 1015.9049,
|
||||
"x": 337.6033,
|
||||
"y": 861.1827,
|
||||
"direction": 8
|
||||
},
|
||||
"end": {
|
||||
@ -956,8 +956,8 @@
|
||||
"columnIds": [
|
||||
"LThoWR2ZYb2TEm3lISqrP"
|
||||
],
|
||||
"x": 415.3727,
|
||||
"y": 1248.25,
|
||||
"x": 360.3727,
|
||||
"y": 1025.75,
|
||||
"direction": 1
|
||||
},
|
||||
"meta": {
|
||||
@ -975,8 +975,8 @@
|
||||
"columnIds": [
|
||||
"T_l8NWwFvW6cE_JEkJL6q"
|
||||
],
|
||||
"x": 1026.6548,
|
||||
"y": 1027.3214,
|
||||
"x": 883.0437,
|
||||
"y": 884.127,
|
||||
"direction": 8
|
||||
},
|
||||
"end": {
|
||||
@ -984,8 +984,8 @@
|
||||
"columnIds": [
|
||||
"hNbULkxqIsGqzvohT_wQr"
|
||||
],
|
||||
"x": 897.3727,
|
||||
"y": 1248.25,
|
||||
"x": 842.3727,
|
||||
"y": 1025.75,
|
||||
"direction": 2
|
||||
},
|
||||
"meta": {
|
||||
@ -1003,8 +1003,8 @@
|
||||
"columnIds": [
|
||||
"4mXeeKYgmIqlM2eUoJFzE"
|
||||
],
|
||||
"x": 334.1311,
|
||||
"y": 791.9049,
|
||||
"x": 337.6033,
|
||||
"y": 637.1827,
|
||||
"direction": 4
|
||||
},
|
||||
"end": {
|
||||
@ -1012,8 +1012,8 @@
|
||||
"columnIds": [
|
||||
"KfQwcc9JMYkCC84mWPuTw"
|
||||
],
|
||||
"x": 471.0675,
|
||||
"y": 550.548,
|
||||
"x": 408.5675,
|
||||
"y": 544.298,
|
||||
"direction": 1
|
||||
},
|
||||
"meta": {
|
||||
@ -1031,8 +1031,8 @@
|
||||
"columnIds": [
|
||||
"T_l8NWwFvW6cE_JEkJL6q"
|
||||
],
|
||||
"x": 1026.6548,
|
||||
"y": 779.3214,
|
||||
"x": 883.0437,
|
||||
"y": 636.127,
|
||||
"direction": 4
|
||||
},
|
||||
"end": {
|
||||
@ -1040,8 +1040,8 @@
|
||||
"columnIds": [
|
||||
"Cnotkxe-ecAoyfjrbJEx9"
|
||||
],
|
||||
"x": 915.0675,
|
||||
"y": 550.548,
|
||||
"x": 852.5675,
|
||||
"y": 544.298,
|
||||
"direction": 2
|
||||
},
|
||||
"meta": {
|
||||
|
Reference in New Issue
Block a user