Skip to content
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

Develop to Main 3 #36

Merged
merged 29 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
770bbe1
feat: photobooth api login ๊ถŒํ•œ ์ œ๊ฑฐ
Jeongh00 Oct 8, 2024
5f7aeec
fix: photobooth brand list parameter ๋กœ ๋ณ€ํ™˜
Jeongh00 Oct 8, 2024
2935e10
docs: swagger ๋ฌธ์„œ ์ˆ˜์ •
Jeongh00 Oct 8, 2024
764e86b
fix: brand ํƒ€์ž… ์ถ”๊ฐ€
Jeongh00 Oct 8, 2024
7dc7fe3
fix: batch writer ์ค‘๋ณต ์ ์žฌ ๋ฐฉ์ง€
Jeongh00 Oct 9, 2024
3649cc1
fix: double x, y ํ•„๋“œ๊ฐ‘ ์ถ”๊ฐ€ ์ „๋‹ฌ
Jeongh00 Oct 9, 2024
4fe2db9
refactor: file api ๋ถ„๋ฆฌ
JiinHong Oct 12, 2024
ca9088b
refactor: File API ๋ถ„๋ฆฌ
JiinHong Oct 12, 2024
c29f57e
refactor: AlbumMapper ๋ถ„๋ฆฌ
JiinHong Oct 12, 2024
04d273f
Merge pull request #33 from 9oormthonUniv-seoultech/refactor/#31
Jeongh00 Oct 12, 2024
f8d6ad4
feat: ๋ฆฌ๋ทฐ ๋“ฑ๋ก API
JiinHong Oct 12, 2024
7fac5de
feat: ํฌํ† ๋ถ€์Šค ๋ณ„์  ์กฐํšŒ API
JiinHong Oct 12, 2024
65c2936
feat: ํฌํ† ๋ถ€์Šค ์‚ฌ์ง„ 6๊ฐœ ์กฐํšŒ API
JiinHong Oct 13, 2024
e31253f
feat: ํฌํ† ๋ถ€์Šค ์‚ฌ์ง„ 6๊ฐœ ์กฐํšŒ API (์‚ฌ์ง„ ์ด ๊ฐœ์ˆ˜ ์ถ”๊ฐ€)
JiinHong Oct 13, 2024
d0d6e9c
feat: ํฌํ† ๋ถ€์Šค ์ตœ๊ทผ ๋ฆฌ๋ทฐ 3๊ฐœ ์กฐํšŒ API
JiinHong Oct 13, 2024
1a197ce
feat: ๋ชจ๋“  ๋ฆฌ๋ทฐ ์‚ฌ์ง„ ์กฐํšŒ API
JiinHong Oct 13, 2024
3dc3ba0
feat: ํฌํ† ๋ถ€์Šค ์ตœ๊ทผ ๋ฆฌ๋ทฐ 2๊ฐœ ์กฐํšŒ API (3๊ฐœ์—์„œ 2๊ฐœ๋กœ ๋ณ€๊ฒฝ)
JiinHong Oct 13, 2024
a4374da
feat: ๋ฆฌ๋ทฐ ํฌํ† ๋ถ€์Šค ํŠน์ง• ์กฐํšŒ API
JiinHong Oct 13, 2024
a70dc5b
feat: ๋ฆฌ๋ทฐ ํฌํ† ๋ถ€์Šค ํŠน์ง• ์กฐํšŒ API (์ˆ˜์ •)
JiinHong Oct 13, 2024
c6fa59e
feat: ๋ฆฌ๋ทฐ ์ดฌ์˜ ํŠน์ง• ์กฐํšŒ API
JiinHong Oct 13, 2024
9c16e83
feat:ํฌํ† ๋ถ€์Šค ์ด๋ฆ„ ์กฐํšŒ(at ๋ฆฌ๋ทฐ ๋“ฑ๋ก ํŽ˜์ด์ง€) API
JiinHong Oct 13, 2024
d7b372e
docs: swagger ๋ฌธ์„œ ์ž…ํžˆ๊ธฐ
Jeongh00 Oct 13, 2024
6964817
feat: ์ฝ”๋“œ๋ฆฌ๋ทฐ ๋ฐ˜์˜
JiinHong Oct 14, 2024
5fb4e89
feat: querydsl ์„ค์ • & ์ฟผ๋ฆฌ ์ ์šฉ
Jeongh00 Oct 16, 2024
c5f89ee
feat: query dsl config
Jeongh00 Oct 16, 2024
efea6bd
feat: ๋ถ€์Šค ๋ฐ ์ดฌ์˜ ํŠน์ง• ๊ด€๋ จ ์ค‘๊ฐ„ ํ…Œ์ด๋ธ” ์ƒ์„ฑ ๋ฐ API ์ถ”๊ฐ€
JiinHong Oct 17, 2024
6ffa597
feat: ๋ถ€์Šค ๋ฐ ์ดฌ์˜ ํŠน์ง• ๊ด€๋ จ ์ค‘๊ฐ„ ํ…Œ์ด๋ธ” ์ƒ์„ฑ ๋ฐ API ์ถ”๊ฐ€
JiinHong Oct 17, 2024
707e396
docs: swagger ๋ฌธ์„œ ์ถ”๊ฐ€
Jeongh00 Oct 17, 2024
fe550a8
Merge pull request #35 from 9oormthonUniv-seoultech/feat/#34
Jeongh00 Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.pocket.batch.step.AddPlacesReader;
import com.pocket.batch.step.AddPlacesWriter;
import com.pocket.domain.dto.photobooth.PhotoBoothFindResponseDto;
import com.pocket.outbound.entity.JpaPhotoBooth;
import com.pocket.outbound.entity.photobooth.JpaPhotoBooth;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.pocket.domain.dto.photobooth.PhotoBoothFindResponseDto;
import com.pocket.domain.entity.photobooth.PhotoBooth;
import com.pocket.outbound.entity.JpaPhotoBooth;
import com.pocket.outbound.entity.photobooth.JpaPhotoBooth;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private List<PhotoBoothFindResponseDto> mapToDto(KakaoLocalResponse response) {
PhotoBoothFindResponseDto dto = new PhotoBoothFindResponseDto(
document.getPlace_name(),
document.getRoad_address_name(),
Double.parseDouble(document.getX()),
Double.parseDouble(document.getY()),
Double.parseDouble(document.getX()),
mapToBrand(document.getCategory_name())
);
dtoList.add(dto);
Expand Down
18 changes: 15 additions & 3 deletions batch/src/main/java/com/pocket/batch/step/AddPlacesWriter.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.pocket.batch.step;

import com.pocket.outbound.entity.JpaPhotoBooth;
import com.pocket.outbound.repository.PhotoBoothRepository;
import com.pocket.outbound.entity.photobooth.JpaPhotoBooth;
import com.pocket.outbound.repository.photobooth.PhotoBoothRepository;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class AddPlacesWriter implements ItemWriter<JpaPhotoBooth> {

Expand All @@ -23,7 +25,17 @@ public void write(Chunk<? extends JpaPhotoBooth> chunk) throws Exception {
if (item == null) {
throw new IllegalArgumentException("Item cannot be null");
}
photoBoothRepository.save(item);

// ์ค‘๋ณต ์ฒดํฌ: ์˜ˆ๋ฅผ ๋“ค์–ด ์ด๋ฆ„๊ณผ ์ขŒํ‘œ๊ฐ€ ๋™์ผํ•œ์ง€๋ฅผ ์ฒดํฌ
Optional<JpaPhotoBooth> existingBooth = photoBoothRepository
.findByPhotoBoothNameAndPhotoBoothXAndPhotoBoothY(item.getPhotoBooth().getName(),
item.getPhotoBooth().getX(),
item.getPhotoBooth().getY());

// ์ค‘๋ณต์ด ์—†์„ ๊ฒฝ์šฐ์—๋งŒ ์ €์žฅ
if (existingBooth.isEmpty()) {
photoBoothRepository.save(item);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.pocket.domain.dto.photobooth.PhotoBoothFindResponseDto;
import com.pocket.domain.entity.photobooth.PhotoBoothBrand;
import com.pocket.outbound.entity.JpaPhotoBooth;
import com.pocket.outbound.entity.photobooth.JpaPhotoBooth;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.pocket.domain.entity.photobooth.PhotoBooth;
import com.pocket.domain.entity.photobooth.PhotoBoothBrand;
import com.pocket.outbound.entity.JpaPhotoBooth;
import com.pocket.outbound.repository.PhotoBoothRepository;
import com.pocket.outbound.entity.photobooth.JpaPhotoBooth;
import com.pocket.outbound.repository.photobooth.PhotoBoothRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}

allprojects {
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/com/pocket/core/config/QueryDslConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.pocket.core.config;

import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QueryDslConfig {

@PersistenceContext
private EntityManager entityManager;

@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.pocket.core.exception.review;


import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@Getter
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class ReviewCustomException extends RuntimeException {

private final ReviewErrorCode errorCode;

public ReviewCustomException(ReviewErrorCode errorCode) {
this.errorCode = errorCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.pocket.core.exception.review;

import com.pocket.core.exception.common.ApiResponse;
import com.pocket.core.exception.common.BaseErrorCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum ReviewErrorCode implements BaseErrorCode {
PHOTO_FEATURE_NOT_FOUND(HttpStatus.BAD_REQUEST, "400","ํ•ด๋‹น ์„ค๋ช…์— ๋งž๋Š” PhotoFeature๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค"),
BOOTH_FEATURE_NOT_FOUND(HttpStatus.BAD_REQUEST, "400","ํ•ด๋‹น ์„ค๋ช…์— ๋งž๋Š” BoothFeature๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค");


private final HttpStatus httpStatus;
private final String code;
private final String message;

@Override
public ApiResponse<Void> getErrorResponse() {
return ApiResponse.onFailure(code, message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.pocket.core.image.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
@Schema(description = "ํ”„๋ฆฌ์‚ฌ์ธ๋“œ URL ์š”์ฒญ DTO")
public class PresignedUrlRequest {

private final String prefix;

private final String fileName;

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pocket.domain.dto.image;
package com.pocket.domain.dto.album;

import java.util.List;

Expand All @@ -9,7 +9,6 @@ public record AlbumRegisterRequestDto(
String date,
List<String> hashtag,
String memo,
String imageName, // ์ด๋ฏธ์ง€ ์ด๋ฆ„
String prefix // S3 ๋ฒ„ํ‚ท ๋‚ด์— ์ €์žฅํ•  ๊ฒฝ๋กœ
String filePath
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.pocket.domain.dto.album;

import java.util.List;

public record AlbumRegisterResponseDto(
Long photoboothId,
String year,
String month,
String date,
List<String> hashtag,
String memo,
String filePath
) {

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.pocket.domain.dto.photobooth;

import com.pocket.domain.entity.photobooth.PhotoBoothBrand;

public record NearPhotoBoothInfo(
Long id,
String name
String name,
PhotoBoothBrand brand,
double x,
double y
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pocket.domain.dto.review;

public record BoothFeatureCountDto(
String featureName,
Long count
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pocket.domain.dto.review;

public record BoothFeatureDto(
Long id,
String featureName
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pocket.domain.dto.review;

public record PhotoFeatureCountDto(
String featureName,
Long count
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pocket.domain.dto.review;

public record PhotoFeatureDto(
Long id,
String featureName
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.pocket.domain.dto.review;

import java.util.List;

public record ReviewGet6ImagesResponseDto(
List<String> filePaths,
int totalImageCount
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.pocket.domain.dto.review;

import java.util.List;

public record ReviewGetRecentResponseDto(
int reviewCount,
List<ReviewPreviewDto> reviews
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.pocket.domain.dto.review;

import java.util.List;

public record ReviewPreviewDto(
Long photoboothId,
String name,
String year,
String month,
String date,
String contents,
List<String> features,
String imageUrl,
int imageCount
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pocket.domain.dto.review;

import java.util.List;

public record ReviewRegisterRequestDto(
Long photoboothId,
int rating,
List<Long> boothFeatures,
List<Long> photoFeatures,
List<String> filePaths,
String content
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pocket.domain.dto.review;

import java.util.List;

public record ReviewRegisterResponseDto(
Long photoboothId,
int rating,
List<String> boothFeatures,
List<String> photoFeatures,
List<String> filePaths,
String content
) {

}
10 changes: 8 additions & 2 deletions domain/src/main/java/com/pocket/domain/entity/image/Image.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pocket.domain.entity.image;

import com.pocket.domain.dto.image.AlbumRegisterRequestDto;
import com.pocket.domain.dto.album.AlbumRegisterRequestDto;
import com.pocket.domain.dto.review.ReviewRegisterRequestDto;
import com.pocket.domain.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
Expand Down Expand Up @@ -30,11 +31,16 @@ public Image(ImageType type) {
this.type = type;
}

public void makeImage(AlbumRegisterRequestDto dto, String filePath) {
public void makeAlbumImage(AlbumRegisterRequestDto dto, String filePath) {
this.type = ImageType.PHOTO;
this.imageUrl = filePath;
this.year = dto.year();
this.month = dto.month();
this.date = dto.date();
}

public void makeReviewImage(String filePath) {
this.type = ImageType.REVIEW;
this.imageUrl = filePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

@Getter
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -26,16 +28,33 @@ public class PhotoBooth {
@Column(name = "photo_booth_brand")
private PhotoBoothBrand photoBoothBrand;

// ์ด ๋ฆฌ๋ทฐ ์ˆ˜
private int totalReviews;

// ํ‰๊ท  ๋ณ„์ 
@Column(precision = 3, scale = 2)
private BigDecimal averageRating; // ๊ธฐ๋ณธ๊ฐ’์„ 0์œผ๋กœ ์„ค์ •

private PhotoBooth(String name, String road, Double x, Double y, PhotoBoothBrand photoBoothBrand) {
this.name = name;
this.road = road;
this.x = x;
this.y = y;
this.photoBoothBrand = photoBoothBrand;
this.totalReviews = 0;
this.averageRating = BigDecimal.ZERO;
}

// ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ
public static PhotoBooth create(String name, String road, Double x, Double y, PhotoBoothBrand brand) {
return new PhotoBooth(name, road, x, y, brand);
}

public void updateRating(int newRating) {
this.totalReviews += 1;
BigDecimal totalScore = this.averageRating.multiply(BigDecimal.valueOf(this.totalReviews - 1))
.add(BigDecimal.valueOf(newRating));
this.averageRating = totalScore.divide(BigDecimal.valueOf(this.totalReviews), 2, BigDecimal.ROUND_HALF_UP);
}

}
Loading
Loading