Skip to content

Commit

Permalink
feat: kakao-tech-campus-2nd-step3#8 guardians 코드리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyyh0x committed Sep 22, 2024
1 parent 3c623f0 commit 7a5daa5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.Comment;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -13,16 +14,13 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/auth/guardians")
@RequestMapping("/v1/admin/guardians")
@RequiredArgsConstructor
@Comment("관리자 페이지의 보호자 관리")
public class AuthGuardiansController {
public class AdminGuardiansController {

private final GuardiansService guardiansService;

public AuthGuardiansController(GuardiansService guardiansService) {
this.guardiansService = guardiansService;
}

@Comment("보호자 전부 조회")
@GetMapping
public ResponseEntity<List<GuardiansResponse>> showAllGuardians() {
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/dbdr/domain/guardians/Guardians.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Comment;

@Entity
@Getter
@Table(name = "guardians")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Guardians extends BaseEntity {

@Comment("보호자 전화번호")
Expand All @@ -19,14 +23,13 @@ public class Guardians extends BaseEntity {
@Column(nullable = false)
private String name;

public Guardians() {
}

@Builder
public Guardians(String phone, String name) {
this.phone = phone;
this.name = name;
}

@Builder
public void updateGuardian(String phone, String name) {
this.phone = phone;
this.name = name;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/dbdr/domain/guardians/GuardiansController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dbdr.domain.guardians;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.Comment;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -12,15 +13,12 @@

@RestController
@RequestMapping("/v1/guardians")
@RequiredArgsConstructor
@Comment("보호자 관련 API")
public class GuardiansController {

private final GuardiansService guardiansService;

public GuardiansController(GuardiansService guardiansService) {
this.guardiansService = guardiansService;
}

@Comment("보호자 자신 정보 조회")
@GetMapping("/{guardianId}")
public ResponseEntity<GuardiansResponse> showGuardianInfo(
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dbdr/domain/guardians/GuardiansRequest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dbdr.domain.guardians;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import org.hibernate.annotations.Comment;

public record GuardiansRequest(
@Comment("보호자 전화번호") @NotBlank(message = "전화번호를 입력하세요.") String phone,
@Comment("보호자 전화번호") @NotBlank(message = "전화번호를 입력하세요.")
@Pattern(regexp = "010\\d{8}", message = "010XXXXXXXX형식으로 입력해주세요.") String phone,
@Comment("보호자 성명") @NotBlank(message = "이름을 입력하세요.") String name) {

}

0 comments on commit 7a5daa5

Please sign in to comment.