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

๐Ÿ”€ 172 delete enrolled service #173

Merged
merged 9 commits into from
Jun 18, 2023
Merged

Conversation

KimTaeO
Copy link
Contributor

@KimTaeO KimTaeO commented Jun 16, 2023

๐Ÿ’ก ๊ฐœ์š”

์œ ์ €๊ฐ€ ๋“ฑ๋กํ•œ ์„œ๋น„์Šค๋ฅผ ์—ฌ๋Ÿฌ ๊ฐœ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋Š” api ์ž‘์„ฑ

๐Ÿ“ƒ ์ž‘์—…๋‚ด์šฉ

๐Ÿ”€ ๋ณ€๊ฒฝ์‚ฌํ•ญ

๐Ÿ™‹โ€โ™‚๏ธ ์งˆ๋ฌธ์‚ฌํ•ญ

โš—๏ธ ์‚ฌ์šฉ๋ฒ•

๐ŸŽธ ๊ธฐํƒ€

) {
fun execute(ids: List<Long>) {
val user = userUtil.fetchCurrentUser()
ids.map { clientRepository.deleteByIdAndCreatedBy(it, user) }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ids.map { clientRepository.deleteByIdAndCreatedBy(it, user) }
ids.forEach { clientRepository.deleteByIdAndCreatedBy(it, user) }

๊ฒฐ๊ณผ ์“ฐ๋Š”๊ฑฐ๋„ ์—†๋Š”๋ฐ map๋ง๊ณ  forEach๋กœ ํ•˜๋Š”๊ฑฐ ์–ด๋–ค๊ฐ€์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

๋„ต
ab909cd

) {
fun execute(ids: List<Long>) {
val user = userUtil.fetchCurrentUser()
ids.forEach { clientRepository.deleteByIdAndCreatedBy(it, user) }
Copy link
Contributor

Choose a reason for hiding this comment

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

ํ•˜๋‚˜์”ฉ ๋‹ค ๊บผ๋‚ด์„œ id๋กœ findํ•˜๋Š”๊ฒƒ๋ณด๋‹จ ids๋กœ ํ•œ๋ฒˆ์— ๋ฐ›์•„์„œ findAll ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค findAllByIdsAndUser(ids: List<Long>, createdBy: User) ์ด๋Ÿฐ์‹์œผ๋กœ์š”

Copy link
Contributor

Choose a reason for hiding this comment

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

fetch join์œผ๋กœ N+1๋„ ํ•ด๊ฒฐํ•˜๋ฉด ์ข‹์„๊ฑฐ๊ฐ™๊ธดํ•œ๋ฐ.. ์†Œ๊ทœ๋ชจํŠธ๋ž˜ํ”ฝ ์„œ๋น„์Šค๋‹ค๋ณด๋‹ˆ ์•„๋ฌด๋ž˜๋„ ๊ณ ๋ ค ์•ˆํ•ด๋„ ๋ ๊ฑฐ๊ฐ™๊ธฐ๋„ํ•˜๊ณ 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image ์•ˆ ๋˜๋˜๋ฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์ด ์žˆ์„๊นŒ์š”

Copy link
Contributor

Choose a reason for hiding this comment

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

deleteAllByIds

Copy link
Contributor

Choose a reason for hiding this comment

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

s๊ฐ€ ๋น ์ ธ์žˆ๋Š”๋Ž์‡ผ๋ผ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image ์ด๋ž˜์š”

Comment on lines 14 to 19
val booleanExpression = (client.id.`in`(ids)).and(client.createdBy.eq(createdBy))

jpaQueryFactory.delete(client)
.where(booleanExpression)
.execute()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

jpaQueryFactory.delete(client)
    .where(client.id.`in`(ids), client.createdBy.eq(createdBy))
    .execute()

๋ณ„๋กœ ์•ˆ๋ณต์žกํ•œ ์ฟผ๋ฆฌ๊ฐ™์€๋ฐ ๊ตณ์ด booleanExpression๋ณด๋‹จ ์ด๋ ‡๊ฒŒ ํ•ด๋„ ๋ ๋“ฏ
In

Copy link
Contributor

Choose a reason for hiding this comment

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

where์ ˆ ๋‚ด์—์„œ ์‰ผํ‘œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์กฐ๊ฑด์„ ์ง์ ‘ ์—ฐ๊ฒฐํ•˜๋ฌ˜ใ…•ใ„ด AND ์—ฐ์‚ฐ์ž์™€ ๊ฒฐํ•ฉ๋œ ์—ฌ๋Ÿฌ ์กฐ๊ฑด์„ ์ง€์ •ํ•  ์žˆ์–ด์„œ. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉดbooleanExpression ๋ณ€์ˆ˜๊ฐ€ ์—†์–ด๋„ ์‹คํ–‰์ด ๋ ๊ฑฐ์—์š”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

4834abe
๋„ค ์‹์„ ์กฐ๊ฑด์„ ์‰ผํ‘œ๋กœ ์—ฐ๊ฒฐํ•˜์˜€์Šต๋‹ˆ๋‹ค

@KimTaeO KimTaeO merged commit 4b54bf2 into main Jun 18, 2023
@KimTaeO KimTaeO deleted the 172-delete-enrolled-service branch June 18, 2023 09:39
@KimTaeO KimTaeO added 2๏ธโƒฃPriority: Medium ์šฐ์„ ์ˆœ์œ„ ์ค‘ โœจ Feature ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ labels Aug 23, 2023
@KimTaeO KimTaeO self-assigned this May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2๏ธโƒฃPriority: Medium ์šฐ์„ ์ˆœ์œ„ ์ค‘ โœจ Feature ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

๋“ฑ๋ก๋œ ์„œ๋น„์Šค ์„ ํƒ ์‚ญ์ œ API
3 participants