packagecom.tensquare.article.dao;importorg.springframework.data.jpa.repository.JpaRepository;importorg.springframework.data.jpa.repository.JpaSpecificationExecutor;importcom.tensquare.article.pojo.Article;importorg.springframework.data.jpa.repository.Modifying;importorg.springframework.data.jpa.repository.Query;/**
* 数据访问接口
* @author Administrator
*
*/publicinterfaceArticleDaoextendsJpaRepository<Article,String>,JpaSpecificationExecutor<Article>{/*文章审核功能
* @Modifying 用于修改和删除的操作,一定要加上这个注解,然后在service层加上@Transition这个注解
*
* @parm id
* where id=?1 表示多个id取第一个
*
*
* */@Modifying@Query(value ="update tb_article set state=1 where id=?1",nativeQuery =true)publicvoidexamine(String id);/*
* 点赞功能
* */@Modifying@Query(value="update tb_article set thumbup=thumbup+1 where id=?1",nativeQuery=true)publicintupdateThumbup(String id);}
tensquare_qa模块:
packagecom.tensquare.qa.dao;importorg.springframework.data.domain.Page;importorg.springframework.data.domain.Pageable;importorg.springframework.data.jpa.repository.JpaRepository;importorg.springframework.data.jpa.repository.JpaSpecificationExecutor;importcom.tensquare.qa.pojo.Problem;importorg.springframework.data.jpa.repository.Query;importjava.util.List;/**
* 数据访问接口
* @author Administrator
*
*/publicinterfaceProblemDaoextendsJpaRepository<Problem,String>,JpaSpecificationExecutor<Problem>{@Query(value="SELECT *from tb_problem,tb_pl where id=problemid and labelid=? ORDER BY replytime DESC",nativeQuery=true)publicPage<Problem>newList(String labelid,Pageable pageable);//不加nativeQuery=true JQL 语句面向实体类的 加上变为Sql语句 面向关系数据库的@Query(value="SELECT *from tb_problem,tb_pl where id=problemid and labelid=? ORDER BY reply DESC",nativeQuery=true)publicPage<Problem>hotList(String labelid,Pageable pageable);@Query(value="select *from tb_pl,tb_problem where id=problemid and labelid=? AND reply=0 order by createtime DESC",nativeQuery=true)publicPage<Problem>waitList(String labelid,Pageable pageable);}