init
This commit is contained in:
198
pkg/util/172/172_test.go
Normal file
198
pkg/util/172/172_test.go
Normal file
@ -0,0 +1,198 @@
|
||||
package _72
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetProduct(t *testing.T) {
|
||||
key := "devttl"
|
||||
secret := "2eed544990ff898cf4fe47ef90b1ce3a"
|
||||
productID := ""
|
||||
timestamp := fmt.Sprintf("%d", time.Now().Unix()) // 当前时间戳,长度为10位
|
||||
|
||||
// 创建请求参数
|
||||
params := GoodsReq{
|
||||
ProductID: productID,
|
||||
BaseParams: BaseParams{
|
||||
Timestamp: timestamp,
|
||||
UserID: key,
|
||||
UserSign: secret,
|
||||
},
|
||||
}
|
||||
|
||||
// 发送 POST 请求
|
||||
apiResponse, err := GetProduct(params)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果成功,处理 data 中的数据
|
||||
if apiResponse.Code == 0 {
|
||||
for index, item := range apiResponse.Data {
|
||||
fmt.Printf("------------------%d\n", index)
|
||||
fmt.Printf("产品ID: %v\n", item.ProductID)
|
||||
fmt.Printf("产品名称: %v\n", item.ProductName)
|
||||
fmt.Printf("产品状态: %v\n", item.Flag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetProductV2(t *testing.T) {
|
||||
key := "devttl"
|
||||
secret := "2eed544990ff898cf4fe47ef90b1ce3a"
|
||||
productID := "1128"
|
||||
timestamp := fmt.Sprintf("%d", time.Now().Unix()) // 当前时间戳,长度为10位
|
||||
|
||||
// 创建请求参数
|
||||
params := GoodsReq{
|
||||
ProductID: productID,
|
||||
BaseParams: BaseParams{
|
||||
Timestamp: timestamp,
|
||||
UserID: key,
|
||||
},
|
||||
}
|
||||
|
||||
// 生成 MD5 签名
|
||||
userSign := generateMD5SignV2(params, secret)
|
||||
|
||||
params.UserSign = userSign
|
||||
|
||||
fmt.Print(params)
|
||||
|
||||
// 发送 POST 请求
|
||||
apiResponse, err := getProductV2(params)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果成功,处理 data 中的数据
|
||||
if apiResponse.Code == 0 {
|
||||
for index, item := range apiResponse.Data {
|
||||
fmt.Printf("------------------%d\n", index)
|
||||
fmt.Printf("产品ID: %v\n", item.ProductID)
|
||||
fmt.Printf("产品名称: %v\n", item.ProductName)
|
||||
fmt.Printf("产品主图: %v\n", item.MainPic)
|
||||
fmt.Printf("发货地区: %v\n", item.Area)
|
||||
fmt.Printf("禁发地区: %v\n", item.DisableArea)
|
||||
fmt.Printf("详情图片: %v\n", item.LittlePicture)
|
||||
fmt.Printf("详情链接: %v\n", item.NetAddr)
|
||||
fmt.Printf("产品状态: %v\n", item.Flag)
|
||||
fmt.Printf("是否选号: %v\n", item.NumberSel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPickNumber(t *testing.T) {
|
||||
key := "devttl"
|
||||
secret := "2eed544990ff898cf4fe47ef90b1ce3a"
|
||||
productID := "1128"
|
||||
timestamp := fmt.Sprintf("%d", time.Now().Unix()) // 当前时间戳,长度为10位
|
||||
|
||||
// 创建请求参数
|
||||
params := PickNumberReq{
|
||||
ProductID: productID,
|
||||
SearchCategory: "3",
|
||||
BaseParams: BaseParams{
|
||||
UserID: key,
|
||||
Timestamp: timestamp,
|
||||
},
|
||||
}
|
||||
|
||||
// 生成 MD5 签名
|
||||
userSign := generateMD5SignV2(params, secret)
|
||||
|
||||
params.UserSign = userSign
|
||||
|
||||
fmt.Println(params)
|
||||
|
||||
// 发送 POST 请求
|
||||
apiResponse, err := GetPickNumber(params)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果成功,处理 data 中的数据
|
||||
if apiResponse.Code == 0 {
|
||||
for index, item := range apiResponse.Data {
|
||||
fmt.Printf("------------------%d\n", index)
|
||||
fmt.Printf("号码: %v\n", item.Number)
|
||||
fmt.Printf("号码类型: %v\n", item.Type)
|
||||
fmt.Printf("号码ID: %v\n", item.NumberId)
|
||||
fmt.Printf("号码池ID: %v\n", item.NumberPoolId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckUserBlack(t *testing.T) {
|
||||
key := "devttl"
|
||||
secret := "2eed544990ff898cf4fe47ef90b1ce3a"
|
||||
number := "15538654901"
|
||||
numberType := "1"
|
||||
timestamp := fmt.Sprintf("%d", time.Now().Unix()) // 当前时间戳,长度为10位
|
||||
|
||||
// 创建请求参数
|
||||
params := BlackReq{
|
||||
Number: number,
|
||||
Type: numberType,
|
||||
Timestamp: timestamp,
|
||||
UserID: key,
|
||||
UserSign: secret,
|
||||
}
|
||||
|
||||
// 发送 POST 请求
|
||||
apiResponse, err := CheckBlackUser(params)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果成功,处理 data 中的数据
|
||||
if apiResponse.Code == 0 {
|
||||
fmt.Println("此用户是黑名单")
|
||||
}
|
||||
if apiResponse.Code == 1 {
|
||||
fmt.Println("此用户不是黑名单")
|
||||
}
|
||||
if apiResponse.Code == -1 {
|
||||
fmt.Println("请输入正确的手机号")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckAgentBlack(t *testing.T) {
|
||||
key := "devttl"
|
||||
secret := "2eed544990ff898cf4fe47ef90b1ce3a"
|
||||
number := "15538654901"
|
||||
numberType := "1"
|
||||
|
||||
// 创建请求参数
|
||||
params := BlackReq{
|
||||
Number: number,
|
||||
Type: numberType,
|
||||
UserID: key,
|
||||
}
|
||||
|
||||
// 生成 MD5 签名
|
||||
userSign := generateMD5SignV2(params, secret)
|
||||
|
||||
params.UserSign = userSign
|
||||
|
||||
fmt.Println(params)
|
||||
|
||||
// 发送 POST 请求
|
||||
apiResponse, err := CheckBlackAgent(params)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果成功,处理 data 中的数据
|
||||
if apiResponse.Code == 0 {
|
||||
fmt.Println("此用户是黑名单代理")
|
||||
}
|
||||
if apiResponse.Code == 1 {
|
||||
fmt.Println("此用户不是黑名单代理")
|
||||
}
|
||||
if apiResponse.Code == -1 {
|
||||
fmt.Println("请输入正确的代理手机号")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user