guntaek 07-29
240729 김건택 단원, 사진첩 CRUD
@b6b81d99e89c5949678c384bba4eee84328a4a5b
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
@@ -64,6 +64,8 @@
                 .requestMatchers("/test/**").permitAll()
                 .requestMatchers("/studentInfo/**").permitAll() // 학생 정보 진입 허용(민수)
                 .requestMatchers("/board/**").permitAll() // 게시판 정보 진입 허용
+                .requestMatchers("/unit/**").permitAll()
+                .requestMatchers("/photo/**").permitAll()
                 .anyRequest().authenticated()); // 나머지 경로는 인증 필요
 
         // jwt 필터 처리 적용
 
src/main/java/com/takensoft/ai_lms/lms/photo/dao/PhotoDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photo/dao/PhotoDAO.java
@@ -0,0 +1,19 @@
+package com.takensoft.ai_lms.lms.photo.dao;
+
+import com.takensoft.ai_lms.lms.photo.vo.PhotoVO;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+import java.util.List;
+
+@Mapper("photoDAO")
+public interface PhotoDAO {
+    List<PhotoVO> photoList () throws Exception;
+
+    int insertPhoto(PhotoVO photoVO) throws Exception;
+
+    int updatePhoto(PhotoVO photoVO) throws Exception;
+
+    int deletePhoto(PhotoVO photoVO) throws Exception;
+
+    List<PhotoVO> photoDetail (PhotoVO photoVO) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/photo/service/Impl/PhotoServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photo/service/Impl/PhotoServiceImpl.java
@@ -0,0 +1,51 @@
+package com.takensoft.ai_lms.lms.photo.service.Impl;
+
+import com.takensoft.ai_lms.common.idgen.service.IdgenService;
+import com.takensoft.ai_lms.lms.photo.dao.PhotoDAO;
+import com.takensoft.ai_lms.lms.photo.service.PhotoService;
+import com.takensoft.ai_lms.lms.photo.vo.PhotoVO;
+import com.takensoft.ai_lms.lms.unit.service.UnitService;
+import com.takensoft.ai_lms.lms.unit.vo.UnitVO;
+import lombok.RequiredArgsConstructor;
+import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service("photoService")
+@RequiredArgsConstructor
+public class PhotoServiceImpl extends EgovAbstractServiceImpl implements PhotoService {
+
+    private final PhotoDAO photoDAO;
+    private final IdgenService photoIdgn;
+
+    @Override
+    public List<PhotoVO> photoList() throws Exception {
+        return photoDAO.photoList();
+    }
+
+    @Override
+    public int insertphoto(PhotoVO photoVO) throws Exception {
+        String photoId = photoIdgn.getNextStringId();
+        photoVO.setPhotoId(photoId);
+        int result = photoDAO.insertPhoto(photoVO);
+        return result;
+    }
+
+    @Override
+    public int updatephoto(PhotoVO photoVO) throws Exception {
+        int result = photoDAO.updatePhoto(photoVO);
+        return result;
+    }
+
+    @Override
+    public int deletephoto(PhotoVO photoVO) throws Exception {
+        int result = photoDAO.deletePhoto(photoVO);
+        return result;
+    }
+
+    @Override
+    public List<PhotoVO> photoDetail(PhotoVO photoVO) throws Exception {
+        return photoDAO.photoDetail(photoVO);
+    }
+}
 
src/main/java/com/takensoft/ai_lms/lms/photo/service/PhotoService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photo/service/PhotoService.java
@@ -0,0 +1,18 @@
+package com.takensoft.ai_lms.lms.photo.service;
+
+import com.takensoft.ai_lms.lms.photo.vo.PhotoVO;
+
+import java.util.List;
+
+public interface PhotoService {
+
+    List<PhotoVO> photoList () throws Exception;
+
+    int insertphoto(PhotoVO photoVO) throws Exception;
+
+    int updatephoto(PhotoVO photoVO) throws Exception;
+
+    int deletephoto(PhotoVO photoVO) throws Exception;
+
+    List<PhotoVO> photoDetail (PhotoVO photoVO) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/photo/vo/PhotoVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photo/vo/PhotoVO.java
@@ -0,0 +1,29 @@
+package com.takensoft.ai_lms.lms.photo.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class PhotoVO {
+
+    // 사진 아이디
+    private String photoId;
+    //사진첩 아이디
+    private String photoMngId;
+    // 등록 일자
+    private String photoDate;
+    // 좋아요 데이터
+    private int likeCount;
+    // 단원 아이디
+    private String unitId;
+    //학생 아이디
+    private String stdId;
+    // 파일 관리 아이디
+    private String fileMngId;
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/photo/web/PhotoController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photo/web/PhotoController.java
@@ -0,0 +1,54 @@
+package com.takensoft.ai_lms.lms.photo.web;
+
+import com.takensoft.ai_lms.lms.photo.service.PhotoService;
+import com.takensoft.ai_lms.lms.photo.vo.PhotoVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+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;
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping(value="/photo")
+public class PhotoController {
+
+    private final PhotoService photoService;
+
+
+    @PostMapping(path = "/photoList.json")
+    public ResponseEntity<?> unitList() throws Exception {
+        List<PhotoVO> result = photoService.photoList();
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/insertPhoto.json")
+    public ResponseEntity<?> insertUnit(@RequestBody PhotoVO photoVO) throws Exception {
+        int result = photoService.insertphoto(photoVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/updatePhoto.json")
+    public ResponseEntity<?> updateUnit(@RequestBody PhotoVO photoVO) throws Exception {
+        int result = photoService.updatephoto(photoVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/deletePhoto.json")
+    public ResponseEntity<?> deleteUnit(@RequestBody PhotoVO photoVO) throws Exception {
+        int result = photoService.deletephoto(photoVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/photoDetail.json")
+    public ResponseEntity<?> unitDetail(@RequestBody PhotoVO photoVO) throws Exception {
+        List<PhotoVO> result = photoService.photoDetail(photoVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+}
 
src/main/java/com/takensoft/ai_lms/lms/photoMng/dao/PhotoMngDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photoMng/dao/PhotoMngDAO.java
@@ -0,0 +1,8 @@
+package com.takensoft.ai_lms.lms.photoMng.dao;
+
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+@Mapper("photoMngDAO")
+public interface PhotoMngDAO {
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/photoMng/service/Impl/PhotoMngServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photoMng/service/Impl/PhotoMngServiceImpl.java
@@ -0,0 +1,4 @@
+package com.takensoft.ai_lms.lms.photoMng.service.Impl;
+
+public class PhotoMngServiceImpl {
+}
 
src/main/java/com/takensoft/ai_lms/lms/photoMng/service/PhotoMngService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photoMng/service/PhotoMngService.java
@@ -0,0 +1,4 @@
+package com.takensoft.ai_lms.lms.photoMng.service;
+
+public interface PhotoMngService {
+}
 
src/main/java/com/takensoft/ai_lms/lms/photoMng/vo/PhotoMngVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photoMng/vo/PhotoMngVO.java
@@ -0,0 +1,19 @@
+package com.takensoft.ai_lms.lms.photoMng.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class PhotoMngVO {
+
+    // 사진첩 아이디
+    private String photoMngId;
+
+    // 반 아이디
+    private String sclsId;
+}
 
src/main/java/com/takensoft/ai_lms/lms/photoMng/web/PhotoMngController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/photoMng/web/PhotoMngController.java
@@ -0,0 +1,4 @@
+package com.takensoft.ai_lms.lms.photoMng.web;
+
+public class PhotoMngController {
+}
 
src/main/java/com/takensoft/ai_lms/lms/unit/dao/UnitDAO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/unit/dao/UnitDAO.java
@@ -0,0 +1,24 @@
+package com.takensoft.ai_lms.lms.unit.dao;
+
+import com.takensoft.ai_lms.lms.unit.vo.UnitVO;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+import java.util.List;
+
+@Mapper("unitDAO")
+public interface UnitDAO {
+    // 단원 전체 조회
+    List<UnitVO> unitList() throws Exception;
+
+    // 단원 등록
+    int insertUnit(UnitVO unitVO) throws Exception;
+
+    // 단원 수정
+    int updateUnit(UnitVO unitVO) throws Exception;
+
+    // 단원 삭제
+    int deleteUnit(UnitVO unitVO) throws Exception;
+
+    // 단원 상세
+    List<UnitVO> unitDetail(UnitVO unitVO) throws Exception;
+}
 
src/main/java/com/takensoft/ai_lms/lms/unit/service/Impl/UnitServiceImpl.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/unit/service/Impl/UnitServiceImpl.java
@@ -0,0 +1,58 @@
+package com.takensoft.ai_lms.lms.unit.service.Impl;
+
+import com.takensoft.ai_lms.common.idgen.service.IdgenService;
+import com.takensoft.ai_lms.lms.unit.dao.UnitDAO;
+import com.takensoft.ai_lms.lms.unit.service.UnitService;
+import com.takensoft.ai_lms.lms.unit.vo.UnitVO;
+import lombok.RequiredArgsConstructor;
+import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+
+@Service("unitService")
+@RequiredArgsConstructor
+public class UnitServiceImpl extends EgovAbstractServiceImpl implements UnitService {
+
+    private final UnitDAO unitDAO;
+
+    private final IdgenService unitIdgn;
+
+    // 단원 전체 조회
+    @Override
+    public List<UnitVO> unitList() throws Exception {
+        return unitDAO.unitList();
+    }
+
+    // 단원 등록
+    @Override
+    public int insertUnit(UnitVO unitVO) throws Exception {
+        String unitId = unitIdgn.getNextStringId();
+        unitVO.setUnitId(unitId);
+        int result = unitDAO.insertUnit(unitVO);
+        return result;
+    }
+
+    // 단원 수정
+    @Override
+    public int updateUnit(UnitVO unitVO) throws Exception {
+        int result = unitDAO.updateUnit(unitVO);
+        return result;
+    }
+
+    // 단원 삭제
+    @Override
+    public int deleteUnit(UnitVO unitVO) throws Exception {
+        int result = unitDAO.deleteUnit(unitVO);
+        return result;
+    }
+
+    // 단원 상세
+    @Override
+    public List<UnitVO> unitDetail(UnitVO unitVO) throws Exception {
+        return unitDAO.unitDetail(unitVO);
+    }
+
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/unit/service/UnitService.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/unit/service/UnitService.java
@@ -0,0 +1,19 @@
+package com.takensoft.ai_lms.lms.unit.service;
+
+import com.takensoft.ai_lms.lms.unit.vo.UnitVO;
+
+import java.util.HashMap;
+import java.util.List;
+
+public interface UnitService {
+    List<UnitVO> unitList () throws Exception;
+
+    int insertUnit(UnitVO unitVO) throws Exception;
+
+    int updateUnit(UnitVO unitVO) throws Exception;
+
+    int deleteUnit(UnitVO unitVO) throws Exception;
+
+    List<UnitVO> unitDetail (UnitVO unitVO) throws Exception;
+
+}
 
src/main/java/com/takensoft/ai_lms/lms/unit/vo/UnitVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/unit/vo/UnitVO.java
@@ -0,0 +1,19 @@
+package com.takensoft.ai_lms.lms.unit.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class UnitVO {
+    // 단원 아이디
+    private String unitId;
+    // 책 아이디
+    private String bookId;
+    // 단원 이름
+    private String unitName;
+}
 
src/main/java/com/takensoft/ai_lms/lms/unit/web/UnitController.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/unit/web/UnitController.java
@@ -0,0 +1,60 @@
+package com.takensoft.ai_lms.lms.unit.web;
+
+import com.takensoft.ai_lms.lms.unit.service.UnitService;
+import com.takensoft.ai_lms.lms.unit.vo.UnitVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+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.HashMap;
+import java.util.List;
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping(value="/unit")
+public class UnitController {
+
+    private final UnitService unitService;
+
+    /**
+     * @author 박민혁
+     * @since 2024.07.06
+     *
+     * 테스트용 데이터 조회
+     */
+    @PostMapping(path = "/unitList.json")
+    public ResponseEntity<?> unitList() throws Exception {
+        List<UnitVO> result = unitService.unitList();
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/insertUnit.json")
+    public ResponseEntity<?> insertUnit(@RequestBody UnitVO unitVO) throws Exception {
+        int result = unitService.insertUnit(unitVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/updateUnit.json")
+    public ResponseEntity<?> updateUnit(@RequestBody UnitVO unitVO) throws Exception {
+        int result = unitService.updateUnit(unitVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/deleteUnit.json")
+    public ResponseEntity<?> deleteUnit(@RequestBody UnitVO unitVO) throws Exception {
+        int result = unitService.deleteUnit(unitVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+
+    @PostMapping(path = "/unitDetail.json")
+    public ResponseEntity<?> unitDetail(@RequestBody UnitVO unitVO) throws Exception {
+        List<UnitVO> result = unitService.unitDetail(unitVO);
+        return new ResponseEntity<>(result, HttpStatus.OK);
+    }
+}
 
src/main/resources/mybatis/mapper/lms/change.xml (deleted)
--- src/main/resources/mybatis/mapper/lms/change.xml
@@ -1,14 +0,0 @@
-<?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.test.dao.TestDAO">
-    <!--
-        작 성 자 : 박민혁
-        작 성 일 : 2024.07.25
-        내   용 : 경로 생성을 위해 만들어 놓은 xml,
-        CRUD를 이용하는데 삭제하거나 수정해서 사용해주세요
-    -->
-    <select id="testList" resultType="HashMap">
-        SELECT test_data
-        FROM test_info
-    </select>
-</mapper>(파일 끝에 줄바꿈 문자 없음)
 
src/main/resources/mybatis/mapper/lms/photo-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/photo-SQL.xml
@@ -0,0 +1,62 @@
+<?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.photo.dao.PhotoDAO">
+    <!--
+        작 성 자 : 박민혁
+        작 성 일 : 2024.07.25
+        내   용 : 경로 생성을 위해 만들어 놓은 xml,
+        CRUD를 이용하는데 삭제하거나 수정해서 사용해주세요
+    -->
+
+    <resultMap id="photoMap" type="photoVO">
+        <result property="photoId" column="photo_id"/>
+        <result property="photoMngId" column="photo_mng_id"/>
+        <result property="photoDate" column="photo_dt"/>
+        <result property="likeCount" column="like_data"/>
+        <result property="unitId" column="unit_id"/>
+        <result property="stdId" column="std_id"/>
+        <result property="fileMngId" column="file_mng_id"/>
+    </resultMap>
+
+    <select id="photoList" resultType="com.takensoft.ai_lms.lms.photo.vo.PhotoVO">
+        SELECT unit_id
+            , book_id
+            , unit_nm
+        FROM unit
+    </select>
+
+    <insert id="insertphoto" parameterType="PhotoVO">
+        INSERT INTO unit (
+            unit_id
+            , book_id
+            , unit_nm
+        ) VALUES (
+              #{unitId}
+            , #{bookId}
+            , #{unitName}
+        )
+    </insert>
+
+    <update id="updatephoto" parameterType="PhotoVO">
+        UPDATE unit
+        SET    unit_id = #{unitId}
+             , book_id = #{bookId}
+             , unit_nm = #{unitName}
+        WHERE  unit_id = #{unitId}
+    </update>
+
+    <delete id="deletephoto" parameterType="PhotoVO">
+        DELETE
+        FROM  unit
+        WHERE unit_id = #{unitId}
+    </delete>
+
+    <select id="photoDetail" parameterType="PhotoVO" resultType="com.takensoft.ai_lms.lms.photo.vo.PhotoVO">
+        SELECT unit_id
+            , book_id
+            , unit_nm
+        WHERE unit_id = #{unitId}
+        FROM unit
+    </select>
+
+</mapper>(파일 끝에 줄바꿈 문자 없음)
 
src/main/resources/mybatis/mapper/lms/unit-SQL.xml (added)
+++ src/main/resources/mybatis/mapper/lms/unit-SQL.xml
@@ -0,0 +1,58 @@
+<?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.unit.dao.UnitDAO">
+    <!--
+        작 성 자 : 박민혁
+        작 성 일 : 2024.07.25
+        내   용 : 경로 생성을 위해 만들어 놓은 xml,
+        CRUD를 이용하는데 삭제하거나 수정해서 사용해주세요
+    -->
+
+    <resultMap id="unitMap" type="UnitVO">
+        <result property="unitId" column="unit_id"/>
+        <result property="bookId" column="book_id"/>
+        <result property="unitName" column="unit_nm"/>
+    </resultMap>
+
+    <select id="unitList" resultType="com.takensoft.ai_lms.lms.unit.vo.UnitVO">
+        SELECT unit_id
+            , book_id
+            , unit_nm
+        FROM unit
+    </select>
+
+    <insert id="insertUnit" parameterType="UnitVO">
+        INSERT INTO unit (
+            unit_id
+            , book_id
+            , unit_nm
+        ) VALUES (
+              #{unitId}
+            , #{bookId}
+            , #{unitName}
+        )
+    </insert>
+
+    <update id="updateUnit" parameterType="UnitVO">
+        UPDATE unit
+        SET    unit_id = #{unitId}
+             , book_id = #{bookId}
+             , unit_nm = #{unitName}
+        WHERE  unit_id = #{unitId}
+    </update>
+
+    <delete id="deleteUnit" parameterType="UnitVO">
+        DELETE
+        FROM  unit
+        WHERE unit_id = #{unitId}
+    </delete>
+
+    <select id="unitDetail" parameterType="UnitVO" resultType="com.takensoft.ai_lms.lms.unit.vo.UnitVO">
+        SELECT unit_id
+            , book_id
+            , unit_nm
+        WHERE unit_id = #{unitId}
+        FROM unit
+    </select>
+
+</mapper>(파일 끝에 줄바꿈 문자 없음)
Add a comment
List