diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/.gitignore" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/.gitignore" new file mode 100644 index 0000000..13566b8 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/.gitignore" @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/.name" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/.name" new file mode 100644 index 0000000..af06312 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/.name" @@ -0,0 +1 @@ +workbook \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/compiler.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/compiler.xml" new file mode 100644 index 0000000..0efb954 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/compiler.xml" @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/dataSources.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/dataSources.xml" new file mode 100644 index 0000000..1cf0bde --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/dataSources.xml" @@ -0,0 +1,17 @@ + + + + + mysql.8 + true + com.mysql.cj.jdbc.Driver + jdbc:mysql://localhost:3306 + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/gradle.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/gradle.xml" new file mode 100644 index 0000000..446c193 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/gradle.xml" @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/jarRepositories.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/jarRepositories.xml" new file mode 100644 index 0000000..fdc392f --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/jarRepositories.xml" @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/misc.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/misc.xml" new file mode 100644 index 0000000..32e588a --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/misc.xml" @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/uiDesigner.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/uiDesigner.xml" new file mode 100644 index 0000000..2b63946 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/uiDesigner.xml" @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/vcs.xml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/vcs.xml" new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/.idea/vcs.xml" @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/build.gradle" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/build.gradle" index 1ec9f14..4e2b9dd 100644 --- "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/build.gradle" +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/build.gradle" @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.4.5' id 'io.spring.dependency-management' version '1.1.7' + id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" } group = 'org.umc' @@ -24,16 +25,52 @@ repositories { } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + // default (web, mysql, jpa, devtool, lombok, junit) implementation 'org.springframework.boot:spring-boot-starter-web' - compileOnly 'org.projectlombok:lombok' - developmentOnly 'org.springframework.boot:spring-boot-devtools' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.mysql:mysql-connector-j' + compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' + developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + // 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" + // jackson +// implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3' +// implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.3' +// implementation 'com.fasterxml.jackson.core:jackson-core:2.13.3' + // validation + implementation 'org.springframework.boot:spring-boot-starter-validation' + // slack webhook + implementation("com.slack.api:slack-api-client:1.45.3") } tasks.named('test') { useJUnitPlatform() } + +// Querydsl 설정부 +def generated = 'src/main/generated' + +querydsl { + jpa = true + querydslSourcesDir = generated +} +sourceSets { + main.java.srcDir generated +} + +compileQuerydsl{ + options.annotationProcessorPath = configurations.querydsl +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } + querydsl.extendsFrom compileClasspath +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QFoodCategory.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QFoodCategory.java" new file mode 100644 index 0000000..5767b31 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QFoodCategory.java" @@ -0,0 +1,52 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QFoodCategory is a Querydsl query type for FoodCategory + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QFoodCategory extends EntityPathBase { + + private static final long serialVersionUID = -1550649825L; + + public static final QFoodCategory foodCategory = new QFoodCategory("foodCategory"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final ListPath preferences = this.createList("preferences", org.umc.workbook.domain.mapping.MemberPrefer.class, org.umc.workbook.domain.mapping.QMemberPrefer.class, PathInits.DIRECT2); + + public final ListPath storeTypes = this.createList("storeTypes", StoreType.class, QStoreType.class, PathInits.DIRECT2); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QFoodCategory(String variable) { + super(FoodCategory.class, forVariable(variable)); + } + + public QFoodCategory(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QFoodCategory(PathMetadata metadata) { + super(FoodCategory.class, metadata); + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QMember.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QMember.java" new file mode 100644 index 0000000..16da63b --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QMember.java" @@ -0,0 +1,74 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QMember is a Querydsl query type for Member + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QMember extends EntityPathBase { + + private static final long serialVersionUID = 106563453L; + + public static final QMember member = new QMember("member1"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + public final StringPath address = createString("address"); + + public final ListPath agreements = this.createList("agreements", org.umc.workbook.domain.mapping.MemberAgree.class, org.umc.workbook.domain.mapping.QMemberAgree.class, PathInits.DIRECT2); + + public final DatePath birthDate = createDate("birthDate", java.time.LocalDate.class); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final StringPath email = createString("email"); + + public final EnumPath gender = createEnum("gender", org.umc.workbook.domain.enums.Gender.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final DateTimePath inactiveDate = createDateTime("inactiveDate", java.time.LocalDateTime.class); + + public final ListPath missions = this.createList("missions", org.umc.workbook.domain.mapping.MemberMission.class, org.umc.workbook.domain.mapping.QMemberMission.class, PathInits.DIRECT2); + + public final StringPath name = createString("name"); + + public final NumberPath point = createNumber("point", Integer.class); + + public final ListPath preferences = this.createList("preferences", org.umc.workbook.domain.mapping.MemberPrefer.class, org.umc.workbook.domain.mapping.QMemberPrefer.class, PathInits.DIRECT2); + + public final ListPath reviews = this.createList("reviews", Review.class, QReview.class, PathInits.DIRECT2); + + public final EnumPath socialType = createEnum("socialType", org.umc.workbook.domain.enums.SocialType.class); + + public final StringPath specAddress = createString("specAddress"); + + public final EnumPath status = createEnum("status", org.umc.workbook.domain.enums.MemberStatus.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QMember(String variable) { + super(Member.class, forVariable(variable)); + } + + public QMember(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QMember(PathMetadata metadata) { + super(Member.class, metadata); + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QMission.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QMission.java" new file mode 100644 index 0000000..0c24211 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QMission.java" @@ -0,0 +1,67 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QMission is a Querydsl query type for Mission + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QMission extends EntityPathBase { + + private static final long serialVersionUID = -870932215L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QMission mission = new QMission("mission"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final DateTimePath deadline = createDateTime("deadline", java.time.LocalDateTime.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final ListPath memberMissions = this.createList("memberMissions", org.umc.workbook.domain.mapping.MemberMission.class, org.umc.workbook.domain.mapping.QMemberMission.class, PathInits.DIRECT2); + + public final StringPath missionSpec = createString("missionSpec"); + + public final NumberPath reward = createNumber("reward", Integer.class); + + public final QStore store; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QMission(String variable) { + this(Mission.class, forVariable(variable), INITS); + } + + public QMission(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QMission(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QMission(PathMetadata metadata, PathInits inits) { + this(Mission.class, metadata, inits); + } + + public QMission(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.store = inits.isInitialized("store") ? new QStore(forProperty("store"), inits.get("store")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QRegion.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QRegion.java" new file mode 100644 index 0000000..142d178 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QRegion.java" @@ -0,0 +1,39 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QRegion is a Querydsl query type for Region + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QRegion extends EntityPathBase { + + private static final long serialVersionUID = 249537495L; + + public static final QRegion region = new QRegion("region"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public QRegion(String variable) { + super(Region.class, forVariable(variable)); + } + + public QRegion(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QRegion(PathMetadata metadata) { + super(Region.class, metadata); + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QReview.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QReview.java" new file mode 100644 index 0000000..dd96e88 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QReview.java" @@ -0,0 +1,68 @@ +package org.umc.workbook.domain; + +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 = 249984059L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QReview review = new QReview("review"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + public final StringPath body = createString("body"); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final ListPath images = this.createList("images", ReviewImage.class, QReviewImage.class, PathInits.DIRECT2); + + public final QMember member; + + public final NumberPath score = createNumber("score", Float.class); + + public final QStore store; + + //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.member = inits.isInitialized("member") ? new QMember(forProperty("member")) : null; + this.store = inits.isInitialized("store") ? new QStore(forProperty("store"), inits.get("store")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QReviewImage.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QReviewImage.java" new file mode 100644 index 0000000..5abf2a6 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QReviewImage.java" @@ -0,0 +1,61 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QReviewImage is a Querydsl query type for ReviewImage + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QReviewImage extends EntityPathBase { + + private static final long serialVersionUID = -1410879008L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QReviewImage reviewImage = new QReviewImage("reviewImage"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath imageUrl = createString("imageUrl"); + + public final QReview review; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QReviewImage(String variable) { + this(ReviewImage.class, forVariable(variable), INITS); + } + + public QReviewImage(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QReviewImage(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QReviewImage(PathMetadata metadata, PathInits inits) { + this(ReviewImage.class, metadata, inits); + } + + public QReviewImage(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.review = inits.isInitialized("review") ? new QReview(forProperty("review"), inits.get("review")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStore.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStore.java" new file mode 100644 index 0000000..8da64be --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStore.java" @@ -0,0 +1,78 @@ +package org.umc.workbook.domain; + +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 = 2087637918L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QStore store = new QStore("store"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + public final StringPath address = createString("address"); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath endTime = createNumber("endTime", Integer.class); + + public final ListPath iamges = this.createList("iamges", Storeimage.class, QStoreimage.class, PathInits.DIRECT2); + + public final NumberPath id = createNumber("id", Long.class); + + public final ListPath missions = this.createList("missions", Mission.class, QMission.class, PathInits.DIRECT2); + + public final StringPath name = createString("name"); + + public final QRegion region; + + public final ListPath reviews = this.createList("reviews", Review.class, QReview.class, PathInits.DIRECT2); + + public final NumberPath score = createNumber("score", Float.class); + + public final NumberPath startTime = createNumber("startTime", Integer.class); + + public final QStoreType type; + + //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.region = inits.isInitialized("region") ? new QRegion(forProperty("region")) : null; + this.type = inits.isInitialized("type") ? new QStoreType(forProperty("type"), inits.get("type")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStoreType.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStoreType.java" new file mode 100644 index 0000000..95140ff --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStoreType.java" @@ -0,0 +1,63 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QStoreType is a Querydsl query type for StoreType + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QStoreType extends EntityPathBase { + + private static final long serialVersionUID = 1000855544L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QStoreType storeType = new QStoreType("storeType"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + public final QFoodCategory category; + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final ListPath stores = this.createList("stores", Store.class, QStore.class, PathInits.DIRECT2); + + public final StringPath type = createString("type"); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QStoreType(String variable) { + this(StoreType.class, forVariable(variable), INITS); + } + + public QStoreType(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QStoreType(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QStoreType(PathMetadata metadata, PathInits inits) { + this(StoreType.class, metadata, inits); + } + + public QStoreType(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.category = inits.isInitialized("category") ? new QFoodCategory(forProperty("category")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStoreimage.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStoreimage.java" new file mode 100644 index 0000000..f1e9560 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QStoreimage.java" @@ -0,0 +1,61 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QStoreimage is a Querydsl query type for Storeimage + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QStoreimage extends EntityPathBase { + + private static final long serialVersionUID = 980772989L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QStoreimage storeimage = new QStoreimage("storeimage"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath imageUrl = createString("imageUrl"); + + public final QStore store; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QStoreimage(String variable) { + this(Storeimage.class, forVariable(variable), INITS); + } + + public QStoreimage(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QStoreimage(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QStoreimage(PathMetadata metadata, PathInits inits) { + this(Storeimage.class, metadata, inits); + } + + public QStoreimage(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.store = inits.isInitialized("store") ? new QStore(forProperty("store"), inits.get("store")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QTerms.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QTerms.java" new file mode 100644 index 0000000..9ccd815 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/QTerms.java" @@ -0,0 +1,54 @@ +package org.umc.workbook.domain; + +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; + + +/** + * QTerms is a Querydsl query type for Terms + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QTerms extends EntityPathBase { + + private static final long serialVersionUID = 2088117316L; + + public static final QTerms terms = new QTerms("terms"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + public final ListPath agreements = this.createList("agreements", org.umc.workbook.domain.mapping.MemberAgree.class, org.umc.workbook.domain.mapping.QMemberAgree.class, PathInits.DIRECT2); + + public final StringPath body = createString("body"); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final BooleanPath optional = createBoolean("optional"); + + public final StringPath title = createString("title"); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QTerms(String variable) { + super(Terms.class, forVariable(variable)); + } + + public QTerms(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QTerms(PathMetadata metadata) { + super(Terms.class, metadata); + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/common/QBaseEntity.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/common/QBaseEntity.java" new file mode 100644 index 0000000..9740fc8 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/common/QBaseEntity.java" @@ -0,0 +1,39 @@ +package org.umc.workbook.domain.common; + +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; + + +/** + * QBaseEntity is a Querydsl query type for BaseEntity + */ +@Generated("com.querydsl.codegen.DefaultSupertypeSerializer") +public class QBaseEntity extends EntityPathBase { + + private static final long serialVersionUID = -1899422348L; + + public static final QBaseEntity baseEntity = new QBaseEntity("baseEntity"); + + public final DateTimePath createdAt = createDateTime("createdAt", java.time.LocalDateTime.class); + + public final DateTimePath updatedAt = createDateTime("updatedAt", java.time.LocalDateTime.class); + + public QBaseEntity(String variable) { + super(BaseEntity.class, forVariable(variable)); + } + + public QBaseEntity(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QBaseEntity(PathMetadata metadata) { + super(BaseEntity.class, metadata); + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberAgree.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberAgree.java" new file mode 100644 index 0000000..78333d5 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberAgree.java" @@ -0,0 +1,64 @@ +package org.umc.workbook.domain.mapping; + +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; + + +/** + * QMemberAgree is a Querydsl query type for MemberAgree + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QMemberAgree extends EntityPathBase { + + private static final long serialVersionUID = -846774513L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QMemberAgree memberAgree = new QMemberAgree("memberAgree"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final org.umc.workbook.domain.QMember member; + + public final EnumPath status = createEnum("status", org.umc.workbook.domain.enums.AgreeStatus.class); + + public final org.umc.workbook.domain.QTerms terms; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QMemberAgree(String variable) { + this(MemberAgree.class, forVariable(variable), INITS); + } + + public QMemberAgree(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QMemberAgree(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QMemberAgree(PathMetadata metadata, PathInits inits) { + this(MemberAgree.class, metadata, inits); + } + + public QMemberAgree(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.member = inits.isInitialized("member") ? new org.umc.workbook.domain.QMember(forProperty("member")) : null; + this.terms = inits.isInitialized("terms") ? new org.umc.workbook.domain.QTerms(forProperty("terms")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberMission.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberMission.java" new file mode 100644 index 0000000..f300ab1 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberMission.java" @@ -0,0 +1,66 @@ +package org.umc.workbook.domain.mapping; + +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; + + +/** + * QMemberMission is a Querydsl query type for MemberMission + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QMemberMission extends EntityPathBase { + + private static final long serialVersionUID = 117227823L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QMemberMission memberMission = new QMemberMission("memberMission"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final org.umc.workbook.domain.QMember member; + + public final org.umc.workbook.domain.QMission mission; + + public final StringPath missionKey = createString("missionKey"); + + public final EnumPath status = createEnum("status", org.umc.workbook.domain.enums.MissionStatus.class); + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QMemberMission(String variable) { + this(MemberMission.class, forVariable(variable), INITS); + } + + public QMemberMission(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QMemberMission(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QMemberMission(PathMetadata metadata, PathInits inits) { + this(MemberMission.class, metadata, inits); + } + + public QMemberMission(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.member = inits.isInitialized("member") ? new org.umc.workbook.domain.QMember(forProperty("member")) : null; + this.mission = inits.isInitialized("mission") ? new org.umc.workbook.domain.QMission(forProperty("mission"), inits.get("mission")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberPrefer.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberPrefer.java" new file mode 100644 index 0000000..6500fc6 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/generated/org/umc/workbook/domain/mapping/QMemberPrefer.java" @@ -0,0 +1,62 @@ +package org.umc.workbook.domain.mapping; + +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; + + +/** + * QMemberPrefer is a Querydsl query type for MemberPrefer + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QMemberPrefer extends EntityPathBase { + + private static final long serialVersionUID = -40996339L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QMemberPrefer memberPrefer = new QMemberPrefer("memberPrefer"); + + public final org.umc.workbook.domain.common.QBaseEntity _super = new org.umc.workbook.domain.common.QBaseEntity(this); + + public final org.umc.workbook.domain.QFoodCategory category; + + //inherited + public final DateTimePath createdAt = _super.createdAt; + + public final NumberPath id = createNumber("id", Long.class); + + public final org.umc.workbook.domain.QMember member; + + //inherited + public final DateTimePath updatedAt = _super.updatedAt; + + public QMemberPrefer(String variable) { + this(MemberPrefer.class, forVariable(variable), INITS); + } + + public QMemberPrefer(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QMemberPrefer(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QMemberPrefer(PathMetadata metadata, PathInits inits) { + this(MemberPrefer.class, metadata, inits); + } + + public QMemberPrefer(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.category = inits.isInitialized("category") ? new org.umc.workbook.domain.QFoodCategory(forProperty("category")) : null; + this.member = inits.isInitialized("member") ? new org.umc.workbook.domain.QMember(forProperty("member")) : null; + } + +} + diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/WorkbookApplication.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/WorkbookApplication.java" index 106a4b7..f72ba61 100644 --- "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/WorkbookApplication.java" +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/WorkbookApplication.java" @@ -1,8 +1,15 @@ package org.umc.workbook; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.umc.workbook.service.MemberService.MemberService; +import org.umc.workbook.service.MissionService.MissionService; + +import java.time.LocalDateTime; @EnableJpaAuditing @SpringBootApplication @@ -11,5 +18,47 @@ public class WorkbookApplication { public static void main(String[] args) { SpringApplication.run(WorkbookApplication.class, args); } - +// +// @Bean +// public CommandLineRunner run(ApplicationContext context) { +// return args -> { +//// StoreQueryService storeService = context.getBean(StoreQueryService.class); +//// +//// // 파라미터 값 설정 +//// String name = "요아정"; +//// Float score = 4.0f; +//// +//// // 쿼리 메서드 호출 및 쿼리 문자열과 파라미터 출력 +//// System.out.println("Executing findStoresByNameAndScore with parameters:"); +//// System.out.println("Name: " + name); +//// System.out.println("Score: " + score); +//// +//// storeService.findStoresByNameAndScore(name, score) +//// .forEach(System.out::println); +// +// // 진행중 미션 쿼리 테스트 +// System.out.println("진행 중 미션 쿼리 테스트"); +// MissionService missionService = context.getBean(MissionService.class); +// +// Long memberId = 1L; +// Integer lastReward = 100; +// LocalDateTime lastCreatedAt = LocalDateTime.now(); +// Long lastMissionId = 1L; +// +// missionService.findMissionByMember(memberId, lastReward, lastCreatedAt, lastMissionId); +// +// // 홈 화면 +// System.out.println("홈 화면 테스트"); +// Long lastMissionId2 = 1L; +// Long memberId2 = 1L; +// missionService.findHomeMission(lastMissionId2, memberId2); +// +// // 마이페이지 +// System.out.println("마이페이지 조회 테스트"); +// Long memberId3 = 1L; +// MemberService memberService = context.getBean(MemberService.class); +// memberService.findById(memberId3); +// }; +// } +// } diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ApiResponse.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ApiResponse.java" new file mode 100644 index 0000000..13e260c --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ApiResponse.java" @@ -0,0 +1,38 @@ +package org.umc.workbook.apiPayload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.umc.workbook.apiPayload.code.SuccessStatus; + +@Getter +@AllArgsConstructor +@JsonPropertyOrder({"isSuccess", "code", "message", "result"}) +public class ApiResponse { + + @JsonProperty("isSuccess") + private final Boolean isSuccess; + private final String code; + private final String message; + @JsonInclude(JsonInclude.Include.NON_NULL) + private T result; + + + // 성공한 경우 응답 생성 + + public static ApiResponse onSuccess(T result){ + return new ApiResponse<>(true, SuccessStatus._OK.getCode() , SuccessStatus._OK.getMessage(), result); + } + + public static ApiResponse of(BaseCode code, T result){ + return new ApiResponse<>(true, code.getReasonHttpStatus().getCode() , code.getReasonHttpStatus().getMessage(), result); + } + + + // 실패한 경우 응답 생성 + public static ApiResponse onFailure(String code, String message, T data){ + return new ApiResponse<>(false, code, message, data); + } +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/BaseCode.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/BaseCode.java" new file mode 100644 index 0000000..a6be556 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/BaseCode.java" @@ -0,0 +1,7 @@ +package org.umc.workbook.apiPayload; + +public interface BaseCode { + ReasonDto getReason(); + + ReasonDto getReasonHttpStatus(); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/BaseErrorCode.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/BaseErrorCode.java" new file mode 100644 index 0000000..a8600d4 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/BaseErrorCode.java" @@ -0,0 +1,7 @@ +package org.umc.workbook.apiPayload; + +public interface BaseErrorCode { + ErrorReasonDto getReason(); + + ErrorReasonDto getReasonHttpStatus(); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ErrorReasonDto.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ErrorReasonDto.java" new file mode 100644 index 0000000..c8a8810 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ErrorReasonDto.java" @@ -0,0 +1,18 @@ +package org.umc.workbook.apiPayload; + +import lombok.Builder; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@Builder +public class ErrorReasonDto { + + private HttpStatus httpStatus; + + private final boolean isSuccess; + private final String code; + private final String message; + + public boolean getIsSuccess(){return isSuccess;} +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ReasonDto.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ReasonDto.java" new file mode 100644 index 0000000..5e62650 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/ReasonDto.java" @@ -0,0 +1,18 @@ +package org.umc.workbook.apiPayload; + +import lombok.Builder; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@Builder +public class ReasonDto { + + private HttpStatus httpStatus; + + private final boolean isSuccess; + private final String code; + private final String message; + + public boolean getIsSuccess(){return isSuccess;} +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/code/ErrorStatus.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/code/ErrorStatus.java" new file mode 100644 index 0000000..512bcf4 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/code/ErrorStatus.java" @@ -0,0 +1,55 @@ +package org.umc.workbook.apiPayload.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; +import org.umc.workbook.apiPayload.BaseErrorCode; +import org.umc.workbook.apiPayload.ErrorReasonDto; + +@Getter +@AllArgsConstructor +public enum ErrorStatus implements BaseErrorCode { + + // 가장 일반적인 응답 + _INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON500", "서버 에러, 관리자에게 문의 바랍니다."), + _BAD_REQUEST(HttpStatus.BAD_REQUEST,"COMMON400","잘못된 요청입니다."), + _UNAUTHORIZED(HttpStatus.UNAUTHORIZED,"COMMON401","인증이 필요합니다."), + _FORBIDDEN(HttpStatus.FORBIDDEN, "COMMON403", "금지된 요청입니다."), + + + // 멤버 관려 에러 + MEMBER_NOT_FOUND(HttpStatus.BAD_REQUEST, "MEMBER4001", "사용자가 없습니다."), + NICKNAME_NOT_EXIST(HttpStatus.BAD_REQUEST, "MEMBER4002", "닉네임은 필수 입니다."), + + // 예시,,, + ARTICLE_NOT_FOUND(HttpStatus.NOT_FOUND, "ARTICLE4001", "게시글이 없습니다."), + + // TODO 워크북 test + // For test + TEMP_EXCEPTION(HttpStatus.BAD_REQUEST, "TEMP4001", "이거는 테스트"); + + + private final HttpStatus httpStatus; + private final String code; + private final String message; + + @Override + public ErrorReasonDto getReason() { + return ErrorReasonDto.builder() + .message(message) + .code(code) + .isSuccess(false) + .build(); + } + + @Override + public ErrorReasonDto getReasonHttpStatus() { + return ErrorReasonDto.builder() + .message(message) + .code(code) + .isSuccess(false) + .httpStatus(httpStatus) + .build() + ; + } +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/code/SuccessStatus.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/code/SuccessStatus.java" new file mode 100644 index 0000000..f7d8488 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/code/SuccessStatus.java" @@ -0,0 +1,39 @@ +package org.umc.workbook.apiPayload.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; +import org.umc.workbook.apiPayload.BaseCode; +import org.umc.workbook.apiPayload.ReasonDto; + +@Getter +@AllArgsConstructor +public enum SuccessStatus implements BaseCode { + + // 일반적인 응답 + _OK(HttpStatus.OK, "COMMON200", "성공입니다."); + + private final HttpStatus httpStatus; + private final String code; + private final String message; + + @Override + public ReasonDto getReason() { + return ReasonDto.builder() + .message(message) + .code(code) + .isSuccess(true) + .build(); + } + + @Override + public ReasonDto getReasonHttpStatus() { + return ReasonDto.builder() + .message(message) + .code(code) + .isSuccess(true) + .httpStatus(httpStatus) + .build() + ; + } +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/ExceptionAdvice.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/ExceptionAdvice.java" new file mode 100644 index 0000000..f913dab --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/ExceptionAdvice.java" @@ -0,0 +1,194 @@ +package org.umc.workbook.apiPayload.exception; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.ConstraintViolationException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.hibernate.cfg.Environment; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.*; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +import org.umc.workbook.apiPayload.ApiResponse; +import org.umc.workbook.apiPayload.ErrorReasonDto; +import org.umc.workbook.apiPayload.code.ErrorStatus; + +import java.time.LocalDateTime; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Optional; + +@Slf4j +@RequiredArgsConstructor +@RestControllerAdvice(annotations = {RestController.class}) +public class ExceptionAdvice extends ResponseEntityExceptionHandler { + + private final RestTemplate restTemplate = new RestTemplate(); + @Value("${slack.webhook.url}") + private String slackWebhookUrl; + @Value("${spring.profiles.active}") + private String activeProfile; + + @ExceptionHandler + public ResponseEntity validation(ConstraintViolationException e, WebRequest request) { + String errorMessage = e.getConstraintViolations().stream() + .map(constraintViolation -> constraintViolation.getMessage()) + .findFirst() + .orElseThrow(() -> new RuntimeException("ConstraintViolationException 추출 도중 에러 발생")); + + return handleExceptionInternalConstraint(e, ErrorStatus.valueOf(errorMessage), HttpHeaders.EMPTY,request); + } + + @Override + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException e, HttpHeaders headers, HttpStatusCode status, WebRequest request) { + + Map errors = new LinkedHashMap<>(); + + e.getBindingResult().getFieldErrors().stream() + .forEach(fieldError -> { + String fieldName = fieldError.getField(); + String errorMessage = Optional.ofNullable(fieldError.getDefaultMessage()).orElse(""); + errors.merge(fieldName, errorMessage, (existingErrorMessage, newErrorMessage) -> existingErrorMessage + ", " + newErrorMessage); + }); + + return handleExceptionInternalArgs(e,HttpHeaders.EMPTY,ErrorStatus.valueOf("_BAD_REQUEST"),request,errors); + } + + @ExceptionHandler + public ResponseEntity exception(Exception e, HttpServletRequest request) { + e.printStackTrace(); + + return handleExceptionInternalFalse(e, ErrorStatus._INTERNAL_SERVER_ERROR, HttpHeaders.EMPTY, ErrorStatus._INTERNAL_SERVER_ERROR.getHttpStatus(),request, e.getMessage()); + } + + @ExceptionHandler(value = GeneralException.class) + public ResponseEntity onThrowException(GeneralException generalException, HttpServletRequest request) { + ErrorReasonDto errorReasonHttpStatus = generalException.getErrorReasonHttpStatus(); + + // slack webhook + if (generalException.getCode().equals(ErrorStatus._INTERNAL_SERVER_ERROR) + && activeProfile.equals("prod")) { + sendSlackErrorNotification(generalException, request); + } + + return handleExceptionInternal(generalException,errorReasonHttpStatus,null, request); + } + + @Override + protected ResponseEntity handleMissingServletRequestParameter( + MissingServletRequestParameterException ex, + HttpHeaders headers, + HttpStatusCode status, + WebRequest request) { + + String parameterName = ex.getParameterName(); + String message = String.format("요청 파라미터 '%s'가 필요합니다.", parameterName); + + ApiResponse body = ApiResponse.onFailure( + ErrorStatus._BAD_REQUEST.getCode(), + message, + null + ); + + return super.handleExceptionInternal(ex, body, headers, HttpStatus.BAD_REQUEST, request); + } + + private ResponseEntity handleExceptionInternal(Exception e, ErrorReasonDto reason, + HttpHeaders headers, HttpServletRequest request) { + + ApiResponse body = ApiResponse.onFailure(reason.getCode(),reason.getMessage(),null); +// e.printStackTrace(); + + WebRequest webRequest = new ServletWebRequest(request); + return super.handleExceptionInternal( + e, + body, + headers, + reason.getHttpStatus(), + webRequest + ); + } + + private ResponseEntity handleExceptionInternalFalse(Exception e, ErrorStatus errorCommonStatus, + HttpHeaders headers, HttpStatus status, HttpServletRequest request, String errorPoint) { + ApiResponse body = ApiResponse.onFailure(errorCommonStatus.getCode(),errorCommonStatus.getMessage(),errorPoint); + WebRequest webRequest = new ServletWebRequest(request); + + return super.handleExceptionInternal( + e, + body, + headers, + status, + webRequest + ); + } + + private ResponseEntity handleExceptionInternalArgs(Exception e, HttpHeaders headers, ErrorStatus errorCommonStatus, + WebRequest request, Map errorArgs) { + ApiResponse body = ApiResponse.onFailure(errorCommonStatus.getCode(),errorCommonStatus.getMessage(),errorArgs); + return super.handleExceptionInternal( + e, + body, + headers, + errorCommonStatus.getHttpStatus(), + request + ); + } + + private ResponseEntity handleExceptionInternalConstraint(Exception e, ErrorStatus errorCommonStatus, + HttpHeaders headers, WebRequest request) { + ApiResponse body = ApiResponse.onFailure(errorCommonStatus.getCode(), errorCommonStatus.getMessage(), null); + return super.handleExceptionInternal( + e, + body, + headers, + errorCommonStatus.getHttpStatus(), + request + ); + } + + private void sendSlackErrorNotification(Exception ex, HttpServletRequest request) { + + + String timestamp = LocalDateTime.now().toString(); + String message = String.format( + "*[🚨 500 Error 발생]* \n" + + "> *요청 URL:* `%s` \n" + + "> *발생 시각:* `%s` \n" + + "> *에러 메시지:* `%s` \n" + + "> *예외 타입:* `%s`", + request.getRequestURI(), + timestamp, + ex.getMessage(), + ex.getClass().getSimpleName() + ); + + try { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + HttpEntity> requestEntity = new HttpEntity<>( + Map.of("text", message), + headers + ); + + ResponseEntity response = restTemplate.postForEntity( + slackWebhookUrl, + requestEntity, + String.class + ); + + log.info("Slack Webhook 응답: {}", response.getStatusCode()); + + } catch (Exception e) { + log.warn("Slack Webhook 전송 실패: {}", e.getMessage()); + } + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/GeneralException.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/GeneralException.java" new file mode 100644 index 0000000..21d5d5b --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/GeneralException.java" @@ -0,0 +1,21 @@ +package org.umc.workbook.apiPayload.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.umc.workbook.apiPayload.BaseErrorCode; +import org.umc.workbook.apiPayload.ErrorReasonDto; + +@Getter +@AllArgsConstructor +public class GeneralException extends RuntimeException { + + private BaseErrorCode code; + + public ErrorReasonDto getErrorReason() { + return this.code.getReason(); + } + + public ErrorReasonDto getErrorReasonHttpStatus(){ + return this.code.getReasonHttpStatus(); + } +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/handler/TempHandler.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/handler/TempHandler.java" new file mode 100644 index 0000000..bb16c8a --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/apiPayload/exception/handler/TempHandler.java" @@ -0,0 +1,11 @@ +package org.umc.workbook.apiPayload.exception.handler; + +import org.umc.workbook.apiPayload.BaseErrorCode; +import org.umc.workbook.apiPayload.exception.GeneralException; + +public class TempHandler extends GeneralException { + + public TempHandler(BaseErrorCode errorCode) { + super(errorCode); + } +} \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/config/QueryDSLConfig.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/config/QueryDSLConfig.java" new file mode 100644 index 0000000..617ee65 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/config/QueryDSLConfig.java" @@ -0,0 +1,24 @@ +package org.umc.workbook.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 final EntityManager entityManager; + + public QueryDSLConfig(EntityManager entityManager) { + this.entityManager = entityManager; + } + + + @Bean + public JPAQueryFactory jpaQueryFactory(){ + return new JPAQueryFactory(entityManager); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/converter/MissionConverter.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/converter/MissionConverter.java" new file mode 100644 index 0000000..8420fa1 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/converter/MissionConverter.java" @@ -0,0 +1,41 @@ +package org.umc.workbook.converter; + +import org.umc.workbook.domain.Member; +import org.umc.workbook.domain.Mission; +import org.umc.workbook.domain.Store; +import org.umc.workbook.domain.enums.MissionStatus; +import org.umc.workbook.domain.mapping.MemberMission; +import org.umc.workbook.dto.MissionDto; + +import java.util.List; +import java.util.stream.Collectors; + +public class MissionConverter { + + public static List toMissionByMember(List missions){ + return missions.stream().map(m -> MissionConverter.toDto(m, m.getMission().getStore(), + m.getMission(), m.getMember())).collect(Collectors.toList()); + + } + + private static MissionDto toDto(MemberMission memberMission, Store store, + Mission mission, Member member) { + MissionDto.StoreDto storeDto = MissionDto.StoreDto.builder() + .id(store.getId()) + .name(store.getName()) + .build(); + + return MissionDto.builder() + .id(memberMission.getId()) + .status(memberMission.getStatus()) + .missionSpec(mission.getMissionSpec()) + .reward(mission.getReward()) + .memberId(member.getId()) + .storeDto(storeDto) + .build(); + } + + public static Mission toEntity(MissionDto dto) { + return null; + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/converter/TempConverter.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/converter/TempConverter.java" new file mode 100644 index 0000000..72f29bf --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/converter/TempConverter.java" @@ -0,0 +1,16 @@ +package org.umc.workbook.converter; + +import org.umc.workbook.web.dto.TempResponse; + +public class TempConverter { + public static TempResponse.TempTestDto toTempTestDTO(){ + return TempResponse.TempTestDto.builder() + .testString("This is Test!") + .build(); + } + public static TempResponse.TempExceptionDTO toTempExceptionDTO(Integer flag){ + return TempResponse.TempExceptionDTO.builder() + .flag(flag) + .build(); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Region.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Region.java" new file mode 100644 index 0000000..6dac152 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Region.java" @@ -0,0 +1,21 @@ +package org.umc.workbook.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class Region { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String name; +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Store.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Store.java" index 343a297..a6483b1 100644 --- "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Store.java" +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/Store.java" @@ -34,8 +34,13 @@ public class Store extends BaseEntity { private Float score; // TODO 쓸지말지 @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "store_type_id") private StoreType type; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "region_id") + private Region region; + @OneToMany(mappedBy = "store") private List missions = new ArrayList<>(); diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/enums/MissionStatus.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/enums/MissionStatus.java" index e8a15b6..8972c0e 100644 --- "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/enums/MissionStatus.java" +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/domain/enums/MissionStatus.java" @@ -1,5 +1,14 @@ package org.umc.workbook.domain.enums; +import java.util.Arrays; + public enum MissionStatus { - FAIL, PROGRESS, SUCCESS + FAIL, PROGRESS, SUCCESS; + + public static MissionStatus of(String value) { + return Arrays.stream(values()) + .filter(e -> e.toString().equals(value)) + .findFirst() + .orElseThrow(RuntimeException::new); + } } diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/dto/MissionDto.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/dto/MissionDto.java" new file mode 100644 index 0000000..22ca56e --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/dto/MissionDto.java" @@ -0,0 +1,28 @@ +package org.umc.workbook.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import org.umc.workbook.domain.Mission; +import org.umc.workbook.domain.Store; +import org.umc.workbook.domain.enums.MissionStatus; +import org.umc.workbook.domain.mapping.MemberMission; + +@Builder +@Data +public class MissionDto { + private Long id; + private Integer reward; + private String missionSpec; + private MissionStatus status; + private Long memberId; + private StoreDto storeDto; + + @Builder + @Data + public static class StoreDto { + private Long id; + private String name; + } + +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/FoodCategoryRepository.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/FoodCategoryRepository.java" new file mode 100644 index 0000000..9d2bb3c --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/FoodCategoryRepository.java" @@ -0,0 +1,4 @@ +package org.umc.workbook.repository; + +public interface FoodCategoryRepository { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepository.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepository.java" new file mode 100644 index 0000000..ef1b737 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepository.java" @@ -0,0 +1,7 @@ +package org.umc.workbook.repository.MemberRepository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.umc.workbook.domain.Member; + +public interface MemberRepository extends JpaRepository, MemberRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepositoryCustom.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepositoryCustom.java" new file mode 100644 index 0000000..07227c6 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepositoryCustom.java" @@ -0,0 +1,8 @@ +package org.umc.workbook.repository.MemberRepository; + +import org.umc.workbook.domain.Store; + +import java.util.List; + +public interface MemberRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepositoryImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepositoryImpl.java" new file mode 100644 index 0000000..34db201 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MemberRepository/MemberRepositoryImpl.java" @@ -0,0 +1,4 @@ +package org.umc.workbook.repository.MemberRepository; + +public class MemberRepositoryImpl implements MemberRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepository.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepository.java" new file mode 100644 index 0000000..61ba44e --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepository.java" @@ -0,0 +1,7 @@ +package org.umc.workbook.repository.MissionRepository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.umc.workbook.domain.Mission; + +public interface MissionRepository extends JpaRepository, MissionRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepositoryCustom.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepositoryCustom.java" new file mode 100644 index 0000000..8262ddd --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepositoryCustom.java" @@ -0,0 +1,14 @@ +package org.umc.workbook.repository.MissionRepository; + +import org.umc.workbook.domain.Mission; +import org.umc.workbook.domain.mapping.MemberMission; + +import java.time.LocalDateTime; +import java.util.List; + +public interface MissionRepositoryCustom { + + List findMissionByMemberPaging(Long memberId, Integer lastReward, LocalDateTime lastCreatedAt, Long lastMissionId); + + List findHoneMissionPaging(Long lastMissionId, Long memberId); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepositoryImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepositoryImpl.java" new file mode 100644 index 0000000..451974c --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/MissionRepository/MissionRepositoryImpl.java" @@ -0,0 +1,89 @@ +package org.umc.workbook.repository.MissionRepository; + +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.JPAExpressions; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Repository; +import org.umc.workbook.domain.Mission; +import org.umc.workbook.domain.QMission; +import org.umc.workbook.domain.enums.MissionStatus; +import org.umc.workbook.domain.mapping.MemberMission; + +import java.time.LocalDateTime; +import java.util.List; + +import static org.umc.workbook.domain.QMember.member; +import static org.umc.workbook.domain.QMission.mission; +import static org.umc.workbook.domain.QRegion.region; +import static org.umc.workbook.domain.QStore.store; +import static org.umc.workbook.domain.mapping.QMemberMission.memberMission; + +@Repository +@RequiredArgsConstructor +public class MissionRepositoryImpl implements MissionRepositoryCustom { + + private final JPAQueryFactory jpaQueryFactory; + @Value("${page.limit}") + private int limit; + + + @Override + public List findMissionByMemberPaging(Long memberId, Integer lastReward, LocalDateTime lastCreatedAt, Long lastMissionId) { + List result = jpaQueryFactory + .select(memberMission) + .from(memberMission) + .leftJoin(memberMission.mission).fetchJoin() + .leftJoin(memberMission.member).fetchJoin() + .leftJoin(memberMission.mission.store).fetchJoin() + .where( + memberMission.member.id.eq(memberId), + memberMission.status.in(List.of(MissionStatus.PROGRESS, MissionStatus.SUCCESS)), + cursorPredicate(mission, lastReward, lastCreatedAt, lastMissionId) + ) + .orderBy( + mission.reward.desc(), + mission.createdAt.desc(), + mission.id.desc() + ) + .limit(limit) + .fetch(); + return result; + } + + @Override + public List findHoneMissionPaging(Long lastMissionId, Long memberId) { + List results = jpaQueryFactory + .select(mission) + .from(mission) + .join(mission.store, store) + .join(store.region, region) + .where( + //region.name.eq(region.name), + mission.deadline.gt(LocalDateTime.now()), + mission.id.lt(lastMissionId), + mission.id.notIn( + JPAExpressions + .select(memberMission.mission.id) + .from(memberMission) + .where(memberMission.member.id.eq(memberId)) + ) + ) + .orderBy(mission.id.desc()) + .limit(10) + .fetch(); + + return results; + } + + private BooleanExpression cursorPredicate(QMission m, Integer reward, LocalDateTime createdAt, Long id) { + if (reward == null || createdAt == null || id == null) { + return null; + } + + return m.reward.lt(reward) + .or(m.reward.eq(reward).and(m.createdAt.lt(createdAt))) + .or(m.reward.eq(reward).and(m.createdAt.eq(createdAt)).and(m.id.lt(id))); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepository.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepository.java" new file mode 100644 index 0000000..6157120 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepository.java" @@ -0,0 +1,7 @@ +package org.umc.workbook.repository.ReviewRepository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.umc.workbook.domain.Review; + +public interface ReviewRepository extends JpaRepository, ReviewRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepositoryCustom.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepositoryCustom.java" new file mode 100644 index 0000000..4a7333e --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepositoryCustom.java" @@ -0,0 +1,4 @@ +package org.umc.workbook.repository.ReviewRepository; + +public interface ReviewRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepositoryImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepositoryImpl.java" new file mode 100644 index 0000000..0517831 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/ReviewRepository/ReviewRepositoryImpl.java" @@ -0,0 +1,18 @@ +package org.umc.workbook.repository.ReviewRepository; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class ReviewRepositoryImpl implements ReviewRepositoryCustom { + + private final JPAQueryFactory jpaQueryFactory; + + @Value("${page.limit}") + private int limit; + + +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepository.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepository.java" new file mode 100644 index 0000000..df4b186 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepository.java" @@ -0,0 +1,7 @@ +package org.umc.workbook.repository.StoreRepository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.umc.workbook.domain.Store; + +public interface StoreRepository extends JpaRepository, StoreRepositoryCustom { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepositoryCustom.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepositoryCustom.java" new file mode 100644 index 0000000..c5024b7 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepositoryCustom.java" @@ -0,0 +1,10 @@ +package org.umc.workbook.repository.StoreRepository; + +import org.umc.workbook.domain.Store; + +import java.util.List; + +public interface StoreRepositoryCustom { + + List dynamicQueryWithBooleanBuilder(String name, Float score); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepositoryImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepositoryImpl.java" new file mode 100644 index 0000000..a67a8f1 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/repository/StoreRepository/StoreRepositoryImpl.java" @@ -0,0 +1,37 @@ +package org.umc.workbook.repository.StoreRepository; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import org.umc.workbook.domain.Store; + +import java.util.List; + +import static org.umc.workbook.domain.QStore.store; + + +@Repository +@RequiredArgsConstructor +public class StoreRepositoryImpl implements StoreRepositoryCustom { + + private final JPAQueryFactory jpaQueryFactory; + + @Override + public List dynamicQueryWithBooleanBuilder(String name, Float score) { + BooleanBuilder predicate = new BooleanBuilder(); + + if (name != null) { + predicate.and(store.name.eq(name)); + } + + if (score != null) { + predicate.and(store.score.goe(4.0f)); + } + + return jpaQueryFactory + .selectFrom(store) + .where(predicate) + .fetch(); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MemberService/MemberService.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MemberService/MemberService.java" new file mode 100644 index 0000000..7ed2935 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MemberService/MemberService.java" @@ -0,0 +1,8 @@ +package org.umc.workbook.service.MemberService; + +import org.umc.workbook.domain.Member; + +public interface MemberService { + + Member findById(Long memberId); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MemberService/MemberServiceImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MemberService/MemberServiceImpl.java" new file mode 100644 index 0000000..9ebe491 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MemberService/MemberServiceImpl.java" @@ -0,0 +1,18 @@ +package org.umc.workbook.service.MemberService; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.umc.workbook.domain.Member; +import org.umc.workbook.repository.MemberRepository.MemberRepository; +import org.umc.workbook.service.MemberService.MemberService; + +@Service +@RequiredArgsConstructor +public class MemberServiceImpl implements MemberService { + + private final MemberRepository memberRepository; + + public Member findById(Long memberId) { + return memberRepository.findById(memberId).orElseThrow(() -> new RuntimeException("멤버 조회 불가")); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MissionService/MissionService.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MissionService/MissionService.java" new file mode 100644 index 0000000..7d54903 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MissionService/MissionService.java" @@ -0,0 +1,12 @@ +package org.umc.workbook.service.MissionService; + +import org.umc.workbook.domain.Mission; +import org.umc.workbook.domain.mapping.MemberMission; + +import java.time.LocalDateTime; +import java.util.List; + +public interface MissionService { + List findMissionByMember(Long memberId, Integer lastReward, LocalDateTime lastCreatedAt, Long lastMissionId); + List findHomeMission(Long missionId, Long memberId); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MissionService/MissionServiceImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MissionService/MissionServiceImpl.java" new file mode 100644 index 0000000..98f7df7 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/MissionService/MissionServiceImpl.java" @@ -0,0 +1,31 @@ +package org.umc.workbook.service.MissionService; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.umc.workbook.domain.Mission; +import org.umc.workbook.domain.mapping.MemberMission; +import org.umc.workbook.repository.MissionRepository.MissionRepository; + +import java.time.LocalDateTime; +import java.util.List; + +@Transactional(readOnly = true) +@Service +@RequiredArgsConstructor +public class MissionServiceImpl implements MissionService { + private final MissionRepository missionRepository; + + // 회원의 진행 중 미션 확인 + @Override + public List findMissionByMember(Long memberId, Integer lastReward, LocalDateTime lastCreatedAt, Long lastMissionId) { + return missionRepository + .findMissionByMemberPaging(memberId, lastReward, lastCreatedAt, lastMissionId); + } + + @Override + public List findHomeMission(Long missionId, Long memberId) { + return missionRepository.findHoneMissionPaging(missionId, memberId); + } + +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/ReviewService/ReviewService.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/ReviewService/ReviewService.java" new file mode 100644 index 0000000..9486507 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/ReviewService/ReviewService.java" @@ -0,0 +1,8 @@ +package org.umc.workbook.service.ReviewService; + +import org.umc.workbook.domain.Review; + +public interface ReviewService { + + Review saveReview(Review review); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/ReviewService/ReviewServiceImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/ReviewService/ReviewServiceImpl.java" new file mode 100644 index 0000000..1e71f5d --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/ReviewService/ReviewServiceImpl.java" @@ -0,0 +1,18 @@ +package org.umc.workbook.service.ReviewService; + + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.umc.workbook.domain.Review; +import org.umc.workbook.repository.ReviewRepository.ReviewRepository; + +@Service +@RequiredArgsConstructor +public class ReviewServiceImpl implements ReviewService { + private final ReviewRepository reviewRepository; + + @Override + public Review saveReview(Review review) { + return reviewRepository.save(review); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/StoreService/StoreQueryService.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/StoreService/StoreQueryService.java" new file mode 100644 index 0000000..981de80 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/StoreService/StoreQueryService.java" @@ -0,0 +1,12 @@ +package org.umc.workbook.service.StoreService; + +import org.umc.workbook.domain.Store; + +import java.util.List; +import java.util.Optional; + +public interface StoreQueryService { + + Optional findStore(Long id); + List findStoreByNameAndScore(String name, Float score); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/StoreService/StoreQueryServiceImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/StoreService/StoreQueryServiceImpl.java" new file mode 100644 index 0000000..d84cdf4 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/StoreService/StoreQueryServiceImpl.java" @@ -0,0 +1,32 @@ +package org.umc.workbook.service.StoreService; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.umc.workbook.domain.Store; +import org.umc.workbook.repository.StoreRepository.StoreRepository; + +import java.util.List; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class StoreQueryServiceImpl implements StoreQueryService { + + private final StoreRepository storeRepository; + + @Override + public Optional findStore(Long id) { + return storeRepository.findById(id); + } + + @Override + public List findStoreByNameAndScore(String name, Float score) { + List filteredStores = storeRepository.dynamicQueryWithBooleanBuilder(name, score); + + filteredStores.forEach(store -> System.out.println("Store: " + store)); + + return filteredStores; + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempCommandService.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempCommandService.java" new file mode 100644 index 0000000..51ae4e4 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempCommandService.java" @@ -0,0 +1,4 @@ +package org.umc.workbook.service.tempService; + +public interface TempCommandService { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempCommandServiceImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempCommandServiceImpl.java" new file mode 100644 index 0000000..38bbf3f --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempCommandServiceImpl.java" @@ -0,0 +1,4 @@ +package org.umc.workbook.service.tempService; + +public class TempCommandServiceImpl { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempQueryService.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempQueryService.java" new file mode 100644 index 0000000..05e90a2 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempQueryService.java" @@ -0,0 +1,6 @@ +package org.umc.workbook.service.tempService; + +public interface TempQueryService { + + void checkFlag(Integer flag); +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempQueryServiceImpl.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempQueryServiceImpl.java" new file mode 100644 index 0000000..8cbb70e --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/service/tempService/TempQueryServiceImpl.java" @@ -0,0 +1,14 @@ +package org.umc.workbook.service.tempService; + +import org.springframework.stereotype.Service; +import org.umc.workbook.apiPayload.code.ErrorStatus; +import org.umc.workbook.apiPayload.exception.handler.TempHandler; + +@Service +public class TempQueryServiceImpl implements TempQueryService{ + @Override + public void checkFlag(Integer flag) { + if (flag == 1) + throw new TempHandler(ErrorStatus.TEMP_EXCEPTION); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/controller/MissionController.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/controller/MissionController.java" new file mode 100644 index 0000000..4cba0c3 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/controller/MissionController.java" @@ -0,0 +1,32 @@ +package org.umc.workbook.web.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.*; +import org.umc.workbook.apiPayload.ApiResponse; +import org.umc.workbook.converter.MissionConverter; +import org.umc.workbook.domain.mapping.MemberMission; +import org.umc.workbook.service.MissionService.MissionService; + +import java.time.LocalDateTime; +import java.util.List; + +@RestController +@RequestMapping("mission") +@RequiredArgsConstructor +public class MissionController { + + private final MissionService missionService; + + @GetMapping("member/{memberId}") + public ApiResponse findMissionByMember(@PathVariable("memberId") Long memberId, + @RequestParam("reward") Integer reward, + @RequestParam("createdAt") @DateTimeFormat(pattern = "yyyyMMddHHmmss")LocalDateTime createdAt, + @RequestParam("missionId") Long missionId) { + List missions = missionService.findMissionByMember(memberId, reward, createdAt, missionId); + + return ApiResponse.onSuccess(MissionConverter.toMissionByMember(missions)); + + } + +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/controller/TempController.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/controller/TempController.java" new file mode 100644 index 0000000..65c2cb2 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/controller/TempController.java" @@ -0,0 +1,38 @@ +package org.umc.workbook.web.controller; + + +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.umc.workbook.apiPayload.ApiResponse; +import org.umc.workbook.apiPayload.code.ErrorStatus; +import org.umc.workbook.apiPayload.exception.handler.TempHandler; +import org.umc.workbook.converter.TempConverter; +import org.umc.workbook.service.tempService.TempQueryService; +import org.umc.workbook.web.dto.TempResponse; + +@RestController +@RequestMapping("/temp") +@RequiredArgsConstructor +public class TempController { + + private final TempQueryService tempQueryService; + + @GetMapping("test") + public ApiResponse testAPI() { + + return ApiResponse.onSuccess(TempConverter.toTempTestDTO()); + } + @GetMapping("/exception") + public ApiResponse exceptionAPI(@RequestParam("flag") Integer flag){ + tempQueryService.checkFlag(flag); + return ApiResponse.onSuccess(TempConverter.toTempExceptionDTO(flag)); + } + @GetMapping("internal-exception") + public ApiResponse exception500API(){ + // _INTERNAL_SERVER_ERROR + throw new TempHandler(ErrorStatus._INTERNAL_SERVER_ERROR); + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/dto/TempRequest.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/dto/TempRequest.java" new file mode 100644 index 0000000..b4b3807 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/dto/TempRequest.java" @@ -0,0 +1,4 @@ +package org.umc.workbook.web.dto; + +public class TempRequest { +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/dto/TempResponse.java" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/dto/TempResponse.java" new file mode 100644 index 0000000..74137ea --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/java/org/umc/workbook/web/dto/TempResponse.java" @@ -0,0 +1,25 @@ +package org.umc.workbook.web.dto; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +public class TempResponse { + @Builder + @AllArgsConstructor + @NoArgsConstructor + @Getter + public static class TempTestDto { + String testString; + } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class TempExceptionDTO{ + Integer flag; + } +} diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application-local.yml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application-local.yml" new file mode 100644 index 0000000..ae3d498 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application-local.yml" @@ -0,0 +1,14 @@ +spring: + config: + activate: + on-profile: local + +logging: + level: + org: + hibernate: + SQL: DEBUG + +slack: + webhook: + url: \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application-prod.yml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application-prod.yml" new file mode 100644 index 0000000..397b967 --- /dev/null +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application-prod.yml" @@ -0,0 +1,17 @@ +spring: + config: + activate: + on-profile: prod + +logging: + level: + org: + hibernate: + SQL: ERROR + +page: + limit: 30 + +slack: + webhook: + url: https://hooks.slack.com/services/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 \ No newline at end of file diff --git "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application.yml" "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application.yml" index 6eaae45..9b8755b 100644 --- "a/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application.yml" +++ "b/\355\214\250\355\212\270_\355\227\210\354\234\240\354\247\204/src/main/resources/application.yml" @@ -1,6 +1,8 @@ spring: application: name: workbook + profiles: + active: prod datasource: driver-class-name: com.mysql.cj.jdbc.Driver @@ -18,10 +20,17 @@ spring: properties: hibernate: globally_quoted_identifiers: true - show_sql: true + show_sql: false format_sql: true - use_sql_comments: true + use_sql_comments: false dialect: org.hibernate.dialect.MySQL8Dialect hbm2ddl: auto: none - default_batch_fetch_size: 1000 \ No newline at end of file + default_batch_fetch_size: 100 + +page: + limit: 30 + +slack: + webhook: + url: https://hooks.slack.com/services/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 \ No newline at end of file