PsHooN7979
07-26
240726 박세훈 게시글 검색 기능 추가
@834c6447b6364b23d2a2c5fdacf30e4a109c63e5
--- src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
... | ... | @@ -35,4 +35,8 @@ |
35 | 35 |
// 게시글 삭제 |
36 | 36 |
int deleteBoard(String bbsId) throws Exception; |
37 | 37 |
|
38 |
+ // 게시글 검색 |
|
39 |
+ List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception; |
|
40 |
+ |
|
41 |
+ |
|
38 | 42 |
} |
--- src/main/java/com/takensoft/ai_lms/lms/board/service/BoardService.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/service/BoardService.java
... | ... | @@ -31,4 +31,7 @@ |
31 | 31 |
|
32 | 32 |
// 게시글 삭제 |
33 | 33 |
int deleteBoard(String bbsId) throws Exception; |
34 |
+ |
|
35 |
+ // 게시글 검색 |
|
36 |
+ List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception; |
|
34 | 37 |
} |
--- src/main/java/com/takensoft/ai_lms/lms/board/service/impl/BoardServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/service/impl/BoardServiceImpl.java
... | ... | @@ -65,6 +65,12 @@ |
65 | 65 |
return boardDAO.deleteBoard(bbsId); |
66 | 66 |
} |
67 | 67 |
|
68 |
+ // 게시글 검색 |
|
69 |
+ @Override |
|
70 |
+ public List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception { |
|
71 |
+ return boardDAO.searchBoard(params); |
|
72 |
+ } |
|
73 |
+ |
|
68 | 74 |
|
69 | 75 |
|
70 | 76 |
|
--- src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 |
import org.springframework.web.bind.annotation.*; |
11 | 11 |
|
12 | 12 |
import java.util.HashMap; |
13 |
+import java.util.List; |
|
13 | 14 |
import java.util.Map; |
14 | 15 |
|
15 | 16 |
/** |
... | ... | @@ -127,6 +128,22 @@ |
127 | 128 |
} |
128 | 129 |
} |
129 | 130 |
|
131 |
+ /** |
|
132 |
+ * @author 박세훈 |
|
133 |
+ * @since 2024.07.26 |
|
134 |
+ * |
|
135 |
+ * 게시글 검색 |
|
136 |
+ */ |
|
137 |
+ |
|
138 |
+ @PostMapping("/search.json") |
|
139 |
+ public ResponseEntity<?> searchBoard(@RequestBody HashMap<String, Object> params) throws Exception { |
|
140 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
141 |
+ |
|
142 |
+ List<HashMap<String, Object>> boardList = boardService.searchBoard(params); |
|
143 |
+ result.put("list", boardList); |
|
144 |
+ return new ResponseEntity<>(result, HttpStatus.OK); |
|
145 |
+ } |
|
146 |
+ |
|
130 | 147 |
|
131 | 148 |
|
132 | 149 |
} |
--- src/main/resources/mybatis/mapper/lms/board-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/board-SQL.xml
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 |
내 용 : 게시글 전체 조회 |
46 | 46 |
--> |
47 | 47 |
<select id="findAllBoard" resultMap="boardMap"> |
48 |
- SELECT bbs_id, bbs_ttl, bbs_cls, bbs_cnt,bbs_tm, file_mng_id, scls_id |
|
48 |
+ SELECT * |
|
49 | 49 |
FROM board |
50 | 50 |
WHERE scls_id = #{sclsId} |
51 | 51 |
ORDER BY bbs_id DESC |
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 |
내 용 : 게시글 상세 조회 |
59 | 59 |
--> |
60 | 60 |
<select id="findByBoardId" parameterType="BoardVO" resultMap="boardMap"> |
61 |
- SELECT bbs_id, bbs_ttl, bbs_cls, bbs_cnt,bbs_tm, file_mng_id |
|
61 |
+ SELECT * |
|
62 | 62 |
FROM board |
63 | 63 |
WHERE bbs_id = #{bbsId} |
64 | 64 |
ORDER BY bbs_id DESC |
... | ... | @@ -66,6 +66,32 @@ |
66 | 66 |
|
67 | 67 |
<!-- |
68 | 68 |
작성자 : 박세훈 |
69 |
+ 작성일 : 2024.07.26 |
|
70 |
+ 내 용 : 게시글 검색 |
|
71 |
+ --> |
|
72 |
+ <select id="searchBoard" parameterType="BoardVO" resultMap="boardMap"> |
|
73 |
+ SELECT * |
|
74 |
+ FROM board |
|
75 |
+ WHERE 1 = 1 |
|
76 |
+ <if test="option != null and keyword != null"> |
|
77 |
+ <choose> |
|
78 |
+ <when test="option == 'bbsTitle'"> |
|
79 |
+ AND bbs_ttl LIKE CONCAT('%', #{keyword}, '%') |
|
80 |
+ </when> |
|
81 |
+ <when test="option == 'bbsCategory'"> |
|
82 |
+ AND bbs_cls LIKE CONCAT('%', #{keyword}, '%') |
|
83 |
+ </when> |
|
84 |
+ <otherwise> |
|
85 |
+ AND bbs_cnt LIKE CONCAT('%', #{keyword}, '%') |
|
86 |
+ </otherwise> |
|
87 |
+ </choose> |
|
88 |
+ </if> |
|
89 |
+ ORDER BY bbs_id DESC |
|
90 |
+ LIMIT #{pageSize} OFFSET #{startIndex} |
|
91 |
+ </select> |
|
92 |
+ |
|
93 |
+ <!-- |
|
94 |
+ 작성자 : 박세훈 |
|
69 | 95 |
작성일 : 2024.07.25 |
70 | 96 |
내 용 : 게시글 수정 |
71 | 97 |
--> |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?