first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package http_api
import (
"servicebase/pkg/log"
"servicebase/pkg/res"
"servicebase/pkg/utils"
"errors"
"github.com/go-resty/resty/v2"
)
type InnerLoginReq struct {
Mobile string `json:"mobile"`
Signature string `json:"signature"`
}
type InnerLoginRes struct {
Code string
Result res.AccessTokenDTO
Msg string
}
func InnerLogin(url, secret, mobile string) (token string, e error) {
var req = map[string]string{
"mobile": mobile,
}
sign := utils.CreateApiSign(req, secret)
req["Signature"] = sign
client := resty.New()
_ = client
var res InnerLoginRes
resp, err := client.R().
SetHeader("Content-Type", "application/json").
SetBody(req).
SetResult(&res). // or SetResult(AuthSuccess{}).
Post(url)
if err != nil {
return "", err
}
log.InfoF("%++v %v", res, string(resp.Body()))
if res.Code == "8000" {
return res.Result.AccessToken, nil
}
return "", errors.New("登录失败:" + res.Msg)
}