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.SupplierContacts;
import com.fjhx.params.supplier.SupplierContactsVo;
import com.fjhx.mapper.supplier.SupplierContactsMapper;
import com.fjhx.service.supplier.SupplierContactsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 供应商联系人 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-08-08
 */
@Service
public class SupplierContactsServiceImpl extends ServiceImpl<SupplierContactsMapper, SupplierContacts> implements SupplierContactsService {

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

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

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

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

    @Override
    public void add(SupplierContactsVo supplierContactsVo) {
        save(supplierContactsVo);
    }

    @Override
    public void edit(SupplierContactsVo supplierContactsVo) {
        updateById(supplierContactsVo);
    }

    @Override
    public void delete(SupplierContactsVo supplierContactsVo) {
        removeById(supplierContactsVo.getId());
    }

}
