package com.zioinfo.esn.service;

import com.zioinfo.esn.domain.TemplateVo;
import com.zioinfo.esn.mapper.TemplateMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@RequiredArgsConstructor
public class TemplateService {
    private final TemplateMapper mapper;

    public List<TemplateVo> list(String tenantCode, String templateType) {
        return mapper.findAll(tenantCode, templateType);
    }

    public TemplateVo get(Long id) { return mapper.findById(id); }

    public TemplateVo create(TemplateVo v) {
        mapper.insert(v);
        return mapper.findById(v.getId());
    }

    public TemplateVo update(Long id, TemplateVo v) {
        v.setId(id);
        mapper.update(v);
        return mapper.findById(id);
    }

    public void delete(Long id) { mapper.delete(id); }
}
