package com.uas.platform.b2b.dao;

import com.uas.platform.b2b.model.NotExistOrders;
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 org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 平台不存在订单数据库操作
 *
 * Created by hejq on 2018-06-19.
 */
@Repository
public interface NotExistOrdersDao extends JpaRepository<NotExistOrders, Long>, JpaSpecificationExecutor<NotExistOrders> {

    /**
     * 通过企业UU和下载状态查询单据
     *
     * @param enUU 企业UU
     * @param status 下载状态
     * @param type 单据类型
     * @return
     */
    List<NotExistOrders> findByEnUUAndStatusAndType(Long enUU, Integer status, String type);

    /**
     * 更新下载状态
     *
     * @param id id
     */
    @Modifying
    @Transactional
    @Query("update NotExistOrders set status = 203 where id = :id")
    void updateStatus(@Param("id") Long id);
}
