package org.jeecg.modules.maintenanceWork.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchDTO;
import org.jeecg.modules.maintenanceWork.dto.WorkBatchSaveOrUpdateDTO;
import org.jeecg.modules.maintenanceWork.entity.WorkBatch;
import org.jeecg.modules.maintenanceWork.entity.WorkBatchDetail;
import org.jeecg.modules.maintenanceWork.mapper.WorkBatchDetailMapper;
import org.jeecg.modules.maintenanceWork.mapper.WorkBatchMapper;
import org.jeecg.modules.maintenanceWork.service.IWorkBatchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.maintenanceWork.vo.WorkBatchVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 维修作业管理-作业计划批次管理表 服务实现类
 * </p>
 *
 * @author hkl
 * @since 2023-08-09
 */
@Service
public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch> implements IWorkBatchService {
    @Resource
    private WorkBatchDetailMapper workBatchDetailMapper;

    @Override
    public Page<WorkBatchVO> listRecord(Page<WorkBatchVO> pageData, WorkBatchDTO dto) {
        return this.baseMapper.listRecord(pageData, dto);
    }

    @Override
    public void saveRecord(WorkBatchSaveOrUpdateDTO dto) {
        WorkBatch workBatch = BeanUtil.copyProperties(dto, WorkBatch.class);
        workBatch.setId(UUIDGenerator.generate());
        this.save(workBatch);
    }

    @Override
    public void updateRecord(WorkBatchSaveOrUpdateDTO dto) {
        WorkBatch workBatch = BeanUtil.copyProperties(dto, WorkBatch.class);
        this.updateById(workBatch);
    }

    @Override
    public void deleteRecord(String id) {
        this.removeById(id);
    }

}
