-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/84 artwork more info #98
Changes from 6 commits
01dfeca
b309938
26fa25c
18a75bd
8def7cf
1ec5f16
1ec953c
109c7d9
3cc2c8d
3bf6b8d
7916681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import com.sptp.backend.art_work.repository.ArtWork; | ||
import com.sptp.backend.art_work.repository.ArtWorkRepository; | ||
import com.sptp.backend.art_work.web.dto.request.ArtWorkSaveRequestDto; | ||
import com.sptp.backend.art_work.web.dto.response.ArtWorkInfoResponseDto; | ||
import com.sptp.backend.art_work_image.repository.ArtWorkImage; | ||
import com.sptp.backend.art_work_image.repository.ArtWorkImageRepository; | ||
import com.sptp.backend.art_work_keyword.repository.ArtWorkKeyword; | ||
|
@@ -21,7 +22,10 @@ | |
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
|
@@ -52,12 +56,19 @@ public void saveArtWork(Long loginMemberId, ArtWorkSaveRequestDto dto) throws IO | |
.member(findMember) | ||
.title(dto.getTitle()) | ||
.material(dto.getMaterial()) | ||
.size(dto.getSize()) | ||
.price(dto.getPrice()) | ||
.status(dto.getStatus()) | ||
.statusDescription(dto.getStatusDescription()) | ||
.guaranteeImage(GuaranteeImageUUID + "." + GuaranteeImageEXT) | ||
.mainImage(mainImageUUID + "." + mainImageEXT) | ||
.genre(dto.getGenre()) | ||
.size(dto.getSize()) | ||
.height(dto.getHeight()) | ||
.length(dto.getLength()) | ||
.width(dto.getWidth()) | ||
.frame(dto.isFrame()) | ||
.description(dto.getDescription()) | ||
.productionYear(dto.getProductionYear()) | ||
.build(); | ||
|
||
artWorkRepository.save(artWork); | ||
|
@@ -104,4 +115,38 @@ public void checkExistsImage(ArtWorkSaveRequestDto dto) { | |
throw new CustomException(ErrorCode.SHOULD_EXIST_IMAGE); | ||
} | ||
} | ||
|
||
public ArtWorkInfoResponseDto getArtWork(Long artWorkId) { | ||
|
||
ArtWork findArtWork = artWorkRepository.findById(artWorkId) | ||
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_ARTWORK)); | ||
|
||
Member findArtist = memberRepository.findById(findArtWork.getMember().getId()) | ||
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_ARTIST)); | ||
|
||
List<ArtWorkImage> artWorkImages = artWorkImageRepository.findByArtWorkId(artWorkId); | ||
List<ArtWorkKeyword> artWorkKeywords = artWorkKeywordRepository.findByArtWorkId(artWorkId); | ||
|
||
ArtWorkInfoResponseDto artWorkInfoResponseDto = ArtWorkInfoResponseDto.builder() | ||
.title(findArtWork.getTitle()) | ||
.artistName(findArtist.getNickname()) | ||
.artistEducation(findArtist.getEducation()) | ||
.productionYear(findArtWork.getProductionYear()) | ||
.material(findArtWork.getMaterial()) | ||
.genre(findArtWork.getGenre()) | ||
.frame(findArtWork.isFrame()) | ||
.width(findArtWork.getWidth()) | ||
.height(findArtWork.getHeight()) | ||
.length(findArtWork.getLength()) | ||
.size(findArtWork.getSize()) | ||
.description(findArtWork.getDescription()) | ||
.guaranteeImage(findArtWork.getGuaranteeImage()) | ||
.mainImage(findArtWork.getMainImage()) | ||
.artistImage(findArtist.getImage()) | ||
.images(artWorkImages.stream().map(m -> m.getImage()).collect(Collectors.toList())) | ||
.keywords(artWorkKeywords.stream().map(m->KeywordMap.getKeywordName(m.getKeywordId())).collect(Collectors.toList())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μΌμ΄ κΈ°λ€μ. νΉμ μ κ° μμ±ν There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ λ§μνμ λΆλΆ μ°Έκ³ ν΄μ μμ ν΄λ³΄κ² μ΅λλ€! |
||
.build(); | ||
|
||
return artWorkInfoResponseDto; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,14 @@ | |
|
||
import com.sptp.backend.art_work.service.ArtWorkService; | ||
import com.sptp.backend.art_work.web.dto.request.ArtWorkSaveRequestDto; | ||
import com.sptp.backend.art_work.web.dto.response.ArtWorkInfoResponseDto; | ||
import com.sptp.backend.jwt.service.dto.CustomUserDetails; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
@@ -27,4 +30,13 @@ public ResponseEntity<Void> saveArtWork(@AuthenticationPrincipal CustomUserDetai | |
|
||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
|
||
// μν μμΈ μ‘°ν | ||
@GetMapping("/art-work/{artWorkId}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /art-worksκ° μλ /art-workλ‘ νμ μλκ° μμΌμ€κΉμ© There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. κΈ°μ‘΄ μνλ±λ‘μ΄ /art-work λ€ λ³΄λ μμΈ λν μ΄λ κ² μμ± ν건λ°, |
||
public ResponseEntity<ArtWorkInfoResponseDto> getArtWork(@PathVariable("artWorkId") Long artWorkId) { | ||
|
||
ArtWorkInfoResponseDto artWorkInfoResponseDto = artWorkService.getArtWork(artWorkId); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).body(artWorkInfoResponseDto); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.sptp.backend.art_work.web.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
|
@@ -14,10 +15,17 @@ public class ArtWorkSaveRequestDto { | |
private MultipartFile guaranteeImage; | ||
private String title; | ||
private String[] keywords; | ||
private String productionYear; | ||
private Integer productionYear; | ||
private String material; | ||
private String size; | ||
private Integer price; | ||
private String status; | ||
private String statusDescription; | ||
private Integer width; | ||
private Integer length; | ||
private Integer height; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μμ§λ λμ νλλ€μ κ°μ²΄λ‘ λ¬Άκ³ , @Embeddedλ₯Ό νμ©νλ©΄ μ’μ κ² κ°μμ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ΅ ν΅ν©λ κ°μ²΄λ‘ κ΄λ¦¬νλκ² λ§λκ² κ°λ€μ© |
||
private Integer size; | ||
private boolean frame; | ||
private String genre; | ||
private Integer price; | ||
private String description; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.sptp.backend.art_work.web.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class ArtWorkInfoResponseDto { | ||
|
||
private String title; | ||
private String artistEducation; | ||
private String artistName; | ||
private Integer productionYear; | ||
private String material; | ||
private String genre; | ||
private boolean frame; | ||
private Integer width; | ||
private Integer length; | ||
private Integer height; | ||
private Integer size; | ||
private String description; | ||
|
||
private String guaranteeImage; | ||
private String mainImage; | ||
private String artistImage; | ||
private List<String> keywords; | ||
private List<String> images; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,12 @@ spring: | |
host: localhost | ||
port: ${application.spring.redis.port} | ||
|
||
datasource: | ||
url: ${application.spring.datasource.url} | ||
username: ${application.spring.datasource.username} | ||
password: ${application.spring.datasource.password} | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. datasourceλ₯Ό μλ΅νλ©΄ h2 inmemory λͺ¨λλ‘ μλμΌλ‘ λμνλ κ²μΌλ‘ μκ³ μμ΅λλ€. νΉμ μ λ κ² μΆκ°νλ©΄ mysqlλ‘ λμνκ³ , λ‘컬 mysql dbμ λ°μ΄ν° μΆ©λμ΄ λ°μν μ μμ§ μλμ©?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μμ λ΅. μ΄ λΆλΆμ μ κ° μμ§λ₯Ό λͺ»ν΄μ μμ ν΄μ μ¬λ¦¬κ² μ΅λλ€! |
||
|
||
jpa: | ||
hibernate: | ||
ddl-auto: create | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ³κ²½λ νλλ erdμ λ°μν΄μ£ΌμΈμ!!