client_test.go 1.9 KB
package k3cloud

import (
	"testing"
)

var (
	acctID = "20211118121754866"
	// username = "Administrator"
	// password = "stxcs@888"
	username = "18559023318"
	password = "stx@123456"
	hostUrl  = "https://tianlian.test.ik3cloud.com/k3cloud"
)

func TestLogin(t *testing.T) {
	client := Client{HttpClient{HostUrl: hostUrl}}
	result, err := client.Login(acctID, username, password)
	if err != nil {
		t.Error(err)
	}
	t.Logf("%+v \n", *result)
}

func TestExecuteBillQuery(t *testing.T) {
	client, err := NewClient(hostUrl, acctID, username, password)
	if err != nil {
		t.Error(err)
		return
	}
	//参见 物料元数据
	// _ = [][2]string{{"FMATERIALID", "表主键"}, {"FDocumentStatus", "数据状态"}, {"FForbidStatus", "禁用状态"}, {"FName", "名称"}, {"FNumber", "编码"}, {"FDescription", "描述"},
	// 	{"FCreateDate", "创建日期"}, {"FModifyDate", "修改日期"}, {"FMnemonicCode", "助记码"}, {"FSpecification", "规格型号"}, {"FForbidDate", "禁用日期"},
	// 	{"FApproveDate", "审核日期"}, {"FOldNumber", "旧物料编码"}, {"FMaterialGroup", "物料分组"}, {"FPLMMaterialId", "PLM物料内码"}, {"FMaterialSRC", "物料来源"},
	// 	{"FIsSalseByNet", "是否网销"}, {"FIsAutoAllocate", "自动分配"}, {"FSPUID", "SPU信息"}, {"FPinYin", "拼音"}, {"FDSMatchByLot", "按批号匹配供需"},
	// 	{"FForbidReson", "禁用原因"}, {"FRefStatus", "已使用"}}
	result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{
		FormId: "BD_MATERIAL",
		Data: ExecuteBillQueryData{
			FormId:       "BD_MATERIAL",
			FieldKeys:    "FMATERIALID,FSpecification,FName,FNumber,FModifyDate,FBaseUnitId.FName,FUseOrgId.FName", //查询的字段
			TopRowCount:  5,
			FilterString: `FMaterialGroup.FNumber like '05%' and FModifyDate<'2022-01-08T19:36:06'`,
		},
	})
	t.Logf("result buf===> %s \n", string(result.Buf))
	if err != nil {
		t.Error(err)
		return
	}
	// t.Logf("tomap===>%v \n", result.ToMapString())
}