Jadyli / YoQuCommunityServer

Yo趣社区小程序项目后端

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

后端API开发接口文档

1. 用户接口

1.1 登陆接口

1.1.1 功能描述

使用Token进行登陆

1.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/user/login

1.1.3 请求头
字段 字段类型 字段说明
Authorization String 验证的token,每个接口必须携带
1.1.4 请求示例

https://localhost:443/community/user/login

1.1.5 返回结果

登陆成功

{
   "code": 200,
   "msg": "请求成功",
    "data": {
        "id": 1,
        "uid": 181203221,
        "realName": "崔志文",
        "sex": true,
        "state": false,
        "registerTime": "Jul 22, 2019 7:33:15 AM",
        "permission": true,
        "unionId": "xxxxxxxxxxxx",
        "openId": "xxxxxxxxxxxxx"
    }
}
1.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 用户信息
1.1.7 用户信息参数
字段 字段类型 说明
id int ID。
uid int 学号。
realName String 真实姓名。
sex Boolean 用户性别。false:女;true:男。
state Boolean 用户状态。false:正常;true:禁言状态。
registerTime String 注册时间。
permission Boolean 用户权限。false:普通用户;true:管理员。
unionId String 微信UnionID。

1.2 绑定微信用户

1.2.1 功能描述

使用Token绑定用户保存数据到邮院社区数据库中

1.2.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/user/binding

1.2.3 请求头
字段 字段类型 字段说明
Authorization String 验证的token,每个接口必须携带
1.2.4 请求参数
字段 字段类型 说明
uid int 学号。
realName String 真实姓名。
sex Boolean 用户性别。false:女;true:男。
state Boolean 用户状态。false:正常;true:禁言状态。
registerTime String 注册时间。
permission Boolean 用户权限。false:普通用户;true:管理员。
unionId String 微信UnionID。
openId String 微信OpenID。
nickName String 用户微信名
1.2.5 请求示例

https://localhost:443/community/user/binding

POST格式

{
    "uid": 181203221,
    "realName": "崔志文",
    "sex": true,
    "state": false,
    "permission": true,
    "unionId": "xxxxxxxxx",
    "openId": "xxxxxxxxxxxx",
    "nickName":"xxx"
}
1.2.6 返回结果

绑定成功

{
    "code": 200,
    "msg": "绑定成功",
    "data": {
        "id": 1,
        "uid": 181203221,
        "realName": "崔志文",
        "sex": true,
        "state": false,
        "registerTime": "Jul 22, 2019 7:33:15 AM",
        "permission": true,
        "unionId": "xxxxxxxxxxxx",
        "openId": "xxxxxxxxxxxxx"
    }
}
1.2.7 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 用户信息
1.2.8 用户信息参数
字段 字段类型 说明
id int ID。
uid int 学号。
realName String 真实姓名。
sex Boolean 用户性别。false:女;true:男。
state Boolean 用户状态。false:正常;true:禁言状态。
registerTime String 注册时间。
permission Boolean 用户权限。false:普通用户;true:管理员。
unionId String 微信UnionID。
openId String 微信OpenID。

1.3 更新微信用户头像和昵称

1.3.1 功能描述

更新微信用户头像和昵称

1.3.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/user/updateWxInfo

1.3.3 请求头
字段 字段类型 字段说明
Authorization String 验证的token,每个接口必须携带
1.3.4 请求参数
字段 字段类型 说明
avatarUrl String 微信头像URL。
nickName String 用户微信名
1.3.5 请求示例

https://localhost:443/community/user/updateWxInfo

POST格式

{
	"nickName" : "Cui",
	"avatarUrl" : "http://xxx.com/头像.png"
}
1.3.6 返回结果

绑定成功

{
    "code": 200,
    "msg": "请求成功"
}
1.3.7 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息

2. 通用帖子接口

2.1 获取帖子列表

2.1.1 功能描述

获取表白墙或树洞列表

2.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/common/getArticles

2.1.3 请求参数
字段 字段类型 说明
postType Integer 帖子类型。0:表白墙;1:树洞
pageNum Integer 页数。
pageSize Integer 每页条目数。
2.1.4 请求示例

获取所有通用帖子:https://localhost:443/community/common/getArticles?postType=0&pageNum=1&pageSize=2

获取个人所有通用帖子:https://localhost:443/community/user/getMyArticles?postType=0&pageNum=1&pageSize=6

2.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 1,
        "pages": 40,
        "total": 40,
        "list": [
            {
                "id": 60,
                "uid": 181203108,
                "title": "",
                "postType": 0,
                "postTime": "2019-10-12 17:04:56",
                "postContent": "",
                "isAnonymous": false,
                "student": {
                    "sex": true,
                    "nickName": "Coisini",
                    "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/FtUUcS29WTlUohHSMyY1uqVczaA5OgbsAMMaR3Qsp7GxLnJRwQAoe75kKk89Siaeiaa7yYXzzeXspNpmYepGz36g/132"
                },
                "img": [
                    {
                        "imgUrl": "tmp_549e5a9c506aae742b28444ea00e19cf.jpg"
                    }
                ],
                "likes": {
                    "loveNum": 2,
                    "viewNum": 5
                },
                "commentNum": 7
            }
        ]
    }
}
2.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 分页数据信息
nickName String 微信名称
avatarUrl String 头像
top boolean 置顶帖子标记,true为置顶,false或没有top则为非置顶
2.1.7 页面信息参数
字段 字段类型 字段说明
pageNum Integer 当前页数。
pageSize Integer 每页数据条数。
pages Integer 总页数。
total Integer 总数据条数。
list Integer 数据列表。
2.1.8 列表参数
字段 字段类型 说明
id int ID。
uid int 学号。
title String 标题。
postType Integer 发布类型。
postTime Date 发布时间。
postContent String 文章内容。
isAnonymous Boolean 是否匿名。false:否;true:是。

2.2 发送通用帖子

2.2.1 功能描述

发表树洞和表白墙的帖子。

2.2.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/common/postArticle

2.2.3 请求参数
字段 字段类型 说明
uid Integer 学号。
title String 标题。
postType Integer 举报的类型。0:表白墙;1:树洞;
postContent String 内容。
isAnonymous Integer 是否匿名。0:实名;1:匿名。
img List 有图片则传,无图片不传或者传 "imgUrl":""
top Boolean 是否置顶,0|1
2.2.4 请求示例

https://localhost:443/community/common/postArticle

有图片

{
	"uid": 181203126,
	"postType": 0,
	"postContent": "照片太帅",
	"isAnonymous": 0,
    "top":1,
    "img": [{
	"imgUrl":"你好"
}]
}

无图片形式一

{
	"uid": 181203126,
	"postType": 0,
	"postContent": "照片太帅",
	"isAnonymous": 0,
    "img": [{
	"imgUrl":"你好"
}]
}

无图片形式二

{
	"uid": 181203126,
	"postType": 0,
	"postContent": "照片太帅",
	"isAnonymous": 0
}
2.2.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": 127
}
2.2.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data int 文章id

2.3 删除通用帖子

2.3.1 功能描述

删除通用帖子

2.3.2 请求方式

请求方式:GET

请求URL :https://localhost:443/community/common/deleteArticle

2.3.3 请求参数
字段 字段类型 说明
uid Integet 发帖人学号
articleType Integer 帖子类型。0:表白墙;1:树洞;
id Integer 帖子ID
img String数组 七牛图片路径
2.3.4 请求示例

http://localhost:8081/community/common/deleteArticle?articleType=0&id=130&uid=181203126&img=tmp_0706b258533cf6a9e0debba783d32d3b.jpg

2.3.5 返回结果
{
    "code": 200,
    "msg": "请求成功"
}

2.4 设置帖子为置顶

2.4.1 功能描述

设置帖子为置顶

2.4.2 请求方式

请求方式:POST

请求URL:http://localhost:8081/community/common/setTop

2.4.3 请求数据示例
{
	"id":150,
	"top":0,
	"postType":1
}
2.4.4 参数说明
字段 字段类型 说明
id Integer 文章的id
top Boolan 置顶状态。0|1
postType Integer 文章类型
2.4.5 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
{
    "code": 1,
    "msg": "请求失败"
}

3. 失物找回接口

3.1 获取失物找回列表

3.1.1 功能描述

获取失物找回的帖子列表

3.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/found/getFounds

3.1.3 请求参数
字段 字段类型 说明
pageNum Integer 页数。
pageSize Integer 每页条目数。
id Integer 要查询的文章id,不传为查询所有,传入一个查询这个id所有的失物信息
articleState Boolean 失物的状态,不传为查询所有,传入一个查询状态下所有的失物信息(值为 0 | 1)

注明:articleState 两者都传就是查询该学生该状态下的失物信息

3.1.4 请求示例

情况一 查询所有失物信息:https://localhost:443/community/found/getFounds?pageNum=1&pageSize=20

情况二 查询某个同学的所有失物信息:https://localhost:443/community/user/getMyFounds?pageNum=1&pageSize=20

情况三 查询某个同学下的某个状态的失物信息 https://localhost:443/community/user/getMyFounds?pageNum=1&pageSize=100&articleState=1

情况四 查询某个文章的所有信息 https://localhost:443/community/found/getFounds?pageNum=1&pageSize=20&id=23

3.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 20,
        "pages": 1,
        "total": 1,
        "list": [
            {
                "id": 2,
                "uid": 181414241,
                "title": "",
                "postTime": "2019-10-10 11:47:46",
                "contactNumber": "",
                "lostTime": "",
                "lostName": "",
                "lostClass": "",
                "lostDescribe": "",
                "address": "",
                "articleState": false,
                "student": {
                    "nickName": "二维世界是个圆",
                    "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/biawTeJ9aaUq5u95NliaAlPjkxB9NAneBsw5G8kn1heyFXiaHtUY4tEmsoU2bMBAIN6aeaY2f84cZ5GfqNu93BF1g/132"
                },
                "img": [
                    {
                        "imgUrl": "tmp_3acd0bfb5c61b43aebfd4a2f219328cb59175d07ff59fae6.jpg"
                    }
                ],
                "likes": {
                    "viewNum": 1
                }
            }
        ]
    }
}
3.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 分页数据信息
nickName String 微信名
avatarUrl String 微信头像
3.1.7 页面信息参数
字段 字段类型 字段说明
pageNum Integer 当前页数。
pageSize Integer 每页数据条数。
pages Integer 总页数。
total Integer 总数据条数。
list Integer 数据列表。
3.1.8 列表参数
字段 字段类型 说明
id int ID。
uid int 学号。
title String 标题。
postTime Date 发布时间。
contactNumber Integer 手机号码。
lostTime String 丢失时间描述。
lostClass String 丢失人班级。
address String 丢失地址。
articleState Boolean 找回状态。false:未找回;true:已找回。
lostDescribe String 失物描述。

foundComments参数

字段 字段类型 说明
createTime DATETIME 评论发表时间
content String 评论的内容

foundImg 参数

字段 字段类型 说明
imgUrl String 七牛上的图片id

3.2 发送失物信息接口

3.2.1 功能描述

发表失物的信息

3.2.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/found/postFound

3.2.3 请求示例

请求数据示例

有图片

{
 "uid": 181203126,
 "title": "我的手机丢了",
 "contactNumber": "13672490475",
 "lostTime": "凌晨",
 "lostName": "叶友贵",
 "lostClass": "移动互联186",
 "lostDescribe": "一台小苹果,小姐姐捡到不用还了",
 "address": "广东省广州市",
 "top":1,
 "img":[{
    "imgUrl":"你好失物"
 }]
}

无图片

{
 "uid": 181203126,
 "title": "我的手机丢了",
 "contactNumber": "13672490475",
 "lostTime": "凌晨",
 "lostName": "叶友贵",
 "lostClass": "移动互联186",
 "lostDescribe": "一台小苹果,小姐姐捡到不用还了",
 "address": "广东省广州市",
 "img":[{
    "imgUrl":""
 }]
}

无图片

{
 "uid": 181203126,
 "title": "我的手机丢了",
 "contactNumber": "13672490475",
 "lostTime": "凌晨",
 "lostName": "叶友贵",
 "lostClass": "移动互联186",
 "lostDescribe": "一台小苹果,小姐姐捡到不用还了",
 "address": "广东省广州市"
}

请求数据字段说明

参数 是否必须 参数类型 说明
uid int 学号
title String 标题
contactNumber String 联系电话
lostTime String 丢失时间描述
lostName String 失主姓名
lostClass String 班级
lostDescribe String 丢失物品描述
address String 丢失地址
top 可选 Boolean 是否置顶
img List 有图片则传,没有则不传或者传空字符传
3.2.4 返回结果
{
    "code": 200,
    "msg": "请求",
    "data": 2
}
3.2.5 返回结果参数说明
字段 类型 说明
data int 发表失物信息成功后的该文章id

3.3 更新失物状态接口

3.3.1 功能描述

在找回失物后需要更新失物状态,或者更改置顶状态

3.3.2 请求方式

请求方式:POST

请求格式:application/json

请求地址:https://localhost:443/community/found/updateFoundStatus

3.3.3 请求示例

更新失物状态请求数据示例

{
	"id":"1",
	"articleState":"true"
}

更新失物置顶状态

{
	"id":"79",
	"top":1
}

请求参数说明

字段 是否必须 类型 说明
id int 当前文章id
articleState Boolean 失物状态(true 或 false)
top 可选 Boolean 帖子置顶状态 0 |1
3.3.4 返回结果

更新成功

{
    "code": 200,
    "msg": "请求成功"
}

更新失败

{
    "code": 60002,
    "msg": "更新失败"
}

3.4 删除失物信息接口

3.4.1 功能描述

删除失物信息包括评论信息和数据库图片信息

3.4.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/found/deleteFoundInfo

3.4.3 请求示例

请求参数

参数 类型 说明
uid Integer 发帖人学号
id Integer 当前帖子的id
img String数组 七牛图片路径

请求URL:http://localhost:8081/community/found/deleteFoundInfo?id=43&uid=181203126&img=tmp_fd511d321245537a3764b575480e4aa5c202a5a49a0641ac.jpg

3.4.4 返回结果

删除成功

{
    "code": 200,
    "msg": "请求成功"
}

删除失败

{
    "code": 60004,
    "msg": "删除失败"
}

4. 举报接口

4.1 获取举报列表

4.1.1 功能描述

用于管理员查看举报帖子的数据

4.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/report/getReports

4.1.3 请求参数
字段 字段类型 说明
pageNum Integer 页数。
pageSize Integer 每页条目数。
4.1.4 请求示例

https://localhost:443/community/report/getReports?pageNum=1&pageSize=2

4.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 1,
        "pages": 23,
        "total": 23,
        "list": [
            {
                "uid": 181203126,
                "articleId": 266,
                "articleType": 0,
                "reportType": "垃圾广告 ",
                "reportTime": "2019-10-18 16:42:52",
                "content": "举报",
                "common": {
                    "postTime": "2019-10-18 14:23:48",
                    "postContent": "折磨胜出苦难,苦难又会加剧折磨,凡间着无穷的循环,将由我来终结!",
                    "isAnonymous": false
                },
                "student": {
                    "nickName": "小丑乐众人",
                    "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/bPicibNR0DCRqaAAcgSVZESJicxKa9IIvicMRaxUKSPpTACXB6wKZDKWOgdrBtD9u1Of92u5dIiavkUJk0shwb4BPtQ/132"
                },
                "img": [
                    {
                        "imgUrl": "tmp/wx5627f208d54a9948.o6zAJsy7iIXBKj_tIr4A9xTGZcNc.rxQ0dEblOuvX27eebf1d8906b01220cb24772d483030.jpg"
                    }
                ]
            }
        ]
    }
}
4.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 分页数据信息
4.1.7 页面信息参数
字段 字段类型 字段说明
pageNum Integer 当前页数。
pageSize Integer 每页数据条数。
pages Integer 总页数。
total Integer 总数据条数。
list Integer 数据列表。
4.1.8 列表参数
字段 字段类型 字段说明
uid Integer 学号。
reportType String 举报类型。
reportTime Date 举报发布时间。
state Boolean 处理状态。
articleType Integer 帖子类型。0:表白墙;1:树洞;2:丢失找回;
articleId Integer 帖子ID。
content String 举报说明。
postTime DateTime 被举报帖子发送时间
postContent String 被举报的内容
isAnonymous boolean 是否匿名
nickName String 被举报的人的名称
avatarUrl String 被举报人的名称
imgUrl String 被举报的图片URL

4.2 发送举报

4.2.1 功能描述

发送举报帖子

4.2.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/report/postReport

4.2.3 请求参数
字段 字段类型 说明
uid Integer 学号。
content String 内容。
reportType Integer 举报的类型;0:表白墙;1:树洞;2:失物。
articleType String 举报的帖子类型。
articleId Integer 帖子id。
4.2.4 请求示例

https://localhost:443/community/report/postReport

{
	"uid": 181203221,
	"content": "照片太帅",
	"reportType": "其他",
	"articleType": 0,
	"articleId": 1
}
4.2.5 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
4.2.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息

4.3 删除举报

4.3.1 功能描述

删除举报

4.3.2 请求方式

请求方式 GET

请求URL http://localhost:8081/report/deleteReport?id=38

4.3.3 请求参数
参数 类型 说明
id lnteger 举报的ID
4.3.4 返回结果
{
    "code": 60003,
    "msg": "删除成功"
}
{
    "code": 60004,
    "msg": "删除失败"
}

5. 反馈接口

5.1 获取反馈列表

5.1.1 功能描述

对于本程序的反馈建议。

5.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/recommend/getRecommends

5.1.3 请求参数
字段 字段类型 说明
pageNum Integer 页数。
pageSize Integer 每页条目数。
5.1.4 请求示例

https://localhost:443/community/recommend/getRecommends?pageNum=1&pageSize=2

5.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 2,
        "pages": 4,
        "total": 7,
        "list": [
            {
                "id": 8,
                "uid": 181203221,
                "time": "Jul 29, 2019 11:55:21 PM",
                "content": "我有话要说,其实也没什么话,就随便投诉下."
            },
            {
                "id": 7,
                "uid": 181203221,
                "time": "Jul 29, 2019 11:51:48 PM",
                "content": "我有话要说,其实也没什么话,就随便投诉下."
            }
        ]
    }
}
5.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 分页数据信息
5.1.7 页面信息参数
字段 字段类型 字段说明
pageNum Integer 当前页数。
pageSize Integer 每页数据条数。
pages Integer 总页数。
total Integer 总数据条数。
list Integer 数据列表。
5.1.8 列表参数
字段 字段类型 字段说明
id Integer ID。
uid Integer 学号
time Date 时间。
content String 内容。

5.2 发送反馈建议

5.2.1 功能描述

发送反馈帖子

5.2.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/recommend/postRecommend

5.2.3 请求参数
字段 字段类型 说明
uid Integer 学号。
content String 内容。
5.2.4 请求示例

https://localhost:443/community/recommend/postRecommend

{
	"uid": 181203221,
	"content": "建议添加私信"
}
5.2.5 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
5.2.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息

5.3 删除反馈建议

5.3.1 功能描述

删除反馈建议

5.3.2 请求方式

请求方式 GET

请求URL http://lcoalhost:8081/recommend/deleteRecommend?id=29

5.3.3 请求参数
参数 类型 说明
id integer 反馈建议的唯一ID
5.3.4 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
{
    "code": 60004,
    "msg": "删除失败"
}

6. 私信接口

6.1 获取私信列表

6.1.1 功能描述

私信聊天接口。

6.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/msg/getMsg

6.1.3 请求参数
字段 字段类型 说明
posterId Integer 通过发送人ID。可不选,不选为只通过下面的接收人ID查。两个必选一个,同时选则获取的双人聊天信息。
receiverId Integer 通过接收人ID。可不选,不选为只通过上面的发送人ID查。两个必选一个,同时选则获取的双人聊天信息。
pageNum Integer 页数。
pageSize Integer 每页条目数。
6.1.4 请求示例

情况一:https://localhost:443/community/msg/getMsg?posterId=181203221&pageNum=1&pageSize=2

情况二:https://localhost:443/community/msg/getMsg?receiverId=181203221&pageNum=1&pageSize=2

情况三:https://localhost:443/community/msg/getMsg?posterId=181203221&receiverId=181414241&pageNum=1&pageSize=2

6.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 2,
        "pages": 1,
        "total": 1,
        "list": [
            {
                "id": 1,
                "posterId": 181203221,
                "receiverId": 181414241,
                "time": "Jul 30, 2019 9:11:19 PM",
                "content": "悄悄告诉你一件事,有人跟你表白"
            }
        ]
    }
}
6.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 分页数据信息
6.1.7 页面信息参数
字段 字段类型 字段说明
pageNum Integer 当前页数。
pageSize Integer 每页数据条数。
pages Integer 总页数。
total Integer 总数据条数。
list Integer 数据列表。
6.1.8 列表参数
字段 字段类型 字段说明
id Integer ID。
posterId Integer 发送人ID。
receiverId Integer 接收人ID。
time Date 消息产生时间。
content String 消息内容。

7.图片接口

7.1 发送图片ID

7.1.1 功能描述

向数据库获取存储的七牛图片id

7.1.2 请求方式

请求方式:POST

请求格式:application/json

请求URL:https://localhost:443/community/img/postImg

7.1.3 请求示例

请求数据

{
	"imgUrl":"测试图片",
	"articleType":"2",
	"articleId":"9990"
}

参数说明

字段 类型 说明
imgUrl String 七牛的图片ID
articleType byte 对应的文章类型
articleId int 对应的文章id
7.1.4 返回结果
{
    "code": 200,
    "msg": "请求成功"
}

7.2 查询图片ID

7.2.1 功能描述

从数据库获取七牛的图片ID

7.2.2 请求方式

请求方式:GET

请求URLhttps://localhost:443/community/img/getImgs

7.2.3 表单参数
字段 类型 说明
articleId int 文章ID
articleType byte 文章类型
pageNum int 当前页数
pageSize int 当前页数据量
7.2.4 请求示例

请求URL https://localhost:443/community/img/getImgs?articleId=2&pageNum=1&pageSize=20&articleType=2

7.2.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 1,
        "pages": 5,
        "total": 5,
        "list": [
            {
                "id": 162,
                "imgUrl": "失物找回图片id4",
                "articleType": 2,
                "articleId": 2
            }
        ]
    }
}

8 评论接口

8.1 获取评论列表

8.1.1 功能描述

获取表白墙或树洞评论列表

8.1.2 请求方式

请求方式:GET

请求URL:https://localhost:443/community/comment/getComments

8.1.3 请求参数
字段 字段类型 说明
articleId Integer 帖子类型。0:表白墙;1:树洞
pageNum Integer 页数。
pageSize Integer 每页条目数。
8.1.4 请求示例

https://localhost:443/community/comment/getComments?articleId=10&pageNum=1&pageSize=2

8.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 2,
        "pages": 4,
        "total": 8,
        "list": [
            {
                "id": 17,
                "type": 0,
                "articleId": 68,
                "replyUid": 181203126,
                "replyNickname": "Role",
                "createTime": "2019-11-08 10:08:32",
                "content": "有趣",
                "student": {
                    "uid": 181203221,
                    "nickName": "Cui",
                    "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/lDYAhoAFvcFaP9PrrV2WOP1CZIUXFibxbtsJIoTv9VNiaPKNTXGQMjmMpsQjhMpwtDYcv0eLrH6VSgzpNfWNfliaA/132"
                }
            },
            {
                "id": 20,
                "type": 0,
                "articleId": 68,
                "createTime": "2019-11-08 10:08:32",
                "content": "可来啦来啦咳咳咳老久了就",
                "student": {
                    "uid": 181203221,
                    "nickName": "Cui",
                    "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/lDYAhoAFvcFaP9PrrV2WOP1CZIUXFibxbtsJIoTv9VNiaPKNTXGQMjmMpsQjhMpwtDYcv0eLrH6VSgzpNfWNfliaA/132"
                }
            }
        ]
    }
}
8.1.6 返回参数
返回字段 字段类型 说明
code int 返回结果状态。0:失败;1:成功。
msg String 返回信息
data Json 分页数据信息
nickName String 微信名
avatarUrl String 头像
8.1.8 列表参数
字段 字段类型 说明
id int ID。
uid int 学号。
type int 评论类型。0:表白墙;1:树洞;2:丢失找回。
articleId Integer 帖子ID。
createTime Date 发布时间。
content String 评论内容。
replyUid interger 回复人的UId
replyName String 回复人的名称

8.2 发表评论

8.2.1 功能描述

发表评论

8.2.2 请求方式

请求方式:POST

请求格式:application/json

请求URLhttps://localhost:443/community/comment/postComment

8.2.3 返回结果
{
    "code": 0,
    "msg": "请求成功"
}
8.2.4 请求数据字段说明
参数 是否必须 参数类型 说明
uid int 学号
type int 帖子类型
articleId int 帖子ID
content String 评论内容

8.3 删除评论

8.3.1 功能描述

删除评论

8.3.2 请求方式

请求方式:GET

请求URL https://localhost:443/community/comment/deleteComment

8.3.3 请求参数
字段 字段类型 说明
id Integer 评论ID
commentUid Integer 评论的学号
8.3.4 请求示例

https://localhost:443/community/comment/deleteComment?id=15&commentUid=181203126

8.3.5 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
{
    "code": 60004,
    "msg": "删除失败"
}

8.4 回复评论

8.4.1 功能描述

回复评论

8.4.2 请求方式

请求方式 POST

请求地址:http://localhost:8081/community/comment/postComment

请求数据:

{
 "replyUid":"181203221",
 "type":"0",
 "articleId":"68",
 "content":"你开心就行"
}
8.4.3 参数说明
参数 类型 说明
replyUid Integer 要回复的人学号
type byte 评论的文章类型
articleId Integer 评论的文章ID
content String 回复的类型
8.4.4 返回结果
{
    "code": 200,
    "msg": "请求成功"
}

9 七牛接口

9.1 获取七牛UpToken

9.1.1 功能描述

获取七牛所需的UpToken

9.1.2 请求方式

请求方式:GET

请求URL: https://localhost/community/qiniu/getUpToken

9.1.3 请求参数
字段 字段类型 说明
accessKey String accessKey
secretKey String secretKey
bucket String bucket
9.1.4 请求示例

https://localhost/community/qiniu/getUpToken?accessKey=xWM4X5DGsVZVkiyApaDdWVvHikkwJhWAz-wytfP3&secretKey=hiurTa7ixf3S1lbyvy4AZw2pucnuv2Pn48pfG4b9&bucket=guptcommunity

9.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "upToken": "xWM4X5DGsVZVkiyApaDdWVvHikkwJhWAz-wytfP3:Jrtp_VXqYf6CUV5ITWLkuKUE1OA=:eyJzY29wZSI6Imd1cHRjb21tdW5pdHkiLCJkZWFkbGluZSI6MTU2NjgxMzQzOH0="
    }
}

10 点赞浏览量接口

10.1 点赞和浏览

10.1.1 功能描述

点赞或浏览

10.1.2 请求方式

请求方式:POST

请求URL:http://localhost:8081/community/likes/postLikeOrView

10.1.3 请求数据

格式: application/josn

点赞 数据示例

{
	"articleId":"4",
	"articleType":"0",
	"loveNum":1
}

浏览 数据示例

{
	"articleId": "1",
	"articleType":"2",
	"viewNum":1
}

温馨提示:两者不可同时传入,否则会报系统异常,原因是调用方法产生二义性

10.1.4 参数说明
字段 字段类型 说明
uid int 学号
articleId String 文章id
articleType Byte 文章类型
loveNum int 点赞量字段
viewNum int 浏览量字段
10.1.5 返回结果
{
    "code": 200,
    "msg": "请求成功"
}

10.2 取消点赞接口

10.2.1 请求方式

请求方式:GET

请求示例:http://localhost:8081/community/likes/deleteLikes?articleId=1&articleType=0

10.2.2 请求参数
字段 字段类型 说明
articleId int 点赞文章id
artilceType Byte 文章类型
10.2.3 返回结果

成功

{
 "code": 200,
 "msg": "请求成功"
}

失败

{
    "code": 40004,
    "msg": "记录不存在",
    "data": false
}

此错是已经取消过点赞了,数据库已经不存在这条记录

10.3查询是否点过赞或者浏览过

10.3.1 请求方式

请求方式 GET

获取是否点过赞

请求地址:http://localhost:8081/community/likes/isLikesOrView?articleId=2&articleType=0

获取是否浏览过

请求地址:http://localhost:8081/community/likes/isLikesOrView?articleId=2&articleType=0&info=view

10.3.2 参数说明
字段 字段类型 说明
loveNum int 点赞数量
viewNum int 浏览数量
info String 浏览量专属标识
10.3.3 返回结果

已点过赞或已浏览过

{
 "code": 200,
 "msg": "请求成功",
 "data": true
}

未点过赞或未浏览过

{
    "code": 40004,
    "msg": "记录不存在",
    "data": false
}

11 置顶帖子

11.1 功能描述

获取三大模块的置顶帖子

11.2 发送置顶帖子

表白墙(0)、树洞(1)

请求URL :http://localhost:8081/community/common/postArticle

请求方式:POST

请求数据

{
	"uid": 181203126,
	"postType": 0,
	"postContent": "测试",
	"isAnonymous": 0,
	"top":1
}

失物找回

请求URL:http://localhost:8081/community/found/postFound

请求方式:POST

请求数据

{
    "uid": 181203126,
    "title": "我的手机丢了",
    "contactNumber": "13672490475",
    "lostTime": "凌晨",
    "lostName": "叶友贵",
    "lostClass": "移动互联186",
    "lostDescribe": "一台小苹果,小姐姐捡到不用还了",
    "address": "广东省广州市",
    "top":1
}

11.3 更新置顶状态

表白墙(0)、树洞(1)

请求URL:http://localhost:8081/community/common/setTop

请求方式:POST

请求数据

{
	"id":1,
	"top":0,
	"postType":1
}
参数 类型 说明
id integer 文章id
top Boolean 0为未置顶,1为置顶
postType integer 0为表白墙,1为失物

失物找回

请求URL:http://localhost:8081/community/found/updateFoundStatus

请求方式:POST

请求数据

{
	"id":"93",
	"top":0
}

11.4 获取置顶帖子

表白墙(0)、树洞(1)

请求URL: http://localhost:8081/community/common/getArticles?postType=0&pageNum=1&pageSize=1&isTop=true

请求方式:GET

失物找回

请求URL:http://localhost:8081/community/found/getFounds?pageNum=1&pageSize=1&isTop=true

请求方式:GET

12 异常返回信息

12.1 绑定返回异常

异常信息:

{
    "code": 20003,
    "msg": "重复绑定"
}

异常说明:

数据库已有记录,并记录是唯一索引

异常触发条件:

重复向用户绑定接口提交相同的数据

触发接口:

http://localhost:8081/community/user/binding

12.2 查询数据不存在异常

异常信息:

{
    "code": 40004,
    "msg": "记录不存在"
}

异常说明:

向数据库查询无果

异常触发条件:

向指定接口查询数据库不存在的记录

触发接口:

http://localhost:8081/community/found/getFoundInfo?articleId=100

http://localhost:8081/community/common/getArticleInfo?articleType=0&articleId=100

http://localhost:8081/community/likes/getLikesOrViews?articleId=1&articleType=1

http://localhost:8081/community/likes/deleteLikes?articleId=32&articleType=0

http://localhost:8081/community/likes/getLikesOrViews?articleId=1&articleType=1

请求参数异常

异常信息:

{
    "code": 40003,
    "msg": "参数异常"
}

异常说明:

丢失所必须的请求参数

异常触发条件:

不传入必要的字段

异常触发接口:

所有接口

13 搜索

13.1 搜索通用帖子

13.1.1 功能描述

搜索通用帖子

13.1.2 请求方式

GET http://localhost:8081/community/common/getArticles?postType=0&pageNum=1&pageSize=10&isSearch=0&searchContent=%E6%88%91

13.1.3 参数说明
字段 类型 说明
isSearch Boolean 是否是搜索接口 0
searchContent URL编码 搜索内容 进行URL编码后的值
postType integer 帖子类型 0|1

13.2 搜索失物帖子

13.2.1 功能描述

搜索失物帖子

13.1.2 请求方式

GET http://localhost:8081/community/found/getFounds?pageNum=1&pageSize=20&isSearch=0&searchContent=%E6%89%8B%E6%9C%BA

13.1.3 参数说明
字段 类型 说明
isSearch Boolean 是否是搜索接口 0
searchContent URL编码 搜索内容 进行URL编码后的值

14 通知

14.1 发送通知

14.1.1 功能描述

管理员发送通知

14.1.2 请求方式

请求方式 POST

请求地址:http://localhost:8081/notification/postNotification

请求数据示例:

{
	"title":"用户规范",
	"topic": "你想想就好",
	"type":1,
	"lastVersion":1
}
14.1.3 参数说明
字段 属性 说明
title String 通知标题
topic String 通知内容
type Byte 通知类型
lastVersion integer 程序版本
14.1.4 返回结果
{
    "code": 200,
    "msg": "请求成功",
    "data": 5
}
{
    "code": 40002,
    "msg": "发送失败"
}

14.2 获取通知

14.2.1 功能描述

获取通知

14.2.2 请求方式

请求方式 GET

请求URL http://localhost:8081/notification/getNotification?pageNum=1&pageSize=10&type=1&version=1.0.0

请求参数:

参数 类型 结果
pageNum integer 页码
pageSize Integer 页面数量
type Byte 通知类型
lastVersion integer 版本
14.2.3 返回结果
{
    "code": 0,
    "msg": "请求成功",
    "data": {
        "pageNum": 1,
        "pageSize": 10,
        "pages": 1,
        "total": 1,
        "list": [
            {
                "id": 1,
                "title": "邮院社区规范",
                "topic": "请遵守邮电社区用户协议,不得在社区传播政治、谣言,不得传播黄色信息、不得在社区言语过激、为营造良好的社区坏境做出一份贡献",
                "type": 1,
                "createTime": "2019-10-20 15:26:21",
                "lastModifyTime": "2019-10-20 15:26:21",
                "version": "1.0.0"
            }
        ]
    }
}

14.3 更新通知

14.3.1 功能描述

更新通知

14.3.2 请求方式

请求方式 POST

请求URL http://localhost:8081/notification/updateNotification

请求数据示例:

{
	"id":9,
	"lastVersion":2,
	"title":"系统升级",
	"topic": "升级完成"
}

参数说明

字段 类型 说明
id integer 要更新通知的Id
lastVersion integer 通知版本
title String 更新的标题
topic String 更新的内容
14.3.3 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
{
    "code": 60002,
    "msg": "更新失败"
}

14.4 删除通知

14.4.1 功能描述

删除通知

14.4.2 请求方式

请求方式 GET

请求地址 http://lcoalhost:8081/notification/deleteNotification?id=3

请求参数:

字段 类型 说明
id integer 通知的ID
14.4.3 返回结果
{
    "code": 200,
    "msg": "请求成功"
}
{
    "code": 60004,
    "msg": "删除失败"
}

15 游客登陆

15.1 登陆信息

信息参数
uid 1818181818
sex 1|2
state 0
realName 游客
permission false
unionId visitor
openId visitor

16 返回状态码

    SUCCESS(200, "请求成功"),
    FAILED(201, "请求失败"),
    REQUEST_ILLEGAL(202, "请求不合法"),
    BINDING_NOT(203, "该用户未绑定邮院社区,请先绑定"),
    TOKEN_EXPIRED(400, "token已过期"),
    TOKEN_ERROR(401, "token错误"),
    VISITOR_FORBIDDEN(403, "无权限访问"),
    LOGIN_FAILED(10002, "登陆失败"),
    BINDING_FAILED(20002, "绑定失败"),
    REPEAT_BINDING(20003, "重复绑定"),
    UNIQUE_INDEX(20004, "重复数据"),
    REPORT_FAILED(30002, "举报失败"),
    RECOMMEND_FAILED(30002, "反馈失败"),
    POST_FAILED(40002, "发送失败"),
    MISSING_PARAMETER(40003, "参数异常"),
    MISSING_RECORD(40004, "记录不存在"),
    SYSTEM_ERROR(50001, "系统异常"),
    UPDATE_FAILED(60002, "更新失败"),
    REQUEST_FREQUENT(50003, "请求过于频繁"),
    DELETE_FAILED(60004, "删除失败");

About

Yo趣社区小程序项目后端

License:Apache License 2.0


Languages

Language:Java 100.0%