package com.fjhx.customer.service.customer.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.customer.entity.customer.dto.CustomerTopDto;
import com.fjhx.customer.entity.customer.po.CustomerTop;
import com.fjhx.customer.mapper.customer.CustomerTopMapper;
import com.fjhx.customer.service.customer.CustomerTopService;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 客户置顶表 服务实现类
 * </p>
 *
 * @author
 * @since 2023-05-09
 */
@Service
public class CustomerTopServiceImpl extends ServiceImpl<CustomerTopMapper, CustomerTop> implements CustomerTopService {

    @Override
    public void add(CustomerTopDto customerTopDto) {
        customerTopDto.setUserId(SecurityUtils.getUserId());
        this.save(customerTopDto);
    }

    @Override
    public void delete(Long id) {
        CustomerTop customerTop = getOne(q -> q.eq(CustomerTop::getUserId, SecurityUtils.getUserId()).eq(CustomerTop::getCustomerId, id));
        this.removeById(customerTop.getId());
    }

}
