package com.fjhx.service.customer.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.customer.CustomerLink;
import com.fjhx.params.customer.CustomerLinkVo;
import com.fjhx.mapper.customer.CustomerLinkMapper;
import com.fjhx.service.customer.CustomerLinkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 客户联系人 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-10-25
 */
@Service
public class CustomerLinkServiceImpl extends ServiceImpl<CustomerLinkMapper, CustomerLink> implements CustomerLinkService {

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

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

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

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

    @Override
    public void add(CustomerLinkVo customerLinkVo) {
        save(customerLinkVo);
    }

    @Override
    public void edit(CustomerLinkVo customerLinkVo) {
        updateById(customerLinkVo);
    }

    @Override
    public void delete(CustomerLinkVo customerLinkVo) {
        removeById(customerLinkVo.getId());
    }

}
