package com.zzsmart.qomo.kn.cost.manage.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
import com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardDetailMapper;
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 标准成本明细表 服务实现类
 * </p>
 *
 * @author cost_purchase_price
 * @since 2024-06-19
 */
@Service
public class CostStandardDetailServiceImpl extends ServiceImpl<CostStandardDetailMapper, CostStandardDetail> implements CostStandardDetailService {

    @Autowired
    CostStandardDetailMapper costStandardDetailMapper;
    /**
     * 分页查询
     *
     * @param page
     * @param costStandard
     * @return
     */
    @Override
    public IPage<CostStandardDetailVO> pageList(Page<CostStandardDetailVO> page, CostStandardDetailVO costStandard) {
        // 查询条件组装
        QueryWrapper queryWrapper = new QueryWrapper();

        if(costStandard != null){

            if(StrUtil.isNotEmpty(costStandard.getMaterialNumber()) ){
                // 物料号
                queryWrapper.like("c1.material_number",costStandard.getMaterialNumber());
            }
            if(StrUtil.isNotEmpty(costStandard.getVersionNumber()) ){
                // 版本号
                queryWrapper.like("c2.version_number",costStandard.getVersionNumber());
            }

        }
        return (IPage<CostStandardDetailVO>) costStandardDetailMapper.pageList(page,queryWrapper);
    }
}
