package com.fjhx.service.apply.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.utils.WrapperUtil;
import com.fjhx.entity.apply.ApplyPurchaseDetails;
import com.fjhx.params.apply.ApplyPurchaseDetailsVo;
import com.fjhx.mapper.apply.ApplyPurchaseDetailsMapper;
import com.fjhx.service.apply.ApplyPurchaseDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 物料申购明细 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-09-14
 */
@Service
public class ApplyPurchaseDetailsServiceImpl extends ServiceImpl<ApplyPurchaseDetailsMapper, ApplyPurchaseDetails> implements ApplyPurchaseDetailsService {

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

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

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

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

    @Override
    public void add(ApplyPurchaseDetailsVo applyPurchaseDetailsVo) {
        save(applyPurchaseDetailsVo);
    }

    @Override
    public void edit(ApplyPurchaseDetailsVo applyPurchaseDetailsVo) {
        updateById(applyPurchaseDetailsVo);
    }

    @Override
    public void delete(ApplyPurchaseDetailsVo applyPurchaseDetailsVo) {
        removeById(applyPurchaseDetailsVo.getId());
    }

}
