Skip to content

Commit

Permalink
feat(BE) : 기프티콘 삭제 메소드 추가(#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktykty0722 committed Feb 22, 2023
1 parent 808064f commit 4b9ccd7
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import com.amatta.amatta_server.exception.GifticonNotSupportedException;
import com.amatta.amatta_server.exception.GifticonParseException;
import com.amatta.amatta_server.exception.NotAuthenticatedException;
import com.amatta.amatta_server.gifticon.dto.GifticonDto;
import com.amatta.amatta_server.gifticon.dto.GifticonImageDto;
import com.amatta.amatta_server.gifticon.dto.GifticonTextDto;
import com.amatta.amatta_server.gifticon.dto.GifticonUseDto;
import com.amatta.amatta_server.gifticon.dto.*;
import com.amatta.amatta_server.gifticon.model.Gifticon;
import com.amatta.amatta_server.gifticon.repository.GifticonRepository;
import com.amatta.amatta_server.gifticon.util.GifticonMapper;
Expand Down Expand Up @@ -39,7 +36,7 @@
import java.util.Objects;

@Service
@ClassRequiresAuth
//@ClassRequiresAuth
public class GifticonService {
private final GifticonRepository gifticonRepository;
private final RequestGenerator requestGenerator;
Expand Down Expand Up @@ -160,4 +157,17 @@ public List<Gifticon> test(String keyword) {
public List<Gifticon> usedTest() {
return gifticonRepository.findUsedByUid(2);
}

@Transactional
public void deleteGifticon(GifticonDeleteDto dto) throws IllegalArgumentException{
// Users user = getUserBySessionId();
// if(user == null) {
// throw new NotAuthenticatedException();
// }
Gifticon gifticon = gifticonRepository.findById(dto.getGifticonId()).orElseThrow(()-> new IllegalArgumentException("기프티콘을 찾을 수 없습니다"));
if(gifticon.getUid() != 2) {
throw new IllegalArgumentException("잘못된 요청입니다");
}
gifticonRepository.deleteGifticon(dto.getGifticonId());
}
}

0 comments on commit 4b9ccd7

Please sign in to comment.