From 929366ed0bda3435e03c225f4ff12bb1f47aeb2b Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 12 Dec 2025 17:20:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(ik3cloud):=20=E6=96=B0=E5=A2=9E=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E6=9C=8D=E5=8A=A1=E4=B8=8E=E5=B8=81=E7=A7=8D=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E5=BC=8F=E6=94=B6=E4=BB=98=E6=AC=BE=E7=94=A8?= =?UTF-8?q?=E9=80=94=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 DictItem 结构体定义字段 field1 至 field8 - 实现 dict.All 方法用于获取字典数据 - 添加 BD_Currency、BD_SETTLETYPE 和 CN_RECPAYPURPOSE 常量 - 在 client.go 中为 ik3cloud 服务增加本地调试发现逻辑 --- client/client.go | 15 ++++++++++++--- ik3cloud/constant/constant.go | 3 +++ ik3cloud/dict.go | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 ik3cloud/dict.go diff --git a/client/client.go b/client/client.go index 8b498d4..df6bd10 100644 --- a/client/client.go +++ b/client/client.go @@ -61,9 +61,18 @@ func GetClient(s interface{}) (*RpcClient, error) { mutex.Lock() xClient, ok = mClient.Load(key) if !ok { - d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) - if err != nil { - return nil, errors.New("系统异常") + var d client.ServiceDiscovery + var err error + if basePath == "ik3cloud" { + d, err = client.NewPeer2PeerDiscovery("tcp@localhost:8081", "") + if err != nil { + return nil, errors.New("系统异常") + } + } else { + d, err = consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) + if err != nil { + return nil, errors.New("系统异常") + } } option := client.DefaultOption option.Retries = 3 diff --git a/ik3cloud/constant/constant.go b/ik3cloud/constant/constant.go index fa9afc1..44c0040 100644 --- a/ik3cloud/constant/constant.go +++ b/ik3cloud/constant/constant.go @@ -14,6 +14,9 @@ const ( ActionReceivable Action = "AR_receivable" // 付款单 ActionPayable Action = "AP_Payable" // 付款单 ActionProduct Action = "BD_MATERIAL" // 物料 + ActionCurrency Action = "BD_Currency" // 币种 + ActionSettleType Action = "BD_SETTLETYPE" // 结算方式 + ActionRecPayPurpose Action = "CN_RECPAYPURPOSE" // 收付款用途 ) type OperatorType = string diff --git a/ik3cloud/dict.go b/ik3cloud/dict.go new file mode 100644 index 0000000..aea53a9 --- /dev/null +++ b/ik3cloud/dict.go @@ -0,0 +1,31 @@ +package ik3cloud + +import ( + "context" + + "git.kumo.work/shama/service/client" + "git.kumo.work/shama/service/ik3cloud/constant" +) + +type dict struct { +} +type DictItem struct { + Field1 any `json:"field1"` + Field2 any `json:"field2"` + Field3 any `json:"field3"` + Field4 any `json:"field4"` + Field5 any `json:"field5"` + Field6 any `json:"field6"` + Field7 any `json:"field7"` + Field8 any `json:"field8"` +} + +// All @TITLE 获取字典 +func (d *dict) All(ctx context.Context, companyType constant.Action) (reply []DictItem, err error) { + xClient, err := client.GetClient(d) + if err != nil { + return + } + err = xClient.Call(ctx, "All", companyType, &reply) + return +}