Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/create user #38

Merged
merged 12 commits into from
Oct 5, 2023
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
kotlin("plugin.jpa") apply false
id("org.springframework.boot") apply false
id("io.spring.dependency-management") apply false
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
id("jacoco")
}

Expand Down Expand Up @@ -43,6 +44,7 @@ subprojects {
apply(plugin = "org.springframework.boot")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "jacoco")
apply(plugin = "org.jlleitschuh.gradle.ktlint")

tasks.getByName("bootJar") {
enabled = false
Expand Down
1 change: 1 addition & 0 deletions commerce-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ dependencies {
runtimeOnly(project(":commerce-infra:db-main"))

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-validation")
testRuntimeOnly("com.h2database:h2")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.hanghae.commerce.user.application

import com.hanghae.commerce.user.domain.User
import com.hanghae.commerce.user.domain.UserType
import com.hanghae.commerce.user.domain.UserWriter
import com.hanghae.commerce.user.presentation.dto.*

Check failure on line 6 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt#L6 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt:6:1: error: Wildcard import (standard:no-wildcard-imports)
import org.springframework.stereotype.Service

@Service
class CustomerWriterService(
private val userWriter: UserWriter,
) {

Check failure on line 13 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt#L13 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt:13:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
fun createCustomer(request: CreateCustomerRequest): CreateCustomerResponse {
val savedUserId = userWriter.save(

Check failure on line 15 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt#L15 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/CustomerWriterService.kt:15:27: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
User.of(
name = request.name,
age = request.age,
email = request.email,
address = request.address,
userType = UserType.CUSTOMER,
),
)

return CreateCustomerResponse(id = savedUserId)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.hanghae.commerce.user.application

import com.hanghae.commerce.user.domain.User
import com.hanghae.commerce.user.domain.UserType
import com.hanghae.commerce.user.domain.UserWriter
import com.hanghae.commerce.user.presentation.dto.*

Check failure on line 6 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt#L6 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt:6:1: error: Wildcard import (standard:no-wildcard-imports)
import org.springframework.stereotype.Service

@Service
class SellerWriterService(
private val userWriter: UserWriter,
) {

Check failure on line 13 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt#L13 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt:13:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
fun createSeller(request: CreateSellerRequest): CreateSellerResponse {
val savedUserId = userWriter.save(

Check failure on line 15 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt#L15 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/SellerWriterService.kt:15:27: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
User.of(
name = request.name,
age = request.age,
email = request.email,
address = request.address,
userType = UserType.SELLER,
),
)

return CreateSellerResponse(id = savedUserId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.hanghae.commerce.user.application

import com.hanghae.commerce.user.domain.UserReader
import com.hanghae.commerce.user.presentation.dto.GetUserResponse
import org.springframework.stereotype.Service

@Service
class UserReaderService(
private val userReader: UserReader,
) {

Check failure on line 11 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/UserReaderService.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/UserReaderService.kt#L11 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/application/UserReaderService.kt:11:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
fun getUserById(userId: Long): GetUserResponse {
val user = userReader.read(userId) ?: throw IllegalArgumentException()
return GetUserResponse.of(user)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
package com.hanghae.commerce.user.domain

class User(
var id: Long? = null,
val name: String,
)
val age: Int,
val email: String,
val address: String,
val userType: UserType,
var id: Long? = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id 를 var와 Nullable 타입으로 선언하신 이유가 궁금합니다! id는 Null을 허용하지 않고 재할당될 수 없는 프로퍼티라고 생각합니다.
UUID 혹은 ULID를 활용하면 DB의 시퀀스나 auto-increment를 사용하지않고 객체 생성 시점에 ID에 값을 할당할 수 있습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀해주신대로 값 변경이 안되도록 val 타입을 사용하는게 맞는것 같습니다. id값을 UUID로 사용하면 nullable 타입으로 사용안해도 괜찮을 것 같네요

) {
init {
if (name.isBlank()) {
throw IllegalArgumentException("이름은 비어 있을 수 없습니다")
}
if (email.isBlank()) {
throw IllegalArgumentException("이메일은 비어 있을 수 없습니다")
}
if (address.isBlank()) {
throw IllegalArgumentException("주소는 비어 있을 수 없습니다")
}
}
Comment on lines +11 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로퍼티들에 대한 유효성 검사 로직을 User 도메인 모델 안에 정의함으로써 응집도를 높일 수 있는 것 같아 좋은 것 같습니다.


companion object {
fun of(name: String, age: Int, email: String, address: String, userType: UserType): User {

Check failure on line 24 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt#L24 <standard:function-signature>

Newline expected after opening parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt:24:16: error: Newline expected after opening parenthesis (standard:function-signature)

Check failure on line 24 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt#L24 <standard:function-signature>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt:24:30: error: Parameter should start on a newline (standard:function-signature)

Check failure on line 24 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt#L24 <standard:function-signature>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt:24:40: error: Parameter should start on a newline (standard:function-signature)

Check failure on line 24 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt#L24 <standard:function-signature>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt:24:55: error: Parameter should start on a newline (standard:function-signature)

Check failure on line 24 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt#L24 <standard:function-signature>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt:24:72: error: Parameter should start on a newline (standard:function-signature)

Check failure on line 24 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt#L24 <standard:function-signature>

Newline expected before closing parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/User.kt:24:90: error: Newline expected before closing parenthesis (standard:function-signature)
return User(name, age, email, address, userType)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import org.springframework.stereotype.Component
class UserReader(
private val userRepository: UserRepository,
) {

fun save(name: String) {
userRepository.save(User(name = name))
}

fun read(id: Long): User? {
return userRepository.read(id)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.hanghae.commerce.user.domain

import org.springframework.stereotype.Repository

@Repository
interface UserRepository {
fun save(user: User)
fun save(user: User): Long
fun read(id: Long): User?
fun allDelete()

Check failure on line 9 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/UserRepository.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/UserRepository.kt#L9 <standard:blank-line-before-declaration>

Expected a blank line for this declaration
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/domain/UserRepository.kt:9:5: error: Expected a blank line for this declaration (standard:blank-line-before-declaration)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.hanghae.commerce.user.domain

enum class UserType {
CUSTOMER,
SELLER,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.hanghae.commerce.user.domain

import org.springframework.stereotype.Component

@Component
class UserWriter(
private val userRepository: UserRepository,
) {
fun save(user: User): Long {
return userRepository.save(user)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hanghae.commerce.user.presentation

import com.hanghae.commerce.user.application.CustomerWriterService
import com.hanghae.commerce.user.presentation.dto.*

Check failure on line 4 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L4 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:4:1: error: Wildcard import (standard:no-wildcard-imports)
import org.springframework.web.bind.annotation.*

Check failure on line 5 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L5 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:5:1: error: Wildcard import (standard:no-wildcard-imports)

@RestController
@RequestMapping("/customer")
class CustomerController(
private val customerWriterService: CustomerWriterService,
) {

Check failure on line 12 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L12 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:12:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
@PostMapping
fun createCustomer(@RequestBody createCustomerRequest: CreateCustomerRequest): CreateCustomerResponse {

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L14 <standard:parameter-list-wrapping>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:14:24: error: Parameter should start on a newline (standard:parameter-list-wrapping)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L14 <standard:function-signature>

Newline expected after opening parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:14:24: error: Newline expected after opening parenthesis (standard:function-signature)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L14 <standard:parameter-list-wrapping>

Missing newline before ")"
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:14:81: error: Missing newline before ")" (standard:parameter-list-wrapping)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt#L14 <standard:function-signature>

Newline expected before closing parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/CustomerController.kt:14:81: error: Newline expected before closing parenthesis (standard:function-signature)
return customerWriterService.createCustomer(createCustomerRequest)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hanghae.commerce.user.presentation

import com.hanghae.commerce.user.application.SellerWriterService
import com.hanghae.commerce.user.presentation.dto.*

Check failure on line 4 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L4 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:4:1: error: Wildcard import (standard:no-wildcard-imports)
import org.springframework.web.bind.annotation.*

Check failure on line 5 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L5 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:5:1: error: Wildcard import (standard:no-wildcard-imports)

@RestController
@RequestMapping("/seller")
class SellerController(
private val sellerService: SellerWriterService,
) {

Check failure on line 12 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L12 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:12:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
@PostMapping
fun createSeller(@RequestBody createSellerRequest: CreateSellerRequest): CreateSellerResponse {

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L14 <standard:parameter-list-wrapping>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:14:22: error: Parameter should start on a newline (standard:parameter-list-wrapping)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L14 <standard:function-signature>

Newline expected after opening parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:14:22: error: Newline expected after opening parenthesis (standard:function-signature)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L14 <standard:parameter-list-wrapping>

Missing newline before ")"
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:14:75: error: Missing newline before ")" (standard:parameter-list-wrapping)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt#L14 <standard:function-signature>

Newline expected before closing parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/SellerController.kt:14:75: error: Newline expected before closing parenthesis (standard:function-signature)
return sellerService.createSeller(createSellerRequest)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
package com.hanghae.commerce.user.presentation

import org.springframework.web.bind.annotation.RestController
import com.hanghae.commerce.user.application.UserReaderService
import com.hanghae.commerce.user.presentation.dto.GetUserResponse
import org.springframework.web.bind.annotation.*

Check failure on line 5 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt#L5 <standard:no-wildcard-imports>

Wildcard import
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt:5:1: error: Wildcard import (standard:no-wildcard-imports)

@RestController
class UserController
@RequestMapping("/user")
class UserController(
private val userService: UserReaderService,
) {

Check failure on line 12 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt#L12 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt:12:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
@GetMapping("/{userId}")
fun getUser(@PathVariable userId: Long): GetUserResponse {

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt#L14 <standard:parameter-list-wrapping>

Parameter should start on a newline
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt:14:17: error: Parameter should start on a newline (standard:parameter-list-wrapping)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt#L14 <standard:function-signature>

Newline expected after opening parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt:14:17: error: Newline expected after opening parenthesis (standard:function-signature)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt#L14 <standard:parameter-list-wrapping>

Missing newline before ")"
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt:14:43: error: Missing newline before ")" (standard:parameter-list-wrapping)

Check failure on line 14 in commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt#L14 <standard:function-signature>

Newline expected before closing parenthesis
Raw output
commerce-api/src/main/kotlin/com/hanghae/commerce/user/presentation/UserController.kt:14:43: error: Newline expected before closing parenthesis (standard:function-signature)
return userService.getUserById(userId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.hanghae.commerce.user.presentation.dto

import jakarta.validation.constraints.NotBlank

data class CreateCustomerRequest(
@field:NotBlank(message = "이름을 공백으로 할 수 없습니다.")
val name: String,
val age: Int,
@field:NotBlank(message = "이메일을 공백으로 할 수 없습니다.")
val email: String,
@field:NotBlank(message = "주소를 공백으로 할 수 없습니다.")
val address: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.hanghae.commerce.user.presentation.dto

data class CreateCustomerResponse(
val id: Long,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.hanghae.commerce.user.presentation.dto

import jakarta.validation.constraints.NotBlank

data class CreateSellerRequest(
@field:NotBlank(message = "이름을 공백으로 할 수 없습니다.")
val name: String,
val age: Int,
@field:NotBlank(message = "이메일을 공백으로 할 수 없습니다.")
val email: String,
@field:NotBlank(message = "주소를 공백으로 할 수 없습니다.")
val address: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.hanghae.commerce.user.presentation.dto

data class CreateSellerResponse(
val id: Long,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.hanghae.commerce.user.presentation.dto

import com.hanghae.commerce.user.domain.User
import com.hanghae.commerce.user.domain.UserType

data class GetUserResponse(
val name: String,
val age: Int,
val email: String,
val address: String,
val id: Long,
val userType: UserType,
) {
companion object {
fun of(user: User): GetUserResponse {
return GetUserResponse(
name = user.name,
age = user.age,
email = user.email,
address = user.address,
userType = user.userType,
id = user.id!!,
)
}
}
}
4 changes: 2 additions & 2 deletions commerce-api/src/main/resources/application-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ spring:
config:
activate:
on-profile: develop


import:
- logging.yml
2 changes: 2 additions & 0 deletions commerce-api/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ spring:
config:
activate:
on-profile: local
import:
- logging.yml
2 changes: 2 additions & 0 deletions commerce-api/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ spring:
config:
activate:
on-profile: prod
import:
- logging.yml
1 change: 0 additions & 1 deletion commerce-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ spring:

config:
import:
- logging.yml
- db-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.hanghae.commerce.user.application

import com.hanghae.commerce.testconfiguration.IntegrationTest
import com.hanghae.commerce.user.domain.UserRepository
import com.hanghae.commerce.user.presentation.dto.CreateCustomerRequest
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired

@IntegrationTest
class CustomerWriterServiceTest(
@Autowired
private val customerWriterService: CustomerWriterService,
@Autowired
private val userRepository: UserRepository,
) {

Check failure on line 18 in commerce-api/src/test/kotlin/com/hanghae/commerce/user/application/CustomerWriterServiceTest.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/test/kotlin/com/hanghae/commerce/user/application/CustomerWriterServiceTest.kt#L18 <standard:no-empty-first-line-in-class-body>

Class body should not start with blank line
Raw output
commerce-api/src/test/kotlin/com/hanghae/commerce/user/application/CustomerWriterServiceTest.kt:18:1: error: Class body should not start with blank line (standard:no-empty-first-line-in-class-body)
@AfterEach
fun tearDown() {
userRepository.allDelete()
}

@Test
fun createCustomer() {
// given
val request = CreateCustomerRequest(

Check failure on line 27 in commerce-api/src/test/kotlin/com/hanghae/commerce/user/application/CustomerWriterServiceTest.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] commerce-api/src/test/kotlin/com/hanghae/commerce/user/application/CustomerWriterServiceTest.kt#L27 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
commerce-api/src/test/kotlin/com/hanghae/commerce/user/application/CustomerWriterServiceTest.kt:27:23: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
name = "sangmin",
age = 20,
email = "hanghae001@gmail.com",
address = "seoul",
)

// when
val result = customerWriterService.createCustomer(request)

// then
Assertions.assertThat(result.id).isNotNull
}
}
Loading
Loading