package cn.iocoder.yudao.module.mes.dal.mysql.subjectmoldplan;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mes.dal.dataobject.subjectmoldplan.SubjectMoldPlanDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mes.controller.admin.subjectmoldplan.vo.*;

/**
 * 项目方案关联 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface SubjectMoldPlanMapper extends BaseMapperX<SubjectMoldPlanDO> {

    default PageResult<SubjectMoldPlanDO> selectPage(SubjectMoldPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SubjectMoldPlanDO>()
                .eqIfPresent(SubjectMoldPlanDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(SubjectMoldPlanDO::getPlanId, reqVO.getPlanId())
                .betweenIfPresent(SubjectMoldPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SubjectMoldPlanDO::getId));
    }

    /**
     * 物理删除指定计划的关联
     *
     * @param planId 计划ID
     */
    @Delete("DELETE FROM besure.mes_subject_mold_plan WHERE plan_id = #{planId}")
    void deleteByPlanId(Long planId);

}