hk-service/pkg/util/172/black_user.go
2025-02-20 17:32:53 +08:00

70 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}