package com.fjhx.service.supplier.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.utils.WrapperUtil;
import com.fjhx.entity.supplier.SupplierPriceChange;
import com.fjhx.params.supplier.SupplierPriceChangeVo;
import com.fjhx.mapper.supplier.SupplierPriceChangeMapper;
import com.fjhx.service.supplier.SupplierPriceChangeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 供应商价格维护变更记录 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-09-13
 */
@Service
public class SupplierPriceChangeServiceImpl extends ServiceImpl<SupplierPriceChangeMapper, SupplierPriceChange> implements SupplierPriceChangeService {

    @Override
    public Page<SupplierPriceChange> getPage(Map<String, String> condition) {

        QueryWrapper<SupplierPriceChange> wrapper = Wrappers.query();

        WrapperUtil.init(condition, wrapper)
                .createTimeDesc();

        Page<SupplierPriceChange> page = page(condition, wrapper);
        return page;
    }

    @Override
    public void add(SupplierPriceChangeVo supplierPriceChangeVo) {
        save(supplierPriceChangeVo);
    }

    @Override
    public void edit(SupplierPriceChangeVo supplierPriceChangeVo) {
        updateById(supplierPriceChangeVo);
    }

    @Override
    public void delete(SupplierPriceChangeVo supplierPriceChangeVo) {
        removeById(supplierPriceChangeVo.getId());
    }

}
