package com.supplier.service.impl;

import com.supplier.mapper.ReleaseMapper;
import com.supplier.model.SupplierRoute;
import com.supplier.service.ReleaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
public class ReleaseServiceImpl implements ReleaseService {

    @Autowired
    private ReleaseMapper releaseMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addReleaseVal(SupplierRoute supplierRoute) {
        releaseMapper.addReleaseVal(supplierRoute);
    }

    @Override
    public List<SupplierRoute> getRelease(SupplierRoute supplierRoute) {
        supplierRoute.setPage((supplierRoute.getPage() - 1) * supplierRoute.getLimit());
        return releaseMapper.getRelease(supplierRoute);
    }

    @Override
    public int getReleaseCount(SupplierRoute supplierRoute) {
        return releaseMapper.getReleaseCount(supplierRoute);
    }

    @Override
    public List<SupplierRoute> getReleaseVal(SupplierRoute supplierRoute) {
        return releaseMapper.getReleaseVal(supplierRoute);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateSupplierRoute(SupplierRoute supplierRoute) {
        releaseMapper.updateSupplierRoute(supplierRoute);
    }
}
