PsHooN7979
07-29
240726 박세훈 설문 조사 CRUD, Idgn 추가
@867a26725ed94b94c9b1771e10a6e6eb63831ea6
--- src/main/java/com/takensoft/ai_lms/common/confing/SecurityConfig.java
+++ src/main/java/com/takensoft/ai_lms/common/confing/SecurityConfig.java
... | ... | @@ -73,6 +73,7 @@ |
73 | 73 |
.requestMatchers("/unit/**").permitAll() |
74 | 74 |
.requestMatchers("/photo/**").permitAll() |
75 | 75 |
.requestMatchers("/wordbook/**").permitAll() |
76 |
+ .requestMatchers("/survey/**").permitAll() |
|
76 | 77 |
.anyRequest().authenticated()); // 나머지 경로는 인증 필요 |
77 | 78 |
|
78 | 79 |
// jwt 필터 처리 적용 |
--- src/main/java/com/takensoft/ai_lms/common/idgen/context/ContextIdgen.java
+++ src/main/java/com/takensoft/ai_lms/common/idgen/context/ContextIdgen.java
... | ... | @@ -216,6 +216,17 @@ |
216 | 216 |
idgenServiceImpl.setTblNm("PHOTO_ID"); |
217 | 217 |
return idgenServiceImpl; |
218 | 218 |
} |
219 |
- |
|
219 |
+ |
|
220 |
+ // 설문 조사 정보 |
|
221 |
+ @Bean(name = "surveyIdgn") |
|
222 |
+ public IdgenService survey() { |
|
223 |
+ IdgenService idgenServiceImpl = new IdgenService(); |
|
224 |
+ idgenServiceImpl.setCipers(15); |
|
225 |
+ idgenServiceImpl.setFillChar('0'); |
|
226 |
+ idgenServiceImpl.setPrefix("SURVEY_"); |
|
227 |
+ idgenServiceImpl.setTblNm("SURVEY_ID"); |
|
228 |
+ return idgenServiceImpl; |
|
229 |
+ } |
|
230 |
+ |
|
220 | 231 |
|
221 | 232 |
}(파일 끝에 줄바꿈 문자 없음) |
--- src/main/java/com/takensoft/ai_lms/lms/class_book/web/ClassBookController.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/web/ClassBookController.java
... | ... | @@ -69,7 +69,7 @@ |
69 | 69 |
* |
70 | 70 |
* 반 교재 삭제 |
71 | 71 |
*/ |
72 |
- @DeleteMapping("/deleteClassBook.json") |
|
72 |
+ @DeleteMapping("/delete.json") |
|
73 | 73 |
public String deleteClassBook(@RequestBody ClassBookVO classBookVO) throws Exception { |
74 | 74 |
try { |
75 | 75 |
int result = classBookService.deleteClassBook(classBookVO); |
+++ src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
... | ... | @@ -0,0 +1,30 @@ |
1 | +package com.takensoft.ai_lms.lms.survey.dao; | |
2 | + | |
3 | + | |
4 | +import com.takensoft.ai_lms.lms.survey.vo.SurveyVO; | |
5 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | + | |
10 | +/** | |
11 | + * @author : 박세훈 | |
12 | + * since : 2024.07.29 | |
13 | + * | |
14 | + * 설문 조사 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("surveyDAO") | |
17 | +public interface SurveyDAO { | |
18 | + | |
19 | + // 설문 조사 등록 | |
20 | + int insertSurvey(SurveyVO surveyVO) throws Exception; | |
21 | + | |
22 | + // 설문 조사 조회 | |
23 | + List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception; | |
24 | + | |
25 | + // 설문 조사 수정 | |
26 | + int updateSurvey(SurveyVO surveyVO) throws Exception; | |
27 | + | |
28 | + // 설문 조사 삭제 | |
29 | + int deleteSurvey(String srvyId) throws Exception; | |
30 | +} |
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
... | ... | @@ -0,0 +1,54 @@ |
1 | +package com.takensoft.ai_lms.lms.survey.service.Impl; | |
2 | + | |
3 | + | |
4 | +import com.takensoft.ai_lms.common.idgen.service.IdgenService; | |
5 | +import com.takensoft.ai_lms.lms.survey.dao.SurveyDAO; | |
6 | +import com.takensoft.ai_lms.lms.survey.service.SurveyService; | |
7 | +import com.takensoft.ai_lms.lms.survey.vo.SurveyVO; | |
8 | +import lombok.RequiredArgsConstructor; | |
9 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
10 | +import org.springframework.stereotype.Service; | |
11 | + | |
12 | +import java.util.List; | |
13 | + | |
14 | + | |
15 | +/** | |
16 | + * @author : 박세훈 | |
17 | + * since : 2024.07.29 | |
18 | + * | |
19 | + * 설문 조사 관련 ServiceImpl | |
20 | + */ | |
21 | +@Service("surveyService") | |
22 | +@RequiredArgsConstructor | |
23 | +public class SurveyServiceImpl extends EgovAbstractServiceImpl implements SurveyService { | |
24 | + | |
25 | + private final SurveyDAO surveyDAO; | |
26 | + | |
27 | + private final IdgenService surveyIdgn; | |
28 | + | |
29 | + // 설문 조사 등록 | |
30 | + @Override | |
31 | + public int insertSurvey(SurveyVO surveyVO) throws Exception{ | |
32 | + String srvyId = surveyIdgn.getNextStringId(); | |
33 | + surveyVO.setSrvyId(srvyId); | |
34 | + return surveyDAO.insertSurvey(surveyVO); | |
35 | + } | |
36 | + | |
37 | + // 설문 조사 조회 | |
38 | + @Override | |
39 | + public List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception { | |
40 | + return surveyDAO.surveyList(surveyVO); | |
41 | + } | |
42 | + | |
43 | + // 설문 조사 수정 | |
44 | + @Override | |
45 | + public int updateSurvey(SurveyVO surveyVO) throws Exception { | |
46 | + return surveyDAO.updateSurvey(surveyVO); | |
47 | + } | |
48 | + | |
49 | + // 설문 조사 삭제 | |
50 | + @Override | |
51 | + public int deleteSurvey(String srvyId) throws Exception { | |
52 | + return surveyDAO.deleteSurvey(srvyId); | |
53 | + } | |
54 | +} |
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
... | ... | @@ -0,0 +1,28 @@ |
1 | +package com.takensoft.ai_lms.lms.survey.service; | |
2 | + | |
3 | +import com.takensoft.ai_lms.lms.survey.vo.SurveyVO; | |
4 | + | |
5 | +import java.util.List; | |
6 | + | |
7 | + | |
8 | +/** | |
9 | + * @author : 박세훈 | |
10 | + * since : 2024.07.29 | |
11 | + * | |
12 | + * 설문 조사 관련 Service | |
13 | + */ | |
14 | + | |
15 | +public interface SurveyService { | |
16 | + | |
17 | + // 설문 조사 등록 | |
18 | + int insertSurvey(SurveyVO surveyVO) throws Exception; | |
19 | + | |
20 | + // 설문 조사 조회 | |
21 | + List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception; | |
22 | + | |
23 | + // 설문 조사 수정 | |
24 | + int updateSurvey(SurveyVO surveyVO) throws Exception; | |
25 | + | |
26 | + // 설문 조사 삭제 | |
27 | + int deleteSurvey(String srvyId) throws Exception; | |
28 | +} |
+++ src/main/java/com/takensoft/ai_lms/lms/survey/vo/SurveyVO.java
... | ... | @@ -0,0 +1,30 @@ |
1 | +package com.takensoft.ai_lms.lms.survey.vo; | |
2 | + | |
3 | + | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | + | |
9 | + | |
10 | +/** | |
11 | + * @author : 박세훈 | |
12 | + * since : 2024.07.29 | |
13 | + * | |
14 | + * 설문 조사 관련 VO | |
15 | + */ | |
16 | +@Getter | |
17 | +@Setter | |
18 | +@AllArgsConstructor | |
19 | +@NoArgsConstructor | |
20 | +public class SurveyVO { | |
21 | + | |
22 | + // 설문 조사 아이디 | |
23 | + private String srvyId; | |
24 | + | |
25 | + // 설문 조사 종류 | |
26 | + private String srvyType; | |
27 | + | |
28 | + // 설문 내용 | |
29 | + private String srvyCnt; | |
30 | +} |
+++ src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
... | ... | @@ -0,0 +1,77 @@ |
1 | +package com.takensoft.ai_lms.lms.survey.web; | |
2 | + | |
3 | + | |
4 | +import com.takensoft.ai_lms.lms.survey.service.SurveyService; | |
5 | +import com.takensoft.ai_lms.lms.survey.vo.SurveyVO; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import org.springframework.web.bind.annotation.*; | |
8 | + | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +/** | |
13 | + * @author : 박세훈 | |
14 | + * since : 2024.07.29 | |
15 | + * | |
16 | + * 설문 조사 관련 Controller | |
17 | + */ | |
18 | + | |
19 | +@RestController | |
20 | +@RequestMapping(value = "/survey") | |
21 | +@RequiredArgsConstructor | |
22 | +public class SurveyController { | |
23 | + | |
24 | + private final SurveyService surveyService; | |
25 | + | |
26 | + @PostMapping("/insert.json") | |
27 | + public String insertSurvey(@RequestBody SurveyVO surveyVO) throws Exception { | |
28 | + try { | |
29 | + int result = surveyService.insertSurvey(surveyVO); | |
30 | + if (result > 0) { | |
31 | + return "success"; | |
32 | + } else { | |
33 | + return "fail"; | |
34 | + } | |
35 | + } catch (Exception e ) { | |
36 | + return "Error"; | |
37 | + } | |
38 | + } | |
39 | + | |
40 | + @GetMapping("/list.json") | |
41 | + public List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception { | |
42 | + return surveyService.surveyList(surveyVO); | |
43 | + } | |
44 | + | |
45 | + | |
46 | + @PutMapping("/update.json") | |
47 | + public String updateSurvey (@RequestBody SurveyVO surveyVO) throws Exception { | |
48 | + try { | |
49 | + int result = surveyService.updateSurvey(surveyVO); | |
50 | + if (result > 0) { | |
51 | + return "success"; | |
52 | + } else { | |
53 | + return "fail"; | |
54 | + } | |
55 | + }catch (Exception e) { | |
56 | + return "Error"; | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + | |
61 | + @DeleteMapping("/delete.json") | |
62 | + public String deleteSurvey (@RequestBody Map<String, String> request) throws Exception { | |
63 | + try { | |
64 | + String srvyId = request.get("srvyId"); | |
65 | + int result = surveyService.deleteSurvey(srvyId); | |
66 | + if ( result > 0) { | |
67 | + return "success"; | |
68 | + } else { | |
69 | + return "fail"; | |
70 | + } | |
71 | + } catch (Exception e) { | |
72 | + return "Error"; | |
73 | + } | |
74 | + } | |
75 | + | |
76 | + | |
77 | +} |
+++ src/main/resources/mybatis/mapper/lms/survey-SQL.xml
... | ... | @@ -0,0 +1,46 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | +<mapper namespace="com.takensoft.ai_lms.lms.survey.dao.SurveyDAO"> | |
4 | + | |
5 | + | |
6 | + <resultMap id="surveyMap" type="SurveyVO"> | |
7 | + <result property="srvyId" column="srvy_id"/> | |
8 | + <result property="srvyType" column="srvy_type"/> | |
9 | + <result property="srvyCnt" column="srvy_cnt"/> | |
10 | + </resultMap> | |
11 | + | |
12 | + | |
13 | + <insert id="insertSurvey" parameterType="SurveyVO"> | |
14 | + INSERT INTO survey( srvy_id, | |
15 | + srvy_type, | |
16 | + srvy_cnt) | |
17 | + VALUES (#{srvyId}, | |
18 | + #{srvyType}, | |
19 | + #{srvyCnt}); | |
20 | + </insert> | |
21 | + | |
22 | + <select id="surveyList" parameterType="SurveyVO"> | |
23 | + SELECT * | |
24 | + FROM survey | |
25 | + </select> | |
26 | + | |
27 | + <update id="updateSurvey" parameterType="SurveyVO"> | |
28 | + UPDATE survey | |
29 | + SET srvy_type = #{srvyType}, | |
30 | + srvy_cnt = #{srvyCnt} | |
31 | + WHERE | |
32 | + srvy_id = #{srvyId} | |
33 | + </update> | |
34 | + | |
35 | + | |
36 | + | |
37 | + | |
38 | + <delete id="deleteSurvey" parameterType="String"> | |
39 | + DELETE FROM survey | |
40 | + WHERE srvy_id = #{srvyId} | |
41 | + </delete> | |
42 | + | |
43 | + | |
44 | + | |
45 | + | |
46 | +</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?