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

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.deviceAsset.dto.RailManagementDTO;
import org.jeecg.modules.deviceAsset.entity.RailManagement;
import org.jeecg.modules.deviceAsset.mapper.RailManagementMapper;
import org.jeecg.modules.deviceAsset.service.IRailManagementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.deviceAsset.vo.RailManagementVO;
import org.jeecg.modules.utils.UnitCodeUtil;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资产管理-钢轨管理 服务实现类
 * </p>
 *
 * @author hkl
 * @since 2023-07-06
 */
@Service
public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper, RailManagement> implements IRailManagementService {

    @Override
    public Page<RailManagementVO> queryPageList(Page<RailManagementVO> pageData, RailManagementDTO dto) {
        return this.baseMapper.queryPageList(pageData, dto);
    }

    @Override
    public void edit(RailManagement railManagement) {
        if (ObjectUtil.isEmpty(railManagement.getId())) {
            String utilCode = UnitCodeUtil.railUnitCodeUtil(railManagement.getLineAliasId());
            railManagement.setUnitCode(utilCode);

            this.save(railManagement);
        } else {
            this.updateById(railManagement);
        }
    }

    @Override
    public void intelligentGeneration() {
        throw new NullPointerException();
    }
}
