Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api 버그 수정 완료 #114

Merged
merged 40 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
918ef2d
merge
yooookm Nov 9, 2024
c1ca0ed
fix: chart 필드 자료형 변경
yooookm Nov 9, 2024
3a641d5
fix: pagable 추가
yooookm Nov 9, 2024
e81df15
feat: chartOverViewResponse 생성
yooookm Nov 9, 2024
1d3b6da
feat: chartOverViewResponse mapper 추가
yooookm Nov 9, 2024
3ac46cb
test: chartOverViewResponse mapper 테스트코드 작성
yooookm Nov 9, 2024
dc06ae5
feat: 차트 전체 조회시 chartOverViewResponse 적용
yooookm Nov 9, 2024
8a38604
feat: chartResponse 에러 처리
yooookm Nov 9, 2024
760b939
fix : admin add 오류 수정
20jcode Nov 9, 2024
9edad1b
refactor : 로그인 리팩토링 (#92)
pykido Nov 9, 2024
b6bd371
refactor: summary 수정 (#93)
hyyyh0x Nov 9, 2024
f9cf1d0
merge:fix-bug-11-9
yooookm Nov 9, 2024
54b259d
Merge pull request #94 from yooookm/fix-chart
yooookm Nov 9, 2024
2309dc3
fix : institution 생성 테스트 (#95)
20jcode Nov 9, 2024
bdfc3b6
test : 요양원 생성 추가 (#96)
20jcode Nov 9, 2024
168df5f
refactor: institution update (#97)
hyyyh0x Nov 9, 2024
e3274a0
refactor: careworker (#98)
mogld Nov 9, 2024
dbb769a
refactor: DTO 제거 (#99)
mogld Nov 9, 2024
9fd3276
Bug fix 11 9 1 (#100)
20jcode Nov 9, 2024
9ea8a2a
refactor : guradina 추가 조회 성공 (#102)
pykido Nov 9, 2024
6410bad
Bug fix 11 9 0101 (#103)
hyyyh0x Nov 9, 2024
0ada9bc
fix: 로그인 관련 오류 수정
yooookm Nov 9, 2024
83fd9f2
Merge pull request #104 from yooookm/bug-fix-11-9
yooookm Nov 9, 2024
a7d1ed7
fix: 요양원 추가 로직 수정
yooookm Nov 9, 2024
d32e1fe
Merge pull request #105 from yooookm/bug-fix-11-9
yooookm Nov 9, 2024
8c9008a
refactor : Admin API 테스트 전부 성공
pykido Nov 9, 2024
767ba5f
Merge remote-tracking branch 'upstream/bug-fix-11-9' into bug-fix-11-9
pykido Nov 9, 2024
ae7d60e
refactor : 간단한 수정 (#106)
pykido Nov 9, 2024
cd73196
refactor: passwordEncoder (#107)
hyyyh0x Nov 9, 2024
3956907
feat: globalExceptionHandler response 통일
yooookm Nov 9, 2024
3175bfb
Merge pull request #108 from yooookm/bug-fix-11-9
yooookm Nov 9, 2024
2f0b0cf
fix: 요양보호사 로그인
yooookm Nov 9, 2024
9b077d7
Merge pull request #109 from yooookm/bug-fix-11-9
yooookm Nov 9, 2024
9419990
fix: 요양보호사 로그인
yooookm Nov 9, 2024
a263e78
Merge branch 'bug-fix-11-9' into bug-fix-11-9
yooookm Nov 9, 2024
e95f218
Bug fix 11 9 01010010101 (#111)
hyyyh0x Nov 9, 2024
aad17c9
fix: 요양보호사 로그인 (#110)
yooookm Nov 9, 2024
09d59b5
refactor: summaryResponse 날짜와 기관이름 추가 (#112)
hyyyh0x Nov 9, 2024
1fd7f6c
fix: chartMapper 수정
yooookm Nov 9, 2024
6adff54
Merge pull request #113 from yooookm/bug-fix-11-9
yooookm Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -22,6 +23,7 @@
@RestController
@RequestMapping("/${spring.app.version}/admin")
@RequiredArgsConstructor
@Slf4j
public class AdminController {

private final AdminService adminService;
Expand All @@ -43,6 +45,8 @@ public ResponseEntity<String> getAdmin(@PathVariable(name = "id") Long id){
@Operation(summary = "서버관리자 추가")
@PostMapping("/add")
public ResponseEntity<Void> addAdmin(@RequestBody AdminCreateRequest adminCreateRequest){

log.info("어드민 생성 시작, {} {}", adminCreateRequest.loginId(), adminCreateRequest.loginPassword());
adminService.addAdmin(adminCreateRequest);
return ResponseEntity.ok().build();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dbdr/domain/admin/service/AdminService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void addAdmin(AdminCreateRequest adminCreateRequest) {
.loginId(adminCreateRequest.loginId())
.loginPassword(passwordEncoder.encode(adminCreateRequest.loginPassword()))
.build();
addAdmin(admin);
adminRepository.save(admin);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package dbdr.domain.careworker.controller;

import dbdr.domain.careworker.dto.request.CareworkerRequestDTO;
import dbdr.domain.careworker.dto.response.CareworkerResponseDTO;
import dbdr.domain.careworker.dto.request.CareworkerRequest;
import dbdr.domain.careworker.dto.response.CareworkerResponse;
import dbdr.domain.careworker.service.CareworkerService;
import dbdr.domain.institution.service.InstitutionService;
import dbdr.global.util.api.ApiUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,38 +24,38 @@ public class CareworkerAdminController {
private final CareworkerService careworkerService;
private final InstitutionService institutionService;

@Operation(summary = "전체 요양보호사 정보 조회")
@Operation(summary = "전체 요양보호사 정보 조회", security = @SecurityRequirement(name = "JWT"))
@GetMapping
public ResponseEntity<ApiUtils.ApiResult<List<CareworkerResponseDTO>>> getAllCareworkers() {
List<CareworkerResponseDTO> careworkers = careworkerService.getAllCareworkers();
public ResponseEntity<ApiUtils.ApiResult<List<CareworkerResponse>>> getAllCareworkers() {
List<CareworkerResponse> careworkers = careworkerService.getAllCareworkers();
return ResponseEntity.ok(ApiUtils.success(careworkers));
}


@Operation(summary = "요양보호사 정보 조회")
@Operation(summary = "요양보호사 정보 조회", security = @SecurityRequirement(name = "JWT"))
@GetMapping("/{careworkerId}")
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponseDTO>> getCareworkerById(
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponse>> getCareworkerById(
@PathVariable Long careworkerId) {
CareworkerResponseDTO careworker = careworkerService.getCareworkerResponseById(careworkerId);
CareworkerResponse careworker = careworkerService.getCareworkerResponseById(careworkerId);
return ResponseEntity.ok(ApiUtils.success(careworker));
}

@Operation(summary = "요양보호사 추가")
@Operation(summary = "요양보호사 추가", security = @SecurityRequirement(name = "JWT"))
@PostMapping
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponseDTO>> createCareworker(
@Valid @RequestBody CareworkerRequestDTO careworkerDTO) {
CareworkerResponseDTO newCareworker = careworkerService.createCareworker(careworkerDTO, careworkerDTO.getInstitutionId());
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponse>> createCareworker(
@Valid @RequestBody CareworkerRequest careworkerDTO) {
CareworkerResponse newCareworker = careworkerService.createCareworker(careworkerDTO);
return ResponseEntity.status(HttpStatus.CREATED).body(ApiUtils.success(newCareworker));

}


@Operation(summary = "요양보호사 정보 수정 ")
@Operation(summary = "요양보호사 정보 수정 ", security = @SecurityRequirement(name = "JWT"))
@PutMapping("/{careworkerId}")
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponseDTO>> updateCareworker(
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponse>> updateCareworker(
@PathVariable Long careworkerId,
@Valid @RequestBody CareworkerRequestDTO careworkerDTO) {
CareworkerResponseDTO updatedCareworker = careworkerService.updateCareworkerByAdmin(careworkerId, careworkerDTO);
@Valid @RequestBody CareworkerRequest careworkerDTO) {
CareworkerResponse updatedCareworker = careworkerService.updateCareworkerByAdmin(careworkerId, careworkerDTO);
return ResponseEntity.ok(ApiUtils.success(updatedCareworker));
}

Expand All @@ -65,4 +66,4 @@ public ResponseEntity<ApiUtils.ApiResult<String>> deleteCareworker(@PathVariable
careworkerService.deleteCareworkerByAdmin(careworkerId);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dbdr.domain.careworker.controller;

import dbdr.domain.careworker.dto.request.CareworkerUpdateRequestDTO;
import dbdr.domain.careworker.dto.response.CareworkerMyPageResponseDTO;
import dbdr.domain.careworker.dto.request.CareworkerUpdateRequest;
import dbdr.domain.careworker.dto.response.CareworkerMyPageResponse;
import dbdr.domain.careworker.entity.Careworker;
import dbdr.domain.careworker.service.CareworkerService;
import dbdr.global.util.api.ApiUtils;
Expand Down Expand Up @@ -34,19 +34,19 @@ public class CareworkerController {

@Operation(summary = "요양보호사 본인의 정보 조회", security = @SecurityRequirement(name = "JWT"))
@GetMapping
public ResponseEntity<ApiUtils.ApiResult<CareworkerMyPageResponseDTO>> showCareworkerInfo(
public ResponseEntity<ApiUtils.ApiResult<CareworkerMyPageResponse>> showCareworkerInfo(
@Parameter(hidden = true) @LoginCareworker Careworker careworker) {
log.info("Careworker Name: {}", careworker.getName());
CareworkerMyPageResponseDTO response = careworkerService.getMyPageInfo(careworker.getId());
CareworkerMyPageResponse response = careworkerService.getMyPageInfo(careworker.getId());
return ResponseEntity.ok(ApiUtils.success(response));
}

@Operation(summary = "요양보호사 본인의 근무일과 알림 시간 수정", security = @SecurityRequirement(name = "JWT"))
@PutMapping
public ResponseEntity<ApiUtils.ApiResult<CareworkerMyPageResponseDTO>> updateCareworkerInfo(
public ResponseEntity<ApiUtils.ApiResult<CareworkerMyPageResponse>> updateCareworkerInfo(
@Parameter(hidden = true) @LoginCareworker Careworker careworker,
@Valid @RequestBody CareworkerUpdateRequestDTO careworkerRequest) {
CareworkerMyPageResponseDTO updatedResponse = careworkerService.updateWorkingDaysAndAlertTime(careworker.getId(), careworkerRequest);
@Valid @RequestBody CareworkerUpdateRequest careworkerRequest) {
CareworkerMyPageResponse updatedResponse = careworkerService.updateWorkingDaysAndAlertTime(careworker.getId(), careworkerRequest);
return ResponseEntity.ok(ApiUtils.success(updatedResponse));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dbdr.domain.careworker.controller;

import dbdr.domain.careworker.dto.request.CareworkerRequestDTO;
import dbdr.domain.careworker.dto.response.CareworkerResponseDTO;
import dbdr.domain.careworker.dto.request.CareworkerRequest;
import dbdr.domain.careworker.dto.response.CareworkerResponse;
import dbdr.domain.careworker.service.CareworkerService;
import dbdr.domain.institution.entity.Institution;
import dbdr.global.util.api.ApiUtils;
Expand All @@ -27,40 +27,40 @@ public class CareworkerInstitutionController {

@Operation(summary = "특정 요양원아이디로 전체 요양보호사 정보 조회", security = @SecurityRequirement(name = "JWT"))
@GetMapping("/institution")
public ResponseEntity<ApiUtils.ApiResult<List<CareworkerResponseDTO>>> getAllCareworkers(
public ResponseEntity<ApiUtils.ApiResult<List<CareworkerResponse>>> getAllCareworkers(
@LoginInstitution Institution institution) {
List<CareworkerResponseDTO> institutions = careworkerService.getCareworkersByInstitution(institution.getId());
List<CareworkerResponse> institutions = careworkerService.getCareworkersByInstitution(institution.getId());
return ResponseEntity.ok(ApiUtils.success(institutions)) ;
}

@Operation(summary = "요양보호사 아이디로 요양보호사 정보 조회", security = @SecurityRequirement(name = "JWT"))
@GetMapping("/{careworkerId}")
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponseDTO>> getCareworkerById(
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponse>> getCareworkerById(
@PathVariable("careworkerId") Long careworkerId,
@LoginInstitution Institution institution) {
CareworkerResponseDTO careworker = careworkerService.getCareworkerByInstitution(careworkerId, institution.getId());
CareworkerResponse careworker = careworkerService.getCareworkerByInstitution(careworkerId, institution.getId());
return ResponseEntity.ok(ApiUtils.success(careworker)) ;
}


@Operation(summary = "요양보호사 추가", security = @SecurityRequirement(name = "JWT"))
@PostMapping
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponseDTO>> createCareworker(
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponse>> createCareworker(
@LoginInstitution Institution institution,
@Valid @RequestBody CareworkerRequestDTO careworkerDTO) {
CareworkerResponseDTO newCareworker = careworkerService.createCareworker(careworkerDTO, institution.getId());
@Valid @RequestBody CareworkerRequest careworkerDTO) {
CareworkerResponse newCareworker = careworkerService.createCareworker(careworkerDTO);
return ResponseEntity.status(HttpStatus.CREATED).body(ApiUtils.success(newCareworker));

}


@Operation(summary = "요양보호사 정보 수정", security = @SecurityRequirement(name = "JWT"))
@PutMapping("/{careworkerId}")
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponseDTO>> updateCareworker(
public ResponseEntity<ApiUtils.ApiResult<CareworkerResponse>> updateCareworker(
@PathVariable Long careworkerId,
@LoginInstitution Institution institution,
@RequestBody CareworkerRequestDTO careworkerDTO) {
CareworkerResponseDTO updatedCareworker = careworkerService.updateCareworker(careworkerId, careworkerDTO, institution.getId());
@RequestBody CareworkerRequest careworkerDTO) {
CareworkerResponse updatedCareworker = careworkerService.updateCareworker(careworkerId, careworkerDTO);
return ResponseEntity.ok(ApiUtils.success(updatedCareworker));
}

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/dbdr/domain/careworker/dto/CareworkerMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dbdr.domain.careworker.dto;

import dbdr.domain.careworker.dto.request.CareworkerRequest;
import dbdr.domain.careworker.dto.response.CareworkerResponse;
import dbdr.domain.careworker.entity.Careworker;
import dbdr.domain.institution.entity.Institution;
import dbdr.domain.institution.service.InstitutionService;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;

@Mapper(componentModel = "spring")
public abstract class CareworkerMapper {
@Autowired
PasswordEncoder passwordEncoder;
@Autowired
private InstitutionService institutionService;

@Mappings({
@Mapping(target = "institutionId", source = "institution.id"),
@Mapping(target = "id", source = "id")})
public abstract CareworkerResponse toResponse(Careworker careworker);

@Mappings({
@Mapping(target = "loginPassword", expression = "java(passwordEncoder.encode(request.getLoginPassword()))"),
@Mapping(target = "institution", source = "institutionId")})
public abstract Careworker toEntity(CareworkerRequest request);

protected Institution mapInstitution(Long institutionId) {
return institutionService.getInstitutionById(institutionId);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class CareworkerRequestDTO {
public class CareworkerRequest {

@Schema(description = "요양기관아이디", example = "1")
@NotNull(message = "요양기관 아이디는 필수 항목입니다.")
Expand All @@ -31,4 +31,10 @@ public class CareworkerRequestDTO {
@NotBlank(message = "휴대폰 번호는 필수 항목입니다.")
@Pattern(regexp = "010\\d{8}", message = "010XXXXXXXX형식으로 입력해주세요.")
private String phone;
}

@Schema(description = "요양보호사 비밀번호", example = "1234")
@NotBlank(message = "비밀번호는 필수 항목입니다.")
private String loginPassword;


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

@Getter
@AllArgsConstructor
public class CareworkerUpdateRequestDTO {
public class CareworkerUpdateRequest {

@NotNull(message = "근무일은 필수 항목입니다.")
private Set<DayOfWeek> workingDays;


@NotNull(message = "알림 시간은 필수 항목입니다.")
private LocalTime alertTime;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package dbdr.domain.careworker.dto.response;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.DayOfWeek;
import java.time.LocalTime;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class CareworkerMyPageResponseDTO {
public class CareworkerMyPageResponse {

private String name;
private String phone;
private String institutionName;
private String loginId;
private Set<DayOfWeek> workingDays;
private LocalTime alertTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CareworkerResponseDTO {
public class CareworkerResponse {

private Long id;
private Long institutionId;
private String name;
private String email;
private String phone;
}
}
Loading