-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from tukcomCD2024/feat#33/save_meme
Feat#33/save meme
- Loading branch information
Showing
9 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...nd/memetory/src/main/java/com/example/memetory/domain/meme/controller/MemeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<HttpStatus> 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(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...memetory/src/main/java/com/example/memetory/domain/meme/dto/ShotStackCallBackRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
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(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/memetory/src/main/java/com/example/memetory/domain/meme/entity/Meme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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.Column; | ||
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.Builder; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Meme extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "meme_id") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
private String s3Url; | ||
|
||
@Builder | ||
public Meme(Member member, String s3Url) { | ||
this.member = member; | ||
this.s3Url = s3Url; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...nd/memetory/src/main/java/com/example/memetory/domain/meme/repository/MemeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Meme, Long> { | ||
} |
20 changes: 20 additions & 0 deletions
20
backend/memetory/src/main/java/com/example/memetory/domain/meme/service/MemeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters