PsHooN7979 07-29
240726 박세훈 반에 등록 된 교재 조회기능 추가
@81e774ea4de33822c75de9eab28f841a85454194
src/main/java/com/takensoft/ai_lms/lms/class_book/dao/ClassBookDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/dao/ClassBookDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/dao/ClassBookDAO.java
@@ -4,9 +4,12 @@
 import com.takensoft.ai_lms.lms.class_book.vo.ClassBookVO;
 import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * @author  : 박세훈
- * since   : 2024.07.20
+ * since   : 2024.07.29
  *
  *  class - book관련 Mapper
  */
@@ -14,9 +17,12 @@
 @Mapper("classBookDAO")
 public interface ClassBookDAO {
 
-    // 책 등록
+    // 교재 등록
     int registerBook(ClassBookVO classBookVO) throws Exception;
 
-    // 책 삭제
+    // 교재 삭제
     int deleteClassBook(ClassBookVO classBookVO) throws Exception;
+
+    // 교재 조회
+    List<HashMap<String, Object>> findByBookId(HashMap<String, Object> params) throws Exception;
 }
src/main/java/com/takensoft/ai_lms/lms/class_book/service/ClassBookService.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/service/ClassBookService.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/service/ClassBookService.java
@@ -2,19 +2,25 @@
 
 import com.takensoft.ai_lms.lms.class_book.vo.ClassBookVO;
 
+import java.util.HashMap;
+import java.util.List;
+
 
 /**
  * @author  : 박세훈
- * since   : 2024.07.20
+ * since   : 2024.07.29
  *
  *  class - book관련 Service
  */
 
 public interface ClassBookService {
 
-    // 책 등록
+    // 교재 등록
     int registerBook(ClassBookVO classBookVO) throws Exception;
 
-    // 책 삭제
+    // 교재 삭제
     int deleteClassBook(ClassBookVO classBookVO) throws Exception;
+
+    // 교재 조회
+    List<HashMap<String, Object>> findByBookId(HashMap<String, Object> params) throws Exception;
 }
src/main/java/com/takensoft/ai_lms/lms/class_book/service/Impl/ClassBookServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/service/Impl/ClassBookServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/service/Impl/ClassBookServiceImpl.java
@@ -8,10 +8,13 @@
 import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+
 
 /**
  * @author  : 박세훈
- * since   : 2024.07.20
+ * since   : 2024.07.29
  *
  *  class - book관련 ServiceImpl
  */
@@ -21,12 +24,21 @@
 
     private final ClassBookDAO classBookDAO;
 
+    // 교재 등록
     @Override
     public int registerBook(ClassBookVO classBookVO) throws Exception {
         return classBookDAO.registerBook(classBookVO);
     }
+
+    // 교재 삭제
     @Override
     public int deleteClassBook(ClassBookVO classBookVO) throws Exception {
         return classBookDAO.deleteClassBook(classBookVO);
     }
+
+    // 등록된 교재 조회
+    @Override
+    public List<HashMap<String, Object>> findByBookId(HashMap<String, Object> params) throws Exception {
+        return classBookDAO.findByBookId(params);
+    }
 }
src/main/java/com/takensoft/ai_lms/lms/class_book/vo/ClassBookVO.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/vo/ClassBookVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/vo/ClassBookVO.java
@@ -14,7 +14,7 @@
     // 반 아이디
     private String sclsId;
 
-    // 책 아이디
+    // 교재 아이디
     private String bookId;
 
 }
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
@@ -3,6 +3,8 @@
 import com.takensoft.ai_lms.lms.class_book.service.ClassBookService;
 import com.takensoft.ai_lms.lms.class_book.vo.ClassBookVO;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
@@ -21,7 +23,7 @@
      * @return
      * @throws  Exception
      *
-     * 반 책 등록
+     * 반 교재 등록
      */
     @PostMapping("/register.json")
     public String registerBook(@RequestBody ClassBookVO classBookVO) throws Exception {
@@ -46,7 +48,26 @@
      * @return
      * @throws  Exception
      *
-     * 반 책 삭제
+     * 반에 등록된 교재 조회
+     */
+    @PostMapping("/findAll.json")
+    public ResponseEntity<?> findByBookId(@RequestBody HashMap<String, Object> params) throws Exception {
+        HashMap<String, Object> result = new HashMap<>();
+
+        result.put("list", classBookService.findByBookId(params));
+
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+
+    /**
+     * @author  박세훈
+     * @since   2024.07.29
+     * param   ClassBookDAO
+     * @return
+     * @throws  Exception
+     *
+     * 반 교재 삭제
      */
     @DeleteMapping("/deleteClassBook.json")
     public String deleteClassBook(@RequestBody ClassBookVO classBookVO) throws Exception {
src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
--- src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
@@ -3,15 +3,13 @@
 <mapper namespace="com.takensoft.ai_lms.lms.class_book.dao.ClassBookDAO">
 
 
-    <resultMap id="classBookMap" type="ClassBookVO" >
-        <result property="sclsId" column="scls_id"/>
-        <result property="sclsNm" column="scls_nm"/>
-    </resultMap>
+
+
 
     <!--
          작성자 : 박세훈
          작성일 : 2024.07.26
-         내 용 : 반에 책 등록
+         내 용 : 반에 교재 등록
      -->
     <insert id="registerBook" parameterType="String" >
         INSERT INTO class_book( book_id,
@@ -21,16 +19,32 @@
         );
     </insert>
 
+
     <!--
          작성자 : 박세훈
          작성일 : 2024.07.26
-         내 용 : 반에 등록 된 책 삭제
+         내 용 : 반에 등록 된 교재 삭제
      -->
     <delete id="deleteClassBook" parameterType="String">
         DELETE FROM class_book
         WHERE
-            book_id = #{bookId} AND 
+            book_id = #{bookId} AND
             scls_id = #{sclsId}
     </delete>
 
+
+    <!--
+         작성자 : 박세훈
+         작성일 : 2024.07.29
+         내 용 : 반에 등록 된 교재 조회
+     -->
+
+    <select id="findByBookId" parameterType="String">
+        SELECT b.book_id, b.book_nm
+        FROM book b
+        JOIN class_book cb ON b.book_id = cb.book_id
+        JOIN class c ON cb.scls_id = c.scls_id
+        WHERE c.scls_id = #{sclsId};
+    </select>
+
 </mapper>
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List