PsHooN7979
07-30
240726 박세훈 게시판 sql 수정
@0b6351dcbee979c5bd353784f397c48106df6e3e
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardClassVO.java
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.takensoft.ai_lms.lms.board.vo; | |
2 | + | |
3 | + | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | + | |
9 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : 박세훈 | |
13 | + * since : 2024.07.25 | |
14 | + * | |
15 | + * 게시판 class 관련 VO | |
16 | + */ | |
17 | + | |
18 | + | |
19 | + | |
20 | +@Getter | |
21 | +@Setter | |
22 | +@AllArgsConstructor | |
23 | +@NoArgsConstructor | |
24 | +public class BoardClassVO { | |
25 | + | |
26 | + // 반 아이디 | |
27 | + private String sclsId; | |
28 | + | |
29 | + //반 이름 | |
30 | + private String sclsNm; | |
31 | + | |
32 | + // 게시판 테이블과 연결 | |
33 | + private List<BoardVO> board; | |
34 | +} |
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardUserVO.java
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.takensoft.ai_lms.lms.board.vo; | |
2 | + | |
3 | + | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | + | |
9 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : 박세훈 | |
13 | + * since : 2024.07.25 | |
14 | + * | |
15 | + * 게시판 user 관련 VO | |
16 | + */ | |
17 | + | |
18 | + | |
19 | + | |
20 | +@Getter | |
21 | +@Setter | |
22 | +@AllArgsConstructor | |
23 | +@NoArgsConstructor | |
24 | +public class BoardUserVO { | |
25 | + | |
26 | + // 사용자 아이디 | |
27 | + private String userId; | |
28 | + | |
29 | + // 사용자 이름 | |
30 | + private String userNm; | |
31 | + | |
32 | + // 반 테이블과 연결 | |
33 | + private List<BoardClassVO> boardClass; | |
34 | +} |
--- src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
... | ... | @@ -32,15 +32,15 @@ |
32 | 32 |
// 게시판 아이디 |
33 | 33 |
private String bbsId; |
34 | 34 |
// 게시판 제목 |
35 |
- private String bbsTitle; |
|
35 |
+ private String bbsTtl; |
|
36 | 36 |
// 게시판 카테고리 |
37 |
- private String bbsCategory; |
|
37 |
+ private String bbsCls; |
|
38 | 38 |
// 게시판 내용 |
39 |
- private String bbsContents; |
|
39 |
+ private String bbsCnt; |
|
40 | 40 |
// 게시판 등록 날짜 |
41 |
- private String bbsTime; |
|
41 |
+ private String bbsTm; |
|
42 | 42 |
// 파일 관리 아이디 |
43 |
- private String fileManageId; |
|
43 |
+ private String fileMngId; |
|
44 | 44 |
// 반 아이디 |
45 | 45 |
private String sclsId; |
46 | 46 |
|
--- src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
... | ... | @@ -23,6 +23,7 @@ |
23 | 23 |
|
24 | 24 |
private final SurveyService surveyService; |
25 | 25 |
|
26 |
+ // 설문 조사 등록 |
|
26 | 27 |
@PostMapping("/insert.json") |
27 | 28 |
public String insertSurvey(@RequestBody SurveyVO surveyVO) throws Exception { |
28 | 29 |
try { |
... | ... | @@ -37,12 +38,13 @@ |
37 | 38 |
} |
38 | 39 |
} |
39 | 40 |
|
41 |
+ // 설문 조사 조회 |
|
40 | 42 |
@GetMapping("/list.json") |
41 | 43 |
public List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception { |
42 | 44 |
return surveyService.surveyList(surveyVO); |
43 | 45 |
} |
44 | 46 |
|
45 |
- |
|
47 |
+ // 설문 조사 수정 |
|
46 | 48 |
@PutMapping("/update.json") |
47 | 49 |
public String updateSurvey (@RequestBody SurveyVO surveyVO) throws Exception { |
48 | 50 |
try { |
... | ... | @@ -58,6 +60,7 @@ |
58 | 60 |
} |
59 | 61 |
|
60 | 62 |
|
63 |
+ // 설문 조사 삭제 |
|
61 | 64 |
@DeleteMapping("/delete.json") |
62 | 65 |
public String deleteSurvey (@RequestBody Map<String, String> request) throws Exception { |
63 | 66 |
try { |
--- src/main/resources/mybatis/mapper/lms/board-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/board-SQL.xml
... | ... | @@ -12,6 +12,23 @@ |
12 | 12 |
<result property="sclsId" column="scls_id"/> |
13 | 13 |
</resultMap> |
14 | 14 |
|
15 |
+ <resultMap id="boardResultMap" type="BoardUserVO"> |
|
16 |
+ <result property="userId" column="user_id" /> |
|
17 |
+ <result property="userNm" column="user_nm" /> |
|
18 |
+ <collection property="boardClass" ofType="BoardClassVO"> |
|
19 |
+ <id property="sclsId" column="scls_id" /> |
|
20 |
+ <result property="sclsNm" column="scls_nm" /> |
|
21 |
+ <collection property="board" ofType="BoardVO" > |
|
22 |
+ <id property="bbsId" column="bbs_id"/> |
|
23 |
+ <result property="bbsTtl" column="bbs_ttl"/> |
|
24 |
+ <result property="bbsCls" column="bbs_cls"/> |
|
25 |
+ <result property="bbsCnt" column="bbs_cnt"/> |
|
26 |
+ <result property="bbsTm" column="bbs_tm"/> |
|
27 |
+ <result property="fileMngId" column="file_mng_id"/> |
|
28 |
+ <result property="sclsId" column="scls_id"/> |
|
29 |
+ </collection> |
|
30 |
+ </collection> |
|
31 |
+ </resultMap> |
|
15 | 32 |
|
16 | 33 |
<!-- |
17 | 34 |
작성자 : 박세훈 |
... | ... | @@ -51,11 +68,22 @@ |
51 | 68 |
작성일 : 2024.07.25 |
52 | 69 |
내 용 : 게시글 전체 조회 |
53 | 70 |
--> |
54 |
- <select id="findAllBoard" resultMap="boardMap"> |
|
55 |
- SELECT * |
|
56 |
- FROM board |
|
57 |
- WHERE scls_id = #{sclsId} |
|
58 |
- ORDER BY bbs_id DESC |
|
71 |
+ <select id="findAllBoard" resultMap="boardResultMap"> |
|
72 |
+ SELECT b.bbs_id, |
|
73 |
+ b.bbs_ttl, |
|
74 |
+ b.bbs_cls, |
|
75 |
+ b.bbs_cnt, |
|
76 |
+ b.bbs_tm, |
|
77 |
+ b.file_mng_id, |
|
78 |
+ c.scls_id, |
|
79 |
+ c.scls_nm, |
|
80 |
+ u.user_id, |
|
81 |
+ u.user_nm |
|
82 |
+ FROM board b |
|
83 |
+ LEFT JOIN class c ON b.scls_id = c.scls_id |
|
84 |
+ LEFT JOIN users u ON c.user_id = u.user_id |
|
85 |
+ WHERE b.scls_id = #{sclsId} |
|
86 |
+ ORDER BY b.bbs_id DESC |
|
59 | 87 |
LIMIT #{pageSize} OFFSET #{startIndex} |
60 | 88 |
</select> |
61 | 89 |
|
... | ... | @@ -64,11 +92,21 @@ |
64 | 92 |
작성일 : 2024.07.25 |
65 | 93 |
내 용 : 게시글 상세 조회 |
66 | 94 |
--> |
67 |
- <select id="findByBoardId" parameterType="BoardVO" resultMap="boardMap"> |
|
68 |
- SELECT * |
|
69 |
- FROM board |
|
70 |
- WHERE bbs_id = #{bbsId} |
|
71 |
- ORDER BY bbs_id DESC |
|
95 |
+ <select id="findByBoardId" resultMap="boardResultMap"> |
|
96 |
+ SELECT b.bbs_id, |
|
97 |
+ b.bbs_ttl, |
|
98 |
+ b.bbs_cls, |
|
99 |
+ b.bbs_cnt, |
|
100 |
+ b.bbs_tm, |
|
101 |
+ b.file_mng_id, |
|
102 |
+ c.scls_id, |
|
103 |
+ c.scls_nm, |
|
104 |
+ u.user_id, |
|
105 |
+ u.user_nm |
|
106 |
+ FROM board b |
|
107 |
+ LEFT JOIN class c ON b.scls_id = c.scls_id |
|
108 |
+ LEFT JOIN users u ON c.user_id = u.user_id |
|
109 |
+ WHERE b.bbs_id = #{bbsId} |
|
72 | 110 |
</select> |
73 | 111 |
|
74 | 112 |
<!-- |
... | ... | @@ -122,4 +160,4 @@ |
122 | 160 |
DELETE FROM board WHERE bbs_id = #{bbsId} |
123 | 161 |
</delete> |
124 | 162 |
|
125 |
-</mapper>(파일 끝에 줄바꿈 문자 없음) |
|
163 |
+</mapper> |
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?