woals 07-25
학생 정보 받아오고 학생 질문 수정하는 기능 추가
@8955dc479b7dc5e077c6c87d1f41ad603b1c7e3f
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("/studentInfo/**").permitAll() // 학생 정보 진입 허용(민수)
                 .anyRequest().authenticated()); // 나머지 경로는 인증 필요
 
         // jwt 필터 처리 적용
 
src/main/java/com/takensoft/ai_lms/lms/student/dao/StudentInfoDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/student/dao/StudentInfoDAO.java
@@ -0,0 +1,30 @@
+package com.takensoft.ai_lms.lms.student.dao;
+
+import com.takensoft.ai_lms.lms.student.vo.StudentInfoVO;
+import org.apache.ibatis.annotations.Param;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+/**
+ * @author 권민수
+ * @since 2024.07.25
+ *
+ * 학생 정보 DAO 클래스
+ */
+
+@Mapper("studentInfoDAO")
+public interface StudentInfoDAO {
+
+    // 학생 정보 불러오기
+    StudentInfoVO getStudentInfo(@Param("userId") String userId);
+
+    // 학생 질문 사항 수정하기
+    void updateStudentQuestion(@Param("userId") String userId, @Param("studentQuestion") String studentQuestion);
+
+}
+
+// users(user_id) - user_nm(사용자 이름),
+// users(user_id) -> institution(ednst_id) - ednst_nm(기관명),
+// user_class(user_id) -> class(scls_id) -> grade(sgrd_id) - grd_no(학년),
+// user_class(user_id) -> class(scls_id) - scls_nm(반 이름),
+// user_class(user_id) - stn_qna(학생 질문),
+// + 오늘의 공부, 최근 학습 히스토리(파일 끝에 줄바꿈 문자 없음)
 
src/main/java/com/takensoft/ai_lms/lms/student/dto/UpdateStudentQuestionDTO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/student/dto/UpdateStudentQuestionDTO.java
@@ -0,0 +1,18 @@
+package com.takensoft.ai_lms.lms.student.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author 권민수
+ * @since 2024.07.25
+ *
+ * 학생 질문 수정용 DTO 클래스
+ */
+
+@Getter
+@Setter
+public class UpdateStudentQuestionDTO {
+    private String userId;
+    private String studentQuestion;
+}
 
src/main/java/com/takensoft/ai_lms/lms/student/service/Impl/StudentInfoServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/student/service/Impl/StudentInfoServiceImpl.java
@@ -0,0 +1,31 @@
+package com.takensoft.ai_lms.lms.student.service.Impl;
+
+import com.takensoft.ai_lms.lms.student.dao.StudentInfoDAO;
+import com.takensoft.ai_lms.lms.student.service.StudentInfoService;
+import com.takensoft.ai_lms.lms.student.vo.StudentInfoVO;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author 권민수
+ * @since 2024.07.25
+ *
+ * 학생 정보 관련 서비스
+ */
+
+@Service
+@RequiredArgsConstructor
+public class StudentInfoServiceImpl implements StudentInfoService {
+
+    private final StudentInfoDAO studentInfoDAO;
+
+    @Override
+    public StudentInfoVO getStudentInfo(String userId) {
+        return studentInfoDAO.getStudentInfo(userId);
+    }
+
+    @Override
+    public void updateStudentQuestion(String userId, String studentQuestion) {
+        studentInfoDAO.updateStudentQuestion(userId, studentQuestion);
+    }
+}
 
src/main/java/com/takensoft/ai_lms/lms/student/service/StudentInfoService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/student/service/StudentInfoService.java
@@ -0,0 +1,20 @@
+package com.takensoft.ai_lms.lms.student.service;
+
+import com.takensoft.ai_lms.lms.student.vo.StudentInfoVO;
+
+/**
+ * @author 권민수
+ * @since 2024.07.25
+ *
+ * 학생 정보 관련 인터페이스
+ */
+
+public interface StudentInfoService {
+
+    // 학생 정보 불러오기
+    StudentInfoVO getStudentInfo(String userId);
+
+    // 학생 질문 사항 수정하기
+    void updateStudentQuestion(String userId, String studentQuestion);
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/student/vo/StudentInfoVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/student/vo/StudentInfoVO.java
@@ -0,0 +1,23 @@
+package com.takensoft.ai_lms.lms.student.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author 권민수
+ * @since 2024.07.25
+ *
+ * 학생 불러오는 정보 VO 클래스
+ */
+
+@Setter
+@Getter
+public class StudentInfoVO {
+    private String studentName;
+    private String institutionName;
+    private String grade;
+    private String className;
+    private String studentQuestion;
+
+}
+
 
src/main/java/com/takensoft/ai_lms/lms/student/web/StudentInfoController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/student/web/StudentInfoController.java
@@ -0,0 +1,37 @@
+package com.takensoft.ai_lms.lms.student.web;
+
+import com.takensoft.ai_lms.lms.student.dto.UpdateStudentQuestionDTO;
+import com.takensoft.ai_lms.lms.student.service.StudentInfoService;
+import com.takensoft.ai_lms.lms.student.vo.StudentInfoVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author 권민수
+ * @since 2024.07.25
+ *
+ * 학생 정보 관련 컨트롤러 클래스
+ */
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping("/studentInfo")
+public class StudentInfoController {
+
+    private final StudentInfoService studentInfoService;
+
+    // 학생 정보 불러오는 api
+    @GetMapping("/student/{userId}")
+    public StudentInfoVO getStudentInfo(@PathVariable String userId) {
+        return studentInfoService.getStudentInfo(userId);
+    }
+
+    // 학생 질문 사항 수정하는 api
+    @PostMapping("/student/updateQuestion")
+    public void updateStudentQuestion(@RequestBody UpdateStudentQuestionDTO request) {
+        studentInfoService.updateStudentQuestion(request.getUserId(), request.getStudentQuestion());
+    }
+
+}
 
src/main/resources/mybatis/mapper/lms/student-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/student-SQL.xml
@@ -0,0 +1,40 @@
+<?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.student.dao.StudentInfoDAO">
+
+    <!--
+        작 성 자 : 권민수
+        작 성 일 : 2024.07.25
+        내   용 : 학생 정보 관련 sql 매핑 xml 문서
+    -->
+
+    <resultMap id="StudentInfoResultMap" type="com.takensoft.ai_lms.lms.student.vo.StudentInfoVO">
+        <result property="studentName" column="studentName"/>
+        <result property="institutionName" column="institutionName"/>
+        <result property="grade" column="grade"/>
+        <result property="className" column="className"/>
+        <result property="studentQuestion" column="studentQuestion"/>
+    </resultMap>
+
+    <select id="getStudentInfo" resultType="com.takensoft.ai_lms.lms.student.vo.StudentInfoVO">
+        SELECT
+            u.user_nm AS studentName,
+            i.ednst_nm AS institutionName,
+            g.grd_no AS grade,
+            c.scls_nm AS className,
+            uc.stn_qna AS studentQuestion
+        FROM users u
+                 JOIN institution i ON u.ednst_id = i.ednst_id
+                 JOIN user_class uc ON u.user_id = uc.user_id
+                 JOIN class c ON uc.scls_id = c.scls_id
+                 JOIN grade g ON c.sgrd_id = g.sgrd_id
+        WHERE u.user_id = #{userId}
+    </select>
+
+    <update id="updateStudentQuestion">
+        UPDATE user_class
+        SET stn_qna = #{studentQuestion}
+        WHERE user_id = #{userId}
+    </update>
+
+</mapper>(파일 끝에 줄바꿈 문자 없음)
Add a comment
List