package cn.iocoder.yudao.module.museum.service.museumflow;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.museum.controller.admin.museumflow.vo.MuseumFlowPageVO;
import cn.iocoder.yudao.module.museum.controller.admin.museumflow.vo.MuseumFlowSaveVO;
import cn.iocoder.yudao.module.museum.dal.database.museumflow.MuseumFlowDO;
import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
import cn.iocoder.yudao.module.museum.dal.mysql.museumflow.MuseumFlowMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MuseumFlowServiceImpl implements MuseumFlowService {

    @Resource
    private MuseumFlowMapper museumFlowMapper;

    @Override
    public Integer createMuseumFlow(MuseumFlowSaveVO saveVO){
        MuseumFlowDO result = BeanUtils.toBean(saveVO, MuseumFlowDO.class);
        return museumFlowMapper.insert(result);
    }

    @Override
    public void updateMuseumFlow(MuseumFlowSaveVO saveVO){
        museumFlowMapper.updateMuseumFlow(BeanUtils.toBean(saveVO,MuseumFlowDO.class));
    }

    @Override
    public void deleteMuseumFlow(Integer id){
//      museumFlowMapper.deleteMuseumFlow(id);
        museumFlowMapper.deleteById(id);
    }

    @Override
    public MuseumFlowDO selectMuseumFlow(Integer id) {
        return museumFlowMapper.selectMuseumFlowById(id);
    }

    /**根据样本编号查找**/
    public MuseumInfoDO selectMuseumFlowSampleId(String sample_id) {
        return museumFlowMapper.selectMuseumFlowBySampleId(sample_id);
    }

    /**将样品状态设置为1*/
    @Override
    public void updateMuseumFlowState(MuseumFlowSaveVO saveVO){
        museumFlowMapper.updateMuseumFlowState(BeanUtils.toBean(saveVO,MuseumFlowDO.class));
    }

    /**将样品状态设置为4*/
    @Override
    public  void updateMuseumFlowState4(MuseumFlowSaveVO saveVO){
        museumFlowMapper.updateMuseumFlowState4(BeanUtils.toBean(saveVO,MuseumFlowDO.class));
    }

    /**将样品状态设置为3*/
    @Override
    public  void updateMuseumFlowState3(MuseumFlowSaveVO saveVO){
        museumFlowMapper.updateMuseumFlowState3(BeanUtils.toBean(saveVO,MuseumFlowDO.class));
    }

    @Override
    public List<MuseumFlowDO> selectPageMuseumFlowOutboundPerson(MuseumFlowPageVO pageVO){
        return museumFlowMapper.selectPageMuseumFlowByOutboundPerson(pageVO);
    }

    @Override
    public PageResult<MuseumFlowDO> selectPageS(MuseumFlowPageVO pageVO){
        return  museumFlowMapper.selectPage1(pageVO);
    }
}
