package com.fjhx.service.check.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.check.CheckDetail;
import com.fjhx.params.check.CheckDetailVo;
import com.fjhx.mapper.check.CheckDetailMapper;
import com.fjhx.service.check.CheckDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 盘点明细 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-11-03
 */
@Service
public class CheckDetailServiceImpl extends ServiceImpl<CheckDetailMapper, CheckDetail> implements CheckDetailService {

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

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

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

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

    @Override
    public void add(CheckDetailVo checkDetailVo) {
        save(checkDetailVo);
    }

    @Override
    public void edit(CheckDetailVo checkDetailVo) {
        updateById(checkDetailVo);
    }

    @Override
    public void delete(CheckDetailVo checkDetailVo) {
        removeById(checkDetailVo.getId());
    }

}
