package com.xvji.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xvji.domain.Component;
import com.xvji.mapper.ComponentMapper;
import com.xvji.service.ComponentService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component> implements ComponentService {

    @Override
    public boolean addComponent(Component component) {
        if (component.getIsEnable() == null) {
            component.setIsEnable(true);
        }
        return save(component);
    }

    @Override
    public List<Component> getComponentsByTaskId(Long taskId) {
        return lambdaQuery().eq(Component::getTaskId, taskId).list();
    }
}