package com.aegis.emergency.plan.service.impl;

import com.aegis.emergency.plan.domain.PlanStepResource;
import com.aegis.emergency.plan.mapper.PlanStepResourceMapper;
import com.aegis.emergency.plan.service.IPlanStepResourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 行动项资源 Service 实现
 */
@Service
public class PlanStepResourceServiceImpl extends ServiceImpl<PlanStepResourceMapper, PlanStepResource> implements IPlanStepResourceService {

    @Override
    public List<PlanStepResource> listByStepId(Long stepId) {
        if (stepId == null) {
            return Collections.emptyList();
        }
        return this.lambdaQuery()
            .eq(PlanStepResource::getStepId, stepId)
            .list();
    }

    @Override
    public boolean removeByStepId(Long stepId) {
        if (stepId == null) {
            return false;
        }
        return this.lambdaUpdate()
            .eq(PlanStepResource::getStepId, stepId)
            .remove();
    }

    @Override
    public boolean removeByPlanId(Long planId) {
        if (planId == null) {
            return false;
        }
        return this.lambdaUpdate()
            .eq(PlanStepResource::getPlanId, planId)
            .remove();
    }
}