package com.zioinfo.esn.service;

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

@Service
@RequiredArgsConstructor
public class ProductService {
    private final ProductMapper mapper;

    public List<ProductVo> list(String tenantCode, Long storeId, String keyword) {
        return mapper.findAll(tenantCode, storeId, keyword);
    }

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

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

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

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