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

[#84] 기존 로직 보완 #90

Merged
merged 5 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -35,6 +35,7 @@
import reborn.backend.user.service.UserService;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Tag(name = "마이페이지", description = "마이페이지 관련 api 입니다.")
Expand Down Expand Up @@ -92,10 +93,14 @@ public ApiResponse<DetailPetDto> getDetailPet(
})
@DeleteMapping("/delete/{pet-id}")
public ApiResponse<Boolean> deletePet(
@AuthenticationPrincipal CustomUserDetails customUserDetails,
@PathVariable(name = "pet-id") Long id
){
User user = userService.findUserByUserName(customUserDetails.getUsername());
if (Objects.equals(user.getContentPetId(),id) ) userService.resetContentPetId(user);

petService.deletePet(id);
return ApiResponse.onSuccess(SuccessCode.PET_DETAIL_VIEW_SUCCESS, true);
return ApiResponse.onSuccess(SuccessCode.PET_DELETED, true);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import reborn.backend.pet.service.PetService;
import reborn.backend.reborn_15._5_reborn.converter.RebornConverter;
import reborn.backend.reborn_15._5_reborn.domain.Reborn;
import reborn.backend.reborn_15._5_reborn.dto.RebornRequestDto.RebornReqDto;
import reborn.backend.reborn_15._5_reborn.dto.RebornRequestDto.ContentRebornReqDto;
import reborn.backend.reborn_15._5_reborn.dto.RebornRequestDto.RebornRebornReqDto;
import reborn.backend.reborn_15._5_reborn.dto.RebornResponseDto.DetailRebornDto;
import reborn.backend.reborn_15._5_reborn.service.RebornService;
import reborn.backend.user.domain.User;
Expand Down Expand Up @@ -68,7 +69,7 @@ public ApiResponse<DetailRebornDto> getDetailReBORN(
@PostMapping("/write/{id}")
public ApiResponse<Boolean> write(
@PathVariable(name = "id") Long id,
@RequestBody RebornReqDto rebornReqDto
@RequestBody ContentRebornReqDto rebornReqDto
){
rebornService.writeReborn(id, rebornReqDto);

Expand All @@ -82,7 +83,7 @@ public ApiResponse<Boolean> write(
@PostMapping("/set/{id}")
public ApiResponse<Boolean> setReborn(
@PathVariable(name = "id") Long id,
@RequestBody RebornReqDto rebornReqDto
@RequestBody RebornRebornReqDto rebornReqDto
){
rebornService.setReborn(id, rebornReqDto);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Reborn {

@Enumerated(EnumType.STRING)
@Column
private RebornType rebornType;
private RebornType rebornType = RebornType.BLACK;

@Column
private Boolean pat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ public class RebornRequestDto {
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class RebornReqDto {
public static class ContentRebornReqDto {
@Schema(description = "반려동물에게 하는 작별인사")
private String rebornContent;
}

@Schema(description = "RebornRebornReqDto")
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class RebornRebornReqDto {
@Schema(description = "리본 타입(YELLOW, BLACK)")
private String rebornType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import reborn.backend.reborn_15._5_reborn.converter.RebornConverter;
import reborn.backend.reborn_15._5_reborn.domain.Reborn;
import reborn.backend.reborn_15._5_reborn.domain.RebornType;
import reborn.backend.reborn_15._5_reborn.dto.RebornRequestDto.RebornReqDto;
import reborn.backend.reborn_15._5_reborn.dto.RebornRequestDto.ContentRebornReqDto;
import reborn.backend.reborn_15._5_reborn.dto.RebornRequestDto.RebornRebornReqDto;
import reborn.backend.reborn_15._5_reborn.repository.RebornRepository;

import java.util.List;
Expand Down Expand Up @@ -100,7 +101,7 @@ public void clotheReborn(Long id) {
}

@Transactional
public void writeReborn(Long id, RebornReqDto rebornReqDto) {
public void writeReborn(Long id, ContentRebornReqDto rebornReqDto) {
Reborn reborn = rebornRepository.findById(id)
.orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND));

Expand All @@ -112,7 +113,7 @@ public void writeReborn(Long id, RebornReqDto rebornReqDto) {
}

@Transactional
public void setReborn(Long id, RebornReqDto rebornReqDto) {
public void setReborn(Long id, RebornRebornReqDto rebornReqDto) {
Reborn reborn = rebornRepository.findById(id)
.orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND));

Expand Down
Loading