This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor : Category 영역에 대한 JPA Migration [#70]
- MainCategory : SubCategory = 1:N 관계 고려
- Loading branch information
Showing
14 changed files
with
122 additions
and
173 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
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
22 changes: 17 additions & 5 deletions
22
src/main/java/kr/fiveminutesmarket/category/dto/response/MainCategoryResponse.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,24 +1,36 @@ | ||
package kr.fiveminutesmarket.category.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import java.util.List; | ||
|
||
public class MainCategoryResponse { | ||
|
||
private Long mainCategoryId; | ||
|
||
private String mainCategoryName; | ||
|
||
public Long getMainCategoryId() { | ||
return mainCategoryId; | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
private List<SubCategoryResponse> subCategoryResponses; | ||
|
||
public MainCategoryResponse() { | ||
} | ||
|
||
public void setMainCategoryId(Long mainCategoryId) { | ||
public MainCategoryResponse(Long mainCategoryId, String mainCategoryName, List<SubCategoryResponse> subCategoryResponses) { | ||
this.mainCategoryId = mainCategoryId; | ||
this.mainCategoryName = mainCategoryName; | ||
this.subCategoryResponses = subCategoryResponses; | ||
} | ||
|
||
public Long getMainCategoryId() { | ||
return mainCategoryId; | ||
} | ||
|
||
public String getMainCategoryName() { | ||
return mainCategoryName; | ||
} | ||
|
||
public void setMainCategoryName(String mainCategoryName) { | ||
this.mainCategoryName = mainCategoryName; | ||
public List<SubCategoryResponse> getSubCategoryResponses() { | ||
return subCategoryResponses; | ||
} | ||
} |
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: 3 additions & 18 deletions
21
src/main/java/kr/fiveminutesmarket/category/repository/MainCategoryRepository.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,24 +1,9 @@ | ||
package kr.fiveminutesmarket.category.repository; | ||
|
||
import kr.fiveminutesmarket.category.domain.MainCategory; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
public interface MainCategoryRepository extends JpaRepository<MainCategory, Long> { | ||
|
||
@Mapper | ||
public interface MainCategoryRepository { | ||
|
||
int insert(@Param("mainCategory") MainCategory mainCategory); | ||
|
||
List<MainCategory> findAll(); | ||
|
||
MainCategory findById(@Param("mainCategoryId") Long mainCategoryId); | ||
|
||
int countByName(@Param("mainCategoryName") String mainCategoryName); | ||
|
||
int updateMainCategory(@Param("mainCategoryId") Long mainCategoryId, | ||
@Param("mainCategory") MainCategory mainCategory); | ||
|
||
void deleteById(@Param("mainCategoryId") Long mainCategoryId); | ||
long countByMainCategoryName(String mainCategoryName); | ||
} |
23 changes: 3 additions & 20 deletions
23
src/main/java/kr/fiveminutesmarket/category/repository/SubCategoryRepository.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,9 @@ | ||
package kr.fiveminutesmarket.category.repository; | ||
|
||
import kr.fiveminutesmarket.category.domain.SubCategory; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
public interface SubCategoryRepository extends JpaRepository<SubCategory, Long> { | ||
|
||
@Mapper | ||
public interface SubCategoryRepository { | ||
|
||
int insert(@Param("subCategory") SubCategory subCategory); | ||
|
||
List<SubCategory> findAll(); | ||
|
||
SubCategory findById(@Param("subCategoryId") Long subCategoryId); | ||
|
||
int countByName(@Param("subCategoryName") String subCategoryName); | ||
|
||
int updateSubCategory(@Param("subCategoryId") Long subCategoryId, | ||
@Param("subCategory") SubCategory subCategory); | ||
|
||
void deleteById(@Param("subCategoryId") Long subCategoryId); | ||
|
||
void deleteByMainCategoryId(@Param("mainCategoryId") Long mainCategoryId); | ||
long countBySubCategoryName(String subCategoryName); | ||
} |
Oops, something went wrong.