-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from oduck-team/feature/139
고객문의 어드민 서비스 구현 #139
- Loading branch information
Showing
29 changed files
with
354 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.oduck.api.domain.admin.entity; | ||
|
||
import io.oduck.api.domain.contact.entity.Answer; | ||
import io.oduck.api.domain.contact.entity.FeedbackType; | ||
import io.oduck.api.domain.contact.service.AnswerHolder; | ||
import io.oduck.api.domain.contact.service.AnswerUpdateHolder; | ||
import io.oduck.api.global.exception.BadRequestException; | ||
import io.oduck.api.global.exception.NotFoundException; | ||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Table(name = "member") | ||
@Entity | ||
public class Admin { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToMany(mappedBy = "admin", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) | ||
private List<Answer> answers = new ArrayList<>(); | ||
|
||
public void answer(AnswerHolder holder) { | ||
Answer answer = Answer.builder() | ||
.content(holder.getContent()) | ||
.helpful(FeedbackType.NONE) | ||
.check(false) | ||
.contact(holder.getContact()) | ||
.admin(this) | ||
.build(); | ||
answers.add(answer); | ||
|
||
answer.answer(); | ||
} | ||
|
||
public void updateAnswer(AnswerUpdateHolder holder) { | ||
Answer answer = answers.stream() | ||
.filter(a -> a.getId() == holder.getAnswerId()) | ||
.findFirst() | ||
.orElseThrow(() -> new NotFoundException("answer")); | ||
|
||
if(answer.isCheck() == true) { | ||
throw new BadRequestException("이미 고객이 확인한 문의입니다."); | ||
} | ||
|
||
answer.update(holder.getContent()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/io/oduck/api/domain/admin/repository/AdminRepository.java
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,13 @@ | ||
package io.oduck.api.domain.admin.repository; | ||
|
||
import io.oduck.api.domain.admin.entity.Admin; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface AdminRepository extends JpaRepository<Admin, Long> { | ||
|
||
@Query("select distinct a from Admin a join fetch a.answers where a.id = :id") | ||
Optional<Admin> findWithAnswerById(@Param("id") Long id); | ||
} |
4 changes: 2 additions & 2 deletions
4
...pi/domain/inquiry/dto/AnswerFeedback.java → ...pi/domain/contact/dto/AnswerFeedback.java
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
2 changes: 1 addition & 1 deletion
2
...uck/api/domain/inquiry/dto/ContactId.java → ...uck/api/domain/contact/dto/ContactId.java
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
4 changes: 2 additions & 2 deletions
4
...ck/api/domain/inquiry/dto/ContactRes.java → ...ck/api/domain/contact/dto/ContactRes.java
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
4 changes: 2 additions & 2 deletions
4
...i/domain/inquiry/entity/FeedbackType.java → ...i/domain/contact/entity/FeedbackType.java
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,7 +1,7 @@ | ||
package io.oduck.api.domain.inquiry.entity; | ||
package io.oduck.api.domain.contact.entity; | ||
|
||
public enum FeedbackType { | ||
HELPFUL, | ||
NOT_HELPFUL, | ||
NOT_SELECT | ||
NONE | ||
} |
2 changes: 1 addition & 1 deletion
2
...pi/domain/inquiry/entity/InquiryType.java → ...pi/domain/contact/entity/InquiryType.java
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
2 changes: 1 addition & 1 deletion
2
...uck/api/domain/inquiry/entity/Result.java → ...uck/api/domain/contact/entity/Result.java
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
2 changes: 1 addition & 1 deletion
2
...uck/api/domain/inquiry/entity/Status.java → ...uck/api/domain/contact/entity/Status.java
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
8 changes: 8 additions & 0 deletions
8
src/main/java/io/oduck/api/domain/contact/repository/AnswerRepository.java
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,8 @@ | ||
package io.oduck.api.domain.contact.repository; | ||
|
||
import io.oduck.api.domain.contact.entity.Answer; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AnswerRepository extends JpaRepository<Answer, Long> { | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
...inquiry/repository/ContactRepository.java → ...contact/repository/ContactRepository.java
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,13 +1,13 @@ | ||
package io.oduck.api.domain.inquiry.repository; | ||
package io.oduck.api.domain.contact.repository; | ||
|
||
import io.oduck.api.domain.inquiry.entity.Contact; | ||
import io.oduck.api.domain.contact.entity.Contact; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface ContactRepository extends JpaRepository<Contact, Long>, ContactRepositoryCustom { | ||
|
||
@Query("select c from Contact c join fetch c.member where c.id = :id") | ||
@Query("select c from Contact c join fetch c.customer where c.id = :id") | ||
Optional<Contact> findWithMemberById(@Param("id") Long id); | ||
} |
4 changes: 2 additions & 2 deletions
4
...y/repository/ContactRepositoryCustom.java → ...t/repository/ContactRepositoryCustom.java
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
17 changes: 17 additions & 0 deletions
17
src/main/java/io/oduck/api/domain/contact/service/AnswerHolder.java
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,17 @@ | ||
package io.oduck.api.domain.contact.service; | ||
|
||
import io.oduck.api.domain.contact.dto.ContactReq.AnswerReq; | ||
import io.oduck.api.domain.contact.entity.Contact; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class AnswerHolder { | ||
private Contact contact; | ||
private String content; | ||
|
||
public static AnswerHolder from(Contact contact, AnswerReq request) { | ||
return new AnswerHolder(contact, request.getContent()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/io/oduck/api/domain/contact/service/AnswerUpdateHolder.java
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,17 @@ | ||
package io.oduck.api.domain.contact.service; | ||
|
||
import io.oduck.api.domain.contact.dto.ContactReq.AnswerUpdateReq; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class AnswerUpdateHolder { | ||
private Long answerId; | ||
private String content; | ||
|
||
public static AnswerUpdateHolder from(Long answerId, AnswerUpdateReq request) { | ||
return new AnswerUpdateHolder(answerId, request.getContent()); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/io/oduck/api/domain/contact/service/ContactService.java
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,27 @@ | ||
package io.oduck.api.domain.contact.service; | ||
|
||
import io.oduck.api.domain.contact.dto.ContactReq.AnswerReq; | ||
import io.oduck.api.domain.contact.dto.ContactReq.AnswerUpdateReq; | ||
import io.oduck.api.domain.contact.dto.ContactReq.PostReq; | ||
import io.oduck.api.domain.contact.dto.ContactRes.DetailRes; | ||
import io.oduck.api.domain.contact.dto.ContactRes.MyInquiry; | ||
import io.oduck.api.domain.contact.entity.FeedbackType; | ||
import io.oduck.api.global.common.PageResponse; | ||
|
||
public interface ContactService { | ||
void inquiry(Long memberId, PostReq request); | ||
|
||
PageResponse<MyInquiry> getAllByMemberId(Long memberId, int page, int size); | ||
|
||
DetailRes getByMemberId(Long inquiryId, Long memberId); | ||
|
||
boolean hasNotCheckedAnswer(Long id, Long memberId); | ||
|
||
void feedbackAnswer(Long id, Long memberId, FeedbackType helpful); | ||
|
||
// Page<?> getAll(); | ||
// | ||
void answer(Long id, Long adminId, AnswerReq request); | ||
|
||
void update(Long answerId, Long adminId, AnswerUpdateReq request); | ||
} |
Oops, something went wrong.