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

🔀 :: (#71) 알림 카테고리 활성화 / 비활성화 변경 #225

Merged
merged 7 commits into from
May 24, 2023

Conversation

lyutvs
Copy link
Member

@lyutvs lyutvs commented May 21, 2023

No description provided.

@lyutvs lyutvs added the 리팩토링 리팩토링이 필요함을 나타냅니다. label May 21, 2023
@lyutvs lyutvs self-assigned this May 21, 2023
Comment on lines 10 to 12
fun saveSetting(categories: List<Category>, userId: UUID, isActivated: Boolean): List<Setting>
fun updateSetting(categories: List<Category>, userId: UUID, isActivated: Boolean): List<Setting>
fun settingExist(categories: List<Category>, userId: UUID): Boolean
Copy link
Member

Choose a reason for hiding this comment

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

함수형도 복수형에 맞게 바꾸면 좋을듯

Copy link
Member Author

Choose a reason for hiding this comment

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

}

override fun updateSetting(category: Category, userId: UUID, isActivated: Boolean): Setting {
private fun saveSettingId(settingId: SettingId, isActivated: Boolean): Setting {
Copy link
Member

Choose a reason for hiding this comment

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

saveSettingId가 아니라 updateIsActiveById에 맞지 않나?

Copy link
Member Author

Choose a reason for hiding this comment

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

아 그러네요 isActivated를 받는다는걸 생각 못했네요

@@ -33,31 +34,21 @@ class SettingController(
}

@Operation(summary = "알림 카테고리 활성화")
Copy link
Member

Choose a reason for hiding this comment

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

p4) Api docs도 변경해주세용

Comment on lines 24 to 33
override fun saveAllSetting(categories: List<Category>, userId: UUID, isActivated: Boolean): List<Setting> {
return getSettingIdList(categories, userId).map {
updateIsActiveById(it, isActivated)
}
}

override fun updateAllSetting(categories: List<Category>, userId: UUID, isActivated: Boolean): List<Setting> {
return getSettingIdList(categories, userId).map {
updateIsActiveById(it, isActivated)
}
Copy link
Member

Choose a reason for hiding this comment

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

Q) 여기는 구현되어있는 부분이 동일한 것 같은데 분리해서 사용하는 이유가있나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

    override fun saveSetting(category: Category, userId: UUID, isActivated: Boolean): Setting {
        return settingMapper.settingEntityToDomain(
            settingRepository.save(
                SettingEntity(
                    settingId = getSettingId(category, userId),
                    isActivated = isActivated
                )
            )
        )
    }

    override fun updateSetting(category: Category, userId: UUID, isActivated: Boolean): Setting {
        return settingMapper.settingEntityToDomain(
            settingRepository.save(
                SettingEntity(
                    settingId = getSettingId(category, userId),
                    isActivated = isActivated
                )
            )
        )
    }

변경하기 전 코드도 동일한 로직이어서 구현은 분리해서 해놨습니다 이거 사용하는 UseCase가 save또는 update 두가지를 가져서 구분해둔것 같습니다

Copy link
Member

Choose a reason for hiding this comment

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

음.. 사용하는 UseCase에서 Save, Update를 나눈게 http status(201, 204)때문인걸로 기억하는데, save/update하는거는 위에서 호출하고 save/update여부에 따라 status만 반환하는게 있으면 되지 않을까 라는 생각이 듭니다.
굳이 동일한 method 2개를 유지할 필요는 없어보여서요!

Comment on lines 24 to 28
override fun saveAllSetting(categories: List<Category>, userId: UUID, isActivated: Boolean): List<Setting> {
return getSettingIdList(categories, userId).map {
updateIsActiveById(it, isActivated)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

p4) 개별적으로 save하는게 아니라 Entity를 만들어준걸 바탕으로 saveAll을 호출하는게 좋을 것 같아요

Copy link
Member

Choose a reason for hiding this comment

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

또는 .map을 사용하지않고, getSettingIdList: List을 updateIsActiveById에 넘겨줘서 한 번에 하는게 좋을지도..?
그냥 의견임니당

isActivated = isActivated
)

override fun updateAllSetting(categories: List<Category>, userId: UUID, isActivated: Boolean): List<Setting> {
Copy link
Member Author

@lyutvs lyutvs May 21, 2023

Choose a reason for hiding this comment

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

@leeseojune53 전부터 궁금했는데 update인데 save 형태로 동작한 이유가 궁금합니다

Copy link
Member

Choose a reason for hiding this comment

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

Update 동작을 하는데 save method를 사용한걸 이야기하는건가유?

Copy link
Member Author

Choose a reason for hiding this comment

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

네네 맞아요 updateSetting이라는 메소드 안에 save method를 사용한 이유가 궁금해요

Copy link
Member

Choose a reason for hiding this comment

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

Jpa에서 제일 간편하게 update 수행하는게 기존 Entity에서 값 변경 후 save라서 사용했습니다 :)

@lyutvs lyutvs requested a review from leeseojune53 May 21, 2023 13:34
Comment on lines 17 to 22
override fun activateCategory(categoryId: UUID, userId: UUID): Int {
override fun activateCategory(isActivate: Boolean, topic: String, userId: UUID): Int {
return saveOrUpdateSetting(
categoryId = categoryId,
isActivate = isActivate,
topic = topic,
userId = userId,
isActivate = true
)
Copy link
Member

@jeongho1209 jeongho1209 May 22, 2023

Choose a reason for hiding this comment

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

isActivate에 따라 활성화 또는 비활성화 시킬 수 있는 메소드니까 activateOrDeActivate 이런식으로 메소드명을 나타내주면 좋을 거 같습니다!

@lyutvs lyutvs requested a review from jeongho1209 May 22, 2023 12:25
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lyutvs lyutvs merged commit 5744326 into main May 24, 2023
@lyutvs lyutvs deleted the COR-71-setting-refector branch May 24, 2023 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
리팩토링 리팩토링이 필요함을 나타냅니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants