-
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.
- Loading branch information
1 parent
7d9de36
commit 7352145
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/com/playkuround/playkuroundserver/domain/fakedoor/api/FakeDoorApi.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,32 @@ | ||
package com.playkuround.playkuroundserver.domain.fakedoor.api; | ||
|
||
import com.playkuround.playkuroundserver.domain.fakedoor.application.FakeDoorService; | ||
import com.playkuround.playkuroundserver.global.common.response.ApiResponse; | ||
import com.playkuround.playkuroundserver.global.security.UserDetailsImpl; | ||
import com.playkuround.playkuroundserver.global.util.ApiUtils; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/fake-door") | ||
@RequiredArgsConstructor | ||
@Tag(name = "fakeDoor API", description = "광고보고 쿠라운드 응원하기 버튼 클릭 API") | ||
public class FakeDoorApi { | ||
|
||
private final FakeDoorService fakeDoorService; | ||
|
||
@PostMapping | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "광고보고 쿠라운드 응원하기 버튼 클릭", description = "광고보고 쿠라운드 응원하기 버튼 클릭시 호출되는 API") | ||
public ApiResponse<Void> saveFakeDoor(@AuthenticationPrincipal UserDetailsImpl userDetails) { | ||
fakeDoorService.saveFakeDoor(userDetails.getUser()); | ||
return ApiUtils.success(null); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...n/java/com/playkuround/playkuroundserver/domain/fakedoor/application/FakeDoorService.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,21 @@ | ||
package com.playkuround.playkuroundserver.domain.fakedoor.application; | ||
|
||
import com.playkuround.playkuroundserver.domain.fakedoor.dao.FakeDoorRepository; | ||
import com.playkuround.playkuroundserver.domain.fakedoor.domain.FakeDoor; | ||
import com.playkuround.playkuroundserver.domain.user.domain.User; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FakeDoorService { | ||
|
||
private final FakeDoorRepository fakeDoorRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public void saveFakeDoor(User user) { | ||
FakeDoor fakeDoor = new FakeDoor(user); | ||
fakeDoorRepository.save(fakeDoor); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/playkuround/playkuroundserver/domain/fakedoor/dao/FakeDoorRepository.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,7 @@ | ||
package com.playkuround.playkuroundserver.domain.fakedoor.dao; | ||
|
||
import com.playkuround.playkuroundserver.domain.fakedoor.domain.FakeDoor; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface FakeDoorRepository extends JpaRepository<FakeDoor, Long> { | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/playkuround/playkuroundserver/domain/fakedoor/domain/FakeDoor.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,25 @@ | ||
package com.playkuround.playkuroundserver.domain.fakedoor.domain; | ||
|
||
import com.playkuround.playkuroundserver.domain.user.domain.User; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class FakeDoor { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
public FakeDoor(User user) { | ||
this.user = user; | ||
} | ||
} |