PsHooN7979
07-30
240730 박세훈 설문 조사 상세 정보 수정
@cab1ef6daf42bd876d790c94bb3cc395059c373d
--- src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
... | ... | @@ -29,8 +29,8 @@ |
29 | 29 |
// 설문 조사 삭제 |
30 | 30 |
int deleteSurvey(String srvyId) throws Exception; |
31 | 31 |
|
32 |
- // 설문 조사 상세 정보 |
|
33 |
- int insertSurveyDetail(SurveyDetailVO surveyDetailVO) throws Exception; |
|
32 |
+ // 설문 조사 상세 정보 등록 |
|
33 |
+ void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception; |
|
34 | 34 |
|
35 | 35 |
// 설문 조사 상세 정보 조회 |
36 | 36 |
List<SurveyDetailVO> surveyDetailList(SurveyDetailVO surveyDetailVO) throws Exception; |
--- src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
... | ... | @@ -14,9 +14,9 @@ |
14 | 14 |
|
15 | 15 |
|
16 | 16 |
/** |
17 |
- * @author : 박세훈 |
|
17 |
+ * @author : 박세훈 |
|
18 | 18 |
* since : 2024.07.29 |
19 |
- * |
|
19 |
+ * <p> |
|
20 | 20 |
* 설문 조사 관련 ServiceImpl |
21 | 21 |
*/ |
22 | 22 |
@Service("surveyService") |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
// 설문 조사 등록 |
33 | 33 |
@Override |
34 |
- public int insertSurvey(SurveyVO surveyVO) throws Exception{ |
|
34 |
+ public int insertSurvey(SurveyVO surveyVO) throws Exception { |
|
35 | 35 |
String srvyId = surveyIdgn.getNextStringId(); |
36 | 36 |
surveyVO.setSrvyId(srvyId); |
37 | 37 |
return surveyDAO.insertSurvey(surveyVO); |
... | ... | @@ -57,10 +57,12 @@ |
57 | 57 |
|
58 | 58 |
// 설문 조사 상세 정보 |
59 | 59 |
@Override |
60 |
- public int insertSurveyDetail(SurveyDetailVO surveyDetailVO) throws Exception { |
|
61 |
- String srvyDtlId = surveyDetailIdgn.getNextStringId(); |
|
62 |
- surveyDetailVO.setSrvyDtlId(srvyDtlId); |
|
63 |
- return surveyDAO.insertSurveyDetail(surveyDetailVO); |
|
60 |
+ public void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception { |
|
61 |
+ for (SurveyDetailVO detail : surveyDetailVO) { |
|
62 |
+ String srvyDtlId = surveyDetailIdgn.getNextStringId(); |
|
63 |
+ detail.setSrvyDtlId(srvyDtlId); |
|
64 |
+ } |
|
65 |
+ surveyDAO.insertSurveyDetail(surveyDetailVO); |
|
64 | 66 |
} |
65 | 67 |
|
66 | 68 |
// 설문 조사 상세 정보 조회 |
--- src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 |
int deleteSurvey(String srvyId) throws Exception; |
29 | 29 |
|
30 | 30 |
// 설문 조사 상세 정보 |
31 |
- int insertSurveyDetail(SurveyDetailVO surveyDetailVO) throws Exception; |
|
31 |
+ void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception; |
|
32 | 32 |
|
33 | 33 |
// 설문 조사 상세 정보 조회 |
34 | 34 |
List<SurveyDetailVO> surveyDetailList(SurveyDetailVO surveyDetailVO) throws Exception; |
--- src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
... | ... | @@ -5,6 +5,8 @@ |
5 | 5 |
import com.takensoft.ai_lms.lms.survey.vo.SurveyDetailVO; |
6 | 6 |
import com.takensoft.ai_lms.lms.survey.vo.SurveyVO; |
7 | 7 |
import lombok.RequiredArgsConstructor; |
8 |
+import org.springframework.http.HttpStatus; |
|
9 |
+import org.springframework.http.ResponseEntity; |
|
8 | 10 |
import org.springframework.web.bind.annotation.*; |
9 | 11 |
|
10 | 12 |
import java.util.List; |
... | ... | @@ -39,17 +41,9 @@ |
39 | 41 |
} |
40 | 42 |
|
41 | 43 |
@PostMapping("/insertDetail.json") |
42 |
- public String insertDetailSurvey(@RequestBody SurveyDetailVO surveyDetailVO) throws Exception { |
|
43 |
- try { |
|
44 |
- int result = surveyService.insertSurveyDetail(surveyDetailVO); |
|
45 |
- if ( result > 0) { |
|
46 |
- return "success"; |
|
47 |
- } else { |
|
48 |
- return "fail"; |
|
49 |
- } |
|
50 |
- } catch (Exception e) { |
|
51 |
- return "Error"; |
|
52 |
- } |
|
44 |
+ public ResponseEntity<Void> insertDetailSurvey(@RequestBody List<SurveyDetailVO> surveyDetailVO) throws Exception { |
|
45 |
+ surveyService.insertSurveyDetail(surveyDetailVO); |
|
46 |
+ return new ResponseEntity<>(HttpStatus.CREATED); |
|
53 | 47 |
} |
54 | 48 |
|
55 | 49 |
|
--- src/main/resources/mybatis/mapper/lms/survey-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/survey-SQL.xml
... | ... | @@ -45,16 +45,20 @@ |
45 | 45 |
내 용 : 설문 조사 상세 정보 등록 |
46 | 46 |
--> |
47 | 47 |
|
48 |
- <insert id="insertSurveyDetail"> |
|
48 |
+ <insert id="insertSurveyDetail" parameterType="java.util.List"> |
|
49 | 49 |
INSERT INTO survey_detail( srvy_dtl_id, |
50 | 50 |
srvy_dtl_cnt, |
51 | 51 |
srvy_id) |
52 |
- VALUES (#{srvyDtlId}, |
|
53 |
- #{srvyDtlCnt}, |
|
54 |
- #{srvyId}); |
|
52 |
+ VALUES |
|
53 |
+ <foreach collection="list" item="detail" separator=","> |
|
54 |
+ (#{detail.srvyDtlId}, |
|
55 |
+ #{detail.srvyDtlCnt}, |
|
56 |
+ #{detail.srvyId}) |
|
57 |
+ </foreach> |
|
55 | 58 |
</insert> |
56 | 59 |
|
57 | 60 |
|
61 |
+ |
|
58 | 62 |
<!-- |
59 | 63 |
작성자 : 박세훈 |
60 | 64 |
작성일 : 2024.07.29 |
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?