이 토이 프로젝트도 마지막 장에 들어왔다
게시판을 이제 만들건데
글쓰기는 이전에 일부 구현했다
https://cordingmonster.tistory.com/153?category=1046973
Springboot 게시판만들기!(1) 글쓰기 summernote 연동하기
이제 에디터를 연동할 건데 ckeditor5/summernote 둘 다 성공했지만 결국 summernote를 선택했다 이유는 ckeditor5 이미지 업로드 시 쿠키를 던져야 하는데 그걸 아직 하는 법을 모른다 그거만 알면 ckeditor5
cordingmonster.tistory.com
https://cordingmonster.tistory.com/154?category=1046973
Springboot 게시판만들기!(2) 글쓰기 썸네일 출력+aws s3
이미지를 저장하는 데는 두 가지 방법이 있다 로컬/클라우드 대세는 클라우드이기도 하고 aws를 쓰고싶기도 해서 도전했다! 이글에 셋팅을 적어놓았다 https://cordingmonster.tistory.com/152 버킷 정책->
cordingmonster.tistory.com
아주말도 안 되는 글쓰기 페이지이지만
기가 막히게 작동한다 ㅋㅋ
또 한 번 모양은 기가 막히지만
나름 작동하는 게시판을 만들어보자 ㅋㅋㅋ
프런트 서버
백엔드 서버
dao
맞게 사용하고 있는지 모르겠지만
나름 이제 서브 쿼리까지 사용하기 시작했다
역시 인터페이스를 만들어서 받아주자
물론 dto에 그냥 totalcount하나 추가해줘도 되지만
괜히 내가 헷갈릴 거 같다 ㅋㅋ
desc정렬과 함께 페이징+총개수를 같이 가져오는 쿼리문이다
일반
@Query(value = "select a.* ,(select count(*) from article)totalcount from article a order by a.bid desc limit ?,?",nativeQuery = true)
검색 시
@Query(value = "select *,(select count(*) from article where title like %?%)totalcount from article a where a.title like %?% order by a.bid desc limit ?,?",nativeQuery = true)
service
페이지와 검색어를 담는다
int nowPage=getAllArticleDto.getNowPage();
String title=getAllArticleDto.getTitle();
검색어가 없다면 null이 들어간다
조건으로 쿼리문을 날려주는 함수
List<getAllArticleinter>array=makeList(title, nowPage);
현재 페이지 숫자 검증
checkNowpage(nowPage, totalPage)
jsonArray로 정보전달
for(getAllArticleinter a:array){
article.put("created", a.getBcreated().toString().replace("T", " ").substring(0, 19));
날짜는 형식 변경 T제거 및. 000초 제거
결과
잘된다!
ㅋㅋ 버그는 페이지 이동할수록 위에
한 칸식 빈칸이 생긴다 ㅋㅋ
이따가 수정해주자 프런트 코드를 조금 건들면 될 거 같다
검색
키워드1 = 제목에 1이 들어가는 모든 게시물 가져오기
기가 막힌 게시판이다 ㅋㅋ
'Spring boot kim's Shop > 게시판' 카테고리의 다른 글
Springboot 게시판만들기!(4)댓글 수정/삭제! (0) | 2021.10.04 |
---|---|
Springboot 게시판만들기!(3)게시물 수정/삭제 (0) | 2021.10.04 |
Springboot 게시판만들기!(2) 게시글+댓글 불러오기! (0) | 2021.10.04 |
Springboot 게시판만들기!(1) 글쓰기 summernote 연동하기 (0) | 2021.09.07 |