package com.ssj.dao.sys.menu.dao;

import com.ssj.bean.sys.menu.domain.WxMsgEvent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface WxMsgEventDao extends JpaRepository<WxMsgEvent, String>{

	@Query(nativeQuery = true, value = "SELECT * from tb_wx_msg_event m where m.event_key=?1 and m.`event`=?2 ORDER BY create_date DESC")
	List<WxMsgEvent> getWxMsgEventByKey(String eventKey, String event);
	
	@Modifying
	@Query(nativeQuery = true, value = "insert into tb_wx_msg_event ( id, weixinid, event, event_key, media_id,create_date,remark) values ( UUID(), ?1 , ?2, ?3 ,?4,NOW(),?5 )  ")
	void saveWxMsgEvent(String weixinid, String event, String eventKey, String mediaId, String remark);
	
	@Modifying
	@Query(nativeQuery = true, value = "DELETE FROM tb_wx_msg_event WHERE event_key = ?1 ")
	void delWxMsgEvent(String eventKey);
	
}
