-
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.
✨ feat: 7차 배포
- Loading branch information
Showing
32 changed files
with
421 additions
and
35 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
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
30 changes: 30 additions & 0 deletions
30
snapspot-api/src/main/java/snap/api/photo/SnapPhotoController.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,30 @@ | ||
package snap.api.photo; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import snap.api.photo.dto.SnapPhotoRequestDto; | ||
import snap.api.photo.dto.SnapPhotoResponseDto; | ||
import snap.domains.member.entity.Member; | ||
import snap.resolver.AuthMember; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/photos") | ||
public class SnapPhotoController { | ||
|
||
private final SnapPhotoService snapPhotoService; | ||
|
||
@PostMapping | ||
public ResponseEntity<SnapPhotoResponseDto> photoRegister(@AuthMember Member member, @RequestBody SnapPhotoRequestDto requestDto) { | ||
return new ResponseEntity<>(snapPhotoService.createPhoto(member, requestDto), HttpStatus.CREATED); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<SnapPhotoResponseDto>> photoList(@AuthMember Member member) { | ||
return new ResponseEntity<>(snapPhotoService.findPhotoListByMember(member), HttpStatus.OK); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
snapspot-api/src/main/java/snap/api/photo/SnapPhotoService.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,31 @@ | ||
package snap.api.photo; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import snap.api.photo.dto.SnapPhotoRequestDto; | ||
import snap.api.photo.dto.SnapPhotoResponseDto; | ||
import snap.domains.member.entity.Member; | ||
import snap.domains.photo.service.SnapPhotoDomainService; | ||
import snap.domains.photographer.entity.Photographer; | ||
import snap.domains.photographer.service.PhotographerDomainService; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class SnapPhotoService { | ||
|
||
private final SnapPhotoDomainService snapPhotoDomainService; | ||
private final PhotographerDomainService photographerDomainService; | ||
|
||
public SnapPhotoResponseDto createPhoto(Member member, SnapPhotoRequestDto requestDto) { | ||
Photographer photographer = photographerDomainService.findById(requestDto.getPhotographerId()); | ||
return new SnapPhotoResponseDto(snapPhotoDomainService.createPhoto(member, requestDto.getImageUrl(), requestDto.getPhotoDate(), | ||
requestDto.getLocation(), photographer, requestDto.getTag1(), requestDto.getTag2(), requestDto.getTag3())); | ||
} | ||
|
||
public List<SnapPhotoResponseDto> findPhotoListByMember(Member member) { | ||
return snapPhotoDomainService.findPhotoListByMember(member).stream().map(SnapPhotoResponseDto::new).toList(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
snapspot-api/src/main/java/snap/api/photo/dto/SnapPhotoRequestDto.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,19 @@ | ||
package snap.api.photo.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class SnapPhotoRequestDto { | ||
private String imageUrl; | ||
private LocalDateTime photoDate; | ||
private String location; | ||
private Long photographerId; | ||
private String tag1; | ||
private String tag2; | ||
private String tag3; | ||
} |
34 changes: 34 additions & 0 deletions
34
snapspot-api/src/main/java/snap/api/photo/dto/SnapPhotoResponseDto.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,34 @@ | ||
package snap.api.photo.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import snap.domains.photo.entity.SnapPhoto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class SnapPhotoResponseDto { | ||
private Long snapPhotoId; | ||
private String imageUrl; | ||
private LocalDateTime photoDate; | ||
private String location; | ||
private Long photographerId; | ||
private String photographerName; | ||
private String tag1; | ||
private String tag2; | ||
private String tag3; | ||
|
||
public SnapPhotoResponseDto(SnapPhoto snapPhoto) { | ||
this.snapPhotoId = snapPhoto.getSnapPhotoId(); | ||
this.imageUrl = snapPhoto.getImageUrl(); | ||
this.photoDate = snapPhoto.getPhotoDate(); | ||
this.location = snapPhoto.getLocation(); | ||
this.photographerId = snapPhoto.getPhotographer().getPhotographerId(); | ||
this.photographerName = snapPhoto.getPhotographer().getMember().getNickname(); | ||
this.tag1 = snapPhoto.getTag1(); | ||
this.tag2 = snapPhoto.getTag2(); | ||
this.tag3 = snapPhoto.getTag3(); | ||
} | ||
} |
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
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
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,9 @@ | ||
FROM azul/zulu-openjdk:17 | ||
|
||
ARG JAR_FILE=./build/libs/*.jar | ||
|
||
COPY ${JAR_FILE} batch.jar | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java","-jar","batch.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
29 changes: 29 additions & 0 deletions
29
snapspot-batch/src/main/java/snap/batch/BatchApplication.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,29 @@ | ||
package snap.batch; | ||
|
||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.util.TimeZone; | ||
|
||
@EnableBatchProcessing | ||
@EnableScheduling | ||
@EntityScan(basePackages = {"snap.domains"}) | ||
@EnableJpaRepositories(basePackages = {"snap.domains"}) | ||
@SpringBootApplication | ||
public class BatchApplication { | ||
|
||
@PostConstruct | ||
public void started() { | ||
// timezone UTC 셋팅 | ||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(BatchApplication.class, args); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
snapspot-batch/src/main/java/snap/batch/config/ComponentScanConfiguration.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 snap.batch.config; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ComponentScan({"snap"}) | ||
class ComponentScanConfiguration {} |
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
Oops, something went wrong.