# hackday **Repository Path**: zsyh9612/hackday ## Basic Information - **Project Name**: hackday - **Description**: 2016.4.8-2016.4.12 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2016-07-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #hackday git 代码地址:https://git.oschina.net/mrbian/hackday.git ##服务器和返回信息 url:139.129.131.240 port:3000 返回格式说明: 1.成功返回status:true,请求失败返回status:false, 错误信息在msg里面,如果status是false,请先查看msg并联系 ``` { "status":"true", "msg":{} } ---------------- { "status":"false", "msg":"wrong msg content" } ``` 特别的:如果***LoginToken***失效或者错误,返回msg特定为"LoginToken",代表需要LoginToken LoginToken默认一小时失效,如果有有效连接则自动延续一小时 2.注意 url开头是 host:port/api/token/ 的都需要在header中加入 ***"LoginToken",LoginToken*** 注意是LoginToken而不是token,后台可以自动根据LoginToken获得用户id 3.下面的请求参数默认必需,默认post方法 4.注意 带有 <> 的路由路径表示那里即使是post方法也需要那种参数去填充! ##登录注册 ###登录 @method post ***url : host:port/api/login*** param 手机号 ***mobile*** param 密码 ***password*** return ``` { "status":"true", "msg": { "userID": "INT", "LoginToken": "STRING", "token" : "STRING" } } ``` ###注册 @method post ***url : host:port/api/register*** param 手机号 ***mobile*** param 密码 ***password*** param 用户昵称 ***userName*** return ``` { "status":"true", " msg": { "userID": "INT", "LoginToken": "STRING", "token" : "STRING" } } ``` ###LoginToken失效后得到新的token @method post ***url : host:port/api/getToken*** param ***token*** return ``` { "status":"true", " msg": { "userID": "INT", "LoginToken": "STRING", "token" : "STRING" } } ``` ###方便测试的debugLogin @Method GET ***url : host:port/api/debugLogin*** return ``` 这个路由可以获得用户id为1的token ``` ##用户信息 ###获取用户信息 @method post ***url : host:port/api/token/userinfo*** param 想要得到用户信息的用户id ***AuthorID*** return ``` { "status":"true", "msg": { "user":{ "id":1, "mobile":"18340861710", "avatar":"http://www.baidu.com", "sign":"hello world", "userName":"test", "token":"VPpBrnWtvWDbVMGXgCvYPBhnkWM=", "sex":2, "noticeEnable":0, "followingEnable":0, "followerEnable":0, "aboutNotice":0, "updateNotice":0 }, "follower":[{},{}] || ["false"], //如果你要看的用户不让看就是["false"] "following":[{},{}] || ["false"], //如果你要看的用户不让看就是["false"] "collectedStoriesCount": INT //收藏的故事数目 } } ``` 上面following和follower在用户是自己或者别人公开的情况下的具体格式如下: ``` following:[{ "id":2, "mobile":"18340861711", "avatar":"http://www.baidu.com", "sign":"hello world", "userName":"test", "token":"qjLzo8VG/TqKbLiqVMvGT3QKT6k=", "sex":2, "noticeEnable":1, "followingEnable":1, "followerEnable":1, "aboutNotice":1, "updateNotice":1, "Follow":{"createdAt":"1460385486","updatedAt":"","followerID":1,"StarID":2} }] ``` ###用户信息更新 @Method post 需要token ***url : host:port/api/token/userinfo/update*** param ***avatar*** 头像url地址 param ***userName*** 用户昵称 param ***sign*** 签名 param ***sex*** 性别 可以上传INT 2 无性别 param ***updateNotice*** 忘了 - - param ***noticeEnable*** 忘了 - - param ***followingEnable*** 我正在关注的是否公开 param ***followerEnable*** 关注我的是否公开 param ***aboutNotice*** 忘了 - - return ``` 和上面用户信息返回的格式一样 ``` ###用户添加关注 @Method post 需要token ***url : host:port/api/token/userinfo/addfollow*** param 要关注的人的id starID return ``` { "status":"true", "msg" : { starID:INT //关注的人的id } } ``` ###用户取消关注 @Method post 需要token ***url : host:port/api/token/userinfo/delfollow*** param 要取消关注的人的id starID return ``` { "status":"true", "msg" : { starID:INT //取消关注的人的id } } ``` ###得到和某人私聊的所有消息 @Method POST ***url : host:port/api/token/chat/get*** param 聊天对象的id ***revID*** return ``` { "status":true, "msg":{ "msgs":[{ "id":201, "updatedAt":"1460452024", "createdAt":"1460452024", "sendID":1, "revID":1, "content":"this a test msg from 1 to 1" }] } } ``` ###发送和某人私聊的消息 @Method POST ***url : host:port/api/token/chat/send*** param 聊天对象的id ***revID*** param 聊天的内容 ***content*** return ``` { "status":true, "msg":{ "msgID":{ "updatedAt":"1460452186", "createdAt":"1460452186", "id":201, "sendID":1, "revID":1, "content":"this a test msg from 1 to 1" } } } ``` ##获取故事信息 ###广场故事列表 @Method POST ***url : host:port/api/token/public/storylist/\/\*** param 你想要请求的时间的时间戳 ***timestamps*** \ 请求的第几页 默认从1开始计数!!! ***page*** \ 请求的每一页的故事数目 ***Count*** return ``` 格式和个人故事列表相同 ``` ###个人故事列表 @Method post ***url : host:port/api/token/storylist/\/\*** param 故事列表所属用户的id ***userID*** \ 请求的第几页 默认从1开始计数!!! ***page*** \ 请求的每一页的故事数目 ***Count*** return ``` { "status":"true", "msg":{ "user": { "id":1, "mobile":"18340861710", "avatar":"http://www.baidu.com", "sign":"hello world", "userName":"test", "token":"VPpBrnWtvWDbVMGXgCvYPBhnkWM=", "sex":2, "noticeEnable":0, "followingEnable":0, "followerEnable":0, "aboutNotice":0, "updateNotice":0 }, "stories":[{ "id":"1e6f3c95-78ca-40d7-becb-6d415d2f2e11", "title":" 这是一篇文章", "flags":"", "content" :"hello world", "publicEnable":1, "createdAt":"1460385486", "updatedAt":"", "AuthorID":1 }], "likeCount":10 } ``` 如果请求的userID和LoginToken吻合,系统判定是本人,会返回所有的故事,如果不吻合,会返回所有公开的故事; 返回的数据里面其实还有所有点赞的人的信息,如果需要可以联系我添加到API里面 ###获取故事内容 @method post ***url : host:port/api/token/story*** param 请求的故事的id ***storyID*** param 故事的作者的id ***AuthorID*** return ``` { "status":true, "msg":{ "story":{ "id":"7ee04563-d2b9-4d20-b59e-9e13b7958c79", "title":" 这是一篇文章", "flags":"", "content":"hello world", "publicEnable":1, "createdAt":"1460385486", "updatedAt":"", "AuthorID":2, "likeCount":10, "isOwn":false }, } } ``` 返回的数据里面其实还有所有点赞的人的信息,数组有点长,如果需要可以联系我添加到API里面 前台可以根据isOwn来判断是否可以编辑 ###添加故事 @Method post ***url : host:port/api/token/addstory*** param 故事的标题 ***title*** param 故事的标签 ***flags*** param 故事的内容 ***content*** param 是否公开 ***publicEnable*** return ``` { "status":"true", "msg" : { "id":"story.id", //UUID类型,应该当成字符串处理 "url": "h5Url" } } ``` ###点赞故事 @Method post ***url : host:port/api/token/story/like*** param 请求的故事的id ***storyID*** param 请求的操作 ***isLike*** return ``` { "status" : "true", "msg" : "true" } ``` ###收藏故事 @Method post ***url : host:port/api/token/story/collect*** param 请求的故事的id ***storyID*** param 请求的操作 ***isCollect*** return ``` { "status" : "true", "msg" : "true" } ``` ##评论和回复 ###得到评论列表 @Method post ***url : host:port/api/token/commentlist/\*** storyID 请求的故事的id \@return ``` { "status":true, "msg":{ "comment":[{ "id":1, "content":"this is a test comment of article", "createdAt":"1460385486", "updatedAt":"", "RevCommentId":null, "UserId":1, "StoryId":"994bfb00-1e1f-49f9-a7ca-5f4b046a619d", "RevComment":[{ "id":21, "content":"this is a test comment of comment", "createdAt":"1460385486", "updatedAt":"", "RevCommentId":1, "UserId":1, "StoryId":"994bfb00-1e1f-49f9-a7ca-5f4b046a619d" }] }] } } ``` ###给文章发表评论 @Method post url host:port/api/token/comment/ param 评论内容 ***commentContent*** return ``` { "status":true, "msg":{ "id":91 评论的id } } ``` ###给评论发表评论 @Method post url host:port/api/token/reply/ param 评论内容 ***replyContent*** return ``` { "status":true, "msg":{ "id":94 回复的id } } ``` 不支持回复的回复