package cn.ztuo.bitrade.dao;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.ztuo.bitrade.dao.base.BaseDao;
import cn.ztuo.bitrade.entity.Announcement;

/**
 * @author GS
 * @description
 * @date 2018/3/5 15:32
 */
public interface AnnouncementDao extends BaseDao<Announcement> {

    @Query("select max(s.sort) from Announcement s")
    int findMaxSort();


    /**
     * 获取公告上一条
     * @param annId
     * @return
     */
    @Query(value = "select * from announcement where id<:annId AND is_show=1 ORDER by id desc limit 0,1",nativeQuery = true)
    Announcement getBack(@Param("annId") long annId);

    /**
     * 获取公告下一条
     * @param annId
     * @return
     */
    @Query(value = "select * from announcement where id>:annId AND is_show=1 limit 0,1",nativeQuery = true)
    Announcement getNext(@Param("annId") long annId);
}
