diff --git a/build.gradle b/build.gradle index 8e950f8..af50701 100644 --- a/build.gradle +++ b/build.gradle @@ -54,6 +54,7 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-api:0.11.2' implementation 'io.jsonwebtoken:jjwt-impl:0.11.2' implementation 'io.jsonwebtoken:jjwt-gson:0.11.2' +// runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' } tasks.named('test') { diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/controller/FileController.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/controller/FileController.java index dc9096b..206379a 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/controller/FileController.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/controller/FileController.java @@ -23,12 +23,12 @@ public class FileController { private final FileService fileService; @PostMapping - public ResponseData> fileUpload(@RequestParam Long id, @RequestParam FileCategory fileCategory, @RequestPart List fileList) { - return fileService.fileUpload(id, fileCategory, fileList); + public ResponseData> fileUpload(@RequestParam Long id, @RequestParam FileCategory file_category, @RequestPart List file_list) { + return fileService.fileUpload(id, file_category, file_list); } @GetMapping("{id}") - public ResponseData> getFiles(@PathVariable Long id, @RequestParam FileCategory fileCategory) { - return fileService.getFiles(id, fileCategory); + public ResponseData> getFiles(@PathVariable Long id, @RequestParam FileCategory file_category) { + return fileService.getFiles(id, file_category); } } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/dto/FileRes.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/dto/FileRes.java index 9cd96fd..ea389d7 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/dto/FileRes.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/dto/FileRes.java @@ -3,7 +3,6 @@ import kr.hs.dgsw.SOPO_server_v2.domain.file.entity.FileEntity; import lombok.Builder; -@Builder public record FileRes ( String fileName, String fileUrl diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java index 8e4f7b2..d85be88 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/entity/FileEntity.java @@ -17,9 +17,11 @@ import kr.hs.dgsw.SOPO_server_v2.global.common.entity.BaseTimeEntity; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import lombok.experimental.SuperBuilder; @Getter +@Setter @Entity @Table(name = "tbl_file") @NoArgsConstructor diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/repository/FileRepository.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/repository/FileRepository.java index 12e6ba9..65eb68a 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/repository/FileRepository.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/repository/FileRepository.java @@ -6,6 +6,6 @@ import java.util.List; public interface FileRepository extends JpaRepository { - List findByBoard_BoardId(Long boardId); - List findByContest_ContestId(Long contestId); + List findByBoardBoardId(Long boardId); + List findByContestContestId(Long contestId); } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/service/FileService.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/service/FileService.java index f2dca8a..1713137 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/service/FileService.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/file/service/FileService.java @@ -1,8 +1,5 @@ package kr.hs.dgsw.SOPO_server_v2.domain.file.service; -import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.model.ObjectMetadata; -import com.amazonaws.services.s3.model.PutObjectRequest; import kr.hs.dgsw.SOPO_server_v2.domain.board.entity.BoardEntity; import kr.hs.dgsw.SOPO_server_v2.domain.board.repository.BoardRepository; import kr.hs.dgsw.SOPO_server_v2.domain.contest.entity.ContestEntity; @@ -11,119 +8,78 @@ import kr.hs.dgsw.SOPO_server_v2.domain.file.entity.FileEntity; import kr.hs.dgsw.SOPO_server_v2.domain.file.enums.FileCategory; import kr.hs.dgsw.SOPO_server_v2.domain.file.repository.FileRepository; +import kr.hs.dgsw.SOPO_server_v2.global.common.aws.S3Service; +import kr.hs.dgsw.SOPO_server_v2.global.common.aws.dto.S3Res; import kr.hs.dgsw.SOPO_server_v2.global.error.custom.board.BoardNotFound; import kr.hs.dgsw.SOPO_server_v2.global.error.custom.contest.ContestNotFound; import kr.hs.dgsw.SOPO_server_v2.global.response.ResponseData; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class FileService { - @Value("${cloud.aws.s3.bucket}") - private String bucket; - - private final AmazonS3 amazonS3; - + private final S3Service s3Service; private final FileRepository fileRepository; - private final BoardRepository boardRepository; - private final ContestRepository contestRepository; @Transactional public ResponseData> fileUpload(Long id, FileCategory fileCategory, List fileList) { - List fileLists = new ArrayList<>(); - - try { - - for (MultipartFile file : fileList) { - String fileName = file.getOriginalFilename(); - - ObjectMetadata metadata = new ObjectMetadata(); - metadata.setContentType(file.getContentType()); - metadata.setContentLength(file.getSize()); - - // S3에 저장하는 코드 - amazonS3.putObject( - new PutObjectRequest(bucket, fileName, file.getInputStream(), metadata) - ); - - // FileRes 형식으로 만들기 - FileRes oneFile = FileRes.builder() - .fileName(fileName) - .fileUrl(amazonS3.getUrl(bucket, fileName).toString()) - .build(); - - fileLists.add(oneFile); - - // 파일 업데이트 하는 코드 - if (fileCategory == FileCategory.BOARD) { - - BoardEntity board = boardRepository.findById(id) - .orElseThrow(() -> BoardNotFound.EXCEPTION); - - // DB에 저장하는 코드 - FileEntity fileEntity = FileEntity.builder() - .fileName(fileName) - .fileCategory(fileCategory) - .fileUrl(amazonS3.getUrl(bucket, fileName).toString()) - .board(board) - .build(); - fileRepository.save(fileEntity); - - // 현재 게시물의 파일 목록에 새로 업로드된 파일 추가 - List files = board.getFile(); - if (files == null) { - files = new ArrayList<>(); - } - files.add(fileEntity); - board.setFile(files); // BoardEntity의 파일 목록 직접 수정 - - // 게시물 엔티티를 DB에 저장하여 파일 목록 반영 - boardRepository.save(board); - - } else if (fileCategory == FileCategory.CONTEST) { - ContestEntity contest = contestRepository.findById(id) - .orElseThrow(() -> ContestNotFound.EXCEPTION); - - // DB에 저장하는 코드 - FileEntity fileEntity = FileEntity.builder() - .fileName(fileName) - .fileCategory(fileCategory) - .fileUrl(amazonS3.getUrl(bucket, fileName).toString()) - .contest(contest) - .build(); - - fileRepository.save(fileEntity); - - // 현재 게시물의 파일 목록에 새로 업로드된 파일 추가 - List files = contest.getFile(); - if (files == null) { - files = new ArrayList<>(); - } - files.add(fileEntity); - contest.setFile(files); // BoardEntity의 파일 목록 직접 수정 - - // 게시물 엔티티를 DB에 저장하여 파일 목록 반영 - contestRepository.save(contest); - } + List fileRes = new ArrayList<>(); + for (MultipartFile file : fileList) { + S3Res s3Res = s3Service.upload(file, fileCategory.toString()); + FileEntity fileEntity = createFileEntity(file, s3Res.url(), fileCategory); + + if (fileCategory == FileCategory.BOARD) { + BoardEntity board = boardRepository.findById(id) + .orElseThrow(() -> BoardNotFound.EXCEPTION); + saveFileEntity(fileEntity, board.getFile(), board, boardRepository::save); + } else if (fileCategory == FileCategory.CONTEST) { + ContestEntity contest = contestRepository.findById(id) + .orElseThrow(() -> ContestNotFound.EXCEPTION); + saveFileEntity(fileEntity, contest.getFile(), contest, contestRepository::save); } - } catch (IOException e) { - throw new RuntimeException("Error uploading file to S3", e); + fileRes.add(FileRes.of(fileEntity)); + } + + return ResponseData.of(HttpStatus.OK, "파일 업로드 완료", fileRes); + } + + private FileEntity createFileEntity(MultipartFile file, String url, FileCategory fileCategory) { + return FileEntity.builder() + .fileName(file.getOriginalFilename()) + .fileCategory(fileCategory) + .fileUrl(url) + .build(); + } + + private void saveFileEntity(FileEntity fileEntity, List files, T entity, Consumer saveFunction) { + if (files == null) { + files = new ArrayList<>(); + } + files.add(fileEntity); + + if (entity instanceof BoardEntity) { + fileEntity.setBoard((BoardEntity) entity); + ((BoardEntity) entity).setFile(files); + } else if (entity instanceof ContestEntity) { + fileEntity.setContest((ContestEntity) entity); + ((ContestEntity) entity).setFile(files); } - return ResponseData.of(HttpStatus.OK, "파일 업로드 완료", fileLists); + + fileRepository.save(fileEntity); + saveFunction.accept(entity); } public ResponseData> getFiles(Long id, FileCategory fileCategory) { @@ -132,19 +88,13 @@ public ResponseData> getFiles(Long id, FileCategory fileCategory) if (fileCategory == FileCategory.BOARD) { - fileList = fileRepository.findByBoard_BoardId(id).stream() - .map(file -> FileRes.builder() - .fileName(file.getFileName()) - .fileUrl(file.getFileUrl()) - .build()) + fileList = fileRepository.findByBoardBoardId(id).stream() + .map(FileRes::of) .collect(Collectors.toList()); } else if (fileCategory == FileCategory.CONTEST) { - fileList = fileRepository.findByContest_ContestId(id).stream() - .map(file -> FileRes.builder() - .fileName(file.getFileName()) - .fileUrl(file.getFileUrl()) - .build()) + fileList = fileRepository.findByContestContestId(id).stream() + .map(FileRes::of) .collect(Collectors.toList()); } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java index 76b80be..d53ce2e 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberController.java @@ -23,4 +23,6 @@ public class MemberController { public Response deleteMember(){ return memberService.deleteMember(); } + + } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java index a0f764c..7152615 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/controller/MemberProfileController.java @@ -19,7 +19,7 @@ public class MemberProfileController { private final MemberProfileService memberProfileService; @Operation(description = "멤버 프로필 수정") - @PatchMapping("") + @PatchMapping public Response modifyMember( @RequestBody MemberModifyReq memberModifyReq) { return memberProfileService.memberModify(memberModifyReq); @@ -30,5 +30,7 @@ public Response modifyMember( public ResponseData readProfile(){ return memberProfileService.readProfile(); } + + } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/req/MemberModifyReq.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/req/MemberModifyReq.java index c507be7..ae029a2 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/req/MemberModifyReq.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/presentation/dto/req/MemberModifyReq.java @@ -7,6 +7,7 @@ public record MemberModifyReq( @Email String memberEmail, String authCode, - String memberPassword + String memberPassword, + String memberSchool ) { } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java index 69186c8..811b411 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/member/service/MemberProfileService.java @@ -1,6 +1,6 @@ package kr.hs.dgsw.SOPO_server_v2.domain.member.service; -import kr.hs.dgsw.SOPO_server_v2.domain.auth.service.AuthEmailService; +import kr.hs.dgsw.SOPO_server_v2.domain.auth.service.AuthEmailService; import kr.hs.dgsw.SOPO_server_v2.domain.member.entity.MemberEntity; import kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.req.MemberModifyReq; import kr.hs.dgsw.SOPO_server_v2.domain.member.presentation.dto.res.ReadProfileRes; @@ -11,6 +11,7 @@ import kr.hs.dgsw.SOPO_server_v2.global.response.Response; import kr.hs.dgsw.SOPO_server_v2.global.response.ResponseData; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpStatus; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Component; @@ -30,8 +31,8 @@ public Response memberModify(MemberModifyReq memberModifyReq) { String memberEmail = memberModifyReq.memberEmail(); String authCode = memberModifyReq.authCode(); - if (memberEmail != null && !memberEmail.isEmpty()) { - if (authCode == null || authCode.isEmpty()) { + if (StringUtils.isNotBlank(memberEmail)) { + if (StringUtils.isBlank(authCode)) { throw NeedAuthCode.EXCEPTION; } if (!authEmailService.verifiedCode(memberEmail, authCode)) { @@ -41,15 +42,20 @@ public Response memberModify(MemberModifyReq memberModifyReq) { } String memberPassword = memberModifyReq.memberPassword(); - if (memberPassword != null) { + if (StringUtils.isNotBlank(memberPassword)) { member.setMemberPassword(new BCryptPasswordEncoder().encode(memberPassword)); } String memberName = memberModifyReq.memberName(); - if (memberName != null) { + if (StringUtils.isNotBlank(memberName)) { member.setMemberName(memberName); } + String memberSchool = memberModifyReq.memberSchool(); + if (StringUtils.isNotBlank(memberSchool)) { + member.setMemberSchool(memberSchool); + } + memberRepository.save(member); return Response.of(HttpStatus.OK, "성공"); diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/entity/PortfolioEntity.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/entity/PortfolioEntity.java index 2427535..f2e23f2 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/entity/PortfolioEntity.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/entity/PortfolioEntity.java @@ -26,7 +26,6 @@ public class PortfolioEntity extends BaseTimeEntity { @Column(name = "portfolio_id") private Long portfolioId; - @Column(name = "portfolio_title") private String portfolioTitle; diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/controller/PortfolioController.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/controller/PortfolioController.java index 896bfc2..31e9615 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/controller/PortfolioController.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/controller/PortfolioController.java @@ -18,6 +18,12 @@ public class PortfolioController { private final PortfolioService portfolioService; + public ResponseData generatePortfolio() { + return portfolioService.generatePortfolio(); + } + + + @Operation(description = "최신 포트폴리오 불러오기") @GetMapping public ResponseData> loadPortfolio( @@ -25,4 +31,6 @@ public ResponseData> loadPortfolio( ){ return portfolioService.pagingPortfolio(pageRequest); } + + } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/dto/req/ModifyPortfolioReq.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/dto/req/ModifyPortfolioReq.java new file mode 100644 index 0000000..1ddd905 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/presentation/dto/req/ModifyPortfolioReq.java @@ -0,0 +1,10 @@ +package kr.hs.dgsw.SOPO_server_v2.domain.portfolio.presentation.dto.req; + +import java.util.List; + +public record ModifyPortfolioReq( + String title, + String content, + List tag +) { +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/service/PortfolioService.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/service/PortfolioService.java index 194550a..3a2966f 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/service/PortfolioService.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/domain/portfolio/service/PortfolioService.java @@ -2,9 +2,12 @@ import kr.hs.dgsw.SOPO_server_v2.domain.portfolio.entity.PortfolioEntity; import kr.hs.dgsw.SOPO_server_v2.domain.portfolio.enums.PortfolioState; +import kr.hs.dgsw.SOPO_server_v2.domain.portfolio.presentation.dto.req.ModifyPortfolioReq; import kr.hs.dgsw.SOPO_server_v2.domain.portfolio.presentation.dto.res.LoadPortfolioRes; import kr.hs.dgsw.SOPO_server_v2.domain.portfolio.repository.PortfolioRepository; +import kr.hs.dgsw.SOPO_server_v2.global.infra.security.GetCurrentMember; import kr.hs.dgsw.SOPO_server_v2.global.page.PageRequest; +import kr.hs.dgsw.SOPO_server_v2.global.response.Response; import kr.hs.dgsw.SOPO_server_v2.global.response.ResponseData; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -17,6 +20,25 @@ @RequiredArgsConstructor public class PortfolioService { private final PortfolioRepository portfolioRepository; + private final GetCurrentMember getCurrentMember; + + public ResponseData generatePortfolio(){ + PortfolioEntity portfolioEntity = portfolioRepository.save( + PortfolioEntity.builder() + .portfolioContent(null) + .portfolioTitle(null) + .portfolioState(PortfolioState.PENDING) + .tagEntity(null) + .member(getCurrentMember.current()) + .build()); + + return ResponseData.of(HttpStatus.OK, "포트폴리오 생성 성공", portfolioEntity.getPortfolioId()); + } + + public Response modifyPortfolio(ModifyPortfolioReq generatePortfolioReq){ + return null; + + } public ResponseData> pagingPortfolio(PageRequest pageRequest){ List portfolioEntities = portfolioRepository.findPortfoliosByState(PortfolioState.ACTIVE); @@ -29,4 +51,5 @@ public ResponseData> pagingPortfolio(PageRequest pageRequ return ResponseData.of(HttpStatus.OK, "성공", loadPortfolioReqList); } + } diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/common/aws/S3Service.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/common/aws/S3Service.java new file mode 100644 index 0000000..92bdcc6 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/common/aws/S3Service.java @@ -0,0 +1,59 @@ +package kr.hs.dgsw.SOPO_server_v2.global.common.aws; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.model.CannedAccessControlList; +import com.amazonaws.services.s3.model.ObjectMetadata; +import com.amazonaws.services.s3.model.PutObjectRequest; +import kr.hs.dgsw.SOPO_server_v2.global.common.aws.dto.S3Res; +import kr.hs.dgsw.SOPO_server_v2.global.config.S3Config; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class S3Service { + + private final AmazonS3 amazonS3; + private final S3Config s3Config; + + public S3Res upload(MultipartFile file, String dirName){ + String originFileName = file.getOriginalFilename(); + + String uuid = UUID.randomUUID().toString(); + assert originFileName != null; + String uniqueFileName = uuid + "_" + originFileName.replaceAll("\\s", "_"); + + String fileName = dirName + "/" + uniqueFileName; + + ObjectMetadata objectMetadata = new ObjectMetadata(); + objectMetadata.setContentLength(file.getSize()); + objectMetadata.setContentType(file.getContentType()); + + try(InputStream inputStream = file.getInputStream()) { + amazonS3.putObject(new PutObjectRequest(s3Config.bucket, fileName, inputStream, objectMetadata) + .withCannedAcl(CannedAccessControlList.PublicRead)); + } catch(IOException e) { + throw new IllegalArgumentException(String.format("파일을 올리는데 실패했습니다. %s", fileName)); + } + String url = amazonS3.getUrl(s3Config.bucket, fileName).toString(); + return S3Res.of(url); + } + + public void deleteFile(String fileName) { + String decodedFileName = URLDecoder.decode(fileName, StandardCharsets.UTF_8); + amazonS3.deleteObject(s3Config.bucket, decodedFileName); + } + + public S3Res updateFile(MultipartFile newFile, String oldFileName, String dirName) throws IOException { + deleteFile(oldFileName); + return upload(newFile, dirName); + } + +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/common/aws/dto/S3Res.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/common/aws/dto/S3Res.java new file mode 100644 index 0000000..5ffc3d1 --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/common/aws/dto/S3Res.java @@ -0,0 +1,11 @@ +package kr.hs.dgsw.SOPO_server_v2.global.common.aws.dto; + +public record S3Res( + String url +) { + public static S3Res of(String url) { + return new S3Res( + url + ); + } +} diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/config/S3Config.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/config/S3Config.java index dd45fde..ec933ca 100644 --- a/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/config/S3Config.java +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/config/S3Config.java @@ -20,6 +20,9 @@ public class S3Config { @Value("${cloud.aws.region.static}") private String region; + @Value("${cloud.aws.s3.bucket}") + public String bucket; + @Bean public AmazonS3 amazonS3Client() { BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); diff --git a/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/response/ResponseException.java b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/response/ResponseException.java new file mode 100644 index 0000000..7a25c8d --- /dev/null +++ b/src/main/java/kr/hs/dgsw/SOPO_server_v2/global/response/ResponseException.java @@ -0,0 +1,4 @@ +package kr.hs.dgsw.SOPO_server_v2.global.response; + +public record ResponseException() { +}