package com.jwipc.inquiry.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.inquiry.entity.Inquiry;
import com.jwipc.inquiry.entity.InquirySupplier;
import com.jwipc.inquiry.mapper.InquirySupplierMapper;
import com.jwipc.inquiry.model.po.InquirySupplierPO;
import com.jwipc.inquiry.model.po.InquirySupplierQuotePO;
import com.jwipc.inquiry.model.query.InquirySupplierQuery;
import com.jwipc.inquiry.service.IInquirySupplierService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 询价供应商表（与询价表一对一） 服务实现类
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-02-22
 */
@Service
public class InquirySupplierServiceImpl extends ServiceImpl<InquirySupplierMapper, InquirySupplier> implements IInquirySupplierService {

    @Override
    public List<InquirySupplierQuotePO> findPageByQuery(Page<InquirySupplier> dbPage, InquirySupplierQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }

    @Override
    public List<InquirySupplierPO> listByInquiryId(Long inquiryId) {
        return baseMapper.listByInquiryId(inquiryId);
    }

    @Override
    public void updateConState(Long xjdetailId, Integer state) {
        baseMapper.update(new LambdaUpdateWrapper<InquirySupplier>().set(InquirySupplier::getStateTurned,state).eq(InquirySupplier::getId,xjdetailId));
    }
}
