package com.ibeetl.admin.flow.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.flow.dao.DirectedChannelDao;
import com.ibeetl.admin.flow.entity.DirectedChannelEntity;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DirectedChannelService extends BaseService<DirectedChannelEntity> {

    private final Log log = LogFactory.getLog(this.getClass());

    @Autowired
    private DirectedChannelDao directedChannelDao;

    public void search(PageQuery<DirectedChannelEntity> query) {
        PageQuery<DirectedChannelEntity> ret = directedChannelDao.searchChannel(query);
        queryListAfter(ret.getList());
    }

    @Transactional(rollbackFor = Exception.class)
    public void saveChannel(DirectedChannelEntity entity) {
        directedChannelDao.saveChannel(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public void updateChannel(DirectedChannelEntity entity) {
        directedChannelDao.updateChannel(entity);
    }

    public DirectedChannelEntity findChannelById(String id) {
        return directedChannelDao.findChannelById(id);
    }

    public List<DirectedChannelEntity> findAllChannel() {
        return directedChannelDao.findAllChannel();
    }
}
