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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package AuthOpenapi
import (
"dsDataex/MyService/Auth/AuthService"
"dsDataex/MyService/MySwagger"
"github.com/gin-gonic/gin"
"net/http"
)
// @Summary 接入系统鉴权
// @Description 【数据交换平台】接入系统鉴权服务接口, 使用数据交换平台提供的接入系统id和key, 验证成功返回系统票据。
// @Tags dataex
// @Accept json
// @Produce json
// @Param input body MySwagger.Auth true "接入系统ID、系统生成验证Token和验证时间, 备注: system_token = MD5.hash(MD5.hash(system_id+auth_time)+system_key)"
// @Success 200 {object} MySwagger.Result
// @Failure 400 {object} MySwagger.Result
// @Router /dataex/dataex/SystemAuth [post]
func SystemAuth ( c * gin . Context ) {
var input MySwagger . Auth
if err := c . ShouldBindJSON ( & input ) ; err != nil {
c . JSON ( http . StatusBadRequest , MySwagger . Result { Success : false , Message : "接入系统数据JSON格式错误" } )
return
}
if input . SystemID == "" || input . SystemToken == "" || input . AuthTime == "" {
c . JSON ( http . StatusBadRequest , MySwagger . Result { Success : false , Message : "接入系统鉴权参数不能为空" } )
return
}
success , result , token := AuthService . CreateToken ( input . SystemID , input . SystemToken , input . AuthTime )
if success {
c . JSON ( http . StatusOK , MySwagger . Result {
Success : true ,
Message : token ,
} )
} else {
c . JSON ( http . StatusOK , MySwagger . Result {
Success : false ,
Message : result ,
} )
}
}