From 74da8c3e1e175800b782f66b280cf709f3f6afea Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sun, 11 Feb 2024 14:51:49 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20migrateProfessorImage=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csereal/core/member/api/ProfessorController.kt | 8 ++++++++ .../csereal/core/member/service/ProfessorService.kt | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/api/ProfessorController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/api/ProfessorController.kt index 548f39f9..d4e0f771 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/api/ProfessorController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/api/ProfessorController.kt @@ -62,4 +62,12 @@ class ProfessorController( ): ResponseEntity> { return ResponseEntity.ok(professorService.migrateProfessors(requestList)) } + + @PatchMapping("/migragteImage/{professorId}") + fun migrateProfessorImage( + @PathVariable professorId: Long, + @RequestPart("mainImage") mainImage: MultipartFile + ): ResponseEntity { + return ResponseEntity.ok(professorService.migrateProfessorImage(professorId, mainImage)) + } } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/service/ProfessorService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/service/ProfessorService.kt index 210c8f58..ebc22b35 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/service/ProfessorService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/service/ProfessorService.kt @@ -28,6 +28,7 @@ interface ProfessorService { ): ProfessorDto fun deleteProfessor(professorId: Long) fun migrateProfessors(requestList: List): List + fun migrateProfessorImage(professorId: Long, mainImage: MultipartFile): ProfessorDto } @Service @@ -225,4 +226,16 @@ class ProfessorServiceImpl( } return list } + + @Transactional + override fun migrateProfessorImage(professorId: Long, mainImage: MultipartFile): ProfessorDto { + val professor = professorRepository.findByIdOrNull(professorId) + ?: throw CserealException.Csereal404("해당 교수님을 찾을 수 없습니다. professorId: $professorId") + + mainImageService.uploadMainImage(professor, mainImage) + + val imageURL = mainImageService.createImageURL(professor.mainImage) + + return ProfessorDto.of(professor, imageURL) + } } From dcae256d7f6529ab11b5b0fc3aa35aaba31d806d Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Thu, 15 Feb 2024 22:31:20 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20migrateResearchImageAndAttachments?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/research/api/ResearchController.kt | 11 ++++++++ .../core/research/service/ResearchService.kt | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt index d6c55a3e..1f54a247 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt @@ -102,6 +102,17 @@ class ResearchController( return ResponseEntity.ok(researchService.migrateLabs(requestList)) } + @PatchMapping("/migrate/{researchId}") + fun migrateResearchDetailImageAndAttachments( + @PathVariable researchId: Long, + @RequestPart("mainImage") mainImage: MultipartFile?, + @RequestPart("attachments") attachments: List? + ): ResponseEntity { + return ResponseEntity.ok( + researchService.migrateResearchDetailImageAndAttachments(researchId, mainImage, attachments) + ) + } + @GetMapping("/search/top") fun searchTop( @RequestParam(required = true) keyword: String, diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt index 48b92497..8d1b4319 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt @@ -35,6 +35,11 @@ interface ResearchService { fun updateLab(labId: Long, request: LabUpdateRequest, pdf: MultipartFile?): LabDto fun migrateResearchDetail(requestList: List): List fun migrateLabs(requestList: List): List + fun migrateResearchDetailImageAndAttachments( + researchId: Long, + mainImage: MultipartFile?, + attachments: List? + ): ResearchDto } @Service @@ -319,4 +324,27 @@ class ResearchServiceImpl( } return list } + + @Transactional + override fun migrateResearchDetailImageAndAttachments( + researchId: Long, + mainImage: MultipartFile?, + attachments: List? + ): ResearchDto { + val researchDetail = researchRepository.findByIdOrNull(researchId) + ?: throw CserealException.Csereal404("해당 연구내용을 찾을 수 없습니다.") + + if (mainImage != null) { + mainImageService.uploadMainImage(researchDetail, mainImage) + } + + if (attachments != null) { + attachmentService.uploadAllAttachments(researchDetail, attachments) + } + + val imageURL = mainImageService.createImageURL(researchDetail.mainImage) + val attachmentResponses = attachmentService.createAttachmentResponses(researchDetail.attachments) + + return ResearchDto.of(researchDetail, imageURL, attachmentResponses) + } } From f0a10d6f5aabbe6cebf7f7e722d5a092213ef940 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Thu, 15 Feb 2024 22:37:58 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20migrateStaffImage=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csereal/core/member/api/StaffController.kt | 8 ++++++++ .../csereal/core/member/service/StaffService.kt | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt index eed5164c..b491aaf5 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/api/StaffController.kt @@ -55,4 +55,12 @@ class StaffController( ): ResponseEntity> { return ResponseEntity.ok(staffService.migrateStaff(requestList)) } + + @PatchMapping("/migrateImage/{staffId}") + fun migrateStaffImage( + @PathVariable staffId: Long, + @RequestPart("mainImage") mainImage: MultipartFile + ): ResponseEntity { + return ResponseEntity.ok(staffService.migrateStaffImage(staffId, mainImage)) + } } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt index 90a527c9..e0b37bca 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/member/service/StaffService.kt @@ -20,6 +20,7 @@ interface StaffService { fun updateStaff(staffId: Long, updateStaffRequest: StaffDto, mainImage: MultipartFile?): StaffDto fun deleteStaff(staffId: Long) fun migrateStaff(requestList: List): List + fun migrateStaffImage(staffId: Long, mainImage: MultipartFile): StaffDto } @Service @@ -122,4 +123,16 @@ class StaffServiceImpl( return list } + + @Transactional + override fun migrateStaffImage(staffId: Long, mainImage: MultipartFile): StaffDto { + val staff = staffRepository.findByIdOrNull(staffId) + ?: throw CserealException.Csereal404("해당 행정직원을 찾을 수 없습니다.") + + mainImageService.uploadMainImage(staff, mainImage) + + val imageURL = mainImageService.createImageURL(staff.mainImage) + + return StaffDto.of(staff, imageURL) + } } From c57f7d5ae1f7b18ef61e9d2e21b2e19683d26fa7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Thu, 15 Feb 2024 23:03:51 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20migrateLabPdf=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/research/api/ResearchController.kt | 18 ++++++++++++++++-- .../core/research/service/ResearchService.kt | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt index 1f54a247..7ee21f75 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/research/api/ResearchController.kt @@ -102,14 +102,28 @@ class ResearchController( return ResponseEntity.ok(researchService.migrateLabs(requestList)) } - @PatchMapping("/migrate/{researchId}") + @PatchMapping("/migrateImageAndAttachments/{researchId}") fun migrateResearchDetailImageAndAttachments( @PathVariable researchId: Long, @RequestPart("mainImage") mainImage: MultipartFile?, @RequestPart("attachments") attachments: List? ): ResponseEntity { return ResponseEntity.ok( - researchService.migrateResearchDetailImageAndAttachments(researchId, mainImage, attachments) + researchService.migrateResearchDetailImageAndAttachments( + researchId, + mainImage, + attachments + ) + ) + } + + @PatchMapping("/lab/migratePdf/{labId}") + fun migrateLabPdf( + @PathVariable labId: Long, + @RequestPart("pdf") pdf: MultipartFile? + ): ResponseEntity { + return ResponseEntity.ok( + researchService.migrateLabPdf(labId, pdf) ) } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt index 8d1b4319..2dc97539 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/research/service/ResearchService.kt @@ -40,6 +40,7 @@ interface ResearchService { mainImage: MultipartFile?, attachments: List? ): ResearchDto + fun migrateLabPdf(labId: Long, pdf: MultipartFile?): LabDto } @Service @@ -347,4 +348,18 @@ class ResearchServiceImpl( return ResearchDto.of(researchDetail, imageURL, attachmentResponses) } + + @Transactional + override fun migrateLabPdf(labId: Long, pdf: MultipartFile?): LabDto { + val lab = labRepository.findByIdOrNull(labId) + ?: throw CserealException.Csereal404("해당 연구실을 찾을 수 없습니다.") + + var pdfURL = "" + if (pdf != null) { + val attachmentDto = attachmentService.uploadAttachmentInLabEntity(lab, pdf) + pdfURL = "${endpointProperties.backend}/v1/file/${attachmentDto.filename}" + } + + return LabDto.of(lab, pdfURL) + } } From 814531b4c4cd0ec569dac48e34b866d1d0835055 Mon Sep 17 00:00:00 2001 From: "DESKTOP-USQPRVG\\gram" Date: Sat, 17 Feb 2024 01:04:33 +0900 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20about=EC=97=90=EC=84=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EB=9E=91=20=EC=B2=A8=EB=B6=80=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csereal/core/about/api/AboutController.kt | 11 ++++++++ .../core/about/service/AboutService.kt | 25 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt b/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt index 87468574..61043e39 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/about/api/AboutController.kt @@ -102,4 +102,15 @@ class AboutController( ): ResponseEntity> { return ResponseEntity.ok(aboutService.migrateDirections(requestList)) } + + @PatchMapping("/migrateImage/{aboutId}") + fun migrateAboutImageAndAttachment( + @PathVariable aboutId: Long, + @RequestPart("mainImage") mainImage: MultipartFile?, + @RequestPart("attachments") attachments: List? + ): ResponseEntity { + return ResponseEntity.ok( + aboutService.migrateAboutImageAndAttachments(aboutId, mainImage, attachments) + ) + } } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt index ccac3db5..9ec4764b 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/about/service/AboutService.kt @@ -6,6 +6,7 @@ import com.wafflestudio.csereal.core.about.database.* import com.wafflestudio.csereal.core.about.dto.* import com.wafflestudio.csereal.core.resource.attachment.service.AttachmentService import com.wafflestudio.csereal.core.resource.mainImage.service.MainImageService +import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import org.springframework.web.multipart.MultipartFile @@ -28,6 +29,11 @@ interface AboutService { fun migrateStudentClubs(requestList: List): List fun migrateFacilities(requestList: List): List fun migrateDirections(requestList: List): List + fun migrateAboutImageAndAttachments( + aboutId: Long, + mainImage: MultipartFile?, + attachments: List? + ): AboutDto } @Service @@ -343,6 +349,25 @@ class AboutServiceImpl( return list } + @Transactional + override fun migrateAboutImageAndAttachments( + aboutId: Long, + mainImage: MultipartFile?, + attachments: List? + ): AboutDto { + val about = aboutRepository.findByIdOrNull(aboutId) + ?: throw CserealException.Csereal404("해당 소개는 존재하지 않습니다.") + + if (mainImage != null) { + mainImageService.uploadMainImage(about, mainImage) + } + + val imageURL = mainImageService.createImageURL(about.mainImage) + val attachmentResponses = attachmentService.createAttachmentResponses(about.attachments) + + return AboutDto.of(about, imageURL, attachmentResponses) + } + private fun makeStringToEnum(postType: String): AboutPostType { try { val upperPostType = postType.replace("-", "_").uppercase()