-
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.
- Loading branch information
Showing
25 changed files
with
322 additions
and
98 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...code-for-deploy/src/main/java/com/example/seminar/common/exception/CategoryException.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,7 @@ | ||
package com.example.seminar.common.exception; | ||
|
||
public class CategoryException extends RuntimeException { | ||
public CategoryException(String message) { | ||
super(message); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...g-code-for-deploy/src/main/java/com/example/seminar/common/exception/MemberException.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,7 @@ | ||
package com.example.seminar.common.exception; | ||
|
||
public class MemberException extends RuntimeException { | ||
public MemberException(String message) { | ||
super(message); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
spring-code-for-deploy/src/main/java/com/example/seminar/common/exception/PostException.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,7 @@ | ||
package com.example.seminar.common.exception; | ||
|
||
public class PostException extends RuntimeException { | ||
public PostException(String message) { | ||
super(message); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
spring-code-for-deploy/src/main/java/com/example/seminar/controller/CategoryController.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
21 changes: 19 additions & 2 deletions
21
spring-code-for-deploy/src/main/java/com/example/seminar/domain/Category.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,21 +1,38 @@ | ||
package com.example.seminar.domain; | ||
|
||
|
||
import com.example.seminar.common.exception.CategoryException; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.util.Assert; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class Category { | ||
|
||
@Id @GeneratedValue | ||
private Short id; | ||
@Id @GeneratedValue(strategy = IDENTITY) | ||
private Integer id; | ||
|
||
private String content; | ||
|
||
@Builder | ||
private Category(String content) { | ||
validateContent(content); | ||
this.content = content; | ||
} | ||
|
||
private void validateContent(final String content) { | ||
if (content.length() > 10) { | ||
throw new CategoryException("카테고리 글자 제한을 넘었습니다."); | ||
} | ||
} | ||
} |
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
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
66 changes: 0 additions & 66 deletions
66
spring-code-for-deploy/src/main/java/com/example/seminar/service/MemberService.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...ng-code-for-deploy/src/main/java/com/example/seminar/service/category/CategoryFinder.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,20 @@ | ||
package com.example.seminar.service.category; | ||
|
||
import com.example.seminar.domain.Category; | ||
import com.example.seminar.repository.CategoryJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.xml.catalog.CatalogException; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CategoryFinder { | ||
|
||
private final CategoryJpaRepository categoryJpaRepository; | ||
|
||
public Category findById(Short id) { | ||
return categoryJpaRepository.findById(id) | ||
.orElseThrow( () -> new CatalogException("존재하지 않는 카테고리입니다.")); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...mple/seminar/service/CategoryService.java → ...nar/service/category/CategoryService.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
17 changes: 17 additions & 0 deletions
17
spring-code-for-deploy/src/main/java/com/example/seminar/service/member/MemberRemover.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 com.example.seminar.service.member; | ||
|
||
|
||
import com.example.seminar.domain.Member; | ||
import com.example.seminar.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MemberRemover { | ||
private final MemberRepository memberRepository; | ||
|
||
public void remove(Member member) { | ||
memberRepository.remove(member); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
spring-code-for-deploy/src/main/java/com/example/seminar/service/member/MemberRetriever.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,30 @@ | ||
package com.example.seminar.service.member; | ||
|
||
|
||
import com.example.seminar.domain.Member; | ||
import com.example.seminar.repository.MemberJpaRepository; | ||
import jakarta.persistence.EntityNotFoundException; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class MemberRetriever { | ||
|
||
private final MemberJpaRepository memberJpaRepository; | ||
|
||
public MemberRetriever(MemberJpaRepository memberJpaRepository) { | ||
this.memberJpaRepository = memberJpaRepository; | ||
} | ||
|
||
public Member findById(Long id) { | ||
return memberJpaRepository | ||
.findById(id) | ||
.orElseThrow(() -> new EntityNotFoundException("해당하는 회원이 없습니다.")); | ||
} | ||
|
||
public List<Member> findAll() { | ||
return memberJpaRepository.findAll(); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
spring-code-for-deploy/src/main/java/com/example/seminar/service/member/MemberSaver.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,18 @@ | ||
package com.example.seminar.service.member; | ||
|
||
|
||
import com.example.seminar.domain.Member; | ||
import com.example.seminar.repository.MemberJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MemberSaver { | ||
private final MemberJpaRepository memberJpaRepository; | ||
|
||
public Member save(Member member) { | ||
return memberJpaRepository.save(member); | ||
} | ||
|
||
} |
Oops, something went wrong.