diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..2a90b35 Binary files /dev/null and b/.DS_Store differ diff --git "a/.github/ISSUE_TEMPLATE/\342\234\205-feature.md" "b/.github/ISSUE_TEMPLATE/\342\234\205-feature.md" new file mode 100644 index 0000000..f990c02 --- /dev/null +++ "b/.github/ISSUE_TEMPLATE/\342\234\205-feature.md" @@ -0,0 +1,20 @@ +--- +name: "✅ FEATURE" +about: 기능구현 시 작성해주세요 +title: "[FEAT]" +labels: enhancement +assignees: '' + +--- + +## ✏️ Description +설명을 작성하세요. + +## 📝 ToDo +- [ ] todo +- [ ] todo + +## ETC + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index d3ef6f2..b06c536 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ out/ ### JRebel ### rebel.xml + +### .DS_Store ### +.DS_Store \ No newline at end of file diff --git a/build.gradle b/build.gradle index 463d8d7..5f35045 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,14 @@ +//buildscript { +// ext { +// queryDslVersion = "5.0.0" +// } +//} + plugins { id 'java' id 'org.springframework.boot' version '3.1.3' id 'io.spring.dependency-management' version '1.1.3' +// id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" //QueryDsl } group = 'com.kusitms' @@ -19,6 +26,7 @@ configurations { compileOnly { extendsFrom annotationProcessor } +// querydsl.extendsFrom compileClasspath } repositories { @@ -53,9 +61,30 @@ dependencies { //lombok compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' + //queryDsl + implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + annotationProcessor 'com.querydsl:querydsl-apt:5.0.0:jakarta' + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + testImplementation 'org.springframework.boot:spring-boot-starter-test' } tasks.named('test') { useJUnitPlatform() } + +//def querydslDir = "$buildDir/generated/querydsl" +// +//querydsl { +// jpa = true +// querydslSourcesDir = querydslDir +//} +// +//sourceSets { +// main.java.srcDir querydslDir +//} +// +//compileQuerydsl{ +// options.annotationProcessorPath = configurations.querydsl +//} diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..259adc8 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 0000000..70fd712 Binary files /dev/null and b/src/main/.DS_Store differ diff --git a/src/main/generated/com/kusitms/jipbap/chat/domain/entity/QMessage.java b/src/main/generated/com/kusitms/jipbap/chat/domain/entity/QMessage.java new file mode 100644 index 0000000..0a2b3a0 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/chat/domain/entity/QMessage.java @@ -0,0 +1,67 @@ +package com.kusitms.jipbap.chat.domain.entity; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QMessage is a Querydsl query type for Message + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QMessage extends EntityPathBase { + + private static final long serialVersionUID = -928480451L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QMessage message1 = new QMessage("message1"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath message = createString("message"); + + public final StringPath receiverName = createString("receiverName"); + + public final QRoom room; + + public final StringPath senderName = createString("senderName"); + + public final StringPath sentTime = createString("sentTime"); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QMessage(String variable) { + this(Message.class, forVariable(variable), INITS); + } + + public QMessage(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QMessage(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QMessage(PathMetadata metadata, PathInits inits) { + this(Message.class, metadata, inits); + } + + public QMessage(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.room = inits.isInitialized("room") ? new QRoom(forProperty("room"), inits.get("room")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/chat/domain/entity/QRoom.java b/src/main/generated/com/kusitms/jipbap/chat/domain/entity/QRoom.java new file mode 100644 index 0000000..6db28c7 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/chat/domain/entity/QRoom.java @@ -0,0 +1,64 @@ +package com.kusitms.jipbap.chat.domain.entity; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QRoom is a Querydsl query type for Room + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QRoom extends EntityPathBase { + + private static final long serialVersionUID = 1449900389L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QRoom room = new QRoom("room"); + + public final NumberPath id = createNumber("id", Long.class); + + public final ListPath messageList = this.createList("messageList", Message.class, QMessage.class, PathInits.DIRECT2); + + public final StringPath receiverName = createString("receiverName"); + + public final StringPath roomId = createString("roomId"); + + public final StringPath roomName = createString("roomName"); + + public final StringPath senderName = createString("senderName"); + + public final com.kusitms.jipbap.store.QStore store; + + public final com.kusitms.jipbap.user.QUser user; + + public QRoom(String variable) { + this(Room.class, forVariable(variable), INITS); + } + + public QRoom(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QRoom(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QRoom(PathMetadata metadata, PathInits inits) { + this(Room.class, metadata, inits); + } + + public QRoom(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.store = inits.isInitialized("store") ? new com.kusitms.jipbap.store.QStore(forProperty("store"), inits.get("store")) : null; + this.user = inits.isInitialized("user") ? new com.kusitms.jipbap.user.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/common/entity/QDateEntity.java b/src/main/generated/com/kusitms/jipbap/common/entity/QDateEntity.java new file mode 100644 index 0000000..228441c --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/common/entity/QDateEntity.java @@ -0,0 +1,39 @@ +package com.kusitms.jipbap.common.entity; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; + + +/** + * QDateEntity is a Querydsl query type for DateEntity + */ +@Generated("com.querydsl.codegen.DefaultSupertypeSerializer") +public class QDateEntity extends EntityPathBase { + + private static final long serialVersionUID = -170761146L; + + public static final QDateEntity dateEntity = new QDateEntity("dateEntity"); + + public final DateTimePath createdAt = createDateTime("createdAt", java.time.LocalDateTime.class); + + public final DateTimePath updatedAt = createDateTime("updatedAt", java.time.LocalDateTime.class); + + public QDateEntity(String variable) { + super(DateEntity.class, forVariable(variable)); + } + + public QDateEntity(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QDateEntity(PathMetadata metadata) { + super(DateEntity.class, metadata); + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/food/QCategory.java b/src/main/generated/com/kusitms/jipbap/food/QCategory.java new file mode 100644 index 0000000..bb4ab7a --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/food/QCategory.java @@ -0,0 +1,49 @@ +package com.kusitms.jipbap.food; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; + + +/** + * QCategory is a Querydsl query type for Category + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QCategory extends EntityPathBase { + + private static final long serialVersionUID = 1489953153L; + + public static final QCategory category = new QCategory("category"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath image = createString("image"); + + public final StringPath name = createString("name"); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QCategory(String variable) { + super(Category.class, forVariable(variable)); + } + + public QCategory(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QCategory(PathMetadata metadata) { + super(Category.class, metadata); + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/food/QFood.java b/src/main/generated/com/kusitms/jipbap/food/QFood.java new file mode 100644 index 0000000..2f47c48 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/food/QFood.java @@ -0,0 +1,70 @@ +package com.kusitms.jipbap.food; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QFood is a Querydsl query type for Food + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QFood extends EntityPathBase { + + private static final long serialVersionUID = -1116673439L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QFood food = new QFood("food"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + public final QCategory category; + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final StringPath description = createString("description"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final NumberPath price = createNumber("price", Long.class); + + public final NumberPath recommendCount = createNumber("recommendCount", Long.class); + + public final com.kusitms.jipbap.store.QStore store; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QFood(String variable) { + this(Food.class, forVariable(variable), INITS); + } + + public QFood(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QFood(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QFood(PathMetadata metadata, PathInits inits) { + this(Food.class, metadata, inits); + } + + public QFood(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.category = inits.isInitialized("category") ? new QCategory(forProperty("category")) : null; + this.store = inits.isInitialized("store") ? new com.kusitms.jipbap.store.QStore(forProperty("store"), inits.get("store")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/notifiication/QNotification.java b/src/main/generated/com/kusitms/jipbap/notifiication/QNotification.java new file mode 100644 index 0000000..9d082e4 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/notifiication/QNotification.java @@ -0,0 +1,65 @@ +package com.kusitms.jipbap.notifiication; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QNotification is a Querydsl query type for Notification + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QNotification extends EntityPathBase { + + private static final long serialVersionUID = -150217532L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QNotification notification = new QNotification("notification"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath message = createString("message"); + + public final EnumPath notificationType = createEnum("notificationType", Notification.NotificationType.class); + + public final BooleanPath readYn = createBoolean("readYn"); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public final com.kusitms.jipbap.user.QUser user; + + public QNotification(String variable) { + this(Notification.class, forVariable(variable), INITS); + } + + public QNotification(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QNotification(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QNotification(PathMetadata metadata, PathInits inits) { + this(Notification.class, metadata, inits); + } + + public QNotification(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.user = inits.isInitialized("user") ? new com.kusitms.jipbap.user.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/order/QCart.java b/src/main/generated/com/kusitms/jipbap/order/QCart.java new file mode 100644 index 0000000..5b76ec0 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/order/QCart.java @@ -0,0 +1,62 @@ +package com.kusitms.jipbap.order; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QCart is a Querydsl query type for Cart + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QCart extends EntityPathBase { + + private static final long serialVersionUID = 1961564653L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QCart cart = new QCart("cart"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final com.kusitms.jipbap.food.QFood food; + + public final NumberPath id = createNumber("id", Long.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public final com.kusitms.jipbap.user.QUser user; + + public QCart(String variable) { + this(Cart.class, forVariable(variable), INITS); + } + + public QCart(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QCart(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QCart(PathMetadata metadata, PathInits inits) { + this(Cart.class, metadata, inits); + } + + public QCart(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.food = inits.isInitialized("food") ? new com.kusitms.jipbap.food.QFood(forProperty("food"), inits.get("food")) : null; + this.user = inits.isInitialized("user") ? new com.kusitms.jipbap.user.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/order/QOrder.java b/src/main/generated/com/kusitms/jipbap/order/QOrder.java new file mode 100644 index 0000000..9b6a21f --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/order/QOrder.java @@ -0,0 +1,64 @@ +package com.kusitms.jipbap.order; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QOrder is a Querydsl query type for Order + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QOrder extends EntityPathBase { + + private static final long serialVersionUID = 690536993L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QOrder order = new QOrder("order1"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final com.kusitms.jipbap.food.QFood food; + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath orderCount = createNumber("orderCount", Long.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public final com.kusitms.jipbap.user.QUser user; + + public QOrder(String variable) { + this(Order.class, forVariable(variable), INITS); + } + + public QOrder(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QOrder(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QOrder(PathMetadata metadata, PathInits inits) { + this(Order.class, metadata, inits); + } + + public QOrder(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.food = inits.isInitialized("food") ? new com.kusitms.jipbap.food.QFood(forProperty("food"), inits.get("food")) : null; + this.user = inits.isInitialized("user") ? new com.kusitms.jipbap.user.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/order/QReview.java b/src/main/generated/com/kusitms/jipbap/order/QReview.java new file mode 100644 index 0000000..f3f45f7 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/order/QReview.java @@ -0,0 +1,63 @@ +package com.kusitms.jipbap.order; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QReview is a Querydsl query type for Review + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QReview extends EntityPathBase { + + private static final long serialVersionUID = 6231781L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QReview review = new QReview("review"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath message = createString("message"); + + public final QOrder order; + + public final NumberPath rating = createNumber("rating", Long.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QReview(String variable) { + this(Review.class, forVariable(variable), INITS); + } + + public QReview(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QReview(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QReview(PathMetadata metadata, PathInits inits) { + this(Review.class, metadata, inits); + } + + public QReview(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.order = inits.isInitialized("order") ? new QOrder(forProperty("order"), inits.get("order")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/post/QPost.java b/src/main/generated/com/kusitms/jipbap/post/QPost.java new file mode 100644 index 0000000..8847b4c --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/post/QPost.java @@ -0,0 +1,57 @@ +package com.kusitms.jipbap.post; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; + + +/** + * QPost is a Querydsl query type for Post + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QPost extends EntityPathBase { + + private static final long serialVersionUID = 1997030305L; + + public static final QPost post = new QPost("post"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + public final StringPath content = createString("content"); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final DateTimePath createdBy = createDateTime("createdBy", java.time.LocalDateTime.class); + + public final NumberPath hit = createNumber("hit", Long.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final EnumPath postType = createEnum("postType", Post.PostType.class); + + public final StringPath title = createString("title"); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public final DateTimePath updatedBy = createDateTime("updatedBy", java.time.LocalDateTime.class); + + public QPost(String variable) { + super(Post.class, forVariable(variable)); + } + + public QPost(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QPost(PathMetadata metadata) { + super(Post.class, metadata); + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/store/QStore.java b/src/main/generated/com/kusitms/jipbap/store/QStore.java new file mode 100644 index 0000000..a36f2a0 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/store/QStore.java @@ -0,0 +1,77 @@ +package com.kusitms.jipbap.store; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QStore is a Querydsl query type for Store + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QStore extends EntityPathBase { + + private static final long serialVersionUID = 1530325767L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QStore store = new QStore("store"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + public final NumberPath avgRate = createNumber("avgRate", Double.class); + + public final NumberPath bookmarkCount = createNumber("bookmarkCount", Long.class); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final StringPath description = createString("description"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath image = createString("image"); + + public final BooleanPath koreanYn = createBoolean("koreanYn"); + + public final NumberPath minOrderAmount = createNumber("minOrderAmount", Long.class); + + public final StringPath name = createString("name"); + + public final com.kusitms.jipbap.user.QUser owner; + + public final NumberPath rateCount = createNumber("rateCount", Long.class); + + public final NumberPath reviewCount = createNumber("reviewCount", Long.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QStore(String variable) { + this(Store.class, forVariable(variable), INITS); + } + + public QStore(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QStore(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QStore(PathMetadata metadata, PathInits inits) { + this(Store.class, metadata, inits); + } + + public QStore(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.owner = inits.isInitialized("owner") ? new com.kusitms.jipbap.user.QUser(forProperty("owner")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/store/QStoreBookmark.java b/src/main/generated/com/kusitms/jipbap/store/QStoreBookmark.java new file mode 100644 index 0000000..aef2d53 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/store/QStoreBookmark.java @@ -0,0 +1,62 @@ +package com.kusitms.jipbap.store; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QStoreBookmark is a Querydsl query type for StoreBookmark + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QStoreBookmark extends EntityPathBase { + + private static final long serialVersionUID = 542965085L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QStoreBookmark storeBookmark = new QStoreBookmark("storeBookmark"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final QStore store; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public final com.kusitms.jipbap.user.QUser user; + + public QStoreBookmark(String variable) { + this(StoreBookmark.class, forVariable(variable), INITS); + } + + public QStoreBookmark(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QStoreBookmark(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QStoreBookmark(PathMetadata metadata, PathInits inits) { + this(StoreBookmark.class, metadata, inits); + } + + public QStoreBookmark(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.store = inits.isInitialized("store") ? new QStore(forProperty("store"), inits.get("store")) : null; + this.user = inits.isInitialized("user") ? new com.kusitms.jipbap.user.QUser(forProperty("user")) : null; + } + +} + diff --git a/src/main/generated/com/kusitms/jipbap/user/QUser.java b/src/main/generated/com/kusitms/jipbap/user/QUser.java new file mode 100644 index 0000000..32b4a65 --- /dev/null +++ b/src/main/generated/com/kusitms/jipbap/user/QUser.java @@ -0,0 +1,65 @@ +package com.kusitms.jipbap.user; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; + + +/** + * QUser is a Querydsl query type for User + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QUser extends EntityPathBase { + + private static final long serialVersionUID = 333743745L; + + public static final QUser user = new QUser("user"); + + public final com.kusitms.jipbap.common.entity.QDateEntity _super = new com.kusitms.jipbap.common.entity.QDateEntity(this); + + public final StringPath address = createString("address"); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final StringPath email = createString("email"); + + public final StringPath fcmToken = createString("fcmToken"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath image = createString("image"); + + public final StringPath oauth = createString("oauth"); + + public final StringPath password = createString("password"); + + public final StringPath phoneNum = createString("phoneNum"); + + public final StringPath refreshToken = createString("refreshToken"); + + public final EnumPath role = createEnum("role", Role.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public final StringPath username = createString("username"); + + public QUser(String variable) { + super(User.class, forVariable(variable)); + } + + public QUser(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QUser(PathMetadata metadata) { + super(User.class, metadata); + } + +} + diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store new file mode 100644 index 0000000..5238c52 Binary files /dev/null and b/src/main/java/.DS_Store differ diff --git a/src/main/java/com/.DS_Store b/src/main/java/com/.DS_Store new file mode 100644 index 0000000..9f3bb0d Binary files /dev/null and b/src/main/java/com/.DS_Store differ diff --git a/src/main/java/com/kusitms/.DS_Store b/src/main/java/com/kusitms/.DS_Store new file mode 100644 index 0000000..03d9596 Binary files /dev/null and b/src/main/java/com/kusitms/.DS_Store differ diff --git a/src/main/java/com/kusitms/jipbap/.DS_Store b/src/main/java/com/kusitms/jipbap/.DS_Store new file mode 100644 index 0000000..ee8f8e4 Binary files /dev/null and b/src/main/java/com/kusitms/jipbap/.DS_Store differ diff --git a/src/main/java/com/kusitms/jipbap/auth/.DS_Store b/src/main/java/com/kusitms/jipbap/auth/.DS_Store new file mode 100644 index 0000000..ff4c1a1 Binary files /dev/null and b/src/main/java/com/kusitms/jipbap/auth/.DS_Store differ diff --git a/src/main/java/com/kusitms/jipbap/chat/.DS_Store b/src/main/java/com/kusitms/jipbap/chat/.DS_Store new file mode 100644 index 0000000..d0102f9 Binary files /dev/null and b/src/main/java/com/kusitms/jipbap/chat/.DS_Store differ diff --git a/src/main/java/com/kusitms/jipbap/chat/domain/.DS_Store b/src/main/java/com/kusitms/jipbap/chat/domain/.DS_Store new file mode 100644 index 0000000..dc61b2c Binary files /dev/null and b/src/main/java/com/kusitms/jipbap/chat/domain/.DS_Store differ diff --git a/src/main/java/com/kusitms/jipbap/common/.DS_Store b/src/main/java/com/kusitms/jipbap/common/.DS_Store new file mode 100644 index 0000000..5199c4b Binary files /dev/null and b/src/main/java/com/kusitms/jipbap/common/.DS_Store differ diff --git a/src/main/java/com/kusitms/jipbap/common/QueryDslUtil.java b/src/main/java/com/kusitms/jipbap/common/QueryDslUtil.java new file mode 100644 index 0000000..b72da60 --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/common/QueryDslUtil.java @@ -0,0 +1,14 @@ +package com.kusitms.jipbap.common; + +import com.querydsl.core.types.Order; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.Expressions; + +public class QueryDslUtil { + + public static OrderSpecifier getSortedColumn(Order order, Path parent, String fieldName) { + Path fieldPath = Expressions.path(Object.class, parent, fieldName); + return new OrderSpecifier(order, fieldPath); + } +} \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/common/response/ErrorCode.java b/src/main/java/com/kusitms/jipbap/common/response/ErrorCode.java index 1b28095..41bb7aa 100644 --- a/src/main/java/com/kusitms/jipbap/common/response/ErrorCode.java +++ b/src/main/java/com/kusitms/jipbap/common/response/ErrorCode.java @@ -27,7 +27,8 @@ public enum ErrorCode { ROOM_NOT_FOUND_ERROR(false, HttpStatus.BAD_REQUEST.value(), "존재하지 않는 채팅방입니다."), //store - STORE_NOT_FOUND_ERROR(false, HttpStatus.BAD_REQUEST.value(), "존재하지 않는 가게입니다."); + STORE_NOT_FOUND_ERROR(false, HttpStatus.BAD_REQUEST.value(), "존재하지 않는 가게입니다."), + STORE_ALREADY_EXISTS_ERROR(false, HttpStatus.BAD_REQUEST.value(), "이미 채팅방을 만든 유저입니다.") ; private Boolean isSuccess; diff --git a/src/main/java/com/kusitms/jipbap/config/QueryDslConfig.java b/src/main/java/com/kusitms/jipbap/config/QueryDslConfig.java new file mode 100644 index 0000000..1cd6ede --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/config/QueryDslConfig.java @@ -0,0 +1,18 @@ +package com.kusitms.jipbap.config; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import jakarta.persistence.EntityManager; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@RequiredArgsConstructor +public class QueryDslConfig { + private final EntityManager entityManager; + + @Bean + public JPAQueryFactory jpaQueryFactory() { + return new JPAQueryFactory(entityManager); + } +} \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/food/Category.java b/src/main/java/com/kusitms/jipbap/food/Category.java index 6558bd7..54311c4 100644 --- a/src/main/java/com/kusitms/jipbap/food/Category.java +++ b/src/main/java/com/kusitms/jipbap/food/Category.java @@ -17,9 +17,10 @@ public class Category extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="category_id") + @Column(name ="id") private Long id; //고유 pk + @Column(name = "category_name") private String name; private String image; diff --git a/src/main/java/com/kusitms/jipbap/food/Food.java b/src/main/java/com/kusitms/jipbap/food/Food.java index 0a5163b..25f877b 100644 --- a/src/main/java/com/kusitms/jipbap/food/Food.java +++ b/src/main/java/com/kusitms/jipbap/food/Food.java @@ -19,17 +19,18 @@ public class Food extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="food_id") + @Column(name ="id") private Long id; //고유 pk @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "store_id") private Store store; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "category_id") private Category category; + @Column(name = "food_name") private String name; private Long price; private String description; diff --git a/src/main/java/com/kusitms/jipbap/notifiication/Notification.java b/src/main/java/com/kusitms/jipbap/notifiication/Notification.java index 201d1e2..4ebf3ac 100644 --- a/src/main/java/com/kusitms/jipbap/notifiication/Notification.java +++ b/src/main/java/com/kusitms/jipbap/notifiication/Notification.java @@ -19,7 +19,7 @@ public class Notification extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="notification_id") + @Column(name ="id") private Long id; //고유 pk @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/com/kusitms/jipbap/order/Cart.java b/src/main/java/com/kusitms/jipbap/order/Cart.java index 5fb36af..9fb4996 100644 --- a/src/main/java/com/kusitms/jipbap/order/Cart.java +++ b/src/main/java/com/kusitms/jipbap/order/Cart.java @@ -20,15 +20,15 @@ public class Cart extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="cart_id") + @Column(name ="id") private Long id; //고유 pk @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "user_id") private User user; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "food_id") private Food food; } \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/order/Order.java b/src/main/java/com/kusitms/jipbap/order/Order.java index 8c87859..4ebac54 100644 --- a/src/main/java/com/kusitms/jipbap/order/Order.java +++ b/src/main/java/com/kusitms/jipbap/order/Order.java @@ -21,15 +21,15 @@ public class Order extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="order_id") + @Column(name ="id") private Long id; //고유 pk @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "user_id") private User user; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "food_id") private Food food; private Long orderCount; diff --git a/src/main/java/com/kusitms/jipbap/order/Review.java b/src/main/java/com/kusitms/jipbap/order/Review.java index 6b5a685..36e2eca 100644 --- a/src/main/java/com/kusitms/jipbap/order/Review.java +++ b/src/main/java/com/kusitms/jipbap/order/Review.java @@ -19,15 +19,14 @@ public class Review extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="review_id") + @Column(name ="id") private Long id; //고유 pk @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "order_id") private Order order; private Long rating; - private Long like; private String message; } \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/post/Post.java b/src/main/java/com/kusitms/jipbap/post/Post.java index ad6dc8a..b0b957d 100644 --- a/src/main/java/com/kusitms/jipbap/post/Post.java +++ b/src/main/java/com/kusitms/jipbap/post/Post.java @@ -21,7 +21,7 @@ public class Post extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="post_id") + @Column(name ="id") private Long id; //고유 pk @Enumerated(EnumType.STRING) diff --git a/src/main/java/com/kusitms/jipbap/store/Store.java b/src/main/java/com/kusitms/jipbap/store/Store.java index 486f5ea..0222a57 100644 --- a/src/main/java/com/kusitms/jipbap/store/Store.java +++ b/src/main/java/com/kusitms/jipbap/store/Store.java @@ -19,16 +19,16 @@ public class Store extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="store_id") + @Column(name ="id") private Long id; //고유 pk @OneToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "owner_id") private User owner; - //TODO("읍면동 지역 id?") - + + @Column(name = "store_name") private String name; private String description; @@ -36,7 +36,23 @@ public class Store extends DateEntity { @Column(columnDefinition = "TINYINT(1)") private Boolean koreanYn; //한국인 인증 여부 - private Double avgRate; - + private Double avgRate; // 가게 평점 + private Long minOrderAmount; //최소 주문 금액 private String image; + + private Long reviewCount; // 가게 후기 개수 + private Long bookmarkCount; // 가게 즐겨찾기 횟수 (추천순) + private Long rateCount; // 평점 남긴 인원수 + + public void increaseBookmarkCount() { + this.bookmarkCount++; + } + + public void increaseReviewCount() { + this.reviewCount++; + } + + public void updateAvgRate(Double newRate) { + this.avgRate = (avgRate*rateCount+newRate)/(rateCount+1); + } } \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/store/StoreBookmark.java b/src/main/java/com/kusitms/jipbap/store/StoreBookmark.java index b924e0b..34d745e 100644 --- a/src/main/java/com/kusitms/jipbap/store/StoreBookmark.java +++ b/src/main/java/com/kusitms/jipbap/store/StoreBookmark.java @@ -19,15 +19,15 @@ public class StoreBookmark extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="store_bookmark_id") + @Column(name ="id") private Long id; //고유 pk @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn - private User owner; + @JoinColumn(name = "user_id") + private User user; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn + @JoinColumn(name = "store_id") private Store store; diff --git a/src/main/java/com/kusitms/jipbap/store/StoreBookmarkRepository.java b/src/main/java/com/kusitms/jipbap/store/StoreBookmarkRepository.java new file mode 100644 index 0000000..a4eb7ab --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/store/StoreBookmarkRepository.java @@ -0,0 +1,8 @@ +package com.kusitms.jipbap.store; + +import com.kusitms.jipbap.user.User; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface StoreBookmarkRepository extends JpaRepository { + Boolean existsByUserAndStore(User user, Store store); +} diff --git a/src/main/java/com/kusitms/jipbap/store/StoreController.java b/src/main/java/com/kusitms/jipbap/store/StoreController.java index c6793db..7d6ce0a 100644 --- a/src/main/java/com/kusitms/jipbap/store/StoreController.java +++ b/src/main/java/com/kusitms/jipbap/store/StoreController.java @@ -4,14 +4,15 @@ import com.kusitms.jipbap.security.Auth; import com.kusitms.jipbap.security.AuthInfo; import com.kusitms.jipbap.store.dto.RegisterStoreRequestDto; -import com.kusitms.jipbap.user.User; -import com.kusitms.jipbap.user.UserRepository; -import com.kusitms.jipbap.user.exception.UserNotFoundException; +import com.kusitms.jipbap.store.dto.StoreDetailResponseDto; +import com.kusitms.jipbap.store.dto.StoreDto; +import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; -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 org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -20,11 +21,50 @@ @RequiredArgsConstructor public class StoreController { + private final int PAGESIZE = 10; private final StoreService storeService; + @Operation(summary = "가게 등록하기") @PostMapping - public CommonResponse registerStore(@Auth AuthInfo authInfo, @Valid @RequestBody RegisterStoreRequestDto dto) { - storeService.registerStore(authInfo.getEmail(), dto); - return new CommonResponse<>("가게 등록 완료"); + public CommonResponse registerStore(@Auth AuthInfo authInfo, @Valid @RequestBody RegisterStoreRequestDto dto) { + return new CommonResponse<>(storeService.registerStore(authInfo.getEmail(), dto)); } + + /** + * 가게 검색 api - 페이지네이션 적용 + * api의 복잡도와 성능을 희생하는 대신, 데이터 중복/삭제 현상을 감안함 + * + * @param keyword: 검색 키워드 (키워드가 포함한 가게를 검색한다) + * @param field: 검색 기준 (추천-bookmark, 후기-review, 평점-rate, 가격-price, 최신-id) + * (추천순: 가게 즐겨찾기 개수 순서, 후기: 가게에 속한 주문에 달린 리뷰 수) + * @param direction: 정렬 기준 (ASC, DESC) + * @param lastId: 결과 리스트에서 마지막으로 출력된 가게의 id + * @return Slice: 슬라이스 단위 + */ + @Operation(summary = "가게 리스트 검색") + @GetMapping + public CommonResponse> searchStore( + @Auth AuthInfo authInfo, + @RequestParam(required = false) String keyword, + @RequestParam String field, + @RequestParam String direction, + @RequestParam(required = false) Long lastId + ) { + Sort sort; + if ("asc".equals(direction) || "ASC".equals(direction)) { + sort = Sort.by(Sort.Direction.ASC, field); + } else { + sort = Sort.by(Sort.Direction.DESC, field); + } + Pageable pageable = PageRequest.of(0, PAGESIZE, sort); + return new CommonResponse<>(storeService.searchStoreList(authInfo.getEmail(), pageable, keyword, field, direction, lastId)); + } + + + @Operation(summary = "가게 상세정보") + @GetMapping("/{storeId}") + public CommonResponse storeDetail(@Auth AuthInfo authInfo, @PathVariable Long storeId) { + return new CommonResponse<>(storeService.getStoreDetail(authInfo.getEmail(), storeId)); + } + } diff --git a/src/main/java/com/kusitms/jipbap/store/StoreExceptionHandler.java b/src/main/java/com/kusitms/jipbap/store/StoreExceptionHandler.java index 3d05cf6..e0d45a3 100644 --- a/src/main/java/com/kusitms/jipbap/store/StoreExceptionHandler.java +++ b/src/main/java/com/kusitms/jipbap/store/StoreExceptionHandler.java @@ -2,6 +2,7 @@ import com.kusitms.jipbap.common.response.CommonResponse; import com.kusitms.jipbap.common.response.ErrorCode; +import com.kusitms.jipbap.store.exception.StoreExistsException; import com.kusitms.jipbap.store.exception.StoreNotExistsException; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; @@ -17,7 +18,13 @@ public class StoreExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) public CommonResponse handleStoreNotExistsException(StoreNotExistsException e, HttpServletRequest request) { log.warn("STORE-001> 요청 URI: " + request.getRequestURI() + ", 에러 메세지: " + e.getMessage()); - return new CommonResponse<>(ErrorCode.ROOM_NOT_FOUND_ERROR); + return new CommonResponse<>(ErrorCode.STORE_NOT_FOUND_ERROR); } + @ExceptionHandler(StoreExistsException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public CommonResponse handleStoreExistsException(StoreExistsException e, HttpServletRequest request) { + log.warn("STORE-002> 요청 URI: " + request.getRequestURI() + ", 에러 메세지: " + e.getMessage()); + return new CommonResponse<>(ErrorCode.STORE_ALREADY_EXISTS_ERROR); + } } diff --git a/src/main/java/com/kusitms/jipbap/store/StoreRepository.java b/src/main/java/com/kusitms/jipbap/store/StoreRepository.java index 27a10f8..a4d6653 100644 --- a/src/main/java/com/kusitms/jipbap/store/StoreRepository.java +++ b/src/main/java/com/kusitms/jipbap/store/StoreRepository.java @@ -1,6 +1,11 @@ package com.kusitms.jipbap.store; +import com.kusitms.jipbap.user.User; import org.springframework.data.jpa.repository.JpaRepository; -public interface StoreRepository extends JpaRepository { +import java.util.Optional; + +public interface StoreRepository extends JpaRepository, StoreRepositoryExtension { + Optional findById(Long id); + Boolean existsByOwner(User user); } diff --git a/src/main/java/com/kusitms/jipbap/store/StoreRepositoryExtension.java b/src/main/java/com/kusitms/jipbap/store/StoreRepositoryExtension.java new file mode 100644 index 0000000..8d00fc1 --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/store/StoreRepositoryExtension.java @@ -0,0 +1,11 @@ +package com.kusitms.jipbap.store; + +import com.kusitms.jipbap.store.dto.StoreDetailResponseDto; +import com.kusitms.jipbap.user.User; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; + +public interface StoreRepositoryExtension { + + Slice searchByKeywordOrderBySort(User user, Pageable pageable, String keyword, String standard, String order, Long lastId); +} diff --git a/src/main/java/com/kusitms/jipbap/store/StoreRepositoryExtensionImpl.java b/src/main/java/com/kusitms/jipbap/store/StoreRepositoryExtensionImpl.java new file mode 100644 index 0000000..7ebcb2f --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/store/StoreRepositoryExtensionImpl.java @@ -0,0 +1,141 @@ +package com.kusitms.jipbap.store; + +import com.kusitms.jipbap.common.QueryDslUtil; +import com.kusitms.jipbap.store.dto.StoreDetailResponseDto; +import com.kusitms.jipbap.store.dto.StoreDto; +import com.kusitms.jipbap.user.User; +import com.querydsl.core.types.Order; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.SliceImpl; +import org.springframework.data.domain.Sort; + +import java.util.ArrayList; +import java.util.List; + +import static com.kusitms.jipbap.store.QStore.*; +import static com.kusitms.jipbap.store.QStore.store; +import static org.springframework.util.ObjectUtils.isEmpty; + +@RequiredArgsConstructor +public class StoreRepositoryExtensionImpl implements StoreRepositoryExtension{ + + private final JPAQueryFactory queryFactory; + private final StoreBookmarkRepository storeBookmarkRepository; + + @Override + public Slice searchByKeywordOrderBySort(User user, Pageable pageable, String keyword, String standard, String order, Long lastId) { + + List> orderSpecifiers = getAllOrderSpecifiers(pageable); + + List storeList = queryFactory.selectFrom(store) + .where( + lastStore(pageable, lastId), + containsKeyword(keyword) + ) + .limit(pageable.getPageSize()+1) + .orderBy(orderSpecifiers.toArray(OrderSpecifier[]::new)) + .fetch(); + + List dtoList = new ArrayList<>(); + + for(Store s: storeList) { + dtoList.add(new StoreDetailResponseDto( + new StoreDto( + s.getId(), + s.getName(), + s.getDescription(), + s.getKoreanYn(), + s.getAvgRate(), + s.getMinOrderAmount(), + s.getImage() + ), + isUserBookmarkedStore(user, s) + )); + } + + // 무한스크롤을 위한 길이 확인 + boolean hasNext = false; + if(storeList.size() > pageable.getPageSize()) { + dtoList.remove(pageable.getPageSize()); + hasNext = true; + } + + return new SliceImpl<>(dtoList, pageable, hasNext); + } + + // user가 즐겨찾기한 store인지 검사 + private Boolean isUserBookmarkedStore(User user, Store store) { + return storeBookmarkRepository.existsByUserAndStore(user, store); + } + + // no-offset 방식 처리하는 메서드 + // 정렬조건에 따라서 다음에 나와야 할 친구들을 구함 + private BooleanExpression lastStore(Pageable pageable, Long id) { + if(id==null) return null; + + Store stdStore = queryFactory.selectFrom(QStore.store) + .where(QStore.store.id.eq(id)) + .fetchFirst(); + + for (Sort.Order order : pageable.getSort()) { + return switch (order.getProperty()) { + case "bookmark" -> // 추천순 + store.bookmarkCount.lt(stdStore.getBookmarkCount()); + case "review" -> // 후기순 + store.reviewCount.lt(stdStore.getReviewCount()); + case "rate" -> // 평점순 + store.rateCount.lt(stdStore.getRateCount()); + case "id" -> // 최신순 + store.id.lt(stdStore.getId()); + default -> null; + }; + } + + return null; + } + + private BooleanExpression containsKeyword(String keyword) { + if(keyword == null) { + return null; + } + return store.name.contains(keyword); + } + + private List> getAllOrderSpecifiers(Pageable pageable) { + + List> orderSpecifierList = new ArrayList<>(); + + if (!isEmpty(pageable.getSort())) { + for (Sort.Order order : pageable.getSort()) { + Order direction = order.getDirection().isAscending() ? Order.ASC : Order.DESC; + switch (order.getProperty()) { + // 기본 정렬조건: 추천순 + case "bookmark": // 추천순 + orderSpecifierList.add(QueryDslUtil.getSortedColumn(direction, store, "bookmarkCount")); + orderSpecifierList.add(QueryDslUtil.getSortedColumn(Order.DESC, store, "id")); + break; + case "review": // 후기순 + orderSpecifierList.add(QueryDslUtil.getSortedColumn(direction, store, "reviewCount")); + orderSpecifierList.add(QueryDslUtil.getSortedColumn(Order.DESC, store, "id")); + break; + case "rate": // 평점순 + orderSpecifierList.add(QueryDslUtil.getSortedColumn(direction, store, "avgRate")); + orderSpecifierList.add(QueryDslUtil.getSortedColumn(Order.DESC, store, "id")); + break; + case "id": // 최신순 + orderSpecifierList.add(QueryDslUtil.getSortedColumn(direction, store, "id")); + break; + default: + break; + } + } + } + + return orderSpecifierList; + } +} \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/store/StoreService.java b/src/main/java/com/kusitms/jipbap/store/StoreService.java index bb6582c..5926249 100644 --- a/src/main/java/com/kusitms/jipbap/store/StoreService.java +++ b/src/main/java/com/kusitms/jipbap/store/StoreService.java @@ -1,12 +1,19 @@ package com.kusitms.jipbap.store; import com.kusitms.jipbap.store.dto.RegisterStoreRequestDto; +import com.kusitms.jipbap.store.dto.StoreDetailResponseDto; +import com.kusitms.jipbap.store.dto.StoreDto; +import com.kusitms.jipbap.store.exception.StoreExistsException; +import com.kusitms.jipbap.store.exception.StoreNotExistsException; import com.kusitms.jipbap.user.User; import com.kusitms.jipbap.user.UserRepository; import com.kusitms.jipbap.user.exception.UserNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @@ -14,13 +21,48 @@ public class StoreService { private final StoreRepository storeRepository; + private final StoreBookmarkRepository storeBookmarkRepository; private final UserRepository userRepository; - public void registerStore(String email, RegisterStoreRequestDto dto) { + @Transactional + public StoreDto registerStore(String email, RegisterStoreRequestDto dto) { User user = userRepository.findByEmail(email).orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다.")); - storeRepository.save( - new Store(null, user, dto.getName(), dto.getDescription(), dto.getKoreanYn(), dto.getAvgRate(), null) + if(storeRepository.existsByOwner(user)) { + throw new StoreExistsException("이미 가게를 생성한 유저입니다."); + } + Store store = storeRepository.save( + new Store(null, user, dto.getName(), dto.getDescription(), dto.getKoreanYn(), 0D, dto.getMinOrderAmount(),null, 0L, 0L, 0L) ); + return new StoreDto(store.getId(), store.getName(), store.getDescription(), store.getKoreanYn(), store.getAvgRate(), store.getBookmarkCount(), store.getImage()); + } + + @Transactional + public Slice searchStoreList(String email, Pageable pageable, String keyword, String standard, String order, Long lastId) { + User user = userRepository.findByEmail(email).orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다.")); + + return storeRepository.searchByKeywordOrderBySort(user, pageable, keyword, standard, order, lastId); + } + + @Transactional + public StoreDetailResponseDto getStoreDetail(String email, Long storeId) { + User user = userRepository.findByEmail(email).orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다.")); + + Store store = storeRepository.findById(storeId).orElseThrow(()-> new StoreNotExistsException("storeId: "+storeId+"에 해당하는 가게가 존재하지 않습니다.")); + return new StoreDetailResponseDto( + new StoreDto( + store.getId(), + store.getName(), + store.getDescription(), + store.getKoreanYn(), + store.getAvgRate(), + store.getMinOrderAmount(), + store.getImage() + ), + isStoreBookmarked(user, store) + ); + } + private Boolean isStoreBookmarked(User user, Store store){ + return storeBookmarkRepository.existsByUserAndStore(user, store); } } diff --git a/src/main/java/com/kusitms/jipbap/store/dto/RegisterStoreRequestDto.java b/src/main/java/com/kusitms/jipbap/store/dto/RegisterStoreRequestDto.java index 688a652..192a44d 100644 --- a/src/main/java/com/kusitms/jipbap/store/dto/RegisterStoreRequestDto.java +++ b/src/main/java/com/kusitms/jipbap/store/dto/RegisterStoreRequestDto.java @@ -7,9 +7,8 @@ @Setter public class RegisterStoreRequestDto { - private Long userId; private String name; private String description; private Boolean koreanYn; - private Double avgRate; + private Long minOrderAmount; } diff --git a/src/main/java/com/kusitms/jipbap/store/dto/StoreDetailResponseDto.java b/src/main/java/com/kusitms/jipbap/store/dto/StoreDetailResponseDto.java new file mode 100644 index 0000000..7e0c4f7 --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/store/dto/StoreDetailResponseDto.java @@ -0,0 +1,14 @@ +package com.kusitms.jipbap.store.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class StoreDetailResponseDto { + + private StoreDto storeDto; + private Boolean isBookmarked; +} diff --git a/src/main/java/com/kusitms/jipbap/store/dto/StoreDto.java b/src/main/java/com/kusitms/jipbap/store/dto/StoreDto.java new file mode 100644 index 0000000..f834b94 --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/store/dto/StoreDto.java @@ -0,0 +1,19 @@ +package com.kusitms.jipbap.store.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class StoreDto { + + private Long id; + private String name; + private String description; + private Boolean koreanYn; + private Double avgRate; // 가게 평점 + private Long minOrderAmount; //최소 주문 금액 + private String image; +} diff --git a/src/main/java/com/kusitms/jipbap/store/exception/StoreExistsException.java b/src/main/java/com/kusitms/jipbap/store/exception/StoreExistsException.java new file mode 100644 index 0000000..e772fc9 --- /dev/null +++ b/src/main/java/com/kusitms/jipbap/store/exception/StoreExistsException.java @@ -0,0 +1,7 @@ +package com.kusitms.jipbap.store.exception; + +public class StoreExistsException extends RuntimeException{ + public StoreExistsException(String message) { + super(message); + } +} diff --git a/src/main/java/com/kusitms/jipbap/user/User.java b/src/main/java/com/kusitms/jipbap/user/User.java index 0a91b37..56a0452 100644 --- a/src/main/java/com/kusitms/jipbap/user/User.java +++ b/src/main/java/com/kusitms/jipbap/user/User.java @@ -19,7 +19,7 @@ public class User extends DateEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name ="user_id") + @Column(name ="id") private Long id; //고유 pk @NotBlank diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3a1625f..cc2af70 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -22,7 +22,7 @@ spring: jpa: open-in-view: true hibernate: - ddl-auto: create + ddl-auto: create-drop show-sql: true properties: hibernate: