이은진 이은진 07-26
240726 이은진 지문 CRUD
@7b2a240330fec3e375eb0ad2cc9f0bbb8d54b3e7
gradle/wrapper/gradle-wrapper.properties
--- gradle/wrapper/gradle-wrapper.properties
+++ gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,6 @@
+#Wed Jul 24 13:48:54 KST 2024
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
-zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
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
@@ -62,6 +62,7 @@
                 .requestMatchers( "/auth/**", "/auth/login.json").permitAll() // /user/** 경로는 모두 허용
                 .requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll() // swagger 진입 허용
                 .requestMatchers("/test/**").permitAll()
+                .requestMatchers("/text/**").permitAll()
                 .requestMatchers("/studentInfo/**").permitAll() // 학생 정보 진입 허용(민수)
                 .requestMatchers("/board/**").permitAll() // 게시판 정보 진입 허용
                 .requestMatchers("/book/**").permitAll() // 교재 정보 진입 허용
 
src/main/java/com/takensoft/ai_lms/lms/text/dao/TextDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/text/dao/TextDAO.java
@@ -0,0 +1,34 @@
+package com.takensoft.ai_lms.lms.text.dao;
+
+import com.takensoft.ai_lms.lms.text.vo.TextVO;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author  : 이은진
+ * @since   : 2024.07.25
+ *
+ * 지문 관련 Mapper
+ */
+@Mapper("TextDAO")
+public interface TextDAO {
+    // 지문 등록
+    int insertText(TextVO TextVO) throws Exception;
+
+    // 지문 리스트 조회
+    List<HashMap<String, Object>> selectTextList(HashMap<String, Object> params) throws Exception;
+
+    // 지문 수 조회
+    int textCount(HashMap<String, Object> params) throws Exception;
+
+    // 지문 출력
+    List<HashMap<String, Object>> selectOneText(HashMap<String, Object> params) throws Exception;
+
+    // 지문 수정
+    int textUpdate(TextVO TextVO) throws Exception;
+
+    // 지문 삭제
+    int textDelete(String textId) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/text/service/Impl/TextServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/text/service/Impl/TextServiceImpl.java
@@ -0,0 +1,83 @@
+package com.takensoft.ai_lms.lms.text.service.Impl;
+
+import com.takensoft.ai_lms.common.idgen.service.IdgenService;
+import com.takensoft.ai_lms.lms.text.dao.TextDAO;
+import com.takensoft.ai_lms.lms.text.service.TextService;
+import com.takensoft.ai_lms.lms.text.vo.TextVO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author : 이은진
+ * @since : 2024.07.25
+ */
+
+@Service("textService")
+@RequiredArgsConstructor
+public class TextServiceImpl implements TextService {
+
+    private final TextDAO textDAO;
+    private final IdgenService textIdgn;
+
+    /**
+     * 지문 등록
+     */
+    @Override
+    @Transactional
+    public int insertText(TextVO textVO) throws Exception {
+        String textID = textIdgn.getNextStringId();
+        textVO.setTextId(textID);
+        return textDAO.insertText(textVO);
+    }
+
+    /**
+     * 지문 리스트 조회
+     */
+    @Override
+    public List<HashMap<String, Object>> selectTextList(HashMap<String, Object> params) throws Exception {
+        int page = Integer.parseInt(params.get("page").toString());
+        int pageSize = Integer.parseInt(params.get("pageSize").toString());
+
+        int startIndex = (page - 1) * pageSize;
+        params.put("startIndex", startIndex);
+        params.put("pageSize", pageSize);
+        return textDAO.selectTextList(params);
+    }
+
+    /**
+     * 지문 수 조회
+     */
+    @Override
+    public int textCount(HashMap<String, Object> params) throws Exception {
+        return textDAO.textCount(params);
+    }
+
+    /**
+     * 지문 출력
+     */
+    @Override
+    public List<HashMap<String, Object>> selectOneText(HashMap<String, Object> params) throws Exception {
+        return textDAO.selectOneText(params);
+    }
+
+    /**
+     * 지문 수정
+     */
+    @Override
+    public int textUpdate(TextVO textVO) throws Exception {
+        return textDAO.textUpdate(textVO);
+    }
+
+    /**
+     * 지문 삭제
+     */
+    @Override
+    public int textDelete(String textId) throws Exception {
+        return textDAO.textDelete(textId);
+    }
+}
 
src/main/java/com/takensoft/ai_lms/lms/text/service/TextService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/text/service/TextService.java
@@ -0,0 +1,32 @@
+package com.takensoft.ai_lms.lms.text.service;
+import com.takensoft.ai_lms.lms.text.vo.TextVO;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author  : 이은진
+ * since   : 2024.07.25
+ *
+ * 지문 관련 인터페이스
+ */
+
+public interface TextService {
+    // 지문 등록
+    int insertText(TextVO textVO) throws Exception;
+
+    // 지문 리스트 조회
+    List<HashMap<String, Object>> selectTextList(HashMap<String, Object> params) throws Exception;
+
+    // 지문 수 조회
+    int textCount(HashMap<String, Object> params) throws Exception;
+
+    // 지문 출력
+    List<HashMap<String, Object>> selectOneText(HashMap<String, Object> params)  throws Exception;
+
+    // 지문 수정
+    int textUpdate(TextVO textVO) throws Exception;
+
+    // 지문 삭제
+    int textDelete(String textId) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/text/vo/TextVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/text/vo/TextVO.java
@@ -0,0 +1,34 @@
+package com.takensoft.ai_lms.lms.text.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author  : 이은진
+ * since   : 2024.07.26
+ *
+ * 지문 관련 VO
+ */
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class TextVO {
+
+    // 지문 아이디
+    private String textId;
+    // 지문 내용
+    private String textCnt;
+    // 등록일
+    private String regDt;
+    // 파일 관리 아이디
+    private String fileMngId;
+    // 유형 아이디
+    private String textTypeId;
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/text/web/TextController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/text/web/TextController.java
@@ -0,0 +1,142 @@
+package com.takensoft.ai_lms.lms.text.web;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.takensoft.ai_lms.lms.text.service.TextService;
+import com.takensoft.ai_lms.lms.text.vo.TextVO;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author 이은진
+ * @since 2024.07.25
+ */
+
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping(value = "/text")
+public class TextController {
+
+    private final TextService TextService;
+
+    /**
+     * 지문 등록
+     */
+    @PostMapping("/insertText.json")
+    @Operation(summary = "지문 등록")
+    public String insertText(@RequestBody TextVO textVO) throws Exception {
+        Gson gson = new Gson();
+        JsonObject response = new JsonObject();
+
+        try {
+            int result = TextService.insertText(textVO);
+            if (result > 0) {
+                response.addProperty("status", "success");
+                response.addProperty("message", "지문이 등록되었습니다.");
+                return gson.toJson(response);
+            } else {
+                response.addProperty("message", "지문 등록 실패");
+                return gson.toJson(response);
+            }
+        } catch (Exception e) {
+            response.addProperty("status", "error");
+            response.addProperty("message", e.getMessage());
+            return gson.toJson(response);
+        }
+    }
+
+
+    /**
+     * 지문 리스트 조회
+     */
+    @GetMapping("/selectTextList.json")
+    @Operation(summary = "지문 리스트 조회")
+    public HashMap<String, Object> getTextList(@RequestBody HashMap<String, Object> params) throws Exception {
+        HashMap<String, Object> result = new HashMap<>();
+
+        int page = Integer.parseInt(params.get("page").toString());
+        int pageSize = Integer.parseInt(params.get("pageSize").toString());
+
+        int totalText = TextService.textCount(params);
+        result.put("totalText", totalText);
+        result.put("texts", TextService.selectTextList(params));
+
+        return result;
+    }
+
+    /**
+     * 지문 출력
+     */
+    @GetMapping("/selectOneText.json")
+    @Operation(summary = "지문 출력")
+    public List<HashMap<String, Object>> selectOneText(@RequestParam HashMap<String, Object> textId) throws Exception {
+        return TextService.selectOneText(textId);
+    }
+
+
+    /**
+     * 지문 수정
+     */
+    @PutMapping(value = "/textUpdate.json")
+    @Operation(summary = "지문 수정")
+    public String textUpdate(@RequestBody TextVO textVO) throws Exception {
+        Gson gson = new Gson();
+        JsonObject response = new JsonObject();
+
+        try {
+            int result = TextService.textUpdate(textVO);
+            if (result > 0) {
+                response.addProperty("status", "success");
+                response.addProperty("message", "지문이 수정되었습니다.");
+                return gson.toJson(response);
+            } else {
+                response.addProperty("message", "수정 실패");
+                return gson.toJson(response);
+            }
+        } catch (Exception e) {
+            response.addProperty("status", "error");
+            response.addProperty("message", e.getMessage());
+            return gson.toJson(response);
+        }
+    }
+
+
+    /**
+     * 지문 삭제
+     */
+    @DeleteMapping(value = "/textDelete.json")
+    @Operation(summary = "지문 삭제")
+    public String textDelete(@RequestBody Map<String, String> request) throws Exception {
+        Gson gson = new Gson();
+        JsonObject response = new JsonObject();
+
+        String textId = request.get("textId");
+        int result = TextService.textDelete(textId);
+        try {
+            if (result > 0) {
+                response.addProperty("status", "success");
+                response.addProperty("message", "사용자가 삭제되었습니다.");
+                return gson.toJson(response);
+            } else {
+                response.addProperty("message", "삭제 실패");
+                return gson.toJson(response);
+            }
+        } catch (Exception e) {
+            response.addProperty("status", "error");
+            response.addProperty("message", e.getMessage());
+            return gson.toJson(response);
+        }
+    }
+}
+
 
src/main/resources/mybatis/mapper/lms/text-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/text-SQL.xml
@@ -0,0 +1,100 @@
+<?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.text.dao.TextDAO">
+
+    <resultMap id="textMap" type="TextVO">
+        <result property="textId" column="text_id"/>
+        <result property="textCnt" column="text_cnt"/>
+        <result property="regDt" column="reg_dt"/>
+        <result property="fileMngId" column="file_mng_id"/>
+        <result property="textTypeId" column="text_type_id"/>
+    </resultMap>
+
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.26
+         내 용 : 지문 등록
+     -->
+    <insert id="insertText" parameterType="TextVO">
+        INSERT INTO text (text_id
+                         ,text_cnt
+                         ,reg_dt
+                         ,file_mng_id
+                         ,text_type_id
+        ) VALUES (#{textId}
+                 ,#{textCnt}
+                 ,now()
+                 ,#{fileMngId}
+                 ,#{textTypeId}
+                 );
+    </insert>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.26
+         내 용 : 지문 수 조회
+     -->
+    <select id="textCount" resultType="Integer">
+        SELECT COUNT(*)
+        FROM text
+    </select>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.26
+         내 용 : 지문 리스트 조회
+     -->
+    <select id="selectTextList"  resultMap="textMap">
+        SELECT text_id
+              ,text_cnt
+              ,reg_dt
+              ,file_mng_id
+              ,text_type_id
+        FROM text
+        ORDER BY text_id DESC
+        LIMIT #{pageSize}
+        OFFSET #{startIndex}
+    </select>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.26
+         내 용 : 지문 출력
+     -->
+    <select id="selectOneText" parameterType="HashMap" resultType="HashMap">
+        SELECT text_id
+             , text_cnt
+             , reg_dt
+             , file_mng_id
+             , text_type_id
+
+        FROM text
+        WHERE text_id = #{textId}
+        ORDER BY text_id DESC
+    </select>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.26
+         내 용 : 지문 수정
+     -->
+    <update id="textUpdate" parameterType="TextVO">
+        UPDATE text
+        SET text_cnt = #{textCnt}
+          , file_mng_id = #{fileMngId}
+          , text_type_id = #{textTypeId}
+        WHERE text_id = #{textId}
+    </update>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.26
+         내 용 : 지문 삭제
+     -->
+    <delete id="textDelete" parameterType="String">
+    DELETE FROM text
+    WHERE text_id = #{textId}
+    </delete>
+
+</mapper>
Add a comment
List