Skip to content

Commit

Permalink
Refactor: 불필요한 static method 수정 (Kernel360#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
anso33 authored Jan 19, 2024
1 parent 2c96dca commit 16966b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package kernel.jdon.faq.dto.request;

import kernel.jdon.faq.domain.Faq;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CreateFaqRequest {
private String title;
private String content;

public static Faq toEntity(CreateFaqRequest createFaqRequest) {
public Faq toEntity() {
return Faq.builder()
.title(createFaqRequest.title)
.content(createFaqRequest.content)
.title(this.title)
.content(this.content)
.build();
}
}
11 changes: 5 additions & 6 deletions module-api/src/main/java/kernel/jdon/faq/service/FaqService.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package kernel.jdon.faq.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import kernel.jdon.faq.domain.Faq;
import kernel.jdon.faq.dto.request.CreateFaqRequest;
import kernel.jdon.faq.dto.request.UpdateFaqRequest;
Expand All @@ -16,6 +11,10 @@
import kernel.jdon.faq.repository.FaqRepository;
import kernel.jdon.global.exception.ApiException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
Expand All @@ -30,7 +29,7 @@ private Faq findById(Long faqId) {

@Transactional
public CreateFaqResponse create(CreateFaqRequest createFaqRequest) {
Faq savedFaq = faqRepository.save(CreateFaqRequest.toEntity(createFaqRequest));
Faq savedFaq = faqRepository.save(createFaqRequest.toEntity());

return CreateFaqResponse.of(savedFaq.getId());
}
Expand Down

0 comments on commit 16966b0

Please sign in to comment.