-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : build.gradle : MySQL 의존성 추가 * feat : application.yml : AWS RDS 데이터베이스 연결 정보를 포함. * chore: 설정 파일 수정 * feat: 공통 엔티티 작성 - 식별자, 생성/수정일자, 삭제 상태값 등의 공통 필드를 baseEntity로 정의 * feat: 차트 엔티티 작성 * feat: 차트 신체활동 엔티티 작성 - 청결, 식사 관련 필드는 임베디드 타입으로 선언 * feat: chart-bodyNote 연관관계 설정 - chart와 신체활동(bodyNote)는 일대일 연관관계 설정 * feat: 신체 활동 관련 임베디드 타입 생성자 추가 * feat: 차트 세부항목 - 간호 활동 엔티티 작성 - 혈압 관련 필드는 임베디드 타입으로 관리 * chore: 신체활동 엔티티 이름 변경 * feat: 차트- 간호활동 연관관계 설정 * feat: 인지 훈련 엔티티 작성 * feat: 차트 - 인지 훈련 엔티티 연관관계 설정 * chore: 불필요한 컬럼 속성 삭제 * chore: 간호활동 엔티티 상속 수정 - baseEntity 상속 * build: 스프링 버전 수정 * chore: 마지막 개행 추가 * chore: 마지막 개행 추가 * feat: baseEntity 삭제 함수 추가 * feat: baseEntity 상태값 필드명 변경 * Feat: 요양보호사 CRUD (#7) * fix: API 주소 수정 * feat: 돌봄대상자 CRUD (#6) * feat: 요양보호사 ID 검증 추가 * refactor: 코드 리뷰 반영 * fix: 일부 메세지 변경 * refactor: DTO 분리 * refactor: chart 도메인 일부 변경 * [관리자 페이지] 보호자 도메인 CRUD (#15) * feat: guardians * feat: #8 guardians 코드리뷰 반영 * fix: chart 도메인 부분 수정 * refactor: guardian 폴더 분리, exception 등 코드리뷰 반영 * fix: chart is_active 수정 --------- Co-authored-by: pykido <animoto1@naver.com> Co-authored-by: 김태윤 <77539625+pykido@users.noreply.github.com> Co-authored-by: Yoo KyeongMi <yookyungmi02@gmail.com> Co-authored-by: Yoo KyeongMi <89245114+yooookm@users.noreply.github.com> Co-authored-by: mogld <143364802+mogld@users.noreply.github.com> Co-authored-by: hyyyh0x <141637975+hyyyh0x@users.noreply.github.com>
- Loading branch information
1 parent
e83ef54
commit ce1b25a
Showing
27 changed files
with
951 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/main/java/dbdr/controller/AdminGuardiansController.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,61 @@ | ||
package dbdr.controller; | ||
|
||
import dbdr.dto.request.GuardiansRequest; | ||
import dbdr.dto.response.GuardiansResponse; | ||
import dbdr.service.GuardiansService; | ||
import jakarta.validation.Valid; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/v1/admin/guardians") | ||
@RequiredArgsConstructor | ||
public class AdminGuardiansController { | ||
|
||
private final GuardiansService guardiansService; | ||
|
||
@GetMapping | ||
public ResponseEntity<List<GuardiansResponse>> showAllGuardians() { | ||
List<GuardiansResponse> guardiansResponseList = guardiansService.getAllGuardians(); | ||
return ResponseEntity.ok(guardiansResponseList); | ||
} | ||
|
||
@GetMapping("/{guardianId}") | ||
public ResponseEntity<GuardiansResponse> showOneGuardian( | ||
@PathVariable("guardianId") Long guardianId) { | ||
GuardiansResponse guardiansResponse = guardiansService.getGuardianById(guardianId); | ||
return ResponseEntity.ok(guardiansResponse); | ||
} | ||
|
||
@PostMapping | ||
public ResponseEntity<GuardiansResponse> addGuardian( | ||
@Valid @RequestBody GuardiansRequest guardiansRequest) { | ||
GuardiansResponse guardiansResponse = guardiansService.addGuardian(guardiansRequest); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(guardiansResponse); | ||
} | ||
|
||
@PutMapping("/{guardianId}/update") | ||
public ResponseEntity<GuardiansResponse> updateGuardianAuth( | ||
@PathVariable("guardianId") Long guardianId, | ||
@Valid @RequestBody GuardiansRequest guardiansRequest) { | ||
GuardiansResponse guardiansResponse = guardiansService.updateGuardianById(guardianId, | ||
guardiansRequest); | ||
return ResponseEntity.ok(guardiansResponse); | ||
} | ||
|
||
@PutMapping("/{guardianId}/delete") | ||
public ResponseEntity<Void> deleteGuardianAuth( | ||
@PathVariable("guardianId") Long guardianId) { | ||
guardiansService.deleteGuardianById(guardianId); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
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,59 @@ | ||
package dbdr.controller; | ||
|
||
import dbdr.dto.request.CareworkerRequestDTO; | ||
import dbdr.dto.response.CareworkerResponseDTO; | ||
import dbdr.service.CareworkerService; | ||
import jakarta.validation.Valid; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/v1/careworkers") | ||
public class CareworkerController { | ||
|
||
private final CareworkerService careworkerService; | ||
|
||
public CareworkerController(CareworkerService careworkerService) { | ||
this.careworkerService = careworkerService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<CareworkerResponseDTO>> getAllCareworkers( | ||
@RequestParam(value = "institutionId", required = false) Long institutionId) { | ||
List<CareworkerResponseDTO> careworkers; | ||
if (institutionId != null) { | ||
careworkers = careworkerService.getCareworkersByInstitution(institutionId); | ||
} else { | ||
careworkers = careworkerService.getAllCareworkers(); | ||
} | ||
return ResponseEntity.ok(careworkers); | ||
} | ||
|
||
@GetMapping("/{id}") | ||
public ResponseEntity<CareworkerResponseDTO> getCareworkerById(@PathVariable Long id) { | ||
CareworkerResponseDTO careworker = careworkerService.getCareworkerById(id); | ||
return ResponseEntity.ok(careworker); | ||
} | ||
|
||
@PostMapping | ||
public ResponseEntity<CareworkerResponseDTO> createCareworker(@Valid @RequestBody CareworkerRequestDTO careworkerDTO) { | ||
CareworkerResponseDTO newCareworker = careworkerService.createCareworker(careworkerDTO); | ||
return ResponseEntity.created(URI.create("/v1/careworkers/" + newCareworker.getId())) | ||
.body(newCareworker); | ||
} | ||
|
||
@PutMapping("/{id}") | ||
public ResponseEntity<CareworkerResponseDTO> updateCareworker(@PathVariable Long id, @Valid @RequestBody CareworkerRequestDTO careworkerDTO) { | ||
CareworkerResponseDTO updatedCareworker = careworkerService.updateCareworker(id, careworkerDTO); | ||
return ResponseEntity.ok(updatedCareworker); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<Void> deleteCareworker(@PathVariable Long id) { | ||
careworkerService.deleteCareworker(id); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
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,38 @@ | ||
package dbdr.controller; | ||
|
||
import dbdr.dto.request.GuardiansRequest; | ||
import dbdr.dto.response.GuardiansResponse; | ||
import dbdr.service.GuardiansService; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/v1/guardians") | ||
@RequiredArgsConstructor | ||
public class GuardiansController { | ||
|
||
private final GuardiansService guardiansService; | ||
|
||
@GetMapping("/{guardianId}") | ||
public ResponseEntity<GuardiansResponse> showGuardianInfo( | ||
@PathVariable("guardianId") Long guardianId) { | ||
GuardiansResponse guardiansResponse = guardiansService.getGuardianById(guardianId); | ||
return ResponseEntity.ok(guardiansResponse); | ||
} | ||
|
||
@PutMapping("/{guardianId}") | ||
public ResponseEntity<GuardiansResponse> updateGuardianInfo( | ||
@PathVariable("guardianId") Long guardianId, | ||
@Valid @RequestBody GuardiansRequest guardiansRequest) { | ||
GuardiansResponse guardiansResponse = guardiansService.updateGuardianById(guardianId, | ||
guardiansRequest); | ||
return ResponseEntity.ok(guardiansResponse); | ||
} | ||
} |
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,53 @@ | ||
package dbdr.controller; | ||
|
||
import dbdr.dto.request.RecipientRequestDTO; | ||
import dbdr.dto.response.RecipientResponseDTO; | ||
import dbdr.service.RecipientService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import jakarta.validation.Valid; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/v1/recipients") | ||
public class RecipientController { | ||
|
||
private final RecipientService recipientService; | ||
|
||
public RecipientController(RecipientService recipientService) { | ||
this.recipientService = recipientService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<RecipientResponseDTO>> getAllRecipients() { | ||
List<RecipientResponseDTO> recipients = recipientService.getAllRecipients(); | ||
return ResponseEntity.ok(recipients); | ||
} | ||
|
||
@GetMapping("/{id}") | ||
public ResponseEntity<RecipientResponseDTO> getRecipientById(@PathVariable Long id) { | ||
RecipientResponseDTO recipient = recipientService.getRecipientById(id); | ||
return ResponseEntity.ok(recipient); | ||
} | ||
|
||
@PostMapping | ||
public ResponseEntity<RecipientResponseDTO> createRecipient(@Valid @RequestBody RecipientRequestDTO recipientDTO) { | ||
RecipientResponseDTO newRecipient = recipientService.createRecipient(recipientDTO); | ||
return ResponseEntity.created(URI.create("/v1/recipients/" + newRecipient.getId())) | ||
.body(newRecipient); | ||
} | ||
|
||
@PutMapping("/{id}") | ||
public ResponseEntity<RecipientResponseDTO> updateRecipient(@PathVariable Long id, @RequestBody RecipientRequestDTO recipientDTO) { | ||
RecipientResponseDTO updatedRecipient = recipientService.updateRecipient(id, recipientDTO); | ||
return ResponseEntity.ok(updatedRecipient); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<Void> deleteRecipient(@PathVariable Long id) { | ||
recipientService.deleteRecipient(id); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
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,40 @@ | ||
package dbdr.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MappedSuperclass; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import org.hibernate.annotations.ColumnDefault; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(updatable = false, nullable = false) | ||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@Column(nullable = true) | ||
@LastModifiedDate | ||
private LocalDateTime updateAt; | ||
|
||
@Column(nullable = false) | ||
@ColumnDefault("true") | ||
private boolean isActive = true; | ||
|
||
public void deactivate() { | ||
this.isActive = false; | ||
} | ||
} |
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,44 @@ | ||
package dbdr.domain; | ||
|
||
import dbdr.dto.request.CareworkerRequestDTO; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.SQLRestriction; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(name = "careworker") | ||
@SQLDelete(sql = "UPDATE careworker SET is_active = false WHERE id = ?") | ||
@SQLRestriction("is_active= true") | ||
public class Careworker extends BaseEntity { | ||
|
||
@Column(nullable = false) | ||
private Long institutionId; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false, unique = true) | ||
private String email; | ||
|
||
@Column(nullable = false) | ||
private String phone; | ||
|
||
|
||
public Careworker(Long institutionId, String name, String email, String phone) { | ||
this.institutionId = institutionId; | ||
this.name = name; | ||
this.email = email; | ||
this.phone = phone; | ||
} | ||
|
||
public void updateCareworker(CareworkerRequestDTO careworkerDTO) { | ||
//this.institutionId = careworkerDTO.getInstitutionId(); | ||
this.name = careworkerDTO.getName(); | ||
this.email = careworkerDTO.getEmail(); | ||
this.phone = careworkerDTO.getPhone(); | ||
} | ||
} |
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,33 @@ | ||
package dbdr.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "guardians") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Guardians extends BaseEntity { | ||
|
||
@Column(nullable = false, unique = true) | ||
private String phone; | ||
@Column(nullable = false, length = 50) | ||
private String name; | ||
|
||
@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; | ||
} | ||
} |
Oops, something went wrong.