package com.sw.mes.yb.pc.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.pc.entity.CrucibleCheckItem;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface CrucibleCheckItemDAO extends BaseDao<CrucibleCheckItem, Integer> {

    @Query(value = "SELECT * FROM zhxx_operate_crucible_check_item WHERE parent_id=?1 ", nativeQuery = true)
    List<CrucibleCheckItem> findByParentId(Integer parentId);

    @Query(value = "SELECT * FROM zhxx_operate_crucible_check_item ORDER BY priority ASC ", nativeQuery = true)
    List<CrucibleCheckItem> findAllOrderByPriority();

    @Modifying
    @Transactional
    @Query(value = "DELETE FROM zhxx_operate_crucible_check_item WHERE parent_id=?1 ", nativeQuery = true)
    void deleteByParentId(Integer parentId);
}
