package com.zioinfo.esn.service;

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

@Service
@RequiredArgsConstructor
public class StoreService {
    private final StoreMapper mapper;

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

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

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

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

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