package com.jiayue.ipfcst.dataexchange.repository;

import com.jiayue.ipfcst.dataexchange.domain.TemplatePoint;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * 模版点位信息仓库
 *
 * @author 修唯xiuwei
 * @version 3.0
 */
public interface TemplatePointRepository extends JpaRepository<TemplatePoint, Integer>, JpaSpecificationExecutor<TemplatePoint> {


  /**
   * 通过绑定的模版id来修改点表绑定的通道
   *
   * @param tunnelId                通道ID
   * @param equipmentDataTemplateId 设备号
   * @return {@link Integer}
   */
  @Modifying
  @Query("update TemplatePoint t set t.tunnelId = ?1 where t.equipmentDataTemplateId = ?2")
  Integer updateTunnelByTemplateId(String tunnelId, Integer equipmentDataTemplateId);
}
