이은진 이은진 07-29
240729 이은진 학습 일정 정보 CRUD
@111cd810f6a8c46000d918f54954ad6bd9a140db
 
src/main/java/com/takensoft/ai_lms/lms/schedule/dao/ScheduleDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/schedule/dao/ScheduleDAO.java
@@ -0,0 +1,25 @@
+package com.takensoft.ai_lms.lms.schedule.dao;
+
+import com.takensoft.ai_lms.lms.schedule.vo.ScheduleVO;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author  : 이은진
+ * @since   : 2024.07.29
+ *
+ * 학습 일정 관련 Mapper
+ */
+public interface ScheduleDAO {
+    //학습 일정 등록
+    int insertSchedule(ScheduleVO scheduleVO) throws Exception;
+
+    // 학습 일정 출력
+    List<HashMap<String, Object>> selectSchedule(HashMap<String, Object> params) throws Exception;
+
+    // 학습 일정 수정
+    int scheduleUpdate(ScheduleVO scheduleVO) throws Exception;
+
+    // 학습 일정 삭제
+    int scheduleDelete(String scheduleID) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/schedule/service/Impl/ScheduleServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/schedule/service/Impl/ScheduleServiceImpl.java
@@ -0,0 +1,58 @@
+package com.takensoft.ai_lms.lms.schedule.service.Impl;
+
+import com.takensoft.ai_lms.common.idgen.service.IdgenService;
+import com.takensoft.ai_lms.lms.schedule.dao.ScheduleDAO;
+import com.takensoft.ai_lms.lms.schedule.service.ScheduleService;
+import com.takensoft.ai_lms.lms.schedule.vo.ScheduleVO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import java.util.HashMap;
+import java.util.List;
+
+
+/**
+ * @author : 이은진
+ * @since : 2024.07.29
+ */
+
+@Service("scheduleService")
+@RequiredArgsConstructor
+public class ScheduleServiceImpl implements ScheduleService {
+
+    private final ScheduleDAO scheduleDAO;
+    private final IdgenService scheduleIdgn;
+
+    /**
+     * 학습 일정 등록
+     */
+    @Override
+    public int insertSchedule(ScheduleVO scheduleVO) throws Exception {
+        String scheduleId = scheduleIdgn.getNextStringId();
+        scheduleVO.setScheduleId(scheduleId);
+        return scheduleDAO.insertSchedule(scheduleVO);
+    }
+
+    /**
+     * 학습 일정 출력
+     */
+    @Override
+    public List<HashMap<String, Object>> selectSchedule(HashMap<String, Object> params) throws Exception {
+        return scheduleDAO.selectSchedule(params);
+    }
+
+    /**
+     * 학습 일정 수정
+     */
+    @Override
+    public int scheduleUpdate(ScheduleVO scheduleVO) throws Exception {
+        return scheduleDAO.scheduleUpdate(scheduleVO);
+    }
+
+    /**
+     * 학습 일정 삭제
+     */
+    @Override
+    public int scheduleDelete(String scheduleId) throws Exception {
+        return scheduleDAO.scheduleDelete(scheduleId);
+    }
+}
 
src/main/java/com/takensoft/ai_lms/lms/schedule/service/ScheduleService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/schedule/service/ScheduleService.java
@@ -0,0 +1,26 @@
+package com.takensoft.ai_lms.lms.schedule.service;
+
+import com.takensoft.ai_lms.lms.schedule.vo.ScheduleVO;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author  : 이은진
+ * since   : 2024.07.29
+ *
+ * 학습 일정 관련 인터페이스
+ */
+public interface ScheduleService {
+
+    // 학습 일정 등록
+    int insertSchedule(ScheduleVO scheduleVO) throws Exception;
+
+    // 학습 일정 출력
+    List<HashMap<String, Object>> selectSchedule(HashMap<String, Object> params)  throws Exception;
+
+    // 학습 일정 수정
+    int scheduleUpdate(ScheduleVO scheduleVO) throws Exception;
+
+    // 학습 일정 삭제
+    int scheduleDelete(String scheduleId) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/schedule/vo/ScheduleVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/schedule/vo/ScheduleVO.java
@@ -0,0 +1,30 @@
+package com.takensoft.ai_lms.lms.schedule.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * @author  : 이은진
+ * since   : 2024.07.29
+ *
+ * 스케줄 관련 VO
+ */
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class ScheduleVO {
+    // 학습 일정 아이디
+    private String scheduleId;
+    // 학습 날짜
+    private String scheduleDt;
+    // 학습 교시
+    private String scheduleUnit;
+    // 책 아이디
+    private String bookId;
+    // 학생 아이디
+    private String stdId;
+}(파일 끝에 줄바꿈 문자 없음)
 
src/main/java/com/takensoft/ai_lms/lms/schedule/web/ScheduleController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/schedule/web/ScheduleController.java
@@ -0,0 +1,118 @@
+package com.takensoft.ai_lms.lms.schedule.web;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.takensoft.ai_lms.lms.schedule.service.ScheduleService;
+import com.takensoft.ai_lms.lms.schedule.vo.ScheduleVO;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author 이은진
+ * @since 2024.07.29
+ */
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping(value = "/schedule")
+public class ScheduleController {
+
+    private final ScheduleService scheduleService;
+
+    /**
+     * 학습 일정 등록
+     */
+    @PostMapping("/insertSchedule.json")
+    @Operation(summary = "스케줄 등록")
+    public String insertSchedule(@RequestBody ScheduleVO schedulevO) throws Exception {
+        Gson gson = new Gson();
+        JsonObject response = new JsonObject();
+
+        try {
+            int result = scheduleService.insertSchedule(schedulevO);
+            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("/selectSchedule.json")
+    @Operation(summary = "스케줄 출력")
+    public List<HashMap<String, Object>> selectSchedule(@RequestParam HashMap<String, Object> scheduleId) throws Exception {
+        return scheduleService.selectSchedule(scheduleId);
+    }
+
+
+    /**
+     * 학습 일정 수정
+     */
+    @PutMapping(value = "/scheduleUpdate.json")
+    @Operation(summary = "스케줄 수정")
+    public String scheduleUpdate(@RequestBody ScheduleVO scheduleVO) throws Exception {
+        Gson gson = new Gson();
+        JsonObject response = new JsonObject();
+
+        try {
+            int result = scheduleService.scheduleUpdate(scheduleVO);
+            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 = "/scheduleDelete.json")
+    @Operation(summary = "스케줄 삭제")
+    public String scheduleDelete(@RequestBody Map<String, String> request) throws Exception {
+        Gson gson = new Gson();
+        JsonObject response = new JsonObject();
+
+        String scheduleId = request.get("scheduleId");
+        int result = scheduleService.scheduleDelete(scheduleId);
+        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/java/com/takensoft/ai_lms/lms/text/vo/TextVO.java
--- src/main/java/com/takensoft/ai_lms/lms/text/vo/TextVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/text/vo/TextVO.java
@@ -5,7 +5,6 @@
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
-import java.time.LocalDateTime;
 
 /**
  * @author  : 이은진
@@ -22,13 +21,19 @@
 
     // 지문 아이디
     private String textId;
+    // 지문 제목
+    private String textTtl;
     // 지문 내용
     private String textCnt;
+    // 지문 url
+    private String textUrl;
     // 등록일
     private String regDt;
     // 파일 관리 아이디
     private String fileMngId;
     // 유형 아이디
     private String textTypeId;
+    // 사용자 아이디(선생님)
+    private String userId;
 
 }
src/main/java/com/takensoft/ai_lms/lms/text/web/TextController.java
--- src/main/java/com/takensoft/ai_lms/lms/text/web/TextController.java
+++ src/main/java/com/takensoft/ai_lms/lms/text/web/TextController.java
@@ -80,7 +80,7 @@
      */
     @GetMapping("/selectOneText.json")
     @Operation(summary = "지문 출력")
-    public List<HashMap<String, Object>> selectOneText(@RequestParam HashMap<String, Object> textId) throws Exception {
+    public List<HashMap<String, Object>> selectOneText(@RequestBody HashMap<String, Object> textId) throws Exception {
         return TextService.selectOneText(textId);
     }
 
 
src/main/resources/mybatis/mapper/lms/schedule-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/schedule-SQL.xml
@@ -0,0 +1,72 @@
+<?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.schedule.dao.ScheduleDAO">
+
+    <resultMap id="scheduleMap" type="ScheduleVO">
+        <result property="scheduleId" column="schdl_id"/>
+        <result property="scheduleDt" column="schdl_dt"/>
+        <result property="scheduleUnit" column="schdl_unit"/>
+        <result property="bookId" column="book_id"/>
+        <result property="stdId" column="std_id"/>
+    </resultMap>
+
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.29
+         내 용 : 스케줄 등록
+     -->
+    <insert id="insertSchedule" parameterType="ScheduleVO">
+        INSERT INTO schedule (schdl_id
+                         ,schdl_dt
+                         ,schdl_unit
+                         ,book_id
+                         ,std_id
+        ) VALUES (#{scheduleId}
+                 ,now()
+                 ,#{scheduleUnit}
+                 ,#{bookId}
+                 ,#{stdId}
+                 );
+    </insert>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.29
+         내 용 : 스케줄 출력
+     -->
+    <select id="selectSchedule" parameterType="HashMap" resultType="HashMap">
+        SELECT schdl_id
+             , schdl_dt
+             , schdl_unit
+             , book_id
+             , std_id
+
+        FROM schedule
+        ORDER BY schdl_dt DESC
+    </select>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.29
+         내 용 : 스케줄 수정
+     -->
+    <update id="scheduleUpdate" parameterType="ScheduleVO">
+        UPDATE schedule
+        SET schdl_dt = #{scheduleDt}
+          , schdl_unit = #{scheduleUnit}
+          , book_id = #{bookId}
+        WHERE schdl_id = #{scheduleId}
+    </update>
+
+    <!--
+         작성자 : 이은진
+         작성일 : 2024.07.29
+         내 용 : 스케줄 삭제
+     -->
+    <delete id="scheduleDelete" parameterType="String">
+    DELETE FROM schedule
+    WHERE schdl_id = #{scheduleId}
+    </delete>
+
+</mapper>
src/main/resources/mybatis/mapper/lms/text-SQL.xml
--- src/main/resources/mybatis/mapper/lms/text-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/text-SQL.xml
@@ -4,10 +4,13 @@
 
     <resultMap id="textMap" type="TextVO">
         <result property="textId" column="text_id"/>
+        <result property="textTtl" column="text_ttl"/>
         <result property="textCnt" column="text_cnt"/>
+        <result property="textUrl" column="text_url"/>
         <result property="regDt" column="reg_dt"/>
         <result property="fileMngId" column="file_mng_id"/>
         <result property="textTypeId" column="text_type_id"/>
+        <result property="userId" column="user_id"/>
     </resultMap>
 
 
@@ -18,15 +21,21 @@
      -->
     <insert id="insertText" parameterType="TextVO">
         INSERT INTO text (text_id
+                         ,text_ttl
                          ,text_cnt
+                         ,text_url
                          ,reg_dt
                          ,file_mng_id
                          ,text_type_id
+                         ,user_id
         ) VALUES (#{textId}
+                 ,#{textTtl}
                  ,#{textCnt}
+                 ,#{textUrl}
                  ,now()
                  ,#{fileMngId}
                  ,#{textTypeId}
+                 ,#{userId}
                  );
     </insert>
 
@@ -47,10 +56,13 @@
      -->
     <select id="selectTextList"  resultMap="textMap">
         SELECT text_id
+              ,text_ttl
               ,text_cnt
+              ,text_url
               ,reg_dt
               ,file_mng_id
               ,text_type_id
+              ,user_id
         FROM text
         ORDER BY text_id DESC
         LIMIT #{pageSize}
@@ -64,11 +76,13 @@
      -->
     <select id="selectOneText" parameterType="HashMap" resultType="HashMap">
         SELECT text_id
+              ,text_ttl
              , text_cnt
+              ,text_url
              , reg_dt
              , file_mng_id
              , text_type_id
-
+              ,user_id
         FROM text
         WHERE text_id = #{textId}
         ORDER BY text_id DESC
@@ -81,7 +95,9 @@
      -->
     <update id="textUpdate" parameterType="TextVO">
         UPDATE text
-        SET text_cnt = #{textCnt}
+        SET text_ttl = #{textTtl}
+          , text_cnt = #{textCnt}
+          , text_url = #{textUrl}
           , file_mng_id = #{fileMngId}
           , text_type_id = #{textTypeId}
         WHERE text_id = #{textId}
@@ -112,9 +128,15 @@
                 <when test="option == 'textId'">
                     AND text_id LIKE CONCAT('%', #{keyword}, '%')
                 </when>
+                <when test="option == 'textTtl'">
+                    AND text_ttl LIKE CONCAT('%', #{keyword}, '%')
+                </when>
                 <when test="option == 'textCnt'">
                     AND text_cnt LIKE CONCAT('%', #{keyword}, '%')
                 </when>
+                <when test="option == 'userId'">
+                    AND user_id LIKE CONCAT('%', #{keyword}, '%')
+                </when>
                 <when test="option == 'regDt'">
                     AND TO_CHAR(reg_dt, 'YYYY-MM-DD HH24:MI:SS') LIKE CONCAT('%', #{keyword}, '%')
                 </when>
Add a comment
List