-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Entity 생성 및 Domain Service 어노테이션 작성
Feature: Entity 생성 및 Domain Service 어노테이션 작성
- Loading branch information
Showing
34 changed files
with
1,363 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[{*.java,*.gradle}] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = tab | ||
indent_size = 4 | ||
tab_width = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
cakk-common/src/main/java/com/cakk/common/enums/CakeDesignCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.cakk.common.enums; | ||
|
||
public enum CakeDesignCategory { | ||
|
||
FLOWER | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.cakk.common.enums; | ||
|
||
public enum Gender { | ||
|
||
MALE, FEMALE, UNKNOWN | ||
} |
6 changes: 6 additions & 0 deletions
6
cakk-common/src/main/java/com/cakk/common/enums/LinkKind.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.cakk.common.enums; | ||
|
||
public enum LinkKind { | ||
|
||
WEB, KAKAOTALK, INSTAGRAM | ||
} |
6 changes: 6 additions & 0 deletions
6
cakk-common/src/main/java/com/cakk/common/enums/Provider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.cakk.common.enums; | ||
|
||
public enum Provider { | ||
|
||
APPLE, GOOGLE, KAKAO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
public enum Role { | ||
|
||
ROLE_ADMIN, | ||
ROLE_MERCHANT, | ||
ROLE_USER | ||
} |
5 changes: 3 additions & 2 deletions
5
cakk-common/src/main/java/com/cakk/common/exception/CakkException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cakk-domain/src/main/java/com/cakk/domain/annotation/Reader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.cakk.domain.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.springframework.core.annotation.AliasFor; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Indicates that an annotated class is a "Reader" (e.g. a data access object). | ||
* | ||
* <p>This annotation serves as a specialization of {@link Component @Component}, | ||
* allowing for implementation classes to be autodetected through classpath scanning. | ||
* | ||
* @author komment | ||
* @see Component | ||
* @see Repository | ||
*/ | ||
|
||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Component | ||
public @interface Reader { | ||
|
||
/** | ||
* Alias for {@link Component#value}. | ||
*/ | ||
@AliasFor(annotation = Component.class) | ||
String value() default ""; | ||
} |
34 changes: 34 additions & 0 deletions
34
cakk-domain/src/main/java/com/cakk/domain/annotation/Writer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.cakk.domain.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.springframework.core.annotation.AliasFor; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Indicates that an annotated class is a "Writer" (e.g. a data access object). | ||
* | ||
* <p>This annotation serves as a specialization of {@link Component @Component}, | ||
* allowing for implementation classes to be autodetected through classpath scanning. | ||
* | ||
* @author komment | ||
* @see Component | ||
* @see Repository | ||
*/ | ||
|
||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Component | ||
public @interface Writer { | ||
|
||
/** | ||
* Alias for {@link Component#value}. | ||
*/ | ||
@AliasFor(annotation = Component.class) | ||
String value() default ""; | ||
} |
2 changes: 2 additions & 0 deletions
2
cakk-domain/src/main/java/com/cakk/domain/config/DataSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
cakk-domain/src/main/java/com/cakk/domain/config/P6spyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.cakk.domain.config; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.p6spy.engine.spy.P6SpyOptions; | ||
|
||
@Configuration | ||
public class P6spyConfig { | ||
|
||
@PostConstruct | ||
public void setLogMessageFormat() { | ||
P6SpyOptions.getActiveInstance().setLogMessageFormat(P6spySqlFormatterConfig.class.getName()); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
cakk-domain/src/main/java/com/cakk/domain/config/P6spySqlFormatterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.cakk.domain.config; | ||
|
||
import static java.util.Arrays.*; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Locale; | ||
import java.util.Stack; | ||
import java.util.function.Predicate; | ||
|
||
import org.hibernate.engine.jdbc.internal.FormatStyle; | ||
|
||
import com.p6spy.engine.logging.Category; | ||
import com.p6spy.engine.spy.appender.MessageFormattingStrategy; | ||
|
||
public class P6spySqlFormatterConfig implements MessageFormattingStrategy { | ||
|
||
private static final String NEW_LINE = System.lineSeparator(); | ||
private static final String P6SPY_FORMATTER = "P6spySqlFormatterConfig"; | ||
private static final String PACKAGE = "com.cakk"; | ||
private static final String CREATE = "create"; | ||
private static final String ALTER = "alter"; | ||
private static final String COMMENT = "comment"; | ||
|
||
@Override | ||
public String formatMessage(final int connectionId, | ||
final String now, | ||
final long elapsed, | ||
final String category, | ||
final String prepared, | ||
final String sql, | ||
final String url) { | ||
return sqlFormatToUpper(sql, category, getMessage(connectionId, elapsed, getStackBuilder())); | ||
} | ||
|
||
@SuppressWarnings("StringBufferReplaceableByString") | ||
private String sqlFormatToUpper(final String sql, final String category, final String message) { | ||
if (sql.trim().isEmpty()) { | ||
return ""; | ||
} | ||
|
||
return new StringBuilder() | ||
.append(sqlFormatToUpper(sql, category)) | ||
.append(message) | ||
.toString(); | ||
} | ||
|
||
private String sqlFormatToUpper(final String sql, final String category) { | ||
if (isStatementDdl(sql, category)) { | ||
return FormatStyle.DDL | ||
.getFormatter() | ||
.format(sql) | ||
.toUpperCase(Locale.ROOT) | ||
.replace("+0900", ""); | ||
} | ||
return FormatStyle.BASIC | ||
.getFormatter() | ||
.format(sql) | ||
.replace("+0900", ""); | ||
} | ||
|
||
private boolean isStatementDdl(final String sql, final String category) { | ||
return isStatement(category) && isDdl(sql.trim().toLowerCase(Locale.ROOT)); | ||
} | ||
|
||
private boolean isStatement(final String category) { | ||
return Category.STATEMENT.getName().equals(category); | ||
} | ||
|
||
private boolean isDdl(final String lowerSql) { | ||
return lowerSql.startsWith(CREATE) || lowerSql.startsWith(ALTER) || lowerSql.startsWith(COMMENT); | ||
} | ||
|
||
private String getMessage(final int connectionId, final long elapsed, final StringBuilder callStackBuilder) { | ||
return new StringBuilder() | ||
.append(NEW_LINE) | ||
.append(NEW_LINE) | ||
.append("\t").append(String.format("Connection ID: %s", connectionId)) | ||
.append(NEW_LINE) | ||
.append("\t").append(String.format("Execution Time: %s ms", elapsed)) | ||
.append(NEW_LINE) | ||
.append(NEW_LINE) | ||
.append("\t").append(String.format("Call Stack (number 1 is entry point): %s", callStackBuilder)) | ||
.append(NEW_LINE) | ||
.append(NEW_LINE) | ||
.append("------------------------------------------------------------------------------------------------") | ||
.toString(); | ||
} | ||
|
||
private StringBuilder getStackBuilder() { | ||
final Stack<String> callStack = new Stack<>(); | ||
stream(new Throwable().getStackTrace()) | ||
.map(StackTraceElement::toString) | ||
.filter(isExcludeWords()) | ||
.forEach(callStack::push); | ||
|
||
int order = 1; | ||
final StringBuilder callStackBuilder = new StringBuilder(); | ||
while (!callStack.empty()) { | ||
callStackBuilder.append(MessageFormat.format("{0}\t\t{1}. {2}", NEW_LINE, order++, callStack.pop())); | ||
} | ||
return callStackBuilder; | ||
} | ||
|
||
private Predicate<String> isExcludeWords() { | ||
return charSequence -> charSequence.startsWith(PACKAGE) && !charSequence.contains(P6SPY_FORMATTER); | ||
} | ||
} |
Oops, something went wrong.