-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#57] νλ μμ API ꡬν
- Loading branch information
Showing
6 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hobak/happinessql/domain/activity/application/ActivityUpdateService.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,26 @@ | ||
package com.hobak.happinessql.domain.activity.application; | ||
|
||
import com.hobak.happinessql.domain.activity.converter.ActivityConverter; | ||
import com.hobak.happinessql.domain.activity.domain.Activity; | ||
import com.hobak.happinessql.domain.activity.dto.ActivityUpdateRequestDto; | ||
import com.hobak.happinessql.domain.activity.dto.ActivityUpdateResponseDto; | ||
import com.hobak.happinessql.domain.activity.exception.ActivityNotFoundException; | ||
import com.hobak.happinessql.domain.activity.repository.ActivityRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class ActivityUpdateService { | ||
private final ActivityRepository activityRepository; | ||
|
||
public ActivityUpdateResponseDto updateActivity(Long activityId, ActivityUpdateRequestDto requestDto){ | ||
Activity activity = activityRepository.findById(activityId) | ||
.orElseThrow(()-> new ActivityNotFoundException("Activity with id " + activityId)); | ||
activity.updateName(requestDto.getName()); | ||
return ActivityConverter.toActivityUpdateResponseDto(activity); | ||
} | ||
|
||
} |
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
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/hobak/happinessql/domain/activity/dto/ActivityUpdateRequestDto.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,16 @@ | ||
package com.hobak.happinessql.domain.activity.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ActivityUpdateRequestDto { | ||
String name; | ||
@Builder | ||
ActivityUpdateRequestDto(String name){ | ||
this.name = name; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/hobak/happinessql/domain/activity/dto/ActivityUpdateResponseDto.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,22 @@ | ||
package com.hobak.happinessql.domain.activity.dto; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
|
||
public class ActivityUpdateResponseDto { | ||
private Long categoryId; | ||
private String categoryName; | ||
private Long activityId; | ||
private String activityName; | ||
@Builder | ||
ActivityUpdateResponseDto(Long categoryId, String categoryName, Long activityId, String activityName){ | ||
this.categoryId = categoryId; | ||
this.categoryName = categoryName; | ||
this.activityId = activityId; | ||
this.activityName = activityName; | ||
} | ||
} |