-
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.
Related to: #346
- Loading branch information
Showing
8 changed files
with
92 additions
and
92 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
44 changes: 10 additions & 34 deletions
44
app/src/main/java/com/mongmong/namo/data/dto/CategoryDTO.kt
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 |
---|---|---|
@@ -1,56 +1,32 @@ | ||
package com.mongmong.namo.data.dto | ||
|
||
import com.mongmong.namo.domain.model.BaseResponse | ||
import com.google.gson.annotations.SerializedName | ||
import com.mongmong.namo.domain.model.CategoryModel | ||
|
||
/** 카테고리 생성 */ | ||
class PostCategoryResponse ( | ||
val result: PostCategoryResult | ||
) : BaseResponse() | ||
|
||
class PostCategoryResult ( | ||
@SerializedName("id") val categoryId: Long = 0 | ||
) | ||
import com.mongmong.namo.domain.model.BaseResponse | ||
|
||
data class CategoryRequestBody( | ||
val name : String, | ||
val paletteId: Int, | ||
val isShare: Boolean = true | ||
val categoryName : String, | ||
val colorId: Int, | ||
val isShared: Boolean = true | ||
) | ||
|
||
/** 카테고리 수정 */ | ||
class EditCategoryResponse ( | ||
val result: EditCategoryResult | ||
data class CategoryBaseResponse( | ||
val result: String | ||
) : BaseResponse() | ||
|
||
class EditCategoryResult ( | ||
@SerializedName("id") val categoryId: Long = 0 | ||
) | ||
|
||
/** 카테고리 삭제 */ | ||
data class DeleteCategoryResponse ( | ||
@SerializedName("result") val result : String | ||
) : BaseResponse() | ||
|
||
/** 모든 카테고리 조회 */ | ||
class GetCategoryResponse ( | ||
val result: List<GetCategoryResult> | ||
val result: List<CategoryDTO> | ||
) : BaseResponse() | ||
|
||
class GetCategoryResult ( | ||
class CategoryDTO ( | ||
val categoryId: Long, | ||
val categoryName: String, | ||
val colorId: Int, | ||
val baseCategory: Boolean, | ||
val shared: Boolean | ||
) { | ||
fun convertToCategory(): CategoryModel { | ||
return CategoryModel( | ||
categoryId = this.categoryId, | ||
name = this.categoryName, | ||
colorId = this.colorId, | ||
isShare = this.shared, | ||
) | ||
} | ||
} | ||
val isShared: Boolean | ||
) |
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
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/mongmong/namo/data/utils/mappers/CategoryMapper.kt
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,24 @@ | ||
package com.mongmong.namo.data.utils.mappers | ||
|
||
import com.mongmong.namo.data.dto.CategoryDTO | ||
import com.mongmong.namo.data.dto.CategoryRequestBody | ||
import com.mongmong.namo.domain.model.CategoryModel | ||
|
||
object CategoryMapper { | ||
fun CategoryModel.toDTO(): CategoryRequestBody { | ||
return CategoryRequestBody( | ||
categoryName = this.name, | ||
colorId = this.colorId, | ||
isShared = this.isShare | ||
) | ||
} | ||
|
||
fun CategoryDTO.toModel(): CategoryModel { | ||
return CategoryModel( | ||
categoryId = this.categoryId, | ||
name = this.categoryName, | ||
colorId = this.colorId, | ||
isShare = this.isShared | ||
) | ||
} | ||
} |
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