package com.uas.platform.b2b.dao;

import com.uas.platform.b2b.model.SaleTenderQuestion;
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 org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 投标单提问单
 * 2017-09-11
 */
@Repository
public interface SaleTenderQuestionDao extends JpaSpecificationExecutor<SaleTenderQuestion>, JpaRepository<SaleTenderQuestion, Long> {

    /**
     * 根据答疑单id修改提问单状态为已回复
     * @param answerId
     */
    @Modifying@Transactional
    @Query("update SaleTenderQuestion q set q.status = 201,q.replyDate = :replyDate where q.saleTenderAnswer.id = :answerId")
    void setReplied(@Param("answerId") Long answerId, @Param("replyDate") Date replyDate);
}
