# java **Repository Path**: bin-project/java ## Basic Information - **Project Name**: java - **Description**: 博客项目1111111111111111111111111111111111111111111111111111 - **Primary Language**: Java - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-04-13 - **Last Updated**: 2023-01-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 博客 接口文档 #### 请求 api ```ini /api/public/*** 无需权限 /api/user/*** 需要登录之后才能访问 ``` #### 后端返回格式 ```ini #例如 RespJson.pack(200,"查询成功",blogs); {     code: 状态码, msg : '后台操作的结果描述', data: 数据 } ``` #### 默认管理员账号 ```ini 用户名 : admin 密码 : 123456 ``` #### 登录用户功能 ```ini 1. 个人中心 - 文章管理 #添加博客 #列出自己的博客 - 文章类别 #添加类别 - 评论管理 #查看文章的所有评论 #删除用户的评论 #在文章中发表评论 - 点赞管理 #可以点赞文章 #在后台能查询出我点赞过的文章 ``` #### 说明 ```ini 1.前端限制用户点赞的间隔,防止用户反复请求 ``` #### 未完善 ```q 1.评论用户删除自己的评论 ``` #### 实体类 ##### blog 博文 ```java @Document("t_blog") public class Blog { // 博文表 /** * content 内容可能比较大 * 单独建立一张表存放 博文内容 * t_blog 设计成 2 张表 */ @Id private String id; //博文id private String contentId; //内容id private String typeid; //类型 id private String title; //文章的标题 private String uid; //发布用户 private Date sendTime; //发布时间 private Integer pageView=0; //浏览量 /** * 作者 冗余字段 * 透明属性 */ @Transient private String author; ``` ##### 博文内容 BlogContent ```java @Document("t_content") public class BlogContent {//存放 博客 内容 @Id private String id; private String content; private String head; //博文标题 ``` ##### 博文类型 BlogType ```java @Document("t_blogtype") public class BlogType { @Id private String typeid; //类型id private String type; //类名名称 } ``` ##### 评论内容 Comment ```java @Document("t_comment") public class Comment { @Id private String id; // 主键 //博文 id private String blogId; //评论用户 private String uid; //评论内容 private String content; //评论时间 private Date sentTime; } ``` #### 用户 user ```java @Document("t_user") public class MyUser implements UserDetails { @Id private String id; //id private String username; //账号 private String password; //密码 private String nickname; //昵称 private Date createDate; //注册时间 } ``` #### 点赞 ```java @Document("t_licks") public class Mylikes { @Id private String id; //主键id private String uid; //点赞的用户 private String blogid; //点赞的文章 } ``` #### 组合类 ##### 评论 + 博文 BlogComment ```java //评论 - 用户 组合表 public class BlogComment { //用户 private MyUser users; // 评论的内容 private Comment comment; } ``` ##### 博文 + 内容 ```java //博文 + 内容 组合类 public class BlogInfo { private Blog blog; private BlogContent blogContent; } ``` ### 一 : 前台 /api/public/ ```ini #登录 Post : /api/public/login 参数 : 用户对象 user:{ username : "",password: ""} 返回 : 无 #跳转到首页 #注册用户 Post : /api/public/addUser 参数 : Json对象 user:{ username : "",password: ""} 返回 : RespJson.pack(200,"注册成功",null); #获取登录用户 -- 识别用户是否登录 Get : /api/public/getUser/ 参数 : 无 返回 : RespJson.pack(200,"用户状态",boolean值); #查询全部博文 + 博文内容 Get : /api/public/findAllBlog 参数 : 无 返回 : RespJson.pack(200,"查询全部成功",数组[ BlogInfo对象 ]) #查找所有类型 Get/Post : /api/public/findAllType 参数 : 无 返回 : RespJson.pack(200,"查询成功",数组[type]) #根据 类型id 找到 博文集合 Get/Post : /api/public/findByTypeid/{typeid} 路径参数 : 类型id 返回 : RespJson.pack(200,"查询成功",数组[ BlogInfo对象 ]) #根据 文章id 找到该文章的评论内容 + 用户 按照时间降序排序 Get : /api/public/findCommnetById/{blogid} 路径参数 : 博客id 返回 : RespJson.pack(200,"查询成功",数组 [ BlogComment对象 ]) #根据作者 查找博文 + 内容 Get/Pots : /api/public/findByAuthor/{uid} 路径参数 : 用户id 返回 : RespJson.pack(200,"查询成功",数组[ BlogInfo ]); #分页查找 博文 Get/Post : /api/public/findByPage/{start}/{num} 路径参数 : start 起始页,num 数量 返回 : RespJson.pack(200,"查询成功",{total:总行数,BlogInfo 数组对象}); ``` #### 二:登陆后才能操作 /api/user/** #### 1.博客管理 /api/user/**blog** ```ini # 查看全文 浏览量 加1 GET/POST : /api/user/blog/findByContentId/{conid} 路径参数 : 文章内容id 返回 : RespJson.pack(200,"查询成功",blog 对象); # 发布博文 Post : /api/user/blog/addContent/{typeid} 路径参数 : 类型id 参数 : blogContent Json 对象 返回 : RespJson.pack(200,"添加成功",null); /api/user/blog/ #点赞 文章的点赞数量加1 取消点赞 数量减 1 本质就是更新 字段的值 Get/Post : /api/user/blog/supportBlog/{blogid} 路径参数 : 博文id 返回 : RespJson.pack(200,"操作成功!",b) b : 布尔值 #判断用户是否点赞该文章 false 表示 未点赞, true 表示 已经点赞过了 Get/Post : /api/user/blog/isSupport/{blogid} 路劲参数 : 博文id 返回 : RespJson.pack(200,"操作成功!!",b) b 布尔值 #根据 id 找到这篇文章 Get : /api/user/blog/findById/{id} 路径参数 : 博文id 返回 : RespJson.pack(200,"查询成功",单个 blog 对象) #添加博文 + 博文内容 Post : /api/user/blog/addContent/{tagid} 路径参数 : 类型id 返回 : RespJson.pack(200,"添加成功","") #分页显示 登录用户的文章 Get/Post :/api/user/blog/findByPageMyBlog/{start}/{num} 路径参数 : start 起始页 , num 数量 返回 : RespJson.pack(200,"查询成功",{"total" : 总行数,blogs : 博文 + 博文内容数组对象}) #根据 uid 找到该用户所有文章 Get : /api/user/blog/findMyBlog 参数 : 无 后端根据登录用户拿uid 返回 : RespJson.pack(200,"查询成功",{blogs : 博文 + 博文内容单个对象}) #根据typeid 实现分页 Get : /api/user/blog/findBageByTypeid/{start}/{num}/{typeid} 路径参数 : start 起始页 , num 数量 typeid 类型id 返回 : RespJson.pack(200,"查询成功",{"total" : 总行数,blogs : 博文 + 博文内容数组对象}) ``` #### 2.类型 /api/user/type ```ini #添加博文类型 Post : /api/user/type/addType 参数 : 类型type Json对象 返回 : return RespJson.pack(200,"操作成功",b); b : 布尔值 #添加博文类型 Post : /api/user/type/findAll 参数 : 无 返回 : return RespJson.pack(200,"操作成功",tags 数组对象); ``` #### 3.评论 /api/user/comment ```ini #用户 发表评论 获取到 博客 id Post : /api/user/comment/addComment 参数 : comment 评论Json对象 返回 : return RespJson.pack(200,"操作成功",comment 对象); #查找我的文章的所有评论 Post : /api/user/comment/findCommentByUid 参数 : 无 后端根据登录用户获取uid 返回 : return RespJson.pack(200,"操作成功",List 对象); #根据 id 删除评论 Get : /api/user/comment/delCommentById/{id} 路径参数 : 评论id 返回 : return RespJson.pack(200,"删除成功", 新的 List 对象); ``` #### 4.用户 /api/user ```ini #注册一个用户 Get : /api/user/addUser 参数 : 用户 JSON对象 返回 :RespJson.pack(200,"注册成功",user); :RespJson.pack(500,"该用户已经存在,请重新注册","") ``` #### 5.点赞 /api/user/likes ```ini # 查看登录用户的 所有点赞文章 Get : /api/user/likes/findMyLikes 参数 : 无 后端根据登录用户获取uid 返回 : return RespJson.pack(200,"查询全部成功",myLikes 数组对象); ```