重构Article模块 新增Message模块 优化安全配置
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
package com.qf.myafterprojecy.repository;
|
||||
|
||||
import com.qf.myafterprojecy.pojo.Article;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ArticleRepository extends CrudRepository<Article,Integer> {
|
||||
//public interface ArticleRepository extends CrudRepository<Article,Integer> {
|
||||
//}
|
||||
public interface ArticleRepository extends JpaRepository<Article, Integer> {
|
||||
|
||||
@Query("SELECT a FROM Article a WHERE a.status = 1 AND a.articleid = :articleid")
|
||||
List<Article> findPublishedByAuthor(@Param("authorId") Integer authorId);
|
||||
|
||||
@Query("SELECT a FROM Article a WHERE a.status = 1 AND a.typeid = :typeid")
|
||||
List<Article> findPublishedByCategory(@Param("categoryId") Integer categoryId);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE Article a SET a.viewCount = a.viewCount + 1 WHERE a.id = :id")
|
||||
void incrementViewCount(@Param("id") Integer id);
|
||||
|
||||
@Query("SELECT a FROM Article a WHERE a.status = 1 ORDER BY a.viewCount DESC")
|
||||
List<Article> findMostViewed();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.qf.myafterprojecy.repository;
|
||||
|
||||
import com.qf.myafterprojecy.pojo.Message;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface MessageRepository extends CrudRepository<Message, Integer> {
|
||||
// 可根据需要添加自定义查询方法
|
||||
}
|
||||
Reference in New Issue
Block a user