-
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 #141 from oduck-team/feature/138
도메인 이름 변경 #138
- Loading branch information
Showing
21 changed files
with
308 additions
and
231 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
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: 8 additions & 9 deletions
17
...ain/inquiry/dto/InquiryRequestHolder.java → ...ain/inquiry/dto/ContactRequestHolder.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,26 +1,25 @@ | ||
package io.oduck.api.domain.inquiry.dto; | ||
|
||
import io.oduck.api.domain.inquiry.dto.InquiryReq.PostReq; | ||
import io.oduck.api.domain.inquiry.entity.Inquiry; | ||
import io.oduck.api.domain.inquiry.dto.ContactReq.PostReq; | ||
import io.oduck.api.domain.inquiry.entity.Contact; | ||
import io.oduck.api.domain.member.entity.Member; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class InquiryRequestHolder { | ||
private Inquiry inquiry; | ||
public class ContactRequestHolder { | ||
private Contact contact; | ||
|
||
public static InquiryRequestHolder from(PostReq request, Member member) { | ||
Inquiry inquiry = Inquiry.builder() | ||
public static ContactRequestHolder from(PostReq request, Member member) { | ||
Contact contact = Contact.builder() | ||
.title(request.getTitle()) | ||
.content(request.getContent()) | ||
.type(request.getType()) | ||
.answer(false) | ||
.check(false) | ||
.answered(false) | ||
.member(member) | ||
.build(); | ||
return new InquiryRequestHolder(inquiry); | ||
return new ContactRequestHolder(contact); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/io/oduck/api/domain/inquiry/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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.oduck.api.domain.inquiry.repository; | ||
|
||
import io.oduck.api.domain.inquiry.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") | ||
Optional<Contact> findWithMemberById(@Param("id") Long id); | ||
} |
7 changes: 5 additions & 2 deletions
7
...y/repository/InquiryRepositoryCustom.java → ...y/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package io.oduck.api.domain.inquiry.repository; | ||
|
||
import io.oduck.api.domain.inquiry.dto.InquiryRes.MyInquiry; | ||
import io.oduck.api.domain.inquiry.dto.ContactRes.MyInquiry; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface InquiryRepositoryCustom { | ||
public interface ContactRepositoryCustom { | ||
|
||
Page<MyInquiry> getAllByMemberId(Long memberId, Pageable pageable); | ||
|
||
boolean existsByIdAndCheck(Long id, Boolean check); | ||
} |
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
15 changes: 0 additions & 15 deletions
15
src/main/java/io/oduck/api/domain/inquiry/repository/InquiryRepository.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/main/java/io/oduck/api/domain/inquiry/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,16 @@ | ||
package io.oduck.api.domain.inquiry.service; | ||
|
||
import io.oduck.api.domain.inquiry.dto.ContactReq.AnswerReq; | ||
import io.oduck.api.domain.inquiry.entity.Contact; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class AnswerHolder { | ||
private Contact contact; | ||
private AnswerReq request; | ||
public static AnswerHolder from(Contact contact, AnswerReq request) { | ||
return new AnswerHolder(contact, request); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/io/oduck/api/domain/inquiry/service/ContactPolicy.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,21 @@ | ||
package io.oduck.api.domain.inquiry.service; | ||
|
||
import io.oduck.api.domain.inquiry.entity.Contact; | ||
import io.oduck.api.domain.member.entity.Member; | ||
import io.oduck.api.global.exception.ForbiddenException; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ContactPolicy { | ||
|
||
public void isAccessOwnInquiry(Contact contact, Member member) { | ||
if(!isOwnInquiry(contact, member)) { | ||
throw new ForbiddenException("not has permission"); | ||
} | ||
contact.getMember().getId(); | ||
} | ||
|
||
private boolean isOwnInquiry(Contact contact, Member member) { | ||
return contact.getMember().getId().equals(member.getId()); | ||
} | ||
} |
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
Oops, something went wrong.