From eb0ac205f09da55a0a983ca1ed9fa7d43db925d7 Mon Sep 17 00:00:00 2001 From: JunRain Date: Mon, 11 Mar 2024 21:02:07 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[#33]=20meme=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../memetory/domain/meme/entity/Meme.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java new file mode 100644 index 00000000..f329078b --- /dev/null +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java @@ -0,0 +1,29 @@ +package com.example.memetory.domain.meme.entity; + +import com.example.memetory.domain.member.entity.Member; +import com.example.memetory.global.entity.BaseEntity; + +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Meme extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name="member_id") + private Member member; + + private String name; + private String s3Url; +} From 93f394336f5396baafb6e5e958ed3842d9c7b18e Mon Sep 17 00:00:00 2001 From: JunRain Date: Mon, 11 Mar 2024 21:03:34 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[#33]=20meme=20repositry=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/memetory/domain/meme/entity/Meme.java | 2 +- .../memetory/domain/meme/repository/MemeRepository.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 backend/memetory/src/main/java/com/example/memetory/domain/meme/repository/MemeRepository.java diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java index f329078b..9ec7b8b7 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java @@ -21,7 +21,7 @@ public class Meme extends BaseEntity { private Long id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name="member_id") + @JoinColumn(name = "member_id") private Member member; private String name; diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/repository/MemeRepository.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/repository/MemeRepository.java new file mode 100644 index 00000000..429e1ffb --- /dev/null +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/repository/MemeRepository.java @@ -0,0 +1,8 @@ +package com.example.memetory.domain.meme.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.example.memetory.domain.meme.entity.Meme; + +public interface MemeRepository extends JpaRepository { +} From 0e2eefbefc7a486a69ecc0c798823351f1223f4b Mon Sep 17 00:00:00 2001 From: JunRain Date: Mon, 11 Mar 2024 21:04:23 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[#33]=20meme=20id=20=EC=B9=BC=EB=9F=BC=20?= =?UTF-8?q?=EB=AA=87=EC=9D=84=20meme=5Fid=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/example/memetory/domain/meme/entity/Meme.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java index 9ec7b8b7..2851ffcd 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java @@ -3,6 +3,7 @@ import com.example.memetory.domain.member.entity.Member; import com.example.memetory.global.entity.BaseEntity; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; @@ -18,6 +19,7 @@ public class Meme extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "meme_id") private Long id; @ManyToOne(fetch = FetchType.LAZY) From 26037c5c2f5d385429ee1c96ed784c1ce51df991 Mon Sep 17 00:00:00 2001 From: JunRain Date: Mon, 11 Mar 2024 21:39:18 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[#33]=20shot=20stack=20=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=ED=95=9C=20webhook=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20DTO=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/meme/dto/ShotStackCallBackRequest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java new file mode 100644 index 00000000..ba5924ed --- /dev/null +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java @@ -0,0 +1,13 @@ +package com.example.memetory.domain.meme.dto; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class ShotStackCallBackRequest { + private String status; + private String url; + private String error; +} From 76065e4b283d27cf2c30bee37085efbdaafaa41f Mon Sep 17 00:00:00 2001 From: JunRain Date: Mon, 11 Mar 2024 22:08:48 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[#33]=20shot=20stack=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=BD=9C=EB=B0=B1=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/service/MemberService.java | 5 +++ .../meme/controller/MemeController.java | 37 +++++++++++++++++++ .../meme/dto/ShotStackCallBackRequest.java | 10 +++++ .../memetory/domain/meme/entity/Meme.java | 8 +++- .../domain/meme/service/MemeService.java | 20 ++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 backend/memetory/src/main/java/com/example/memetory/domain/meme/controller/MemeController.java create mode 100644 backend/memetory/src/main/java/com/example/memetory/domain/meme/service/MemeService.java diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/member/service/MemberService.java b/backend/memetory/src/main/java/com/example/memetory/domain/member/service/MemberService.java index e04da850..cb695ea0 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/member/service/MemberService.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/member/service/MemberService.java @@ -46,4 +46,9 @@ public Member getLoginMember() { return member; } + + @Transactional(readOnly = true) + public Member findById(Long id) { + return memberRepository.findById(id).orElseThrow(NotFoundMemberException::new); + } } diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/controller/MemeController.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/controller/MemeController.java new file mode 100644 index 00000000..bde20e2e --- /dev/null +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/controller/MemeController.java @@ -0,0 +1,37 @@ +package com.example.memetory.domain.meme.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +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 com.example.memetory.domain.member.entity.Member; +import com.example.memetory.domain.member.service.MemberService; +import com.example.memetory.domain.meme.dto.ShotStackCallBackRequest; +import com.example.memetory.domain.meme.entity.Meme; +import com.example.memetory.domain.meme.service.MemeService; + +import lombok.RequiredArgsConstructor; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/meme") +public class MemeController { + private final MemberService memberService; + private final MemeService memeService; + + @PostMapping("/create/{id}") + public ResponseEntity callBackMeme(@PathVariable Long id, + @RequestBody ShotStackCallBackRequest shotStackCallBackRequest) { + + Member member = memberService.findById(id); + Meme meme = shotStackCallBackRequest.toEntity(member); + + memeService.save(meme); + + return ResponseEntity.status(HttpStatus.OK).build(); + } +} diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java index ba5924ed..f96348f9 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java @@ -1,5 +1,8 @@ package com.example.memetory.domain.meme.dto; +import com.example.memetory.domain.member.entity.Member; +import com.example.memetory.domain.meme.entity.Meme; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,4 +13,11 @@ public class ShotStackCallBackRequest { private String status; private String url; private String error; + + public Meme toEntity(Member member) { + return Meme.builder() + .s3Url(this.url) + .member(member) + .build(); + } } diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java index 2851ffcd..d940e417 100644 --- a/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java @@ -12,6 +12,7 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import lombok.AccessLevel; +import lombok.Builder; import lombok.NoArgsConstructor; @Entity @@ -26,6 +27,11 @@ public class Meme extends BaseEntity { @JoinColumn(name = "member_id") private Member member; - private String name; private String s3Url; + + @Builder + public Meme(Member member, String s3Url) { + this.member = member; + this.s3Url = s3Url; + } } diff --git a/backend/memetory/src/main/java/com/example/memetory/domain/meme/service/MemeService.java b/backend/memetory/src/main/java/com/example/memetory/domain/meme/service/MemeService.java new file mode 100644 index 00000000..1244733f --- /dev/null +++ b/backend/memetory/src/main/java/com/example/memetory/domain/meme/service/MemeService.java @@ -0,0 +1,20 @@ +package com.example.memetory.domain.meme.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.example.memetory.domain.meme.entity.Meme; +import com.example.memetory.domain.meme.repository.MemeRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class MemeService { + private final MemeRepository memeRepository; + + @Transactional + public void save(Meme meme) { + memeRepository.save(meme); + } +} From 1ce74e90575aca2e964a94aa8e3eb325385d0cb5 Mon Sep 17 00:00:00 2001 From: JunRain Date: Tue, 12 Mar 2024 10:50:07 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[#33]=20RDS=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B0=B0=ED=8F=AC=EC=9A=A9=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/memetory/.gitignore | 3 +-- backend/memetory/src/main/resources/application.yml | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/memetory/.gitignore b/backend/memetory/.gitignore index 7af35e80..22937949 100644 --- a/backend/memetory/.gitignore +++ b/backend/memetory/.gitignore @@ -36,5 +36,4 @@ out/ ### VS Code ### .vscode/ -src/main/resources/application-jwt.yml -src/main/resources/application-oauth.yml +src/main/resources/application-* diff --git a/backend/memetory/src/main/resources/application.yml b/backend/memetory/src/main/resources/application.yml index c8999899..9cb9a29a 100644 --- a/backend/memetory/src/main/resources/application.yml +++ b/backend/memetory/src/main/resources/application.yml @@ -4,6 +4,13 @@ spring: "local" : "local, jwt, oauth" active : local # "local" 을 실행 +--- +spring: + profiles: + group: + "dev": "dev, jwt, oauth" + active: dev # "dev" 을 실행 + --- spring: config: From 00f4eb28b83c1256d962cba94c114b9825adae71 Mon Sep 17 00:00:00 2001 From: JunRain Date: Tue, 12 Mar 2024 15:12:04 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[#33]=20server=20=EB=B0=B0=ED=8F=AC?= =?UTF-8?q?=EC=9A=A9=20dockerfile=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/memetory/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 backend/memetory/Dockerfile diff --git a/backend/memetory/Dockerfile b/backend/memetory/Dockerfile new file mode 100644 index 00000000..7479d8c3 --- /dev/null +++ b/backend/memetory/Dockerfile @@ -0,0 +1,5 @@ +FROM openjdk:17-oracle + +COPY build/libs/memetory-0.0.1-SNAPSHOT.jar app.jar + +ENTRYPOINT ["java","-Dspring.profiles/active=dev", "-jar", "app.jar"] \ No newline at end of file