package com.zioinfo.esn.service;

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

@Service
@RequiredArgsConstructor
public class TenantService {
    private final TenantMapper mapper;

    public List<TenantVo> list() { return mapper.findAll(); }
    public TenantVo get(Long id) { return mapper.findById(id); }

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

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

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