feat:完善项目

This commit is contained in:
henry
2021-11-02 10:02:52 +08:00
parent 4734344985
commit 690cd96bed
72 changed files with 5516 additions and 8 deletions

82
app/api/account.go Normal file
View File

@ -0,0 +1,82 @@
package api
import (
"ArmedPolice/app/controller"
"ArmedPolice/app/service"
"github.com/gin-gonic/gin"
)
type Account struct{}
/**
* @apiDefine Account 账号管理
*/
/**
* @api {post} /api/account/login 账号登录
* @apiVersion 1.0.0
* @apiName AccountLogin
* @apiGroup Account
*
* @apiHeader {string} x-equipment 设备平台WebH5App
*
* @apiParam {String} account 登录账号
* @apiParam {String} password 登录密码
* @apiParam {Json} captcha 验证码信息
* @apiParam {String} captcha.key 验证key
* @apiParam {String} captcha.value 验证value
*
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
* @apiSuccess (200) {String} data token
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjE3NDU2OTMwIiwiaWF0IjoiMTYxNjg1MjEzMCIsInVpZCI6IjIwMTMxMTI4MTMwMTg0MTkyMDAifQ.D7oSD4OGdz8rJt0rFNVEl5Ea47_vtuC51IDrY9mUTPo"
* }
*/
func (a *Account) Login(c *gin.Context) {
form := &struct {
Account string `json:"account" form:"account" binding:"required"`
Password string `json:"password" form:"password" binding:"required"`
Captcha struct {
Key string `json:"key" form:"key" binding:"required"`
Value string `json:"value" form:"value" binding:"required"`
} `json:"captcha" form:"captcha" binding:"required"`
}{}
if err := bind(form)(c); err != nil {
APIFailure(err.(error))(c)
return
}
data, err := controller.NewAccount()(nil).Login(form.Account, form.Password, form.Captcha.Key, form.Captcha.Value,
c.GetHeader("x-equipment"), c.ClientIP())
APIResponse(err, data)(c)
}
/**
* @api {post} /api/account/logout 账号退出
* @apiVersion 1.0.0
* @apiName AccountLogout
* @apiGroup Account
*
* @apiHeader {string} x-token token
*
* @apiSuccess (200) {Number} code 成功响应状态码!
* @apiSuccess (200) {String} msg 成功提示
*
* @apiSuccessExample {json} Success response:
* HTTPS 200 OK
* {
* "code": 200
* "msg": "ok"
* "data": null
* }
*/
func (a *Account) Logout(c *gin.Context) {
err := controller.NewAccount()(getSession()(c).(*service.Session)).Logout()
APIResponse(err)(c)
}