财务系统支行信息
This commit is contained in:
parent
3fd9995b0f
commit
27be45b5ea
35
config.go
35
config.go
|
@ -141,4 +141,39 @@ type (
|
||||||
FileName string `json:"fileName,optional"` //文件名称。
|
FileName string `json:"fileName,optional"` //文件名称。
|
||||||
FileType string `json:"fileType,optional"` //文件类型。
|
FileType string `json:"fileType,optional"` //文件类型。
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FinanceBank struct {
|
||||||
|
Keyword string `json:"keyword"`
|
||||||
|
BankName string `json:"bankName"` // 模糊查询 (bankName,branchName, branchCode, code)
|
||||||
|
Province string `json:"province"`
|
||||||
|
City string `json:"city"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
IsDesc bool `json:"isDesc"` // 是否倒序查询(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
financeBankRequest struct {
|
||||||
|
Keyword string `json:"keyword"`
|
||||||
|
BankName string `json:"bankName"` // 模糊查询 (bankName,branchName, branchCode, code)
|
||||||
|
Province string `json:"province"`
|
||||||
|
City string `json:"city"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Page uint32 `json:"page"`
|
||||||
|
PageSize uint32 `json:"pageSize"`
|
||||||
|
IsDesc bool `json:"isDesc"` // 是否倒序查询(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
FinanceBankResp struct {
|
||||||
|
Banks []BankItem `json:"banks"`
|
||||||
|
Total uint32 `json:"total"` // 模糊查询 (bankName,branchName, branchCode, code)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BankItem struct {
|
||||||
|
BranchCode string `json:"branchCode"`
|
||||||
|
Province string `json:"province"`
|
||||||
|
City string `json:"city"`
|
||||||
|
BranchName string `json:"branchName"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
BankName string `json:"bankName"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
6
const.go
6
const.go
|
@ -53,3 +53,9 @@ const (
|
||||||
Http RequestWay = iota + 1
|
Http RequestWay = iota + 1
|
||||||
Rpc
|
Rpc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const financeUrl = "https://financeouter.22233.cn"
|
||||||
|
|
||||||
|
const (
|
||||||
|
financeBanks = "/outer/v1/dingtalk/payment/banks"
|
||||||
|
)
|
||||||
|
|
7
go.mod
7
go.mod
|
@ -1,10 +1,14 @@
|
||||||
module gitea.cdlsxd.cn/self-tools/l_msg_api
|
module gitea.cdlsxd.cn/self-tools/l_msg_api
|
||||||
|
|
||||||
go 1.22.2
|
go 1.22.10
|
||||||
|
|
||||||
|
toolchain go1.23.6
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
gitea.cdlsxd.cn/rzy_tools/request v1.0.0
|
||||||
github.com/valyala/fasthttp v1.59.0
|
github.com/valyala/fasthttp v1.59.0
|
||||||
google.golang.org/grpc v1.71.1
|
google.golang.org/grpc v1.71.1
|
||||||
|
google.golang.org/protobuf v1.36.4
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
@ -12,7 +16,6 @@ require (
|
||||||
golang.org/x/sys v0.30.0 // indirect
|
golang.org/x/sys v0.30.0 // indirect
|
||||||
golang.org/x/text v0.22.0 // indirect
|
golang.org/x/text v0.22.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
||||||
google.golang.org/protobuf v1.36.4 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
26
msg.go
26
msg.go
|
@ -4,6 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"gitea.cdlsxd.cn/rzy_tools/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageCenter struct {
|
type MessageCenter struct {
|
||||||
|
@ -126,3 +128,27 @@ func (m *MessageCenter) OAComment(ctx context.Context, outTradeNo, text, comment
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OAComment OA评论,CommentUserId为空则默认审核发起人评论
|
||||||
|
func (m *MessageCenter) FinanceBankList(ctx context.Context, financeBank *FinanceBank, page uint32, pageSize uint32) (data FinanceBankResp, err error) {
|
||||||
|
|
||||||
|
res, err := m.OtherSend(ctx, &request.Request{
|
||||||
|
Method: "GET",
|
||||||
|
Url: fmt.Sprintf("%s%s", financeUrl, financeBanks),
|
||||||
|
Params: mapInterfaceToMapString(structToMap(financeBankRequest{
|
||||||
|
Keyword: financeBank.Keyword,
|
||||||
|
BankName: financeBank.BankName,
|
||||||
|
Province: financeBank.Province,
|
||||||
|
City: financeBank.City,
|
||||||
|
Code: financeBank.Code,
|
||||||
|
Page: page,
|
||||||
|
PageSize: pageSize,
|
||||||
|
IsDesc: financeBank.IsDesc,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(res.Content, &data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
70
paramset.go
70
paramset.go
|
@ -4,8 +4,10 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"gitea.cdlsxd.cn/rzy_tools/request"
|
||||||
"gitea.cdlsxd.cn/self-tools/l_msg_api/cache"
|
"gitea.cdlsxd.cn/self-tools/l_msg_api/cache"
|
||||||
"gitea.cdlsxd.cn/self-tools/l_msg_api/httpclient"
|
"gitea.cdlsxd.cn/self-tools/l_msg_api/httpclient"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -98,6 +100,11 @@ func (m *MessageCenter) post(ctx context.Context, path string, data []byte, resR
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MessageCenter) OtherSend(ctx context.Context, request *request.Request) (res request.Response, err error) {
|
||||||
|
res, err = request.Send()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MessageCenter) accessPost(path requestPathIndex, data []byte, resReflect interface{}) (err error) {
|
func (m *MessageCenter) accessPost(path requestPathIndex, data []byte, resReflect interface{}) (err error) {
|
||||||
pathStr := requestPath[path][Http]
|
pathStr := requestPath[path][Http]
|
||||||
var body responseBody
|
var body responseBody
|
||||||
|
@ -132,3 +139,66 @@ func (m *MessageCenter) setHeader() (err error) {
|
||||||
m.header = map[string]string{"Authorization": token, "content-type": "application/json; charset=utf-8"}
|
m.header = map[string]string{"Authorization": token, "content-type": "application/json; charset=utf-8"}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StructToMap 将一个struct转换为map[string]interface{}
|
||||||
|
func structToMap(obj interface{}) map[string]interface{} {
|
||||||
|
// 获取obj的类型
|
||||||
|
val := reflect.ValueOf(obj)
|
||||||
|
if val.Kind() == reflect.Ptr {
|
||||||
|
val = val.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保obj是一个struct
|
||||||
|
if val.Kind() != reflect.Struct {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个map来保存结果
|
||||||
|
data := make(map[string]interface{})
|
||||||
|
|
||||||
|
// 遍历struct的字段
|
||||||
|
for i := 0; i < val.NumField(); i++ {
|
||||||
|
// 获取字段的类型和值
|
||||||
|
valueField := val.Field(i)
|
||||||
|
typeField := val.Type().Field(i)
|
||||||
|
jsonTag := typeField.Tag.Get("json")
|
||||||
|
if idx := strings.Index(jsonTag, ","); idx != -1 {
|
||||||
|
// 如果有逗号,则取逗号之前的部分
|
||||||
|
jsonTag = jsonTag[:idx]
|
||||||
|
}
|
||||||
|
// 忽略未导出的字段(字段名首字母小写)
|
||||||
|
if !typeField.IsExported() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将字段名和值添加到map中
|
||||||
|
data[jsonTag] = valueField.Interface()
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapInterfaceToMapString map[string]interface{} to map[string]string
|
||||||
|
func mapInterfaceToMapString(inputMap map[string]interface{}) map[string]string {
|
||||||
|
var mapString = make(map[string]string)
|
||||||
|
for key, value := range inputMap {
|
||||||
|
mapString[key] = fmt.Sprintf("%v", value)
|
||||||
|
}
|
||||||
|
return mapString
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChunkSlice 将一个切片分割成多个子切片,每个子切片最多包含 maxSize 个元素
|
||||||
|
func ChunkSlice[T any](slice []T, maxSize int) [][]T {
|
||||||
|
var chunks [][]T
|
||||||
|
length := len(slice)
|
||||||
|
|
||||||
|
for i := 0; i < length; i += maxSize {
|
||||||
|
end := i + maxSize
|
||||||
|
if end > length {
|
||||||
|
end = length
|
||||||
|
}
|
||||||
|
chunks = append(chunks, slice[i:end])
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks
|
||||||
|
}
|
||||||
|
|
|
@ -82,3 +82,15 @@ func TestContext(*testing.T) {
|
||||||
c := context.Background()
|
c := context.Background()
|
||||||
c.Done()
|
c.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFinanceBankList(t *testing.T) {
|
||||||
|
c := context.Background()
|
||||||
|
msg, err := l_msg_api.NewMessageCenter(serverHost, ClientKey, ClientSecret, "sw_oa", "sw_oa_purchase")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
res, err := msg.FinanceBankList(c, &l_msg_api.FinanceBank{
|
||||||
|
Keyword: "招商",
|
||||||
|
}, 1, 50)
|
||||||
|
t.Log(res, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue