项目属于课上作业迭代,请不要用于真实开发和调试。
本文非解决方案文章,仅作为记录作业使用,类似于写点心路历程。
作业日期:2020年6月04日,作业05
作业安排:博客里以文档格式撰写API设计;代码里面加上用Swagger相关的注解,生成API文档。
代码详见github:github.com/hitofuncy
一、作业概述
文档的格式:文档参造的文档为:https://wenku.baidu.com/view/5a94105c366baf1ffc4ffe4733687e21af45ffec.html
致敬原作者
零、排版BUG
明明制作的时候好好的,显示出来效果就很差。
一、登录
登录主页(/login/to_login)
Info
Value
接口 /login/to_login 地址 https://localhost:8080/login/to_login 描述 登录主页 验证 session 方法 GET/POST 数据 Json
Response
参数名 类型 是否必须 说明 login String Y
example
success
Status body 200 login.html 界面
fail
HTTP Status Code Reason 204 No Content 401 Unauthorized 403 Forbidden
登录(/login/do_login)
Info Value 接口 /login/do_login 地址 https://localhost:8080/login/do_login 描述 开始登录,判断账号密码是否正确,错误提示错误信息,成功跳转页面 验证 Session 方法 GET/POST 数据 Json
Request
参数名 类型 是否必须 说明 response HttpServletResponse Y 封装了向客户端发送数据、发送响应头,发送响应状态码的方法 loginVo LoginVo Y 存储前台输入手机号、密码的数据 mobile String Y 手机号 password String Y 密码
Response
参数名 类型 是否必须 说明 code int Y 状态码 msg String Y 提示信息 data T Y 数据
example
success
code msg data 0 success true
fail
code msg data 500101 参数校验异常:手机号码格式不正确 null 500215 密码错误 null
手机号验证登录主页(/login/mobile/)
Info Value 接口 /login/mobile 地址 https://localhost:8080/login/mobile 描述 手机号发送验证码登录的主页 验证 Session 方法 GET/POST 数据 Json
Response
参数名 类型 是否必须 说明 mobile String Y 显示手机登录页面
example
success
Status body 200 mobile.html 代码信息
fail
Code Reason 204 No Content 401 Unauthorized 403 Forbidden
手机号发送验证码(/login/do_authcode)
Info Value 接口
/login/do_authcode 地址 https://localhost:8080/login/do_authcode 描述 通过阿里云短信服务API发送验证码 验证 Session 方法 GET/POST 数据 Json Request
参数名 类型 是否必须 说明 response HttpServletResponse Y 封装了向客户端发送数据、发送响应头,发送响应状态码的方法 loginVo LoginVo Y 存储前台输入手机号、密码的数据 mobile String Y 手机号
Response
参数名 类型 是否必须 说明 code int Y 状态码 msg String Y 提示信息 data T Y 数据
example
success
code msg data 0 success true fail
code msg data 500101 参数校验异常:手机号码格式不正确 null
手机号开始登录(/login/authcode_login)
Info Value 接口 /login/authcode_login 地址 https://localhost:8080/login/authcode_login 描述 开始登录,验证手机号、验证码是否正确 验证 Session 方法 GET/POST 数据 Json
Request
参数名 类型 是否必须 说明 mobile String Y 手机号 password String Y 验证码
Response
参数名 类型 是否必须 说明 code int Y 状态码 msg String Y 提示信息 data T Y 数据
example
success
Status body 200 商品列表页面
fail
code msg data 500101 参数校验异常:手机号码格式不正确 null 500215 密码(验证码)错误 null
QQ登录url(/getQQCode)
Info Value 接口 /getQQCode 地址 https://localhost:8080/getQQCode 描述 获得跳转到qq登录页的url,前台直接连接访问 验证 Sesion 方法 GET/POST 数据 Json
Request
参数名 类型 Y否必须 说明 login String Y 登录界面 url String Y QQ登录的链接 example
success
Status body 200 将url显示login.html 界面中 fail
HTTP Status Code Reason 204 No Content 401 Unauthorized 403 Forbidden
跳转QQ登录界面进行登录(/QQLogin)
Info Value 接口 /QQLogin 地址 https://localhost:8080/QQLogin 描述 QQ进行登录 验证 Session 方法 GET/POST 数据 Json Request
参数名 类型 是否必须 说明 code int Y 用户授权获得code Response
参数名 类型 是否必须 说明 userInfo QQUserInfo Y 用户授权信息 example
success
Status body 200 goods_list.html 代码信息 fail
HTTP Status Code Reason 204 No Content 401 Unauthorized 403 Forbidden
二、秒杀
商品列表(/goods/to_list)
Info Value 接口 /goods/to_list 地址 https://localhost:8080/goods/to_list 描述 显示商品列表 验证 Session 方法 GET/POST 数据 Json Request
参数名 类型 是否必须 说明 user MiaoshaUser Y 用户的信息 model Model Y 将数据返回前端界面 Response
参数名 类型 是否必须 说明 goodsList String Y 商品信息展示的页面 goodsList List Y 数据中存储的商品信息 user Miaosha Y 用户信息 example
success
Status body 200 goods_list.html 代码信息 fail
HTTP Status Code Reason 204 No Content 401 Unauthorized 403 Forbidden
商品详情(/goods/to_detail/)
Info Value 接口 /goods/to_detail 地址 https://localhost:8080 /goods/to_detail 描述 显示商品详细信息 验证 Session 方法 GET/POST 数据 Json Request
参数名 类型 是否必须 说明 user MiaoshaUser Y 用户的信息 goodsId long Y 数据库中商品的主键编号 model Model Y 将数据返回前端界面 Response
参数名 类型 是否必须 说明 goods_detail String Y 商品详情信息展示页面 miaoshaStatus int Y 秒杀的状态码 remainSeconds int Y 秒杀时间 goods GoodsVo Y 根据goodsId获取商品信息 user MiaoshaUser Y 用户的信息 code int Y 状态码 msg String Y 提示信息 data T Y 数据
example
success
code body 200 goods_details.html 代码信息
fail
code msg data 500100 服务端异常 null
秒杀——登录才可进行(/miaosha/do_miaosha)
Info Value 接口 /miaosha/do_miaosha 地址 https://localhost:8080/miaosha/do_miaosha 描述 在用户登录后,可以进行秒杀操作 验证 Session 方法 GET/POST 数据 Json
Request
参数名 类型 是否必须 说明 user Miaosha Y 用户信息 goodsId Long Y 商品编号 model Model Y 将数据返回前端界面
Response
参数名 类型 是否必须 说明 order_detail String Y 秒杀订单详情界面 login String Y 登录界面 user MiaoshaUser Y 用户信息 orderInfo OrderInfo Y 秒杀订单信息 goods GoodsVo Y 商品信息 code int Y 状态码 msg String Y 提示信息 data T Y 数据
example
success
code body 200 order_detail.html 代码信息 fail
code msg data 500500 秒杀已经完毕 null 500501 不能重复秒杀 null
状态码
状态码 描述 0 success 500100 服务器异常 500101 参数校验异常 500210 session不存在或已经失效 500211 登录密码不能为空 500212 手机号不能为空 500213 手机号格式错误 500214 手机号不存在 500215 密码错误 500500 秒杀已经完毕 500501 不能重复秒杀 204 没有内容 401 未经授权 403 禁止访问
衔接swagger
正在衔接之中,遇见一些困难,正在解决,没有很好了解swagger,有一些思路还没有整理好。将在下一次课之前彻底解决这个问题。