29 lines
764 B
Java
29 lines
764 B
Java
package io.spring.infrastructure.comment;
|
|
|
|
import io.spring.core.comment.Comment;
|
|
import io.spring.core.comment.CommentRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.Optional;
|
|
|
|
@Component
|
|
public class MyBatisCommentRepository implements CommentRepository {
|
|
private CommentMapper commentMapper;
|
|
|
|
@Autowired
|
|
public MyBatisCommentRepository(CommentMapper commentMapper) {
|
|
this.commentMapper = commentMapper;
|
|
}
|
|
|
|
@Override
|
|
public void save(Comment comment) {
|
|
commentMapper.insert(comment);
|
|
}
|
|
|
|
@Override
|
|
public Optional<Comment> findById(String id) {
|
|
return Optional.ofNullable(commentMapper.findById(id));
|
|
}
|
|
}
|