Skip to content

Commit

Permalink
Merge pull request #23 from pick-time/feature/gift
Browse files Browse the repository at this point in the history
feat: 선물 삭제 api
  • Loading branch information
comody authored Jul 19, 2023
2 parents dfc37c7 + ff65f86 commit 97dbce5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/com/teo15/picktimebe/gift/GiftController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.nio.file.FileSystemException;
import java.util.List;

@RestController
@RequestMapping("/gift")
Expand Down Expand Up @@ -57,4 +57,16 @@ public ResponseEntity<GiftResponse> createGift(@PathVariable("targetId") Long ta
public ResponseEntity<GiftResponse> updateGiftInfo(@PathVariable("giftId") Long giftId, @ModelAttribute UpdateGiftInfoRequest request, @RequestParam(value ="file", required=false) MultipartFile file) throws FileSystemException {
return ResponseEntity.ok(giftService.updateAndgetList(giftId, request, file));
}

/**
* 선물 삭제 API
* req : targetId
*/
@DeleteMapping("/{targetId}")
@ApiOperation(value = "선물 삭제", notes = "선물을 삭제하고, 성공시 204 No Content를 응답")
public ResponseEntity<Void> removeGift(@PathVariable("targetId") Long targetId) {
giftService.deleteGift(targetId);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

}
5 changes: 5 additions & 0 deletions src/main/java/com/teo15/picktimebe/gift/GiftService.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ private String getContent(OpenGraph page, String propertyName) {
return "태그 없음";
}
}

@Transactional
public void deleteGift(Long targetId) {
giftRepository.deleteById(targetId);
}
}

0 comments on commit 97dbce5

Please sign in to comment.