Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ android {
applicationId = "com.sampoom.android"
minSdk = 26
targetSdk = 36
versionCode = 5
versionName = "1.0.4"
versionCode = 7
versionName = "1.0.6"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class AuthPreferences @Inject constructor(
val USER_EMAIL: Preferences.Key<String> = stringPreferencesKey("user_email")
val USER_ROLE: Preferences.Key<String> = stringPreferencesKey("user_role")
val USER_POSITION: Preferences.Key<String> = stringPreferencesKey("user_position")
val USER_WORKSPACE: Preferences.Key<String> = stringPreferencesKey("user_workspace")
val USER_BRANCH: Preferences.Key<String> = stringPreferencesKey("user_branch")
val USER_AGENCY_ID: Preferences.Key<String> = stringPreferencesKey("user_agency_id")
val USER_STARTED_AT: Preferences.Key<String> = stringPreferencesKey("user_started_at")
Expand All @@ -52,7 +51,6 @@ class AuthPreferences @Inject constructor(
prefs[Keys.USER_EMAIL] = cryptoManager.encrypt(user.email)
prefs[Keys.USER_ROLE] = cryptoManager.encrypt(user.role)
prefs[Keys.USER_POSITION] = cryptoManager.encrypt(user.position.name)
prefs[Keys.USER_WORKSPACE] = cryptoManager.encrypt(user.workspace)
prefs[Keys.USER_BRANCH] = cryptoManager.encrypt(user.branch)
prefs[Keys.USER_AGENCY_ID] = cryptoManager.encrypt(user.agencyId.toString())
prefs[Keys.USER_STARTED_AT] = cryptoManager.encrypt(user.startedAt.toString())
Expand Down Expand Up @@ -81,14 +79,13 @@ class AuthPreferences @Inject constructor(
val refreshToken = prefs[Keys.REFRESH_TOKEN]
val expiresAt = prefs[Keys.TOKEN_EXPIRES_AT]
val userPosition = prefs[Keys.USER_POSITION]
val userWorkspace = prefs[Keys.USER_WORKSPACE]
val userBranch = prefs[Keys.USER_BRANCH]
val userAgencyId = prefs[Keys.USER_AGENCY_ID]
val userStartedAt = prefs[Keys.USER_STARTED_AT]
val userEndedAt = prefs[Keys.USER_ENDED_AT]

if (userId != null && userName != null && userEmail != null && userRole != null &&
accessToken != null && refreshToken != null && userPosition != null && userWorkspace != null && userBranch != null && userAgencyId != null && userStartedAt != null && userEndedAt != null
accessToken != null && refreshToken != null && userPosition != null && userBranch != null && userAgencyId != null && userStartedAt != null && userEndedAt != null
) {
try {
val remaining = expiresAt?.let {
Expand All @@ -106,7 +103,6 @@ class AuthPreferences @Inject constructor(
cryptoManager.decrypt(userPosition).let { decrypted ->
try { UserPosition.valueOf(decrypted.uppercase()) } catch (_: Exception) { UserPosition.STAFF }
},
cryptoManager.decrypt(userWorkspace),
cryptoManager.decrypt(userBranch),
cryptoManager.decrypt(userAgencyId).toLong(),
cryptoManager.decrypt(userStartedAt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ fun LoginResponseDto.toModel(): User = User(
refreshToken = refreshToken,
expiresIn = expiresIn,
position = UserPosition.STAFF,
workspace = "",
branch = "",
agencyId = 0,
startedAt = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sampoom.android.feature.auth.data.remote.dto

data class LoginRequestDto(
val workspace: String,
val role: String,
val email: String,
val password: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.sampoom.android.feature.auth.data.remote.dto
data class SignUpRequestDto(
val email: String,
val password: String,
val workspace: String,
val role: String,
val branch: String,
val userName: String,
val position: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AuthRepositoryImpl @Inject constructor(
override suspend fun signUp(
email: String,
password: String,
workspace: String,
role: String,
branch: String,
userName: String,
position: String
Expand All @@ -32,7 +32,7 @@ class AuthRepositoryImpl @Inject constructor(
SignUpRequestDto(
email = email,
password = password,
workspace = workspace,
role = role,
branch = branch,
userName = userName,
position = position
Expand All @@ -55,7 +55,7 @@ class AuthRepositoryImpl @Inject constructor(
return runCatching {
val loginDto = api.login(
LoginRequestDto(
workspace = "AGENCY",
role = "AGENCY",
email = email,
password = password
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface AuthRepository {
suspend fun signUp(
email: String,
password: String,
workspace: String,
role: String,
branch: String,
userName: String,
position: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class SignUpUseCase @Inject constructor(
suspend operator fun invoke(
email: String,
password: String,
workspace: String,
role: String,
branch: String,
userName: String,
position: String
): Result<User> = repository.signUp(
email = email,
password = password,
workspace = workspace,
role = role,
branch = branch,
userName = userName,
position = position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.sampoom.android.feature.auth.domain.model.Vendor

data class SignUpUiState(
val name: String = "",
val workspace: String = "AGENCY",
val role: String = "AGENCY",
val branch: String = "",
val position: UserPosition? = null,
val email: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class SignUpViewModel @Inject constructor(
singUp(
email = s.email,
password = s.password,
workspace = s.workspace,
role = s.role,
branch = s.branch,
userName = s.name,
position = s.position!!.name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sampoom.android.feature.order.data.remote.dto

data class OrderRequestDto(
val agencyId: Long,
val agencyName: String, // branch
val items: List<OrderCategoryDto>
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class OrderRepositoryImpl @Inject constructor(
/** 주문 처리 */
override suspend fun createOrder(cartList: CartList): Result<Order> {
return runCatching {
val agencyId = authPreferences.getStoredUser()?.agencyId ?: throw Exception()
val agencyName = authPreferences.getStoredUser()?.branch ?: throw Exception()
val items = cartList.items.map { cart ->
OrderCategoryDto(
Expand All @@ -59,6 +60,7 @@ class OrderRepositoryImpl @Inject constructor(
}

val request = OrderRequestDto(
agencyId = agencyId,
agencyName = agencyName,
items = items
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fun GetProfileResponseDto.toModel(): User = User(
refreshToken = "",
expiresIn = 0L,
position = position.toUserPosition(),
workspace = workspace,
branch = branch,
agencyId = organizationId,
startedAt = startedAt,
Expand All @@ -41,7 +40,6 @@ fun UpdateProfileResponseDto.toModel(): User = User(
refreshToken = "",
expiresIn = 0L,
position = UserPosition.STAFF,
workspace = "",
branch = "",
agencyId = 0,
startedAt = null,
Expand All @@ -51,9 +49,8 @@ fun UpdateProfileResponseDto.toModel(): User = User(
fun EditEmployeeResponseDto.toModel(): Employee = Employee(
userId = userId,
email = "",
role = "",
role = role,
userName = userName,
workspace = workspace,
organizationId = 0,
branch = "",
position = position.toUserPosition(),
Expand All @@ -67,9 +64,8 @@ fun EditEmployeeResponseDto.toModel(): Employee = Employee(
fun UpdateEmployeeStatusResponseDto.toModel(): Employee = Employee(
userId = userId,
email = "",
role = "",
role = role,
userName = userName,
workspace = workspace,
organizationId = 0,
branch = "",
position = UserPosition.STAFF,
Expand All @@ -85,7 +81,6 @@ fun EmployeeDto.toModel(): Employee = Employee(
email,
role,
userName,
workspace,
organizationId,
branch,
position,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import retrofit2.http.Query
interface UserApi {
// 프로필 조회
@GET("user/profile")
suspend fun getProfile(@Query("workspace") workspace: String): ApiResponse<GetProfileResponseDto>
suspend fun getProfile(@Query("role") role: String): ApiResponse<GetProfileResponseDto>

// 프로필 수정
@PATCH("user/profile")
Expand All @@ -28,14 +28,14 @@ interface UserApi {
@PATCH("user/profile/{userId}")
suspend fun editEmployee(
@Path("userId") userId: Long,
@Query("workspace") workspace: String,
@Query("role") role: String,
@Body body: EditEmployeeRequestDto
): ApiResponse<EditEmployeeResponseDto>

// 직원 목록 조회
@GET("user/info")
suspend fun getEmployeeList(
@Query("workspace") workspace: String,
@Query("role") role: String,
@Query("organizationId") organizationId: Long,
@Query("page") page: Int = 0,
@Query("size") size: Int = 20
Expand All @@ -45,7 +45,7 @@ interface UserApi {
@PATCH("user/status/{userId}")
suspend fun updateEmployeeStatus(
@Path("userId") userId: Long,
@Query("workspace") workspace: String,
@Query("role") role: String,
@Body body: UpdateEmployeeStatusRequestDto
): ApiResponse<UpdateEmployeeStatusResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.sampoom.android.feature.user.data.remote.dto
data class EditEmployeeResponseDto(
val userId: Long,
val userName: String,
val workspace: String,
val role: String,
val position: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ data class EmployeeDto(
val email: String,
val role: String,
val userName: String,
val workspace: String,
val organizationId: Long,
val branch: String,
val position: UserPosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ data class GetProfileResponseDto(
val email: String,
val role: String,
val position: String,
val workspace: String,
val branch: String,
val organizationId: Long,
val startedAt: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.sampoom.android.feature.user.data.remote.dto
data class UpdateEmployeeStatusResponseDto(
val userId: Long,
val userName: String,
val workspace: String,
val role: String,
val employeeStatus: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class UserRepositoryImpl @Inject constructor(
}

/** 프로필 조회 */
override suspend fun getProfile(workspace: String): Result<User> {
override suspend fun getProfile(role: String): Result<User> {
return runCatching {
retry(times = 5, initialDelay = 300) {
val dto = api.getProfile(workspace)
val dto = api.getProfile(role)
if (!dto.success) throw Exception(dto.message)
val profileUser = dto.data.toModel()
val loginUser = preferences.getStoredUser()
Expand All @@ -46,7 +46,6 @@ class UserRepositoryImpl @Inject constructor(
refreshToken = loginUser.refreshToken, // 저장된 토큰
expiresIn = loginUser.expiresIn, // 저장된 토큰
position = profileUser.position,
workspace = profileUser.workspace,
branch = profileUser.branch,
agencyId = profileUser.agencyId,
startedAt = profileUser.startedAt,
Expand Down Expand Up @@ -82,7 +81,6 @@ class UserRepositoryImpl @Inject constructor(
refreshToken = storedUser.refreshToken,
expiresIn = storedUser.expiresIn,
position = user.position,
workspace = user.workspace,
branch = user.branch,
agencyId = user.agencyId,
startedAt = user.startedAt,
Expand All @@ -106,15 +104,15 @@ class UserRepositoryImpl @Inject constructor(
/** 직원 프로필 수정 */
override suspend fun editEmployee(
employee: Employee,
workspace: String
role: String
): Result<Employee> {
return runCatching {
val requestDto = EditEmployeeRequestDto(
position = employee.position.name
)
val dto = api.editEmployee(
userId = employee.userId,
workspace = workspace,
role = role,
body = requestDto
)
if (!dto.success) throw Exception(dto.message)
Expand All @@ -123,9 +121,8 @@ class UserRepositoryImpl @Inject constructor(
val completeEmployee = Employee(
userId = updatedEmployee.userId,
email = employee.email,
role = employee.role,
role = updatedEmployee.role.takeIf { it.isNotBlank() } ?: employee.role,
userName = updatedEmployee.userName.takeIf { it.isNotBlank() } ?: employee.userName,
workspace = updatedEmployee.workspace.takeIf { it.isNotBlank() } ?: employee.workspace,
organizationId = employee.organizationId,
branch = employee.branch,
position = updatedEmployee.position,
Expand All @@ -143,15 +140,15 @@ class UserRepositoryImpl @Inject constructor(
/** 직원 상태 수정 */
override suspend fun updateEmployeeStatus(
employee: Employee,
workspace: String
role: String
): Result<Employee> {
return runCatching {
val requestDto = UpdateEmployeeStatusRequestDto(
employeeStatus = employee.status.name
)
val dto = api.updateEmployeeStatus(
userId = employee.userId,
workspace = workspace,
role = role,
body = requestDto
)
if (!dto.success) throw Exception(dto.message)
Expand All @@ -160,9 +157,8 @@ class UserRepositoryImpl @Inject constructor(
val completedEmployeeStatus = Employee(
userId = updateEmployeeStatus.userId,
email = employee.email,
role = employee.role,
role = updateEmployeeStatus.role.takeIf { it.isNotBlank() } ?: employee.role,
userName = updateEmployeeStatus.userName.takeIf { it.isNotBlank() } ?: employee.userName,
workspace = updateEmployeeStatus.workspace.takeIf { it.isNotBlank() } ?: employee.workspace,
organizationId = employee.organizationId,
branch = employee.branch,
position = employee.position,
Expand All @@ -181,11 +177,11 @@ class UserRepositoryImpl @Inject constructor(
override suspend fun getEmployeeCount(): Result<Int> {
return runCatching {
val user = preferences.getStoredUser() ?: throw Exception()
val workspace = user.workspace
val role = user.role
val organizationId = user.agencyId

val dto = api.getEmployeeList(
workspace = workspace,
role = role,
organizationId = organizationId,
page = 0,
size = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ data class Employee(
val email: String,
val role: String,
val userName: String,
val workspace: String,
val organizationId: Long,
val branch: String,
val position: UserPosition,
Expand Down
Loading