-
Notifications
You must be signed in to change notification settings - Fork 1
π μ½λ 컨벀μ
μ΅μ€νΈ edited this page Mar 26, 2024
·
11 revisions
KOIN API V2μμ μ¬μ©νλ μ½λ 컨벀μ μ€μ μ λν λ¬Έμμ λλ€.
ν΄λΉ 컨벀μ μ
- μΊ νΌμ€ ν΅λ°μ΄ Java μ½λ© 컨벀μ
- Google Java Style Guide μ μ°Έκ³ νμ¬ μμ±λμμ΅λλ€.
μλ 컨벀μ μ IntelliJμ μ μ©νλ€.
μμΈν μ μ© λ°©μμ π‘ μ½λ컨벀μ μ μ©νκΈ° λ¬Έμλ₯Ό μ°Έκ³ νμ¬ μ μ©νλ€.
νμΌ λ΄μ© 보기
<code_scheme name="BCSDLab-Backend-coding-convention-v1.0">
<!-- Referenced by Naver coding convention for Java (version 1.2) -->
<!-- https://naver.github.io/hackday-conventions-java/ -->
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="3" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
</value>
</option>
<option name="RIGHT_MARGIN" value="120" />
<option name="ENABLE_JAVADOC_FORMATTING" value="false" />
<option name="JD_KEEP_EMPTY_LINES" value="false" />
<option name="FORMATTER_TAGS_ENABLED" value="true" />
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JAVA">
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="THROWS_LIST_WRAP" value="5" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="USE_TAB_CHARACTER" value="false" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
static importλ μμΌλμΉ΄λ(*) μ¬μ©μ νμ©νλ€. λ¨, 3κ°λΆν° νμ©νλ€.
λ€μ΄λ²λ 120, ꡬκΈμ 100μ κΈ°μ€μΌλ‘ μ€ μ΅λ λλΉλ₯Ό μ‘λλ€.
- λ©μλ μ¬μ΄μ λΉ μ€μ μΆκ°νλ€.
- ν΄λμ€μ λ§μ§λ§ λ©μλμλ λΉ μ€μ μΆκ°νμ§ μλλ€. (λ©μλλ₯Ό ν¬ν¨νμ¬ ν΄λμ€ λ΄λΆμ λ§μ§λ§ κ΄νΈμ λΉ μ€μ μΆκ°νμ§ μλλ€.)
ꡬ쑰 보기
βββ koin
βββ KoinApplication.java
βββ domain
β βββ shop
β β βββ controller
β β β βββ ShopController.java
β β βββ domain
β β β βββ Menu.java
β β β βββ MenuCategory.java
β β β βββ MenuCategoryMap.java
β β β βββ MenuImage.java
β β β βββ MenuOption.java
β β βββ dto
β β β βββ ShopMenuResponse.java
β β βββ repository
β β β βββ MenuRepository.java
β β βββ service
β β βββ ShopService.java
βββ global
βββ common
β βββ BaseEntity.java
βββ config
β βββ JpaConfiguration.java
βββ exception
βββ GlobalExceptionHandler.java
-
Service Layer
μμλ λΉμ¦λμ€ λ‘μ§μ λνλ΄λ μ©μ΄λ₯Ό μ¬μ©νλ€.- μ‘°ν:
getXXX
- μ‘°ν:
-
Repository Layer
μμλ λ°μ΄ν°λ² μ΄μ€ μ κ·Όμ λνλ΄λ μ©μ΄λ₯Ό μ¬μ©νλ€.- Repositoryμμ λ¨μ μ‘°νλ‘μ§μ νΈμΆν κ²½μ°
Entity getByXXX()
λ©μλλ₯Ό νΈμΆνλ€. - λ³λμ μμΈ νΈλ€λ§μ΄ νμν κ²½μ°
Optinal<Entity> findByXXX()
λ©μλλ₯Ό νΈμΆνλ€. - JPAλ₯Ό μ¬μ©νμ¬ Repository interfaceλ₯Ό μ μν λ
Repository
λ₯Ό μμλ°μ ꡬννλ€.
- Repositoryμμ λ¨μ μ‘°νλ‘μ§μ νΈμΆν κ²½μ°
- recordλ₯Ό μ¬μ©νλ€.
- Java Codeμμλ camelCaseλ₯Ό ν΅ν΄ μμ±νκ³ κ²°κ³Όλ¬Όλ‘ snake_caseλ₯Ό μꡬν κ²½μ°
@JsonNaming(value = SnakeCaseStrategy.class)
λ±μ ν΅ν΄ snake_caseλ‘ μλ΅λλλ‘νλ€. - κΈ°μ‘΄ μ½μΈμ μλ μλ‘μ΄ κΈ°λ₯μ λ§λλ κ²½μ° κ²°κ³Όλ¬Όλ‘λ snake_caseλ‘ μλ΅λλλ‘ νλ€.
- ν΄λΌμ΄μΈνΈμ νΌλμ λκΈ° μν΄ κΈ°μ‘΄ μ½μΈμ DTO 컨벀μ μ λ°λΌκ°λ€
ν΄λΉ 컨벀μ μ λ§μ΄κ·Έλ μ΄μ κ³Όμ μμ νμλ‘ μ μ©λλ 컨벀μ μ λλ€.
κΈ°λ₯μ μμ±ν λ μΈμν μ€νΈλ₯Ό λ°λμ μμ±ν΄μΌνλ€. μΈμν μ€νΈλ RestAssuredλ₯Ό μ¬μ©νμ¬ μμ±νλ€.
μμΈν λ΄μ©μ μ½λλ₯Ό μ°Έκ³ νλ€.