|
|
@@ -0,0 +1,45 @@
|
|
|
+package cn.seecoder.fdroidrepository.Mapper;
|
|
|
+
|
|
|
+import cn.seecoder.fdroidrepository.DataObject.ForumPost;
|
|
|
+import org.apache.ibatis.annotations.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+@Mapper
|
|
|
+public interface ForumPostMapper {
|
|
|
+
|
|
|
+ @Select("SELECT * FROM forum_posts")
|
|
|
+ @Results({
|
|
|
+ @Result(property = "postId", column = "post_id"),
|
|
|
+ @Result(property = "userId", column = "user_id"),
|
|
|
+ @Result(property = "title", column = "title"),
|
|
|
+ @Result(property = "content", column = "content"),
|
|
|
+ @Result(property = "createdAt", column = "created_at")
|
|
|
+ })
|
|
|
+ List<ForumPost> findAll();
|
|
|
+
|
|
|
+ @Select("SELECT * FROM forum_posts ORDER BY created_at DESC LIMIT #{offset}, #{limit}")
|
|
|
+ @Results({
|
|
|
+ @Result(property = "postId", column = "post_id"),
|
|
|
+ @Result(property = "userId", column = "user_id"),
|
|
|
+ @Result(property = "title", column = "title"),
|
|
|
+ @Result(property = "content", column = "content"),
|
|
|
+ @Result(property = "createdAt", column = "created_at")
|
|
|
+ })
|
|
|
+ List<ForumPost> findWithPagination(@Param("offset") int offset, @Param("limit") int limit);
|
|
|
+
|
|
|
+ @Select("SELECT * FROM forum_posts WHERE post_id = #{postId}")
|
|
|
+ @Results({
|
|
|
+ @Result(property = "postId", column = "post_id"),
|
|
|
+ @Result(property = "userId", column = "user_id"),
|
|
|
+ @Result(property = "title", column = "title"),
|
|
|
+ @Result(property = "content", column = "content"),
|
|
|
+ @Result(property = "createdAt", column = "created_at")
|
|
|
+ })
|
|
|
+ ForumPost findById(@Param("postId") Long postId);
|
|
|
+
|
|
|
+ @Insert("INSERT INTO forum_posts (user_id, title, content, created_at) " +
|
|
|
+ "VALUES (#{userId}, #{title}, #{content}, #{createdAt})")
|
|
|
+ void save(ForumPost post);
|
|
|
+}
|