package cn.iocoder.yudao.module.smartfactory.service.factory;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factory.vo.SfFactoryInfoPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factory.vo.SfFactoryInfoSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factory.SfFactoryInfoDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.factory.SfFactoryInfoMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;


/**
 * 工厂信息 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class SfFactoryInfoServiceImpl implements SfFactoryInfoService {

    @Resource
    private SfFactoryInfoMapper sfFactoryInfoMapper;

    @Override
    public Long createSfFactoryInfo(SfFactoryInfoSaveReqVO createReqVO) {
        // 插入
        SfFactoryInfoDO sfFactoryInfo = BeanUtils.toBean(createReqVO, SfFactoryInfoDO.class);
        sfFactoryInfoMapper.insert(sfFactoryInfo);
        // 返回
        return sfFactoryInfo.getId();
    }

    @Override
    public void updateSfFactoryInfo(SfFactoryInfoSaveReqVO updateReqVO) {
        // 更新
        SfFactoryInfoDO updateObj = BeanUtils.toBean(updateReqVO, SfFactoryInfoDO.class);
        sfFactoryInfoMapper.updateById(updateObj);
    }

    @Override
    public void deleteSfFactoryInfo(Long id) {
        // 删除
        sfFactoryInfoMapper.deleteById(id);
    }

    @Override
    public SfFactoryInfoDO getSfFactoryInfo(Long id) {
        return sfFactoryInfoMapper.selectById(id);
    }

    @Override
    public PageResult<SfFactoryInfoDO> getSfFactoryInfoPage(SfFactoryInfoPageReqVO pageReqVO) {
        return sfFactoryInfoMapper.selectPage(pageReqVO);
    }

}