package com.fjhx.mes.service.border.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.mes.entity.border.po.BorderOfLineJournal;
import com.fjhx.mes.mapper.border.BorderOfLineJournalMapper;
import com.fjhx.mes.service.border.BorderOfLineJournalService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.border.vo.BorderOfLineJournalVo;
import com.fjhx.mes.entity.border.dto.BorderOfLineJournalSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.mes.entity.border.dto.BorderOfLineJournalDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 线边流水记录 服务实现类
 * </p>
 *
 * @author
 * @since 2023-03-31
 */
@DS(SourceConstant.MES)
@Service
public class BorderOfLineJournalServiceImpl extends ServiceImpl<BorderOfLineJournalMapper, BorderOfLineJournal> implements BorderOfLineJournalService {

    @Override
    public Page<BorderOfLineJournalVo> getPage(BorderOfLineJournalSelectDto dto) {
        IWrapper<BorderOfLineJournal> wrapper = getWrapper();
        wrapper.orderByDesc("bolj", BorderOfLineJournal::getId);
        Page<BorderOfLineJournalVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    @Override
    public BorderOfLineJournalVo detail(Long id) {
        BorderOfLineJournal BorderOfLineJournal = this.getById(id);
        BorderOfLineJournalVo result = BeanUtil.toBean(BorderOfLineJournal, BorderOfLineJournalVo.class);
        return result;
    }

    @Override
    public void add(BorderOfLineJournalDto borderOfLineJournalDto) {
        this.save(borderOfLineJournalDto);
    }

    @Override
    public void edit(BorderOfLineJournalDto borderOfLineJournalDto) {
        this.updateById(borderOfLineJournalDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

}
