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

import com.aliyuncs.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.jeecg.modules.device.entity.Part;
import org.jeecg.modules.device.mapper.PartMapper;
import org.jeecg.modules.device.service.IPartService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 设备部件表
 * @Author: jeecg-boot
 * @Date:   2025-01-16
 * @Version: V1.0
 */
@Service
public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements IPartService {
    @Override
    public boolean save(Part entity) {
        if(!StringUtils.isEmpty(entity.getPid())){
            Part part = baseMapper.selectById(entity.getPid());
            if(part == null){
                return false;
            }
            entity.setDevice(part.getDevice());
        }
        return super.save(entity);
    }
}
