package com.njzscloud.dispose.mfg.bom.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.mfg.bom.mapper.BomDetailMapper;
import com.njzscloud.dispose.mfg.bom.pojo.entity.BomDetailEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 物料清单明细
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class BomDetailService extends ServiceImpl<BomDetailMapper, BomDetailEntity> implements IService<BomDetailEntity> {

    /**
     * 新增
     */
    public void add(BomDetailEntity bomDetailEntity) {
        this.save(bomDetailEntity);
    }

    /**
     * 修改
     */
    public void modify(BomDetailEntity bomDetailEntity) {
        this.updateById(bomDetailEntity);
    }

    /**
     * 删除
     */
    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     */
    public BomDetailEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     */
    public PageResult<BomDetailEntity> paging(PageParam pageParam, BomDetailEntity bomDetailEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<BomDetailEntity>query(bomDetailEntity)));
    }
}
