woals 07-30
240730 권민수 지문 이름 단어장 검색 기능 추가, 단어 CRUD 추가
@7b375d3f3562018eba55af0297cfb41bc5cdb3d4
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,7 +73,8 @@
                 .requestMatchers("/unitLearning/**").permitAll() // 로드맵 정보 진입 허용
                 .requestMatchers("/unit/**").permitAll()
                 .requestMatchers("/photo/**").permitAll()
-                .requestMatchers("/wordbook/**").permitAll()
+                .requestMatchers("/wordbook/**").permitAll() // 단어장 정보 진입 허용
+                .requestMatchers("/word/**").permitAll() // 단어 정보 진입 허용
                 .requestMatchers("/survey/**").permitAll()
                 .anyRequest().authenticated()); // 나머지 경로는 인증 필요
 
src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordBookDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordBookDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordBookDAO.java
@@ -30,4 +30,7 @@
     // 단어장 삭제
     int deleteWordBook(String wdBookId);
 
+    // 단어장 검색(지문 이름으로 검색)
+    List<WordBookVO> getWordBooksByTextTitle(String textTitle);
+
 }
 
src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordDAO.java
@@ -0,0 +1,32 @@
+package com.takensoft.ai_lms.lms.word_book.dao;
+
+import com.takensoft.ai_lms.lms.word_book.vo.WordVO;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+import java.util.List;
+
+/**
+ * @author 권민수
+ * @since 2024.07.30
+ *
+ * 단어 정보 DAO 클래스
+ */
+
+@Mapper("wordDAO")
+public interface WordDAO {
+
+    // 단어장에 해당하는 모든 단어 목록 조회
+    List<WordVO> getWordsByBookId(String wdBookId);
+
+    // 단어 등록
+    void insertWord(WordVO word);
+
+    // 단어 수정
+    void updateWord(WordVO word);
+
+    // 단어 삭제
+    void deleteWord(String wdId);
+
+    // String generateWordId();
+
+}
src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordBookServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordBookServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordBookServiceImpl.java
@@ -50,4 +50,9 @@
     public void deleteWordBook(String wdBookId) {
         wordBookDAO.deleteWordBook(wdBookId);
     }
+
+    @Override
+    public List<WordBookVO> getWordBooksByTextTitle(String textTitle) {
+        return wordBookDAO.getWordBooksByTextTitle(textTitle);
+    }
 }
 
src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordServiceImpl.java
@@ -0,0 +1,49 @@
+package com.takensoft.ai_lms.lms.word_book.service.Impl;
+
+import com.takensoft.ai_lms.common.idgen.service.IdgenService;
+import com.takensoft.ai_lms.lms.word_book.dao.WordDAO;
+import com.takensoft.ai_lms.lms.word_book.service.WordService;
+import com.takensoft.ai_lms.lms.word_book.vo.WordVO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author 권민수
+ * @since 2024.07.30
+ *
+ * 단어 정보 관련 서비스
+ */
+
+@Service
+@RequiredArgsConstructor
+public class WordServiceImpl implements WordService {
+
+    private final WordDAO wordDAO;
+
+    private final IdgenService wordIdgn;
+
+    @Override
+    public List<WordVO> getWordsByBookId(String wdBookId) {
+        return wordDAO.getWordsByBookId(wdBookId);
+    }
+
+    @Override
+    public void insertWord(WordVO word) {
+        String wordId = wordIdgn.getNextStringId();
+        word.setWdId(wordId);
+        wordDAO.insertWord(word);
+    }
+
+    @Override
+    public void updateWord(WordVO word) {
+        wordDAO.updateWord(word);
+    }
+
+    @Override
+    public void deleteWord(String wdId) {
+        wordDAO.deleteWord(wdId);
+    }
+
+}
src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordBookService.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordBookService.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordBookService.java
@@ -28,4 +28,8 @@
     // 단어장 삭제
     void deleteWordBook(String wdBookId);
 
+    // 단어장 검색(지문 이름으로 검색)
+    List<WordBookVO> getWordBooksByTextTitle(String textTitle);
+
+
 }
 
src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordService.java
@@ -0,0 +1,28 @@
+package com.takensoft.ai_lms.lms.word_book.service;
+
+import com.takensoft.ai_lms.lms.word_book.vo.WordVO;
+
+import java.util.List;
+
+/**
+ * @author 권민수
+ * @since 2024.07.30
+ *
+ * 단어 정보 Service 인터페이스
+ */
+
+public interface WordService {
+
+    // 단어장에 해당하는 모든 단어 목록 조회
+    List<WordVO> getWordsByBookId(String wdBookId);
+
+    // 단어 등록
+    void insertWord(WordVO word);
+
+    // 단어 수정
+    void updateWord(WordVO word);
+
+    // 단어 삭제
+    void deleteWord(String wdId);
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/word_book/vo/WordVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/vo/WordVO.java
@@ -0,0 +1,23 @@
+package com.takensoft.ai_lms.lms.word_book.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author 권민수
+ * @since 2024.07.30
+ *
+ * 단어 정보 VO 클래스
+ */
+
+@Getter
+@Setter
+public class WordVO {
+
+    private String wdId;
+    private String wdBookId;
+    private String wdNm;
+    private String wdMnng;
+    private String fileMngId;
+
+}
src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordBookController.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordBookController.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordBookController.java
@@ -24,16 +24,19 @@
 
     final private WordBookService wordBookService;
 
-    @GetMapping("/findAll.json")
+    // 단어장 전체 목록 조회
+    @PostMapping("/findAll.json")
     public List<WordBookVO> getAllWordBooks() {
         return wordBookService.getAllWordBooks();
     }
 
+    // 아이디에 해당하는 단어장 조회
     @PostMapping("/find.json")
     public WordBookVO getWordBookById(@RequestBody WordBookVO wordBook) {
         return wordBookService.getWordBookById(wordBook.getWdBookId());
     }
 
+    // 단어장 등록
     @PostMapping("/insert.json")
     public void insertWordBook(@RequestBody Map<String, String> req) {
         WordBookVO wordBook = new WordBookVO();
@@ -43,14 +46,31 @@
         wordBookService.insertWordBook(wordBook);
     }
 
-    @PutMapping("/update.json")
+    // 단어장 수정
+    @PostMapping("/update.json")
     public void updateWordBook(@RequestBody WordBookVO wordBook) {
         wordBookService.updateWordBook(wordBook);
     }
 
-    @DeleteMapping("/delete.json")
+    // 단어장 삭제
+    @PostMapping("/delete.json")
     public void deleteWordBook(@RequestBody WordBookVO wordBook) {
         wordBookService.deleteWordBook(wordBook.getWdBookId());
     }
 
+    // 단어장 검색(지문 이름으로 검색)
+    @PostMapping("/findByTextTitle.json")
+    public List<WordBookVO> getWordBooksByTextTitle(@RequestBody Map<String, String> request) {
+        String textTitle = "%" + request.get("textTitle") + "%"; // 부분 검색 허용
+        return wordBookService.getWordBooksByTextTitle(textTitle);
+    }
+
 }
+
+// 1. 책에 소속된 단어장 리스트 가져오기(보류)
+// 2. 지문 이름 검색으로 지문에 소속되는 단어장 리스트 가져오기(완료)
+// 3. 단어 검색으로 해당 단어를 포함하는 단어장 리스트 가져오기
+// 4. 단어장에 소속되는 단어 리스트 가져오기 (단어R)(완료)
+// 5. 단어장에 단어 추가 (단어C)(완료)
+// 6. 단어 아이디에 해당하는 단어 수정(단어U)(완료)
+// 7. 단어 아이디에 해당하는 단어 삭제(단어D)(완료)
 
src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordController.java
@@ -0,0 +1,54 @@
+package com.takensoft.ai_lms.lms.word_book.web;
+
+import com.takensoft.ai_lms.lms.word_book.service.WordService;
+import com.takensoft.ai_lms.lms.word_book.vo.WordVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author 권민수
+ * @since 2024.07.30
+ *
+ * 단어 정보 관련 컨트롤러 클래스
+ */
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping("/word")
+public class WordController {
+
+    private final WordService wordService;
+
+    // 단어장 아이디에 해당하는 단어 목록 조회
+    @PostMapping("/getWordsByBookId.json")
+    public List<WordVO> getWordsByBookId(@RequestBody Map<String, String> request) {
+        return wordService.getWordsByBookId(request.get("wdBookId"));
+    }
+
+    // 단어 등록
+    @PostMapping("/insert.json")
+    public void insertWord(@RequestBody WordVO word) {
+        wordService.insertWord(word);
+    }
+
+    // 단어 수정
+    @PostMapping("/update.json")
+    public void updateWord(@RequestBody WordVO word) {
+        wordService.updateWord(word);
+    }
+
+    // 단어 삭제
+    @PostMapping("/delete.json")
+    public void deleteWord(@RequestBody WordVO word) {
+        wordService.deleteWord(word.getWdId());
+    }
+
+}
 
src/main/resources/mybatis/mapper/lms/word-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/word-SQL.xml
@@ -0,0 +1,52 @@
+<?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.word_book.dao.WordDAO">
+
+    <!--
+        작 성 자 : 권민수
+        작 성 일 : 2024.07.30
+        내   용 : 단어 정보 관련 sql 매핑 xml 문서
+    -->
+
+    <resultMap id="wordResultMap" type="WordVO">
+        <id property="wdId" column="wd_id" />
+        <result property="wdBookId" column="wd_book_id" />
+        <result property="wdNm" column="wd_nm" />
+        <result property="wdMnng" column="wd_mnng" />
+        <result property="fileMngId" column="file_mng_id" />
+    </resultMap>
+
+    <select id="getWordsByBookId" resultMap="wordResultMap">
+        SELECT *
+        FROM word
+        WHERE wd_book_id = #{wdBookId}
+    </select>
+
+    <insert id="insertWord">
+        INSERT INTO
+            word (wd_id,
+                  wd_book_id,
+                  wd_nm,
+                  wd_mnng,
+                  file_mng_id)
+        VALUES (#{wdId},
+                #{wdBookId},
+                #{wdNm},
+                #{wdMnng},
+                #{fileMngId})
+    </insert>
+
+    <update id="updateWord">
+        UPDATE word
+        SET wd_nm = #{wdNm},
+            wd_mnng = #{wdMnng},
+            file_mng_id = #{fileMngId}
+        WHERE wd_id = #{wdId}
+    </update>
+
+    <delete id="deleteWord">
+        DELETE FROM word
+        WHERE wd_id = #{wdId}
+    </delete>
+
+</mapper>(파일 끝에 줄바꿈 문자 없음)
src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
--- src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
@@ -8,7 +8,7 @@
         내   용 : 단어장 정보 관련 sql 매핑 xml 문서
     -->
 
-    <resultMap id="WordBookResultMap" type="com.takensoft.ai_lms.lms.word_book.vo.WordBookVO">
+    <resultMap id="WordBookResultMap" type="WordBookVO">
         <id property="wdBookId" column="wd_book_id"/>
         <result property="wdBookTypeId" column="wd_book_type_id"/>
         <result property="textId" column="text_id"/>
@@ -34,7 +34,7 @@
         WHERE wd_book_id = #{wdBookId}
     </select>
 
-    <insert id="insertWordBook" parameterType="com.takensoft.ai_lms.lms.word_book.vo.WordBookVO">
+    <insert id="insertWordBook" parameterType="WordBookVO">
         INSERT INTO
             ai_lms.wordbook (wd_book_id,
                              wd_book_type_id,
@@ -46,7 +46,7 @@
                 #{userId})
     </insert>
 
-    <update id="updateWordBook" parameterType="com.takensoft.ai_lms.lms.word_book.vo.WordBookVO">
+    <update id="updateWordBook" parameterType="WordBookVO">
         UPDATE ai_lms.wordbook
         SET wd_book_type_id = #{wdBookTypeId},
             text_id = #{textId},
@@ -59,4 +59,11 @@
         WHERE wd_book_id = #{wdBookId}
     </delete>
 
+    <select id="getWordBooksByTextTitle" resultType="WordBookVO">
+        SELECT wb.*
+        FROM wordbook wb
+        JOIN text t ON wb.text_id = t.text_id
+        WHERE t.text_ttl LIKE #{textTitle}
+    </select>
+
 </mapper>
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List