You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.4 KiB
63 lines
1.4 KiB
/**
|
|
* @Title:
|
|
* @Description:
|
|
* @Author: Yuki Wong(iyuki0430@msn.com)
|
|
* @Update:
|
|
* @Date: 2020/7/20 11:50
|
|
* @File: AccountOpenAPI.go
|
|
* @Software: GoLand
|
|
**/
|
|
package AccountOpenAPI
|
|
|
|
import (
|
|
"dsSupport/MyModel/Account/AccountService"
|
|
"dsSupport/MyModel/MySwagger"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
// 后台登陆 godoc
|
|
// @Summary 后台登陆
|
|
// @Description json:"username" xorm:"not null comment('账号') VARCHAR(100)" example:"example"
|
|
// @Description json:"password" xorm:"not null comment('密码') VARCHAR(100)" example:"123456"
|
|
// @Tags account
|
|
// @ID loginAccount
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param input body MySwagger.AccountSwag true "账号密码"
|
|
// @Success 200 {object} MySwagger.Result
|
|
// @Failure 400 {object} MySwagger.Result
|
|
// @Router /v1/openapi/account/login [post]
|
|
func Login(c *gin.Context) {
|
|
var raw MySwagger.AccountSwag
|
|
|
|
if err := c.ShouldBindJSON(&raw); err != nil {
|
|
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
|
|
return
|
|
}
|
|
username := raw.Username
|
|
password := raw.Password
|
|
|
|
success, _ := AccountService.Login(username, password)
|
|
|
|
if success {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"status" : "ok",
|
|
"type" : "account",
|
|
"currentAuthority" : username,
|
|
})
|
|
|
|
return
|
|
} else {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"status" : "error",
|
|
"type" : "account",
|
|
"currentAuthority" : "guest",
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|