package com.tykj.workflowcore.model_layer.dao;


import com.tykj.workflowcore.model_layer.entity.TableInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName TableInfoDao
 * @Description TODO
 * @Author WWW
 * @Date 2021/2/24 11:20
 * @Version 1.0
 */
public interface TableInfoDao extends JpaRepository<TableInfo, Integer>, JpaSpecificationExecutor<TableInfo> {
    /**
     * 根据表名查询tableInfo
     * @param name
     * @return
     */
    TableInfo findByModelName(String name);


    /**
     * 删除modelType是0的数据
     * @param type
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Modifying
   List<TableInfo> deleteAllByModelType(Integer type);

    /**
     * 根据模型类型查找
     * @param modeType
     * @return
     */
    List<TableInfo> findAllByModelType(Integer modeType);
}
