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
+++ src/main/java/com/takensoft/ai_lms/common/confing/SecurityConfig.java
@@ -73,6 +73,7 @@
                 .requestMatchers("/unit/**").permitAll()
                 .requestMatchers("/photo/**").permitAll()
                 .requestMatchers("/wordbook/**").permitAll()
+                .requestMatchers("/survey/**").permitAll()
                 .anyRequest().authenticated()); // 나머지 경로는 인증 필요
 
         // 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
+++ src/main/java/com/takensoft/ai_lms/common/idgen/context/ContextIdgen.java
@@ -216,6 +216,17 @@
         idgenServiceImpl.setTblNm("PHOTO_ID");
         return idgenServiceImpl;
     }
-    
+
+    // 설문 조사 정보
+    @Bean(name = "surveyIdgn")
+    public IdgenService survey() {
+        IdgenService idgenServiceImpl = new IdgenService();
+        idgenServiceImpl.setCipers(15);
+        idgenServiceImpl.setFillChar('0');
+        idgenServiceImpl.setPrefix("SURVEY_");
+        idgenServiceImpl.setTblNm("SURVEY_ID");
+        return idgenServiceImpl;
+    }
+
 
 }
(파일 끝에 줄바꿈 문자 없음)
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
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/web/ClassBookController.java
@@ -69,7 +69,7 @@
      *
      * 반 교재 삭제
      */
-    @DeleteMapping("/deleteClassBook.json")
+    @DeleteMapping("/delete.json")
     public String deleteClassBook(@RequestBody ClassBookVO classBookVO) throws Exception {
         try {
             int result = classBookService.deleteClassBook(classBookVO);
 
src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
@@ -0,0 +1,30 @@
+package com.takensoft.ai_lms.lms.survey.dao;
+
+
+import com.takensoft.ai_lms.lms.survey.vo.SurveyVO;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+import java.util.List;
+
+
+/**
+ * @author  : 박세훈
+ * since   : 2024.07.29
+ *
+ * 설문 조사 관련 Mapper
+ */
+@Mapper("surveyDAO")
+public interface SurveyDAO {
+
+    // 설문 조사 등록
+    int insertSurvey(SurveyVO surveyVO) throws Exception;
+
+    // 설문 조사 조회
+    List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception;
+
+    // 설문 조사 수정
+    int updateSurvey(SurveyVO surveyVO) throws Exception;
+
+    // 설문 조사 삭제
+    int deleteSurvey(String srvyId) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
@@ -0,0 +1,54 @@
+package com.takensoft.ai_lms.lms.survey.service.Impl;
+
+
+import com.takensoft.ai_lms.common.idgen.service.IdgenService;
+import com.takensoft.ai_lms.lms.survey.dao.SurveyDAO;
+import com.takensoft.ai_lms.lms.survey.service.SurveyService;
+import com.takensoft.ai_lms.lms.survey.vo.SurveyVO;
+import lombok.RequiredArgsConstructor;
+import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * @author  : 박세훈
+ * since   : 2024.07.29
+ *
+ * 설문 조사 관련 ServiceImpl
+ */
+@Service("surveyService")
+@RequiredArgsConstructor
+public class SurveyServiceImpl extends EgovAbstractServiceImpl implements SurveyService {
+
+    private final SurveyDAO surveyDAO;
+
+    private final IdgenService surveyIdgn;
+
+    // 설문 조사 등록
+    @Override
+    public int insertSurvey(SurveyVO surveyVO) throws Exception{
+        String srvyId = surveyIdgn.getNextStringId();
+        surveyVO.setSrvyId(srvyId);
+        return surveyDAO.insertSurvey(surveyVO);
+    }
+
+    // 설문 조사 조회
+    @Override
+    public List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception {
+        return surveyDAO.surveyList(surveyVO);
+    }
+
+    // 설문 조사 수정
+    @Override
+    public int updateSurvey(SurveyVO surveyVO) throws Exception {
+        return surveyDAO.updateSurvey(surveyVO);
+    }
+
+    // 설문 조사 삭제
+    @Override
+    public int deleteSurvey(String srvyId) throws Exception {
+        return surveyDAO.deleteSurvey(srvyId);
+    }
+}
 
src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
@@ -0,0 +1,28 @@
+package com.takensoft.ai_lms.lms.survey.service;
+
+import com.takensoft.ai_lms.lms.survey.vo.SurveyVO;
+
+import java.util.List;
+
+
+/**
+ * @author  : 박세훈
+ * since   : 2024.07.29
+ *
+ * 설문 조사 관련 Service
+ */
+
+public interface SurveyService {
+
+    // 설문 조사 등록
+    int insertSurvey(SurveyVO surveyVO) throws Exception;
+
+    // 설문 조사 조회
+    List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception;
+
+    // 설문 조사 수정
+    int updateSurvey(SurveyVO surveyVO) throws Exception;
+
+    // 설문 조사 삭제
+    int deleteSurvey(String srvyId) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/survey/vo/SurveyVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/survey/vo/SurveyVO.java
@@ -0,0 +1,30 @@
+package com.takensoft.ai_lms.lms.survey.vo;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+
+/**
+ * @author  : 박세훈
+ * since   : 2024.07.29
+ *
+ * 설문 조사 관련 VO
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class SurveyVO {
+
+    // 설문 조사 아이디
+    private String srvyId;
+
+    // 설문 조사 종류
+    private String srvyType;
+
+    // 설문 내용
+    private String srvyCnt;
+}
 
src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
@@ -0,0 +1,77 @@
+package com.takensoft.ai_lms.lms.survey.web;
+
+
+import com.takensoft.ai_lms.lms.survey.service.SurveyService;
+import com.takensoft.ai_lms.lms.survey.vo.SurveyVO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author  : 박세훈
+ * since   : 2024.07.29
+ *
+ * 설문 조사 관련 Controller
+ */
+
+@RestController
+@RequestMapping(value = "/survey")
+@RequiredArgsConstructor
+public class SurveyController {
+
+    private final SurveyService surveyService;
+
+    @PostMapping("/insert.json")
+    public String insertSurvey(@RequestBody SurveyVO surveyVO) throws Exception {
+        try {
+            int result = surveyService.insertSurvey(surveyVO);
+            if (result > 0) {
+                return "success";
+            } else {
+                return "fail";
+            }
+        } catch (Exception e ) {
+            return "Error";
+        }
+    }
+
+    @GetMapping("/list.json")
+    public List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception {
+        return surveyService.surveyList(surveyVO);
+    }
+
+
+    @PutMapping("/update.json")
+    public String updateSurvey (@RequestBody SurveyVO surveyVO) throws Exception {
+        try {
+            int result = surveyService.updateSurvey(surveyVO);
+            if (result > 0) {
+                return "success";
+            } else {
+                return "fail";
+            }
+        }catch (Exception e) {
+            return "Error";
+        }
+    }
+
+
+    @DeleteMapping("/delete.json")
+    public String deleteSurvey (@RequestBody Map<String, String> request) throws Exception {
+        try {
+            String srvyId = request.get("srvyId");
+            int result = surveyService.deleteSurvey(srvyId);
+            if ( result > 0) {
+                return "success";
+            } else {
+                return "fail";
+            }
+        } catch (Exception e) {
+            return "Error";
+        }
+    }
+
+
+}
 
src/main/resources/mybatis/mapper/lms/survey-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/survey-SQL.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takensoft.ai_lms.lms.survey.dao.SurveyDAO">
+
+
+    <resultMap id="surveyMap" type="SurveyVO">
+        <result property="srvyId" column="srvy_id"/>
+        <result property="srvyType" column="srvy_type"/>
+        <result property="srvyCnt" column="srvy_cnt"/>
+    </resultMap>
+
+
+    <insert id="insertSurvey" parameterType="SurveyVO">
+        INSERT INTO survey( srvy_id,
+                            srvy_type,
+                            srvy_cnt)
+        VALUES (#{srvyId},
+                #{srvyType},
+                #{srvyCnt});
+    </insert>
+
+    <select id="surveyList" parameterType="SurveyVO">
+        SELECT *
+        FROM survey
+    </select>
+
+    <update id="updateSurvey" parameterType="SurveyVO">
+        UPDATE survey
+        SET srvy_type = #{srvyType},
+            srvy_cnt = #{srvyCnt}
+        WHERE
+            srvy_id = #{srvyId}
+    </update>
+
+
+
+
+    <delete id="deleteSurvey" parameterType="String">
+        DELETE FROM survey
+        WHERE srvy_id = #{srvyId}
+    </delete>
+
+
+
+
+</mapper>(파일 끝에 줄바꿈 문자 없음)
Add a comment
List