/**
 * @filename:SalesCommodityServiceImpl 2024-09-03
 * @project KJT v1.0.0 Copyright(c) 2024 wanglang Co. Ltd. All right reserved.
 */
package com.trade.service.sales.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trade.service.sales.domain.SalesCommodity;
import com.trade.service.sales.mapper.SalesCommodityMapper;
import com.trade.service.sales.service.SalesCommodityService;
import com.trade.service.sales.vo.SalesCommoditySearch;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:销售商品服务实现
 * @version: v1.0.0
 * @author: wanglang
 */
@Service
public class SalesCommodityServiceImpl extends ServiceImpl<SalesCommodityMapper, SalesCommodity> implements SalesCommodityService {

    @Override
    public List<SalesCommodity> queryBySalesContractId(Long salesContractId) {
        return this.baseMapper.selectBySalesContractId(salesContractId);
    }

    @Override
    public List<SalesCommodity> getContractCommodityList(SalesCommoditySearch search) {
        QueryWrapper<SalesCommodity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("sales_contract_id", search.getSalesContractId());
        if (null != search.getName()) {
            queryWrapper.like("name", search.getName());
        }
        return this.list(queryWrapper);
    }
}
