package com.td.boss.game.commallseed.service;

import com.td.boss.common.service.*;
import com.td.boss.game.commallseed.pojo.ComMallSeed;
import com.td.boss.game.commallseed.vo.ComMallSeedVo;
import com.td.boss.game.commallseed.repository.ComMallSeedRepository;
import com.td.boss.util.CopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
import java.util.Optional;

@Service
@Transactional
public class ComMallSeedServiceImpl extends CommonServiceImpl<ComMallSeedVo, ComMallSeed, Integer> implements ComMallSeedService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private ComMallSeedRepository comMallSeedRepository;


    @Override
    public ComMallSeedVo findById(Integer id) {

        Optional<ComMallSeed> comMallSeed = comMallSeedRepository.findById(id);
        if(comMallSeed.orElse(null) == null){
            return null;
        }else{
            return CopyUtil.copy(comMallSeed.get(), ComMallSeedVo.class);
        }
    }

    @Override
    public List<ComMallSeed> findMallSeedAll() {
        return comMallSeedRepository.findAll();
    }
}
