[#44] 매장 기능 도입 #45

Merged
pricelees merged 116 commits from feat/#44 into main 2025-09-20 03:15:06 +00:00
2 changed files with 54 additions and 30 deletions
Showing only changes of commit 1de8d08cb7 - Show all commits

View File

@ -25,17 +25,11 @@ import java.time.OffsetDateTime
const val INVALID_PK: Long = 9999L const val INVALID_PK: Long = 9999L
val tsidFactory = TsidFactory(0) val tsidFactory = TsidFactory(0)
fun randomPhoneNumber(): String {
val prefix = "010"
val middle = (1000..9999).random()
val last = (1000..9999).random()
return "$prefix$middle$last"
}
object StoreFixture { object StoreFixture {
fun create( fun create(
id: Long = tsidFactory.next(), id: Long = tsidFactory.next(),
name: String = "테스트행복", name: String = "테스트-${randomString()}",
address: String = "서울특별시 강북구 행복길 123", address: String = "서울특별시 강북구 행복길 123",
businessRegNum: String = "123-45-67890", businessRegNum: String = "123-45-67890",
regionCode: String = "1111000000" regionCode: String = "1111000000"
@ -49,24 +43,21 @@ object StoreFixture {
} }
object AdminFixture { object AdminFixture {
val default: AdminEntity = create() val default: AdminEntity = create(
val storeDefault: AdminEntity = create( account = "default"
account = "admin-store",
phone = randomPhoneNumber(),
type = AdminType.STORE,
storeId = tsidFactory.next()
) )
val hqDefault: AdminEntity = create( val storeDefault: AdminEntity = createStoreAdmin(
account = "admin-hq", account = "store-default",
phone = randomPhoneNumber(), )
type = AdminType.HQ,
storeId = null val hqDefault: AdminEntity = createHqAdmin(
account = "hq-default",
) )
fun createStoreAdmin( fun createStoreAdmin(
id: Long = tsidFactory.next(), id: Long = tsidFactory.next(),
account: String = "admin", account: String = randomString(),
password: String = "adminPassword", password: String = "adminPassword",
name: String = "admin12345", name: String = "admin12345",
phone: String = randomPhoneNumber(), phone: String = randomPhoneNumber(),
@ -87,7 +78,7 @@ object AdminFixture {
fun createHqAdmin( fun createHqAdmin(
id: Long = tsidFactory.next(), id: Long = tsidFactory.next(),
account: String = "admin", account: String = randomString(),
password: String = "adminPassword", password: String = "adminPassword",
name: String = "admin12345", name: String = "admin12345",
phone: String = randomPhoneNumber(), phone: String = randomPhoneNumber(),
@ -107,9 +98,9 @@ object AdminFixture {
fun create( fun create(
id: Long = tsidFactory.next(), id: Long = tsidFactory.next(),
account: String = "admin", account: String = randomString(),
password: String = "adminPassword", password: String = "adminPassword",
name: String = "admin12345", name: String = "admin",
phone: String = randomPhoneNumber(), phone: String = randomPhoneNumber(),
type: AdminType = AdminType.STORE, type: AdminType = AdminType.STORE,
storeId: Long? = tsidFactory.next(), storeId: Long? = tsidFactory.next(),
@ -127,14 +118,17 @@ object AdminFixture {
} }
object UserFixture { object UserFixture {
val default: UserEntity = createUser() val default: UserEntity = createUser(
name = "default",
email = "default-user@test.com"
)
fun createUser( fun createUser(
id: Long = tsidFactory.next(), id: Long = tsidFactory.next(),
name: String = "sample", name: String = randomString(),
email: String = "sample@example.com", email: String = randomEmail(),
password: String = "a".repeat(MIN_PASSWORD_LENGTH), password: String = "a".repeat(MIN_PASSWORD_LENGTH),
phone: String = "01012345678", phone: String = randomPhoneNumber(),
regionCode: String = "1111000000", regionCode: String = "1111000000",
status: UserStatus = UserStatus.ACTIVE status: UserStatus = UserStatus.ACTIVE
): UserEntity = UserEntity( ): UserEntity = UserEntity(
@ -148,17 +142,17 @@ object UserFixture {
) )
val createRequest: UserCreateRequest = UserCreateRequest( val createRequest: UserCreateRequest = UserCreateRequest(
name = "sample", name = randomString(),
email = "sample@example.com", email = randomEmail(),
password = "a".repeat(MIN_PASSWORD_LENGTH), password = "a".repeat(MIN_PASSWORD_LENGTH),
phone = "01012345678", phone = randomPhoneNumber(),
regionCode = "1111000000" regionCode = "1111000000"
) )
} }
object ThemeFixture { object ThemeFixture {
val createRequest: ThemeCreateRequest = ThemeCreateRequest( val createRequest: ThemeCreateRequest = ThemeCreateRequest(
name = "Matilda Green", name = randomString(),
description = "constituto", description = "constituto",
thumbnailUrl = "https://duckduckgo.com/?q=mediocrem", thumbnailUrl = "https://duckduckgo.com/?q=mediocrem",
difficulty = Difficulty.VERY_EASY, difficulty = Difficulty.VERY_EASY,

View File

@ -0,0 +1,30 @@
package roomescape.supports
import kotlin.random.Random
inline fun <T> initialize(name: String, block: () -> T): T {
return block()
}
fun randomPhoneNumber(): String {
val prefix = "010"
val middle = (1000..9999).random()
val last = (1000..9999).random()
return "$prefix$middle$last"
}
fun randomString(): String {
val chars = ('a'..'z') + ('0'..'9')
return (1..10)
.map { chars.random() }
.joinToString("")
}
fun randomEmail(): String = "${randomString()}@test.com"
fun randomBusinessRegNum(): String {
val part1 = Random.nextInt(100, 1000)
val part2 = Random.nextInt(10, 100)
val part3 = Random.nextInt(10000, 100000)
return "$part1-$part2-$part3"
}