package com.spring.domain.post.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.spring.domain.post.entity.Post;
import com.spring.domain.post.mapper.PostMapper;
import com.spring.infra.db.orm.jpa.SecondaryJpaConfig;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
@RequiredArgsConstructor
public class PostCreateService {
    
    private final PostMapper postMapper;

    @Transactional(SecondaryJpaConfig.TRANSACTION_MANAGER)
    public void save() {
        postMapper.save(Post.builder().title("testTitle").content("testPost").build());
        List<Post> list = postMapper.findAll();
        list.forEach(item -> log.info(item.getContent()));
    }

}
