Skip to content

Commit

Permalink
이슈 #39 FreeService 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
ezeun committed Jan 17, 2024
1 parent 78a70a0 commit c771aa4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/main/java/umc/forgrad/service/FreeService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package umc.forgrad.service;

import umc.forgrad.domain.common.Free;
import umc.forgrad.repository.FreeRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@Transactional
public class FreeService{

private final FreeRreository freeRepository;

public FreeService(FreeRepository freeRepository){
this.freeRepository = freeRepository;
}

/**
* 메모 추가하기
*/
public Long addMemo(Free free){
freeRepository.save(free);
return free.getId();
}

/**
* 메모 조회하기
*/
public List<Free> findMemos(){
return freeRepository.findAll();
}

public Optional<Free> findOne(Long memoId){
return freeRepository.findById(memoId);
}
}

0 comments on commit c771aa4

Please sign in to comment.