package com.ibeetl.admin.flow.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.flow.dao.DirectedSmsTemplateDao;
import com.ibeetl.admin.flow.entity.DirectedSmsTemplateEntity;
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 DirectedSmsTemplateService extends BaseService<DirectedSmsTemplateEntity> {

    @Autowired
    private DirectedSmsTemplateDao dao;

    public List<DirectedSmsTemplateEntity> findSmstemplateByCpid(String cpid) {
        return dao.findSmsTemplateByCpid(cpid);
    }

    public void search(PageQuery<DirectedSmsTemplateEntity> query) {
        PageQuery<DirectedSmsTemplateEntity> ret = dao.searchSmstemplate(query);
        queryListAfter(ret.getList());
    }

    @Transactional(rollbackFor = Exception.class)
    public void saveSmstemplate(DirectedSmsTemplateEntity entity) {
        dao.saveSmstemplate(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public void updateSmstemplate(DirectedSmsTemplateEntity entity) {
        dao.updateSmstemplate(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteSmstemplate(DirectedSmsTemplateEntity entity) {
        dao.deleteSmstemplate(entity);
    }

    public DirectedSmsTemplateEntity findSmsTemplateByCpSmstype(String smstype) {
        return dao.findSmsTemplateBySmstype(smstype);
    }
}
