init
This commit is contained in:
69
pkg/util/172/black_user.go
Normal file
69
pkg/util/172/black_user.go
Normal file
@ -0,0 +1,69 @@
|
||||
package _72
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"hk/pkg/util/httpUtil"
|
||||
)
|
||||
|
||||
// BlackReq 黑名单请求
|
||||
type BlackReq struct {
|
||||
Number string `json:"number"` // Y 手机号或身份证号
|
||||
Type string `json:"type"` // Y 查询类别 1:手机号 2:身份证号
|
||||
Timestamp string `json:"Timestamp"` // Y 时间戳
|
||||
UserID string `json:"username"` // Y 用户ID
|
||||
UserSign string `json:"sign"` // Y 密钥
|
||||
}
|
||||
|
||||
// CheckBlackUser 判断用户是否为黑名单用户
|
||||
func CheckBlackUser(params BlackReq) (ApiResponse[any], error) {
|
||||
|
||||
formParams := map[string]string{
|
||||
"number": params.Number,
|
||||
"type": params.Type,
|
||||
"Timestamp": params.Timestamp,
|
||||
"username": params.UserID,
|
||||
"sign": params.UserSign,
|
||||
}
|
||||
|
||||
body, err := httpUtil.NewRequest().SendFormData(blackUserUrl, nil, formParams)
|
||||
if err != nil {
|
||||
return ApiResponse[any]{}, err
|
||||
}
|
||||
|
||||
// 解析 JSON 响应
|
||||
var apiResponse ApiResponse[any]
|
||||
err = json.Unmarshal([]byte(body), &apiResponse)
|
||||
if err != nil {
|
||||
fmt.Println("解析响应体时发生错误:", err)
|
||||
return ApiResponse[any]{}, err
|
||||
}
|
||||
|
||||
return apiResponse, nil
|
||||
}
|
||||
|
||||
// CheckBlackAgent 判断用户是否为黑名单代理
|
||||
func CheckBlackAgent(params BlackReq) (ApiResponse[any], error) {
|
||||
|
||||
formParams := map[string]string{
|
||||
"number": params.Number,
|
||||
"type": params.Type,
|
||||
"username": params.UserID,
|
||||
"sign": params.UserSign,
|
||||
}
|
||||
|
||||
body, err := httpUtil.NewRequest().SendFormData(blackAgentUrl, nil, formParams)
|
||||
if err != nil {
|
||||
return ApiResponse[any]{}, err
|
||||
}
|
||||
|
||||
// 解析 JSON 响应
|
||||
var apiResponse ApiResponse[any]
|
||||
err = json.Unmarshal([]byte(body), &apiResponse)
|
||||
if err != nil {
|
||||
fmt.Println("解析响应体时发生错误:", err)
|
||||
return ApiResponse[any]{}, err
|
||||
}
|
||||
|
||||
return apiResponse, nil
|
||||
}
|
Reference in New Issue
Block a user