package cn.reghao.bnt.web.devops.machine.db.repository;

import cn.reghao.bnt.web.devops.machine.model.po.MachineInfo;
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;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author reghao
 * @date 2020-01-21 14:53:03
 */
public interface MachineInfoRepository extends JpaRepository<MachineInfo, Integer>, JpaSpecificationExecutor<MachineInfo> {
    void deleteByMachineId(String machineId);
    @Query("update MachineInfo u " +
            "set u.stat=:stat " +
            "where u.machineId=:machineId")
    @Modifying
    void updateMachineStat(@Param("machineId") String machineId, @Param("stat") int stat);

    MachineInfo findByMachineId(String machineId);
    List<MachineInfo> findByStat(int stat);
}
