Skip to content

Commit 1ea4568

Browse files
committed
CLAP-318 Fix : 2차카테고리 입력 양식(설명 예시) 추가
<footer> - 관련: #392
1 parent e6158cc commit 1ea4568

File tree

11 files changed

+27
-14
lines changed

11 files changed

+27
-14
lines changed

src/main/java/clap/server/adapter/inbound/web/admin/AddCategoryController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public void addMainCategory(@AuthenticationPrincipal SecurityUserDetails userInf
3535
@PostMapping("/sub-category")
3636
@Secured("ROLE_ADMIN")
3737
public void addSubCategory(@AuthenticationPrincipal SecurityUserDetails userInfo, @Valid @RequestBody AddSubCategoryRequest addCategoryRequest) {
38-
addSubCategoryUsecase.addSubCategory(userInfo.getUserId(), addCategoryRequest.mainCategoryId(), addCategoryRequest.code(), addCategoryRequest.name());
38+
addSubCategoryUsecase.addSubCategory(userInfo.getUserId(),
39+
addCategoryRequest.mainCategoryId(),
40+
addCategoryRequest.code(),
41+
addCategoryRequest.name(),
42+
addCategoryRequest.descriptionExample());
3943
}
4044

4145
}

src/main/java/clap/server/adapter/inbound/web/admin/UpdateCategoryController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public class UpdateCategoryController {
2727
@Secured("ROLE_ADMIN")
2828
public void updateCategory(@AuthenticationPrincipal SecurityUserDetails userInfo, @PathVariable Long categoryId,
2929
@Valid @RequestBody UpdateCategoryRequest updateCategoryRequest) {
30-
updateCategoryUsecase.updateCategory(userInfo.getUserId(), categoryId, updateCategoryRequest.name(), updateCategoryRequest.code());
30+
updateCategoryUsecase.updateCategory(userInfo.getUserId(),
31+
categoryId,
32+
updateCategoryRequest.name(),
33+
updateCategoryRequest.code(),
34+
updateCategoryRequest.descriptionExample());
3135
}
3236
}

src/main/java/clap/server/adapter/inbound/web/dto/admin/request/AddSubCategoryRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public record AddSubCategoryRequest(
1111
@NotBlank @Length(max = 20)
1212
String name,
1313
@NotBlank @Pattern(regexp = "^[A-Z]{1,2}$", message = "올바른 카테고리 코드 형식이 아닙니다.")
14-
String code) {
14+
String code,
15+
String descriptionExample) {
1516
}

src/main/java/clap/server/adapter/inbound/web/dto/admin/request/UpdateCategoryRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public record UpdateCategoryRequest(
88
@NotBlank @Length(max = 20)
99
String name,
1010
@NotBlank @Pattern(regexp = "^[A-Z]{1,2}$", message = "올바른 카테고리 코드 형식이 아닙니다.")
11-
String code
11+
String code,
12+
String descriptionExample
1213
) {
1314
}

src/main/java/clap/server/adapter/inbound/web/dto/admin/response/FindSubCategoryResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public record FindSubCategoryResponse(
44
Long id,
55
Long mainCategoryId,
66
String name,
7-
String code
7+
String code,
8+
String descriptionExample
89
) {
910
}

src/main/java/clap/server/application/mapper/CategoryResponseMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public static FindMainCategoryResponse toFindMainCategoryResponse(Category categ
2222
}
2323

2424
public static FindSubCategoryResponse toFindSubCategoryResponse(Category category) {
25-
return new FindSubCategoryResponse(category.getCategoryId(), category.getMainCategory().getCategoryId(), category.getName(), category.getCode());
25+
return new FindSubCategoryResponse(category.getCategoryId(), category.getMainCategory().getCategoryId(), category.getName(), category.getCode(), category.getDescriptionExample());
2626
}
2727
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package clap.server.application.port.inbound.admin;
22

33
public interface AddSubCategoryUsecase {
4-
void addSubCategory(Long adminId, Long mainCategoryId, String code, String name);
4+
void addSubCategory(Long adminId, Long mainCategoryId, String code, String name, String descriptionExample);
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package clap.server.application.port.inbound.admin;
22

33
public interface UpdateCategoryUsecase {
4-
void updateCategory(Long adminId, Long categoryId, String name, String code);
4+
void updateCategory(Long adminId, Long categoryId, String name, String code, String descriptionExample);
55
}

src/main/java/clap/server/application/service/admin/AddCategoryService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public void addMainCategory(Long adminId, String code, String name) {
3636

3737
@Override
3838
@Transactional
39-
public void addSubCategory(Long adminId, Long mainCategoryId, String code, String name) {
39+
public void addSubCategory(Long adminId, Long mainCategoryId, String code, String name, String descriptionExample) {
4040
Optional<Member> activeMember = loadMemberPort.findActiveMemberById(adminId);
4141
Optional<Category> mainCategory = loadCategoryPort.findById(mainCategoryId);
4242

4343
Category subCategory = Category.createSubCategory(
4444
activeMember.orElseThrow(() -> new ApplicationException(ACTIVE_MEMBER_NOT_FOUND)),
4545
mainCategory.orElseThrow(() -> new ApplicationException(CATEGORY_NOT_FOUND)),
46-
code, name);
46+
code, name, descriptionExample);
4747
commandCategoryPort.save(subCategory);
4848
}
4949
}

src/main/java/clap/server/application/service/admin/UpdateCategoryService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public class UpdateCategoryService implements UpdateCategoryUsecase {
2323

2424
@Override
2525
@Transactional
26-
public void updateCategory(Long adminId, Long categoryId, String name, String code) {
26+
public void updateCategory(Long adminId, Long categoryId, String name, String code, String descriptionExample) {
2727
Member admin = loadMemberPort.findActiveMemberById(adminId).orElseThrow(() -> new ApplicationException(ACTIVE_MEMBER_NOT_FOUND));
2828
Category category = loadCategoryPort.findById(categoryId)
2929
.orElseThrow(() -> new ApplicationException(CATEGORY_NOT_FOUND));
30-
category.updateCategory(admin, name, code);
30+
category.updateCategory(admin, name, code, descriptionExample);
3131
commandCategoryPort.save(category);
3232
}
3333
}

0 commit comments

Comments
 (0)