package com.fjhx.service.bom.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.mapper.bom.BomDetailsMapper;
import com.fjhx.utils.WrapperUtil;
import com.fjhx.entity.bom.BomDetails;
import com.fjhx.params.bom.BomDetailsVo;
import com.fjhx.service.bom.BomDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * bom明细 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-07-01
 */
@Service
public class BomDetailsServiceImpl extends ServiceImpl<BomDetailsMapper, BomDetails> implements BomDetailsService {

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

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

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

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

    @Override
    public void add(BomDetailsVo bomDetailsVo) {
        save(bomDetailsVo);
    }

    @Override
    public void edit(BomDetailsVo bomDetailsVo) {
        updateById(bomDetailsVo);
    }

    @Override
    public void delete(BomDetailsVo bomDetailsVo) {
        removeById(bomDetailsVo.getId());
    }

    @Override
    public BomDetails detail(BomDetailsVo bomDetailsVo) {
        BomDetails result = getById(bomDetailsVo.getId());
        return result;
    }

}
