๐Ÿ“คย ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ

ํ…์ €๋ฆฐํ‹ฐยท2023๋…„ 11์›” 15์ผ
0

๐Ÿ›Ÿ ์ƒํ™ฉ

ํ•™์›์— ๋Œ€ํ•ด์„œ ๋ฆฌ๋ทฐ๋ฅผ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์ด ์žˆ๋‹ค.

ํ•™์›์„ ์กฐํšŒํ•  ๋•Œ ๋“ฑ๋ก๋œ ๋ฆฌ๋ทฐ ์นด์šดํŠธ๋ฅผ ๋น ๋ฅด๊ฒŒ ์กฐํšŒํ•  ํ•„์š”๊ฐ€ ์žˆ์—ˆ๋‹ค.

๊ทธ๋ ‡๋‹ค๋ฉด ๋ฆฌ๋ทฐ ๋“ฑ๋กํ•  ๋•Œ ๋ฆฌ๋ทฐ๋กœ ์„ ํƒํ•œ ํƒ€์ž… ์นด์šดํŠธ๊ฐ€ ์ฆ๊ฐ€๋˜์–ด์•ผ ํ•œ๋‹ค.

POST ๋ฉ”์†Œ๋“œ๋กœ ์š”์ฒญ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ, ๊ฐ’ ๊ฐฑ์‹  PATCH ๋ฉ”์†Œ๋“œ ๋™์ž‘์ด ํฌํ•จ๋˜๋Š” ๊ฒƒ์ด๋‹ค.

์„œ๋กœ ๋‹ค๋ฅธ ๋„๋ฉ”์ธ ๊ฐ„์˜ ์˜์กด์„ฑ์„ ์ค„์ผ ๋ฐฉ๋ฒ•์ด ํ•„์š”ํ–ˆ๋‹ค.

์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ

๊ทธ๊ฒŒ ๋‹ต์ด๋ผ ์ƒ๊ฐํ–ˆ๋‹ค.

๐ŸŽจย ERD

์˜ค์ง ํ•™์›์— ๋Œ€ํ•œ ๋ฆฌ๋ทฐ ์นด์šดํŠธ ์กฐํšŒ ์„ฑ๋Šฅ ์œ„ํ•ด ๋ฐ˜์ •๊ทœํ™” ํ–ˆ๋‹ค.

  • academy ๋„๋ฉ”์ธ
    • academies ํ…Œ์ด๋ธ”
      • Id : ์‹๋ณ„์ž
      • academyName : ํ•™์› ์ด๋ฆ„
    • review_counts ํ…Œ์ด๋ธ”
      • kindnessCount : ์นœ์ ˆํ•จ ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
      • goodFacilityCount : ์ข‹์€ ์‹œ์„ค ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
      • cheapFeeCount : ๊ฐ’์‹ผ ๊ต์œก๋น„ ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
      • goodManagementCount : ์ข‹์€ ๊ด€๋ฆฌ ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
  • reviews ๋„๋ฉ”์ธ
    • reviews ํ…Œ์ด๋ธ”
      • kindness : ์นœ์ ˆํ•จ ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
      • goodFacility : ์ข‹์€ ์‹œ์„ค ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
      • cheapFee : ๊ฐ’์‹ผ ๊ต์œก๋น„ ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜
      • goodManagement : ์ข‹์€ ๊ด€๋ฆฌ ๋ฆฌ๋ทฐ ๊ฐœ์ˆ˜

๋„ค์ด๋ฒ„ ๋ฆฌ๋ทฐ์ฒ˜๋Ÿผ ๋ฆฌ๋ทฐ ๋“ฑ๋ก ์‹œ ํŠน์ • ํ‚ค์›Œ๋“œ๋ฅผ ์„ ํƒํ•ด์„œ ๋ฆฌ๋ทฐ ์นด์šดํŠธ๋ฅผ ์ฆ๊ฐ€์‹œํ‚ค๋Š” ๋ฐฉ์‹์ด๋‹ค.

์ง€๋„์—์„œ ํ•™์›์„ ๊ฒ€์ƒ‰ํ•˜๋ฉด, ์—ฌํƒœ๊นŒ์ง€ ๊ฐฑ์‹ ๋œ ๋ฆฌ๋ทฐ ์นด์šดํŠธ๋ฅผ ์กฐํšŒํ•ด์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ณด์—ฌ์ค€๋‹ค.

๐Ÿค–ย ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ

์Šคํ”„๋ง ์ด๋ฒคํŠธ

  1. ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ EventDispatcher ์—๊ฒŒ ์ „๋‹ฌ
  2. EventDispatcher ๊ฐ€ ๋งคํ•‘๋˜๋Š” EventListener ์—ฐ๊ฒฐ
  3. EventListener ๊ฐ€ ์ „๋‹ฌ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ ํ™œ์šฉํ•ด ์ฝ”๋“œ ์‹คํ–‰

์˜์กด์„ฑ

Spring Web ์˜์กด์„ฑ์ด ํ•„์š”ํ•˜๋‹ค.

๊ทผ๋ฐ ์Šคํ”„๋ง ์“ฐ๋ฉด์„œ ์›น ์˜์กด์„ฑ ์•ˆ ํ•„์š”ํ•  ๋•Œ๊ฐ€ ์žˆ๋‚˜๋ชฐ๋ž‘

implementation 'org.springframework.boot:spring-boot-starter-web'

๊ตฌํ˜„

์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ์‹์€ ๊ฐ„๋‹จํ•˜๋‹ค.

  1. ์ด๋ฒคํŠธ ํด๋ž˜์Šค๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค.
  2. ๋ฆฌ์Šค๋„ˆ ํด๋ž˜์Šค๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค.
  3. ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๋ฅผ ํ˜ธ์ถœํ•ด์„œ ๋ฆฌ์Šค๋„ˆ์—๊ฒŒ ์˜ํ–ฅ์„ ์ค€๋‹ค.

์šฐ๋ฆฌ ํšจ์ž ์Šคํ”„๋ง์ด EventDispatcher๋ฅผ ์ด๋ฏธ ๊ตฌํ˜„ํ•ด๋†“์•˜๊ธฐ ๋•Œ๋ฌธ์— ์šฐ๋ฆฌ๋Š” ํŽธํ•˜๊ฒŒ ์ด๋ฒคํŠธ์™€ ๋ฆฌ์Šค๋„ˆ๋งŒ ๊ตฌํ˜„ํ•˜๊ณ  ๋“ฑ๋กํ•ด์„œ ์“ฐ๋ฉด ๋œ๋‹ค.

์Šคํ”„๋ง 4.2 ์ดํ›„ ๋ฒ„์ „

2023๋…„ ๊ธฐ์ค€ ์Šคํ”„๋ง์„ 4๋ฒ„์ „๊นŒ์ง€ ๋‚ฎ์ถฐ์„œ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ๋žŒ์€ ์—†์„๊ฑฐ๋ผ ์ƒ๊ฐํ•ด์„œ ์ตœ์‹  ๊ธฐ์ค€์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋‹ค.

4.2 ์ด์ „ ์ฝ”๋“œ์™€์˜ ์ฐจ์ด์ ์€ ApplicationEventPublisher ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•˜๋Š” ์ฝ”๋“œ ์œ ๋ฌด ์ •๋„๋‹ค.

์šฐ๋ฆฌ๋Š” ์Šคํ”„๋ง์˜ ํ˜ธ์˜๋ฅผ ๊ฐ์‚ฌํžˆ ๋ฐ›์•„๋“ค์ด๋ฉด ๋œ๋‹ค.

์ด๋ฒคํŠธ ํด๋ž˜์Šค

์ด๋ฒคํŠธ๋ฅผ ๋“ฑ๋ก, ํ˜ธ์ถœํ•˜๋Š” ์ฑ…์ž„์„ ๊ฐ–๋Š”๋‹ค.

์ด๋ฒคํŠธ๋กœ ํ˜ธ์ถœํ•˜๊ณ ํ”ˆ ์ฝ”๋“œ์— ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ์‘์ง‘ํ•˜๋Š” ํ•„๋“œ๋ฅผ ๋„ฃ์–ด๋†จ๋‹ค.

public class NewReviewEvent {

    private final Review review;

    public NewReviewEvent(Review review) {
        this.review = review;
    }

    public long getAcademyId() {
        return review.getAcademyId();
    }

    public Map<String, Boolean> getReviews() {
        return Map.of(
                "kindness", review.isKindness(),
                "goodFacility", review.isGoodFacility(),
                "cheapFee", review.isCheapFee(),
                "goodManagement", review.isGoodManagement());
    }

}

๋ฆฌ์Šค๋„ˆ ํด๋ž˜์Šค

์ด๋ฒคํŠธ ํด๋ž˜์Šค์— ์˜ํ•ด ํ˜ธ์ถœ๋˜๋Š” ํด๋ž˜์Šค

  • @Component ์Šคํ”„๋ง ๋นˆ์œผ๋กœ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋ž˜์•ผ EventDispatcher๊ฐ€ ๋Ÿฐํƒ€์ž„์— Event ํด๋ž˜์Šค์™€ ๋งคํ•‘ํ•ด์„œ ์—ฐ๊ฒฐํ•ด์ค„ ์ˆ˜ ์žˆ๋‹ค.
  • @EventListener ๋ฆฌ์Šค๋„ˆ๋กœ ๋“ฑ๋กํ•œ๋‹ค๋Š” ์˜๋ฏธ. ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ EventPublisher ๋ฅผ ๋ฐ›์•„์„œ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— Event์™€ ๋งคํ•‘๋˜๋Š” ๊ฒƒ. ํ•œ ๋ฆฌ์Šค๋„ˆ ํด๋ž˜์Šค์— ์—ฌ๋Ÿฌ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๋ฅผ ๋“ฑ๋กํ•ด๋„ ๋œ๋‹ค. ์ด๋•Œ๋Š” ๋ชจ๋“  ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๊ฐ€ ํ˜ธ์ถœ๋œ๋‹ค. ๋ฐ”๋กœ ๋‹ค์Œ ์ปฌ๋Ÿผ์— ์„ค๋ช… ์˜ˆ์ •
  • @TransactionalEventListener ๋ฆฌ์Šค๋„ˆ์˜ ๋™์ž‘๊นŒ์ง€๋„ ํŠธ๋žœ์žญ์…˜์— ํฌํ•จ์‹œํ‚ค๋Š” ์–ด๋…ธํ…Œ์ด์…˜์ด๋‹ค. ๋‚˜๋Š” DB ๊ฐฑ์‹ ์— ํ•ด๋‹นํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ๋ฆฌ์Šค๋„ˆ์—์„œ ํ•„์š”ํ•œ ๋‚ด์šฉ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ด ์–ด๋…ธํ…Œ์ด์…˜์„ ์ผ๋‹ค. ๋งŒ์•ฝ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ํ”„๋กœ์‹œ์ €์—์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด, ํ•ด๋‹น ์ด๋ฒคํŠธ์— ํ•ด๋‹นํ•˜๋Š” ํŠธ๋žœ์žญ์…˜ ์ž์ฒด๊ฐ€ ๋ชจ๋‘ ๋กค๋ฐฑ๋œ๋‹ค.
    ์˜ต์…˜(phase)์„ค๋ช…
    TransactionPhase.AFTER_COMMIT(๊ธฐ๋ณธ๊ฐ’) ํŠธ๋žœ์žญ์…˜ ์ปค๋ฐ‹๋  ๋•Œ ์ด๋ฒคํŠธ ์‹คํ–‰
    TransactionPhase.ROLLBACKํŠธ๋žœ์žญ์…˜ ๋กค๋ฐฑ๋  ๋•Œ ์ด๋ฒคํŠธ ์‹คํ–‰
    TransactionPhase.AFTER_COMPLETIONํŠธ๋žœ์žญ์…˜ ์ปค๋ฐ‹ ํ˜น์€ ๋กค๋ฐฑ๋  ๋•Œ ์ด๋ฒคํŠธ ์‹คํ–‰
    TransactionPhase.BEFORE_COMMITํŠธ๋žœ์žญ์…˜ ์ปค๋ฐ‹ ์ „์— ์ด๋ฒคํŠธ ์‹คํ–‰
@Component
public class NewReviewEventListener {

    private final AcademyService academyService;

    public NewReviewEventListener(AcademyService academyService) {
        this.academyService = academyService;
    }

    // @EventListener
		@TransactionalEventListener
    public void sendPush(NewReviewEvent event) {
        long academyId = event.getAcademyId();
        Map<String, Boolean> reviews = event.getReviews();

        academyService.updateReviewCount(academyId, reviews);
    }

}

์ด๋ฒคํŠธ ๋“ฑ๋ก

๋ฆฌ๋ทฐ ๋“ฑ๋ก ๋ฉ”์†Œ๋“œ์—์„œ ์ด๋ฒคํŠธ๋ฅผ ํ™œ์šฉํ–ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ์›ํ•˜๋Š” ๋ฉ”์†Œ๋“œ์—์„œ ์ด๋ฒคํŠธ๋ฅผ ์ƒ์„ฑํ•ด์„œ ๋“ฑ๋กํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

publishEvent ๋ฉ”์†Œ๋“œ๋ฅผ ํ™œ์šฉํ•ด์„œ ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚จ๋‹ค.

@Service
@Transactional(readOnly = true)
public class ReviewService {

		// ์ด๋ฒคํŠธ ๋“ฑ๋ก์ž ์ฃผ์ž…
    private final ApplicationEventPublisher eventPublisher;
    private final ReviewJpaRepository reviewJpaRepository;

    public ReviewService(
            ApplicationEventPublisher eventPublisher,
            ReviewJpaRepository reviewJpaRepository
    ) {
        this.eventPublisher = eventPublisher;
        this.reviewJpaRepository = reviewJpaRepository;
    }

    @Transactional
    public ReviewResult createReview(long academyId, ReviewParam param) {
        Review review = param.toEntity(academyId);
        Review save = reviewJpaRepository.save(review);

				// ๋“ฑ๋กํ•  ์ด๋ฒคํŠธ ์ƒ์„ฑ
        NewReviewEvent newReviewEvent = new NewReviewEvent(save);

				// ์ด๋ฒคํŠธ ๋“ฑ๋ก
        eventPublisher.publishEvent(newReviewEvent);

        return ReviewResult.from(save);
    }

}

๋™๊ธฐ vs ๋น„๋™๊ธฐ

๋ฐ˜๊ฐ€์šด ์šฐ๋ฆฌ ๋™๊ธฐ ํ˜•์ œ.

๋™๊ธฐ๋Š” ์‘๋‹ต ๊ธฐ๋‹ค๋ฆฌ๊ณ  ๋‹ค์Œ๊บผ ์‹คํ–‰.

๋น„๋™๊ธฐ๋Š” ์‘๋‹ต ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š๊ณ  ๋‹ค์Œ๊บผ ์‹คํ–‰.

์—ฌ๊ธฐ์„  ์ด์ •๋„๋กœ ์ •๋ฆฌ ๊ฐ€๋Šฅํ•˜๋‹ค.

์Šคํ”„๋ง ์ด๋ฒคํŠธ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ๋™๊ธฐ ์ฒ˜๋ฆฌ๋ฅผ ์ง€์›ํ•œ๋‹ค.

์‰ฝ๊ฒŒ ๋งํ•ด์„œ ๋ฆฌ์Šค๋„ˆ์˜ ๋ชจ๋“  ๋ฉ”์†Œ๋“œ๊ฐ€ ๊ฐ์ž ์‹คํ–‰ โ†’ ์‘๋‹ต ํ›„์— ๋‹ค์Œ ๋ฉ”์†Œ๋“œ๊ฐ€ ์‹คํ–‰๋œ๋‹ค๋Š” ๊ฒƒ.

๋น„๋™๊ธฐ๋Š” ์‘๋‹ต ์ „์— ๋‹ค๋ฅธ ๋ฉ”์†Œ๋“œ๋„ ์‹คํ–‰ํ•œ๋‹ค.

๋”ฑ ๋ด๋„ ์„ฑ๋Šฅ๊ณผ ์ •ํ•ฉ์„ฑ ํŠธ๋ ˆ์ด๋“œ ์˜คํ”„๋ผ๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋ ‡๋‹ค๋ฉด ๊ถ๊ธˆํ•œ ์ ์ด ์ƒ๊ธด๋‹ค.

๋™๊ธฐ ์ฒ˜๋ฆฌํ•  ๋•Œ ์‹คํ–‰ ์ˆœ์„œ๋Š” ์–ด๋–ป๊ฒŒ ์ •ํ•ด์ง€๋‚˜?

@Slf4j
@Component
public class NewReviewEventListener {

    @EventListener
    public void sendPush(NewReviewEvent event) {
        log.info("์ฒซ ๋ฒˆ์งธ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ์‹คํ–‰");
    }

    @EventListener
    public void sendPush2(NewReviewEvent event) {
        log.info("๋‘ ๋ฒˆ์งธ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ์‹คํ–‰");
    }

}

์‘๋‹ต์„ ๋ณด๋ฉด ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด ์ฝ”๋“œ ์ˆœ์„œ ๋Œ€๋กœ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ๋น„๋™๊ธฐ์ผ ๋•Œ๋Š”?

@Slf4j
@Component
public class NewReviewEventListener {

    @Async
    @EventListener
    public void sendPush(NewReviewEvent event) throws InterruptedException {
        log.info("์ฒซ ๋ฒˆ์งธ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ์‹คํ–‰");

        Thread.sleep(1_000);

        log.info("์ฒซ ๋ฒˆ์งธ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ์ข…๋ฃŒ");
    }

    @Async
    @EventListener
    public void sendPush2(NewReviewEvent event) {
        log.info("๋‘ ๋ฒˆ์งธ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ์‹คํ–‰");
        log.info("๋‘ ๋ฒˆ์งธ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ๋ฉ”์†Œ๋“œ ์ข…๋ฃŒ");
    }

}

@Async ์–ด๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•ด์„œ ๋น„๋™๊ธฐ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.

๐Ÿ—‚๏ธย ํŒจํ‚ค์ง€ ๊ตฌ์กฐ

์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉด์„œ ๊ณ ๋ฏผ๊ฑฐ๋ฆฌ๊ฐ€ ํ•˜๋‚˜ ์žˆ์—ˆ๋‹ค.

๊ฒฐ๋ก ๋ถ€ํ„ฐ ๋งํ•˜์ž๋ฉด, ์ƒ๊ฐ์˜ ์˜ค๋ฅ˜ ๋•Œ๋ฌธ์— ํ–ˆ๋˜ ๊ณ ๋ฏผ์ด์—ˆ๊ณ  ์‰ฝ๊ฒŒ ํ•ด๊ฒฐ ๊ฐ€๋Šฅํ–ˆ๋‹ค.

๊ทธ๋ฆผ์ด ์ƒ๋‹นํžˆ ์ถ”์ƒํ™”๋˜์–ด ์žˆ์–ด์„œ ์•Œ์•„๋ณด๊ธฐ ํž˜๋“ค ์ˆ˜ ์žˆ๋‹ค.

๋‘ ํ˜•ํƒœ์˜ ๊ตฌ์กฐ์—์„œ ๊ฐ๊ฐ ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด ๊ณ ๋ฏผ ํ–ˆ๋‹ค.

๊ทธ๋ฆผ ์•„๋ž˜ ์ •๋ฆฌํ–ˆ๋‹ค.

๊ณ ๋ฏผ์ 

  • 1๋ฒˆ ๊ตฌ์กฐ ๋ฌธ์ œ์ 
    • ์ด๋ฒคํŠธ โ†’ ๋ฆฌ์Šค๋„ˆ ํ˜ธ์ถœ์‹œ DTO ํด๋ž˜์Šค๋Š” ์–ด๋Š ๋„๋ฉ”์ธ์— ์žˆ์–ด์•ผ ํ• ๊นŒ?
  • 2๋ฒˆ ๊ตฌ์กฐ ๋ฌธ์ œ์ 
    • ์ด๋ฒคํŠธ ๋“ฑ๋ก๋งˆ๋‹ค ๊ธ€๋กœ๋ฒŒ์„ ์ฐธ์กฐํ•˜๋Š”๊ฒŒ ๋งž์„๊นŒ?

๊ณ ๋ฏผํƒ€ํŒŒ

  • ์ด๋ฒคํŠธ๋Š” ์• ์ดˆ์— ๋„๋ฉ”์ธ์— ํฌํ•จ๋˜์•ผ ํ•จ.
  • DTO ์“ฐ์ง€ ๋ง๊ณ  Java ๊ธฐ๋ณธ ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋จ

์ข€ ๋” ์„ค๋ช…ํ•˜์ž๋ฉด,

DTO ๋ฅผ ์–ด๋””์— ๊ตฌํ˜„ํ• ์ง€ ๊ณ ๋ฏผํ•  ํ•„์š”๊ฐ€ ์—†์ด, ๋ชจ๋“  ์ •๋ณด๋ฅผ ํŒŒํ•ด์ณ์„œ ๊ธฐ๋ณธ ํƒ€์ž…์œผ๋กœ ๋„˜๊ธฐ๋ฉด ๋˜๋Š” ๋ฌธ์ œ์˜€๋‹ค.

์œ„์— ์ด๋ฒคํŠธ ํด๋ž˜์Šค ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด DTO ๊ฐ€ ์—†๋‹ค.

long ํƒ€์ž…์˜ ๋ณ€์ˆ˜์™€ Map ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ํ™œ์šฉํ•ด์„œ ๋„๋ฉ”์ธ์— ์˜์กดํ•˜์ง€ ์•Š๊ณ  ๋ฐ์ดํ„ฐ ์ „๋‹ฌ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

profile
๊ฐœ๋ฐœํ•˜๊ณ  ๋งํ…Œ์•ผ

0๊ฐœ์˜ ๋Œ“๊ธ€