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

import com.aegis.emergency.plan.domain.PlanStep;
import com.aegis.emergency.plan.mapper.PlanStepMapper;
import com.aegis.emergency.plan.service.IPlanStepService;
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 PlanStepServiceImpl extends ServiceImpl<PlanStepMapper, PlanStep> implements IPlanStepService {

    @Override
    public List<PlanStep> listByPlanId(Long planId) {
        if (planId == null) {
            return Collections.emptyList();
        }
        return this.lambdaQuery()
            .eq(PlanStep::getPlanId, planId)
            .orderByAsc(PlanStep::getStepOrder)
            .list();
    }

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