package cn.hnthyy.thmz.service.impl.thmz;

import cn.hnthyy.thmz.entity.thmz.Template;
import cn.hnthyy.thmz.mapper.thmz.TemplateMapper;
import cn.hnthyy.thmz.service.thmz.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class TemplateServiceImpl implements TemplateService {
    @SuppressWarnings("all")
    @Autowired
    private TemplateMapper templateMapper;
    @Override
    public int saveTemplate(Template template) {
        if(template.getId()==null){
            template.setCreateTime(new Date());
            return templateMapper.insertTemplate(template);
        }
        template.setUpdateTime(new Date());
        return templateMapper.updateTemplateByKey(template);
    }

    @Override
    public List<Template> queryTemplate(String createId, String deptNo) {
        return templateMapper.selectTemplate(createId,deptNo);
    }

    @Override
    public Template queryById(Long id) {
        return templateMapper.selectById(id);
    }

}
