整合springboot-mybatis提供RESTful风格SaaS服务

Spring boot + MyBatis 提供 RESTful 风格 SaaS 服务

一、common包下是封装好的一套公共部分,不掺杂任何业务逻辑。
二、blog包下是博客相关的接口,提供了对文章类别和文章详情的crud操作接口。
三、wechat包下是爬去别人网站提供的接口,提供了搜索公众号名称、分页获取其下文章列表、获取文章详情等接口。

get请求不需要鉴权token,所有的post、put、delete请求均作了接口token鉴权,不过具体的鉴权逻辑没有实现,硬编码 token=123456 为鉴权通过,其余均为非法请求。

—— 接口列表 ——

一、类别相关接口

1.1、添加类别接口

http + post /category
Request body :
{
    "token": "123456",
    "name": "name",
    "introduction": "introduction",
    "preview": "preview"
}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": null
}

1.2、删除类别接口

http + delete /category/{id}
Request body : 
{
    "token":"123456"
}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": null
}

1.3、更新类别接口

http + put /category/{id}
Request body : 
{
    "token":"123456",
    "name": "name",
    "introduction": "introduction",
    "preview":"preview"
}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": null
}

1.4、获取类别详情接口

http + get /category/{id}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": {
    "id": "27837bca658b40f990b2e75768357847",
    "createTime": 1490853441000,
    "updateTime": 1490853441000,
    "name": "name",
    "introduction": "introduction1",
    "preview": "preview"
  }
}

1.5、分页获取类别列表接口

http + get /category?pageno=1&pagesize=10
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": {
    "total": 5,
    "nodes": [
      {
        "id": "27837bca658b40f990b2e75768357847",
        "createTime": 1490853441000,
        "updateTime": 1490853441000,
        "name": "哈哈",
        "introduction": "introduction",
        "preview": "preview"
      },
      {
        "id": "a7878d52932e4028a45205431f6b9032",
        "createTime": 1490854115000,
        "updateTime": 1490854115000,
        "name": "哈哈",
        "introduction": "introduction",
        "preview": "preview"
      }, ......
    ]
  }
}

二、文章相关接口

2.1、添加文章接口

http + post /article
Request body : 
{
    "token": "123456",
    "categoryId": "1838d27816b14735810ed2ee55f30ec2",
    "name": "name",
    "content": "content",
    "preview": "preview"
}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": null
}

2.2、删除文章接口

http + delete /article/{id}
Request body : 
{
    "token":"123456"
}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": null
}

2.3、更新文章接口

http + put /article/{id}
Request body : 
{
    "token":"123456",
    "categoryId": "categoryId",
    "name": "name",
    "content": "content",
    "preview":"preview"
}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": null
}

2.4、获取文章详情接口

http + get /article/{id}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": {
    "id": "fbe10f1a336d4c5fa3b098694f318086",
    "categoryId": "27837bca658b40f990b2e75768357847",
    "categoryName": "name",
    "name": "name",
    "preview": "preview",
    "content": "content",
    "viewNum": 0
  }
}

2.5、分页获取文章列表

http + get /article?pageno=1&pagesize=10
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": {
    "total": 3,
    "nodes": [
      {
        "id": "fbe10f1a336d4c5fa3b098694f318086",
        "categoryId": "27837bca658b40f990b2e75768357847",
        "categoryName": "name",
        "name": "name",
        "preview": "preview",
        "content": "content",
        "viewNum": 1
      },
      {
        "id": "d84fb1d691f3496885fb9a21caeed16e",
        "categoryId": "27837bca658b40f990b2e75768357847",
        "categoryName": "name",
        "name": "name",
        "preview": "preview",
        "content": "content",
        "viewNum": 0
      },
      {
        "id": "142fbfeb8763448d99c4b400ca1eea79",
        "categoryId": "27837bca658b40f990b2e75768357847",
        "categoryName": "name",
        "name": "name",
        "preview": "preview",
        "content": "content",
        "viewNum": 0
      }
    ]
  }
}

三、爬取其他网站接口

3.1、搜索微信公众号接口

http + get /wechat/search/{keywords}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": [
    {
      "photo": "http://xxxxxx.jpg",
      "describe": "xxxxxx",
      "title": "xxxxxx",
      "account": "xxxxxx"
    },
    {
      "photo": "http://xxxxxx.jpg",
      "describe": "xxxxxx",
      "title": "xxxxxx",
      "account": "xxxxxx"
    }
  ]
}

3.2、获取某公众号文章列表接口

http + get /wechat/account/{account}/{pageno}
**注意事项:最后的分页(pageno)必须是12的倍数**
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": {
    "total": 3552,
    "articles": [
      {
        "createTime": "2017-02-12",
        "id": "1561973031016",
        "title": "xxxxxx"
      },
      {
        "createTime": "2017-02-11",
        "id": "1557723531913",
        "title": "xxxxxx"
      }, ......
    ]
  }
}

3.3、获取文章详细信息接口

http + get /wechat/article/{articleId}
Response data :
{
  "code": 0,
  "msg": "OK",
  "result": {
    "createTime": "2016-05-13",
    "nickName": "xxx",
    "author": "xxx",
    "name": "xxx",
    "content": "xxx"
  }
}

详细信息科参见源码:https://github.com/Qbian61/SpringBoot-MyBatis

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值