1 Star 0 Fork 0

wosylf/龙飞工具仓库

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
布尔.go 3.45 KB
一键复制 编辑 原始数据 按行查看 历史
itlun 提交于 2024-08-21 11:11 +08:00 . 初步添加一下布尔的风控情况
package xutil
import (
"crypto/rsa"
"fmt"
"net/url"
"os"
"gitee.com/wosylf/ltool"
"gitee.com/wosylf/ltool/encrypt"
"gitee.com/wosylf/ltool/pkg/xhttp"
)
const (
V请求域名_沙箱 = "http://sit-shouwei.shouxin168.com/sandbox" //测试
V请求域名_正式 = "https://shouwei.shouxin168.com/api" //正式
V天狼星报告星耀版 = "/lightning/product/query"
V统一接口地址 = "/lightning/product/query"
V合同上传地址 = "/contract/file/upload"
)
type S布尔 struct {
PrivateKey *rsa.PrivateKey
Iid string //id
AES_KEY string //加密解密的
Notifiy string //密钥
Mode string //密钥
V沙箱 bool
Desc encrypt.S加解密接口
}
var (
V布尔链接 *S布尔
)
func F新建布尔链接(InstitutionId, AES_KEY, notifiy, mode string) (client *S布尔, err error) {
client = &S布尔{
Iid: InstitutionId,
AES_KEY: AES_KEY,
Notifiy: notifiy,
Mode: mode,
Desc: encrypt.F新建Ase配置(AES_KEY, "ECB", "base64"),
}
return client, nil
}
func (a *S布尔) F查询星耀报告(id, name, phone, 完整路径 string) (by []byte, err error) {
bm := make(ltool.BodyMap)
bm.Set("ident_number", id).
Set("name", name).Set("phone", phone).
Set("mode", a.Mode).
Set("licenseUrl", 完整路径).
Set("licenseType", 1).
Set("service", "risk_report_service")
by, err = a.F发送请求(bm, V天狼星报告星耀版)
return
}
func (a *S布尔) F企业认证(id, name, phone string) (by []byte, err error) {
bm := make(ltool.BodyMap)
bm.Set("orgCode", id).
Set("name", name).Set("notifyUrl", a.Notifiy).
Set("mode", "mode_company_identity_auth").
Set("phone", phone).
Set("service", "online_signature_service")
by, err = a.F发送请求(bm, V统一接口地址)
return
}
func (a *S布尔) F个人认证(id, name, phone string) (by []byte, err error) {
bm := make(ltool.BodyMap)
bm.Set("orgCode", id).
Set("name", name).Set("notifyUrl", a.Notifiy).
Set("mode", "mode_company_identity_auth").
Set("phone", phone).
Set("service", "online_signature_service")
by, err = a.F发送请求(bm, V统一接口地址)
return
}
func F上传合同(filepath string) {
fileContent, err := os.ReadFile(filepath)
if err != nil {
return
}
bm := make(ltool.BodyMap)
bm.SetFormFile("file", &ltool.File{
Name: "file",
Content: fileContent,
})
fmt.Println("进入合同上传")
httpClient := xhttp.NewClient()
_, bs, err := httpClient.Type(xhttp.TypeMultipartFormData).Post(V合同上传地址).
SendMultipartBodyMap(bm).EndBytes(ctx)
if err != nil {
fmt.Println("错误信息", err.Error())
}
fmt.Println("请求的结果是", string(bs))
}
func (a *S布尔) F发送请求(bm ltool.BodyMap, url string) (bs []byte, err error) {
bm1 := make(ltool.BodyMap)
bm1.Set("institution_id", a.Iid)
bm1.Set("biz_data", a.F获取biz数据(bm))
//sign = a.F获取签名(bm)
//bm1.Set("sign", a.F获取签名(bm))
完整路径 := V请求域名_正式 + url
if a.V沙箱 {
完整路径 = V请求域名_沙箱 + url
}
httpClient := xhttp.NewClient()
httpClient.Header.Add("keepAlive", "false")
_, bs, err = httpClient.Type(xhttp.TypeFormData).
Post(完整路径).
SendString(bm1.EncodeAliPaySignParams()).EndBytes(ctx)
if err != nil {
fmt.Println(err.Error())
return
}
return
}
func (a *S布尔) F获取biz数据(bm ltool.BodyMap) (biz string) {
jm, _ := a.Desc.F加密信息(bm.JsonBody())
biz = UrlEncode(jm)
return
}
func UrlEncode(str string) string {
return url.QueryEscape(str)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wosylf/ltool.git
git@gitee.com:wosylf/ltool.git
wosylf
ltool
龙飞工具仓库
4aab2f4b94f9

搜索帮助