Skip to content

Commit

Permalink
Merge pull request #56 from Happy-HOBAK/feat/#55
Browse files Browse the repository at this point in the history
  • Loading branch information
yel-m authored May 7, 2024
2 parents 677bc4e + 6d77d27 commit fa936e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hobak.happinessql.domain.activity.api;

import com.hobak.happinessql.domain.activity.application.ActivityCreateService;
import com.hobak.happinessql.domain.activity.application.ActivityDeleteService;
import com.hobak.happinessql.domain.activity.dto.ActivityCreateRequestDto;
import com.hobak.happinessql.domain.activity.dto.ActivityCreateResponseDto;
import com.hobak.happinessql.domain.activity.dto.ActivityListResponseDto;
Expand All @@ -16,6 +17,7 @@ public class ActivityController {

private final ActivityListService activityListService;
private final ActivityCreateService activityCreateService;
private final ActivityDeleteService activityDeleteService;

@GetMapping
public DataResponseDto<ActivityListResponseDto> getActivitiesByUserId(@RequestParam Long userId) {
Expand All @@ -27,4 +29,9 @@ public DataResponseDto<ActivityCreateResponseDto> createActivity(@RequestBody Ac
ActivityCreateResponseDto response = activityCreateService.createActivity(request,userId);
return DataResponseDto.of(response,"ν™œλ™μ„ μ„±κ³΅μ μœΌλ‘œ μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.");
}
@DeleteMapping("/{activityId}")
public Long deleteActivity(@PathVariable Long activityId){
activityDeleteService.deleteActivity(activityId);
return activityId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hobak.happinessql.domain.activity.application;


import com.hobak.happinessql.domain.activity.domain.Activity;
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 ActivityDeleteService {
private final ActivityRepository activityRepository;
public void deleteActivity(Long activityId){
Activity activity = activityRepository.findById(activityId)
.orElseThrow(()->new ActivityNotFoundException("Activity with id " + activityId));
activityRepository.delete(activity);
}
}

0 comments on commit fa936e1

Please sign in to comment.