From b0609e3ff182ebba58c994bfa7d49453faf3c4f8 Mon Sep 17 00:00:00 2001 From: yehongyang Date: Mon, 22 Nov 2021 17:59:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=91=E8=9D=B6=E4=BA=91utils=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 8 +- utils/k3cloud.go | 77 +++++++++++ utils/k3cloud/base/const.go | 17 +++ utils/k3cloud/base/curl.go | 125 ++++++++++++++++++ utils/k3cloud/base/postdata.go | 26 ++++ utils/k3cloud/base/util.go | 46 +++++++ utils/k3cloud/fill/rootFill.go | 33 +++++ .../fill/voucher/save/fDetailIDFill.go | 113 ++++++++++++++++ .../k3cloud/fill/voucher/save/fEntityFill.go | 97 ++++++++++++++ utils/k3cloud/fill/voucher/save/modelFill.go | 60 +++++++++ utils/k3cloud/service/voucher.go | 34 +++++ utils/k3cloud/struct/commonStruct.go | 9 ++ .../struct/response/responseToStruct.go | 62 +++++++++ utils/k3cloud/struct/rootStruct.go | 16 +++ .../struct/voucher/saveVoucherStruct.go | 59 +++++++++ 15 files changed, 781 insertions(+), 1 deletion(-) create mode 100644 utils/k3cloud.go create mode 100644 utils/k3cloud/base/const.go create mode 100644 utils/k3cloud/base/curl.go create mode 100644 utils/k3cloud/base/postdata.go create mode 100644 utils/k3cloud/base/util.go create mode 100644 utils/k3cloud/fill/rootFill.go create mode 100644 utils/k3cloud/fill/voucher/save/fDetailIDFill.go create mode 100644 utils/k3cloud/fill/voucher/save/fEntityFill.go create mode 100644 utils/k3cloud/fill/voucher/save/modelFill.go create mode 100644 utils/k3cloud/service/voucher.go create mode 100644 utils/k3cloud/struct/commonStruct.go create mode 100644 utils/k3cloud/struct/response/responseToStruct.go create mode 100644 utils/k3cloud/struct/rootStruct.go create mode 100644 utils/k3cloud/struct/voucher/saveVoucherStruct.go diff --git a/main.go b/main.go index eec66e3..8e0bd5e 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,8 @@ import ( "leit.com/LAPP_CHEERSSON_BACKEND/db" "leit.com/LAPP_CHEERSSON_BACKEND/infra/logger" "leit.com/LAPP_CHEERSSON_BACKEND/utils" + utilService "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/service" + _struct "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/struct" "leit.com/LAPP_CHEERSSON_BACKEND/web/middleware/glog" "leit.com/LAPP_CHEERSSON_BACKEND/web/routes" "log" @@ -112,7 +114,11 @@ func imain() { } //加载配置 conf.AppOtherParse() - + //加载金蝶云系统 + utils.K3configInit() + //测试 + var root11 _struct.Root + utilService.VoucherInit().GetVoucher(root11) app := iris.New() //注册中间件 //conf.PreSettring(app) diff --git a/utils/k3cloud.go b/utils/k3cloud.go new file mode 100644 index 0000000..893c2a3 --- /dev/null +++ b/utils/k3cloud.go @@ -0,0 +1,77 @@ +package utils + +import ( + "fmt" + util "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/base" + "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/struct/response" +) + +type K3config struct { + CloudUrl string `json:"cloudUrl"` // 地址 + AcctID string `json:"acctID"` //Id + Username string `json:"username"` + Password string `json:"password"` + LcID int `json:"lcid"` + session *util.Browser + K3Response response.K3ResponseStruct +} + +var K3Obj *K3config + +const k3url = "http://101.201.121.115/K3Cloud/" +const accID = "6197725c05f1f6" +const username = "Administrator" +const password = "q1w2e3r4!@#$" + +// 初始化 +func K3configInit() { + k3config := &K3config{} + k3config.CloudUrl = k3url + k3config.AcctID = accID + k3config.Password = password + k3config.Username = username + k3config.LcID = 2052 + k3config.session = util.NewBrowser() + k3config.Login() + K3Obj = k3config +} + +/** +K3cloud 登录 +*/ +func (k3config *K3config) Login() { + formParams := util.CreateLoginPostData(k3config.AcctID, k3config.Username, k3config.Password, k3config.LcID) + res := k3config.session.PostJson(k3config.CloudUrl+util.LOGIN_API, formParams) + k3Response := response.K3LoginResponseToStruct(res) + if k3Response.LoginResultType == 0 { + panic(k3Response.Message) + } +} + +/** + + */ +func (k3config *K3config) GetSession() *util.Browser { + return k3config.session +} + +/** +k3cloud 打印 +*/ +func (k3config *K3config) Print() { + fmt.Println(k3config.K3Response) +} + +/** +返回接口数据 +*/ +func (k3config *K3config) Get() response.K3ResponseStruct { + return k3config.K3Response +} + +/** +返回API接口数据 +*/ +func (k3config *K3config) GetResponse() response.K3ResponseStruct { + return k3config.K3Response +} diff --git a/utils/k3cloud/base/const.go b/utils/k3cloud/base/const.go new file mode 100644 index 0000000..770ce50 --- /dev/null +++ b/utils/k3cloud/base/const.go @@ -0,0 +1,17 @@ +package util + +const LOGIN_API = "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc" + +const SAVE_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.save.common.kdsvc" + +const BATCHSAVE_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.batchSave.common.kdsvc" + +const VIEW_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.view.common.kdsvc" + +const DRAFT_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.draft.common.kdsvc" + +const DELETE_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.delete.common.kdsvc" + +const GETBILL_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc" + +const QUERYINFO_API = "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.QueryBusinessInfo.common.kdsvc" diff --git a/utils/k3cloud/base/curl.go b/utils/k3cloud/base/curl.go new file mode 100644 index 0000000..62c4848 --- /dev/null +++ b/utils/k3cloud/base/curl.go @@ -0,0 +1,125 @@ +/** +1.可设置代理 +2.可设置 cookie +3.自动保存并应用响应的 cookie +4.自动为重新向的请求添加 cookie +*/ +package util + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +type Browser struct { + cookies []*http.Cookie + client *http.Client +} + +//初始化 +func NewBrowser() *Browser { + hc := &Browser{} + hc.client = &http.Client{} + //为所有重定向的请求增加cookie + hc.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + if len(via) > 0 { + for _, v := range hc.GetCookie() { + req.AddCookie(v) + } + } + return nil + } + return hc +} + +//设置代理地址 +func (self *Browser) SetProxyUrl(proxyUrl string) { + proxy := func(_ *http.Request) (*url.URL, error) { + return url.Parse(proxyUrl) + } + transport := &http.Transport{Proxy: proxy} + self.client.Transport = transport +} + +//设置请求cookie +func (self *Browser) AddCookie(cookies []*http.Cookie) { + self.cookies = append(self.cookies, cookies...) +} + +//获取当前所有的cookie +func (self *Browser) GetCookie() []*http.Cookie { + return self.cookies +} + +//发送Get请求 +func (self *Browser) Get(requestUrl string) ([]byte, int) { + request, _ := http.NewRequest("GET", requestUrl, nil) + self.setRequestCookie(request) + response, _ := self.client.Do(request) + defer response.Body.Close() + + data, _ := ioutil.ReadAll(response.Body) + return data, response.StatusCode +} + +//发送Post请求 +func (self *Browser) Post(requestUrl string, params map[string]string) []byte { + postData := self.encodeParams(params) + request, _ := http.NewRequest("POST", requestUrl, strings.NewReader(postData)) + request.Header.Set("Content-Type", "application/x-www-form-urlencoded") + self.setRequestCookie(request) + + response, _ := self.client.Do(request) + defer response.Body.Close() + + //保存响应的 cookie + respCks := response.Cookies() + self.cookies = append(self.cookies, respCks...) + + data, _ := ioutil.ReadAll(response.Body) + return data +} + +//发送PostJson请求 +func (self *Browser) PostJson(requestUrl string, params map[string]interface{}) []byte { + postData := self.jsonParams(params) + request, _ := http.NewRequest("POST", requestUrl, strings.NewReader(postData)) + request.Header.Set("Content-Type", "application/json") + self.setRequestCookie(request) + + response, err := self.client.Do(request) + fmt.Println(err) + defer response.Body.Close() + + //保存响应的 cookie + respCks := response.Cookies() + self.cookies = append(self.cookies, respCks...) + data, _ := ioutil.ReadAll(response.Body) + return data +} + +//为请求设置 cookie +func (self *Browser) setRequestCookie(request *http.Request) { + for _, v := range self.cookies { + request.AddCookie(v) + } +} + +//参数 encode +func (self *Browser) encodeParams(params map[string]string) string { + paramsData := url.Values{} + for k, v := range params { + paramsData.Set(k, v) + } + return paramsData.Encode() +} + +//参数 json +func (self *Browser) jsonParams(params map[string]interface{}) string { + j, _ := json.Marshal(params) + return string(j) +} diff --git a/utils/k3cloud/base/postdata.go b/utils/k3cloud/base/postdata.go new file mode 100644 index 0000000..6f66fd3 --- /dev/null +++ b/utils/k3cloud/base/postdata.go @@ -0,0 +1,26 @@ +package util + +import "time" + +func CreateLoginPostData(parameters ...interface{}) map[string]interface{} { + var data = make(map[string]interface{}) + var rid = make(map[string]interface{}) + data = map[string]interface{}{ + "format": 1, + "useragent": "ApiClient", + "rid": rid, + "parameters": parameters, + "timestamp": time.Now().Format("2006-01-02"), + "v": "1.0", + } + return data +} + +func CreateBusinessPostData(formId string, parameters interface{}) map[string]interface{} { + var data = make(map[string]interface{}) + data = map[string]interface{}{ + "formid": formId, + "data": parameters, + } + return data +} diff --git a/utils/k3cloud/base/util.go b/utils/k3cloud/base/util.go new file mode 100644 index 0000000..4c344df --- /dev/null +++ b/utils/k3cloud/base/util.go @@ -0,0 +1,46 @@ +package util + +import ( + "encoding/json" + "fmt" + _struct "github.com/athlon18/k3cloud/service/struct" + "reflect" +) + +func FNumber(str string) _struct.FNumber { + fNumber := _struct.FNumber{} + fNumber.FNumber = str + return fNumber +} + +func Struct2Map(obj interface{}) map[string]interface{} { + t := reflect.TypeOf(obj) + v := reflect.ValueOf(obj) + + var data = make(map[string]interface{}) + for i := 0; i < t.NumField(); i++ { + data[t.Field(i).Name] = v.Field(i).Interface() + } + return data +} + +func StructJsonMap(obj interface{}) map[string]interface{} { + t := reflect.TypeOf(obj) + v := reflect.ValueOf(obj) + + var data = make(map[string]interface{}) + for i := 0; i < t.NumField(); i++ { + data[t.Field(i).Tag.Get("json")] = v.Field(i).Interface() + } + return data +} + +func J(obj interface{}) { + bb, _ := json.Marshal(obj) + fmt.Println(string(bb)) +} + +func ToJson(obj interface{}) string { + bb, _ := json.Marshal(obj) + return string(bb) +} diff --git a/utils/k3cloud/fill/rootFill.go b/utils/k3cloud/fill/rootFill.go new file mode 100644 index 0000000..6bffcf3 --- /dev/null +++ b/utils/k3cloud/fill/rootFill.go @@ -0,0 +1,33 @@ +package _fill + +import _struct "github.com/athlon18/k3cloud/service/struct" + +type root struct { + root _struct.Root +} + +func RootInit() *root { + root := &root{} + root.root.NeedUpDateFields = []string{} + root.root.NeedReturnFields = []string{} + root.root.IsDeleteEntry = true + root.root.IsVerifyBaseDataField = false + root.root.IsEntryBatchFill = true + root.root.ValidateFlag = true + root.root.NumberSearch = true + root.root.IsAutoSubmitAndAudit = false + return root +} + +func (this *root) NeedUpDateFields(needUpDateFields ...string) *root { + this.root.NeedUpDateFields = needUpDateFields + return this +} +func (this *root) NeedReturnFields(needReturnFields ...string) *root { + this.root.NeedReturnFields = needReturnFields + return this +} + +func (this *root) Get() _struct.Root { + return this.root +} diff --git a/utils/k3cloud/fill/voucher/save/fDetailIDFill.go b/utils/k3cloud/fill/voucher/save/fDetailIDFill.go new file mode 100644 index 0000000..e21b131 --- /dev/null +++ b/utils/k3cloud/fill/voucher/save/fDetailIDFill.go @@ -0,0 +1,113 @@ +package voucher + +import ( + "github.com/athlon18/k3cloud/service/struct/voucher" + "github.com/athlon18/k3cloud/service/util" +) + +type fDetailID struct { + fDetailID voucher.FDetailID +} + +func FDetailIDInit() *fDetailID { + fDetailID := &fDetailID{} + return fDetailID +} + +func (this *fDetailID) FDETAILIDFFLEX9(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX9 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX10(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX10 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX11(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX11 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF100002(str string) *fDetailID { + this.fDetailID.FDETAILIDFF100002 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF101001(str string) *fDetailID { + this.fDetailID.FDETAILIDFF101001 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF101501(str string) *fDetailID { + this.fDetailID.FDETAILIDFF101501 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX4(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX4 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX12(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX12 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX5(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX5 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX13(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX13 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX6(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX6 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF101002(str string) *fDetailID { + this.fDetailID.FDETAILIDFF101002 = util.FNumber(str) + return this +} +func (this *fDetailID) FDETAILIDFFLEX7(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX7 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF102501(str string) *fDetailID { + this.fDetailID.FDETAILIDFF102501 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFFLEX8(str string) *fDetailID { + this.fDetailID.FDETAILIDFFLEX8 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF103001(str string) *fDetailID { + this.fDetailID.FDETAILIDFF103001 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF102001(str string) *fDetailID { + this.fDetailID.FDETAILIDFF102001 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF100501(str string) *fDetailID { + this.fDetailID.FDETAILIDFF100501 = util.FNumber(str) + return this +} + +func (this *fDetailID) FDETAILIDFF103501(str string) *fDetailID { + this.fDetailID.FDETAILIDFF103501 = util.FNumber(str) + return this +} + +func (this *fDetailID) Get() voucher.FDetailID { + return this.fDetailID +} diff --git a/utils/k3cloud/fill/voucher/save/fEntityFill.go b/utils/k3cloud/fill/voucher/save/fEntityFill.go new file mode 100644 index 0000000..95861c9 --- /dev/null +++ b/utils/k3cloud/fill/voucher/save/fEntityFill.go @@ -0,0 +1,97 @@ +package voucher + +import ( + "github.com/athlon18/k3cloud/service/struct/voucher" + "github.com/athlon18/k3cloud/service/util" +) + +type fEntity struct { + fEntity voucher.FEntity +} + +func FEntityInit() *fEntity { + fEntity := &fEntity{} + return fEntity +} + +func (this *fEntity) FEntryID(str string) *fEntity { + this.fEntity.FEntryID = str + return this +} + +func (this *fEntity) FEXPLANATION(str string) *fEntity { + this.fEntity.FEXPLANATION = str + return this +} + +func (this *fEntity) FACCOUNTID(str string) *fEntity { + this.fEntity.FACCOUNTID = util.FNumber(str) + return this +} + +func (this *fEntity) FCURRENCYID(str string) *fEntity { + this.fEntity.FCURRENCYID = util.FNumber(str) + return this +} + +func (this *fEntity) FEXCHANGERATETYPE(str string) *fEntity { + this.fEntity.FEXCHANGERATETYPE = util.FNumber(str) + return this +} + +func (this *fEntity) FEXCHANGERATE(str string) *fEntity { + this.fEntity.FEXCHANGERATE = str + return this +} + +func (this *fEntity) FUnitID(str string) *fEntity { + this.fEntity.FUnitID = util.FNumber(str) + return this +} + +func (this *fEntity) FPrice(str string) *fEntity { + this.fEntity.FPrice = str + return this +} +func (this *fEntity) FQty(str string) *fEntity { + this.fEntity.FQty = str + return this +} + +func (this *fEntity) FAMOUNTFOR(str string) *fEntity { + this.fEntity.FAMOUNTFOR = str + return this +} +func (this *fEntity) FDEBIT(str string) *fEntity { + this.fEntity.FDEBIT = str + return this +} +func (this *fEntity) FCREDIT(str string) *fEntity { + this.fEntity.FCREDIT = str + return this +} + +func (this *fEntity) FSettleTypeID(str string) *fEntity { + this.fEntity.FSettleTypeID = util.FNumber(str) + return this +} +func (this *fEntity) FSETTLENO(str string) *fEntity { + this.fEntity.FSETTLENO = str + return this +} +func (this *fEntity) FEXPORTENTRYID(str string) *fEntity { + this.fEntity.FEXPORTENTRYID = str + return this +} + +/** +辅助核算 +*/ +func (this *fEntity) FDetailID(str voucher.FDetailID) *fEntity { + this.fEntity.FDetailID = str + return this +} + +func (this *fEntity) Get() voucher.FEntity { + return this.fEntity +} diff --git a/utils/k3cloud/fill/voucher/save/modelFill.go b/utils/k3cloud/fill/voucher/save/modelFill.go new file mode 100644 index 0000000..732771b --- /dev/null +++ b/utils/k3cloud/fill/voucher/save/modelFill.go @@ -0,0 +1,60 @@ +package voucher + +import ( + "github.com/athlon18/k3cloud/service/struct/voucher" + "github.com/athlon18/k3cloud/service/util" +) + +type model struct { + model voucher.Model +} + +func ModelInit() *model { + model := &model{} + model.model.FVOUCHERID = "0" + model.model.FAccountBookID = util.FNumber("") + model.model.FVOUCHERGROUPID = util.FNumber("PRE001") + model.model.FSourceBillKey = util.FNumber("78050206-2fa6-40e3-b7c8-bd608146fa38") + model.model.FVOUCHERGROUPNO = "" + model.model.FDocumentStatus = "Z" + model.model.FISADJUSTVOUCHER = false + return model +} + +func (this *model) FYEAR(str string) *model { + this.model.FYEAR = str + return this +} + +func (this *model) FPERIOD(str string) *model { + this.model.FPERIOD = str + return this +} + +func (this *model) FDate(str string) *model { + this.model.FDate = str + return this +} + +func (this *model) FSourceBillKey(str string) *model { + this.model.FSourceBillKey = util.FNumber(str) + return this +} + +func (this *model) FAccountBookID(str string) *model { + this.model.FAccountBookID = util.FNumber(str) + return this +} + +func (this *model) FVOUCHERGROUPID(str string) *model { + this.model.FVOUCHERGROUPID = util.FNumber(str) + return this +} +func (this *model) FATTACHMENTS(str string) *model { + this.model.FATTACHMENTS = str + return this +} + +func (this *model) Get() voucher.Model { + return this.model +} diff --git a/utils/k3cloud/service/voucher.go b/utils/k3cloud/service/voucher.go new file mode 100644 index 0000000..d4b8dac --- /dev/null +++ b/utils/k3cloud/service/voucher.go @@ -0,0 +1,34 @@ +package service + +import ( + utils2 "leit.com/LAPP_CHEERSSON_BACKEND/utils" + util "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/base" + _struct "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/struct" + "leit.com/LAPP_CHEERSSON_BACKEND/utils/k3cloud/struct/response" +) + +type VoucherService struct { + *utils2.K3config +} + +func VoucherInit() *VoucherService { + voucher := &VoucherService{ + utils2.K3Obj, + } + return voucher +} + +/** +凭证写入 +*/ +func (_this *VoucherService) GetVoucher(root _struct.Root) *VoucherService { + + //root.Model + formParams := util.CreateBusinessPostData("GL_VOUCHER", util.Struct2Map(root)) + res := _this.GetSession().PostJson(_this.CloudUrl+util.SAVE_API, formParams) + _this.K3Response = response.K3ResponseToStruct(res) + if _this.K3Response.Result.ResponseStatus.IsSuccess == false { + panic(_this.K3Response.Result.ResponseStatus.Errors) + } + return _this +} diff --git a/utils/k3cloud/struct/commonStruct.go b/utils/k3cloud/struct/commonStruct.go new file mode 100644 index 0000000..dcd3159 --- /dev/null +++ b/utils/k3cloud/struct/commonStruct.go @@ -0,0 +1,9 @@ +package _struct + +type FNumber struct { + FNumber string `json:"FNumber,omitempty"` +} + +type FUserID struct { + FUserID string `json:"FUserID,omitempty"` +} diff --git a/utils/k3cloud/struct/response/responseToStruct.go b/utils/k3cloud/struct/response/responseToStruct.go new file mode 100644 index 0000000..cc8b940 --- /dev/null +++ b/utils/k3cloud/struct/response/responseToStruct.go @@ -0,0 +1,62 @@ +package response + +import ( + "encoding/json" +) + +type K3LoginResponseStruct struct { + Message string `json:"Message"` + MessageCode string `json:"MessageCode"` + LoginResultType int `json:"LoginResultType"` + Context interface{} `json:"Context"` + KDSVCSessionID string `json:"KDSVCSessionId"` + FormID interface{} `json:"FormId"` + RedirectFormParam interface{} `json:"RedirectFormParam"` + FormInputObject interface{} `json:"FormInputObject"` + ErrorStackTrace interface{} `json:"ErrorStackTrace"` + Lcid int `json:"Lcid"` + AccessToken interface{} `json:"AccessToken"` + KdAccessResult interface{} `json:"KdAccessResult"` + IsSuccessByAPI bool `json:"IsSuccessByAPI"` +} + +type K3ResponseStruct struct { + Result Result `json:"Result"` +} + +type Result struct { + ResponseStatus ResponseStatus `json:"ResponseStatus"` + ID int `json:"Id"` + Number string `json:"Number"` + NeedReturnData []NeedReturnData `json:"NeedReturnData"` +} +type NeedReturnData struct { + FVOUCHERGROUPNO string `json:"FVOUCHERGROUPNO"` + FVOUCHERID string `json:"FVOUCHERID"` +} + +type ResponseStatus struct { + IsSuccess bool `json:"IsSuccess"` + Errors []interface{} `json:"Errors"` + SuccessEntitys []SuccessEntitys `json:"SuccessEntitys"` + SuccessMessages []interface{} `json:"SuccessMessages"` + MsgCode int `json:"MsgCode"` +} + +type SuccessEntitys struct { + ID int `json:"Id"` + Number string `json:"Number"` + DIndex int `json:"DIndex"` +} + +func K3LoginResponseToStruct(data []byte) K3LoginResponseStruct { + var response K3LoginResponseStruct + _ = json.Unmarshal(data, &response) + return response +} + +func K3ResponseToStruct(data []byte) K3ResponseStruct { + var response K3ResponseStruct + _ = json.Unmarshal(data, &response) + return response +} diff --git a/utils/k3cloud/struct/rootStruct.go b/utils/k3cloud/struct/rootStruct.go new file mode 100644 index 0000000..9bccddd --- /dev/null +++ b/utils/k3cloud/struct/rootStruct.go @@ -0,0 +1,16 @@ +package _struct + +type Root struct { + Creator string `json:"Creator"` + NeedUpDateFields interface{} `json:"NeedUpDateFields"` + NeedReturnFields interface{} `json:"NeedReturnFields"` + IsDeleteEntry bool `json:"IsDeleteEntry"` + SubSystemID string `json:"SubSystemId"` + IsVerifyBaseDataField bool `json:"IsVerifyBaseDataField"` + IsEntryBatchFill bool `json:"IsEntryBatchFill"` + ValidateFlag bool `json:"ValidateFlag"` + NumberSearch bool `json:"NumberSearch"` + InterationFlags string `json:"InterationFlags"` + IsAutoSubmitAndAudit bool `json:"IsAutoSubmitAndAudit"` + Model interface{} `json:"Model"` +} diff --git a/utils/k3cloud/struct/voucher/saveVoucherStruct.go b/utils/k3cloud/struct/voucher/saveVoucherStruct.go new file mode 100644 index 0000000..b9ffa01 --- /dev/null +++ b/utils/k3cloud/struct/voucher/saveVoucherStruct.go @@ -0,0 +1,59 @@ +package voucher + +type Model struct { + FVOUCHERID string `json:"FVOUCHERID"` + FAccountBookID interface{} `json:"FAccountBookID"` + FDate string `json:"FDate"` + FVOUCHERGROUPID interface{} `json:"FVOUCHERGROUPID"` + FVOUCHERGROUPNO string `json:"FVOUCHERGROUPNO"` + FATTACHMENTS string `json:"FATTACHMENTS"` + FISADJUSTVOUCHER bool `json:"FISADJUSTVOUCHER"` + FDocumentStatus string `json:"FDocumentStatus"` + FYEAR string `json:"FYEAR"` + FSourceBillKey interface{} `json:"FSourceBillKey"` + FCreatorId interface{} `json:"FCreatorId"` + FPERIOD string `json:"FPERIOD"` + FIMPORTVERSION string `json:"FIMPORTVERSION"` + FEntity []FEntity `json:"FEntity"` +} + +type FEntity struct { + FEntryID string `json:"FEntryID,omitempty"` + FEXPLANATION string `json:"FEXPLANATION,omitempty"` + FACCOUNTID interface{} `json:"FACCOUNTID,omitempty"` + FDetailID interface{} `json:"FDetailID,omitempty"` + FCURRENCYID interface{} `json:"FCURRENCYID,omitempty"` + FEXCHANGERATETYPE interface{} `json:"FEXCHANGERATETYPE,omitempty"` + FEXCHANGERATE string `json:"FEXCHANGERATE,omitempty"` + FUnitID interface{} `json:"FUnitId,omitempty"` + FPrice string `json:"FPrice,omitempty"` + FQty string `json:"FQty,omitempty"` + FAMOUNTFOR string `json:"FAMOUNTFOR,omitempty"` + FDEBIT string `json:"FDEBIT,omitempty"` + FCREDIT string `json:"FCREDIT,omitempty"` + FSettleTypeID interface{} `json:"FSettleTypeID,omitempty"` + FSETTLENO string `json:"FSETTLENO,omitempty"` + FEXPORTENTRYID string `json:"FEXPORTENTRYID,omitempty"` +} + +type FDetailID struct { + FDETAILIDFFLEX9 interface{} `json:"FDETAILID__FFLEX9,omitempty"` + FDETAILIDFFLEX10 interface{} `json:"FDETAILID__FFLEX10,omitempty"` + FDETAILIDFFLEX11 interface{} `json:"FDETAILID__FFLEX11,omitempty"` + FDETAILIDFF100002 interface{} `json:"FDETAILID__FF100002,omitempty"` + FDETAILIDFF101001 interface{} `json:"FDETAILID__FF101001,omitempty"` + FDETAILIDFF101501 interface{} `json:"FDETAILID__FF101501,omitempty"` + FDETAILIDFFLEX4 interface{} `json:"FDETAILID__FFLEX4,omitempty"` + FDETAILIDFFLEX12 interface{} `json:"FDETAILID__FFLEX12,omitempty"` + FDETAILIDFFLEX5 interface{} `json:"FDETAILID__FFLEX5,omitempty"` + FDETAILIDFFLEX13 interface{} `json:"FDETAILID__FFLEX13,omitempty"` + FDETAILIDFFLEX6 interface{} `json:"FDETAILID__FFLEX6,omitempty"` + FDETAILIDFF101002 interface{} `json:"FDETAILID__FF101002,omitempty"` + FDETAILIDFFLEX7 interface{} `json:"FDETAILID__FFLEX7,omitempty"` + FDETAILIDFF102501 interface{} `json:"FDETAILID__FF102501,omitempty"` + FDETAILIDFFLEX8 interface{} `json:"FDETAILID__FFLEX8,omitempty"` + FDETAILIDFF103001 interface{} `json:"FDETAILID__FF103001,omitempty"` + FDETAILIDFF102001 interface{} `json:"FDETAILID__FF102001,omitempty"` + FDETAILIDFF100501 interface{} `json:"FDETAILID__FF100501,omitempty"` + FDETAILIDFF103501 interface{} `json:"FDETAILID__FF103501,omitempty"` +}