package com.lrm.dao;

import com.lrm.po.Blog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by limi on 2017/10/20.
 */
public interface BlogRepository extends JpaRepository<Blog, Long>, JpaSpecificationExecutor<Blog> {

    @Query("select b from Blog b where b.recommend = true")
    List<Blog> findTop(Pageable pageable);

    @Query("select b from Blog b where b.title like ?1 or b.content like ?1")
    Page<Blog> findByQuery(String query,Pageable pageable);


    @Transactional
    @Modifying
    @Query("update Blog b set b.views = b.views+1 where b.id = ?1")
    int updateViews(Long id);

    @Query("select function('date_format',b.updateTime,'%Y') as year from Blog b group by function('date_format',b.updateTime,'%Y') order by year desc ")
    List<String> findGroupYear();

    @Query("select b from Blog b where function('date_format',b.updateTime,'%Y') = ?1")
    List<Blog> findByYear(String year);
}
最近下载更多
微信网友_7513956916826112  LV3 2025年5月18日
xuweisong2010  LV28 2024年11月18日
陈小灏  LV18 2024年1月14日
xiongwei11231  LV9 2023年10月10日
lvhongquan  LV11 2023年9月20日
meyuso  LV9 2023年8月17日
tangyongheng08  LV6 2023年7月24日
monolog  LV4 2023年6月18日
mengmeng12323423  LV4 2023年6月18日
*  LV2 2023年6月14日
最近浏览更多
dane168  LV10 2025年8月29日
6418368  LV10 2025年8月16日
微信网友_7513956916826112  LV3 2025年5月18日
19297348520 2025年5月18日
暂无贡献等级
zdh3907  LV15 2025年4月30日
1140717565  LV2 2025年4月10日
xs13883100  LV1 2025年4月4日
nightstarshii 2025年1月26日
暂无贡献等级
ma406805131  LV19 2024年12月18日
tiancj  LV1 2024年11月25日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友