From 772df884b771b91e1428c55c8dd6a32ba5fe9063 Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 26 Sep 2024 15:43:25 +0300 Subject: [PATCH] - --- go.mod | 2 +- go.sum | 2 + internal/models/getListFields.go | 33 +++---- internal/models/getListSteps.go | 6 -- pkg/bitrixClient/bitrix_test.go | 161 ++++++++++++++++--------------- 5 files changed, 100 insertions(+), 104 deletions(-) diff --git a/go.mod b/go.mod index 8592a14..d51bf13 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/lib/pq v1.10.9 github.com/twmb/franz-go v1.17.1 go.uber.org/zap v1.27.0 - penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240926081605-f7dda8704dbf + penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240926124254-355001566829 penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3 ) diff --git a/go.sum b/go.sum index 7ffcd62..eacb067 100644 --- a/go.sum +++ b/go.sum @@ -143,5 +143,7 @@ penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240202120244-c4ef330cfe5d/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240926081605-f7dda8704dbf h1:Tnhg4SypUiQP/s5hd9AE6LQ38mABe070czaa5xjuIu8= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240926081605-f7dda8704dbf/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0= +penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240926124254-355001566829 h1:GZ6cDgC799ds9hVEQXDa4A+ENVyfJDOmPBPydetdZXU= +penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240926124254-355001566829/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0= penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3 h1:sf6e2mp582L3i/FMDd2q6QuWm1njRXzYpIX0SipsvM4= penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3/go.mod h1:i7M72RIpkSjcQtHID6KKj9RT/EYZ1rxS6tIPKWa/BSY= diff --git a/internal/models/getListFields.go b/internal/models/getListFields.go index 924e4d0..33a3c2e 100644 --- a/internal/models/getListFields.go +++ b/internal/models/getListFields.go @@ -12,23 +12,22 @@ type FieldsResponse struct { } type Fields struct { - ID string `json:"ID"` - EntityID model.FieldsType `json:"ENTITY_ID"` - FieldName string `json:"FIELD_NAME"` - UserTypeID string `json:"USER_TYPE_ID"` - XMLID string `json:"XML_ID"` - Sort string `json:"SORT"` - Multiple string `json:"MULTIPLE"` - Mandatory string `json:"MANDATORY"` - ShowFilter string `json:"SHOW_FILTER"` - ShowInList string `json:"SHOW_IN_LIST"` - EditInList string `json:"EDIT_IN_LIST"` - IsSearchable string `json:"IS_SEARCHABLE"` - EditFormLabel string `json:"EDIT_FORM_LABEL"` - ListColumnLabel string `json:"LIST_COLUMN_LABEL"` - ListFilterLabel string `json:"LIST_FILTER_LABEL"` - ErrorMessage string `json:"ERROR_MESSAGE"` - HelpMessage string `json:"HELP_MESSAGE"` + ID string `json:"ID"` + EntityID model.FieldsType `json:"ENTITY_ID"` + FieldName string `json:"FIELD_NAME"` + UserTypeID model.CustomFieldsType `json:"USER_TYPE_ID"` + Sort string `json:"SORT"` + Multiple string `json:"MULTIPLE"` + Mandatory string `json:"MANDATORY"` + ShowFilter string `json:"SHOW_FILTER"` + ShowInList string `json:"SHOW_IN_LIST"` + EditInList string `json:"EDIT_IN_LIST"` + IsSearchable string `json:"IS_SEARCHABLE"` + EditFormLabel string `json:"EDIT_FORM_LABEL"` + ListColumnLabel string `json:"LIST_COLUMN_LABEL"` + ListFilterLabel string `json:"LIST_FILTER_LABEL"` + ErrorMessage string `json:"ERROR_MESSAGE"` + HelpMessage string `json:"HELP_MESSAGE"` } type AddFields struct { diff --git a/internal/models/getListSteps.go b/internal/models/getListSteps.go index d079c74..a2f9e84 100644 --- a/internal/models/getListSteps.go +++ b/internal/models/getListSteps.go @@ -17,10 +17,4 @@ type Steps struct { Color string `json:"COLOR,omitempty"` Semantics string `json:"SEMANTICS,omitempty"` CategoryID string `json:"CATEGORY_ID"` - Extra Extra `json:"EXTRA,omitempty"` -} - -type Extra struct { - Semantics string `json:"SEMANTICS,omitempty"` - Color string `json:"COLOR,omitempty"` } diff --git a/pkg/bitrixClient/bitrix_test.go b/pkg/bitrixClient/bitrix_test.go index 00f398b..4c4eee9 100644 --- a/pkg/bitrixClient/bitrix_test.go +++ b/pkg/bitrixClient/bitrix_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "go.uber.org/zap" + "penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/models" "penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/workers/limiter" "testing" "time" @@ -40,81 +41,81 @@ func TestGetListFields(t *testing.T) { // fmt.Println(result) //} // - //fieldAnswer := make(map[string]string) - //fieldAnswer["UF_CRM_1727099993"] = "field1" - //fieldAnswer["UF_CRM_1727099994"] = "field2" - //fieldAnswer["UF_CRM_1727099994"] = "field3" - //fieldAnswer["UF_CRM_1726835607006"] = "field4" - // - //createContactReq := models.CreateContactReq{ - // Fields: models.ContactFields{ - // Name: "Контакт фром апи", - // SecondName: "SecondName", - // LastName: "LastName", - // Opened: "Y", - // LeadID: 1, - // UtmSource: "UtmSource", - // UtmMedium: "UtmMedium", - // UtmCampaign: "UtmCampaign", - // UtmContent: "UtmContent", - // UtmTerm: "UtmTerm", - // }, - //} - // - //reqMap := models.FormattingToMap(&createContactReq, fieldAnswer) - // - //contactResult, err := b.CreateContact(reqMap, "eb19f5660000071b00717f9200000001000007f6c1795b0c3c995cf4cbbae1a9d0394c", "b24-ld76ub.bitrix24.ru") - //if err != nil { - // fmt.Println(err) - //} - // - //createCompanyReq := models.CompanyReq{ - // Fields: models.CompanyFields{ - // Title: "TEST FORMATTER", - // Opened: "Y", - // LeadID: 1, - // UtmSource: "UtmSource", - // UtmMedium: "UtmMedium", - // UtmCampaign: "UtmCampaign", - // UtmContent: "UtmContent", - // UtmTerm: "UtmTerm", - // ContactID: contactResult, - // }, - //} - // - //reqMap = models.FormattingToMap(&createCompanyReq, fieldAnswer) - //companyResult, err := b.CreateCompany(reqMap, "eb19f5660000071b00717f9200000001000007f6c1795b0c3c995cf4cbbae1a9d0394c", "b24-ld76ub.bitrix24.ru") - //if err != nil { - // fmt.Println(err) - //} - // - //createDealReq := models.CreatingDealReq{ - // Fields: models.CreateDealFields{ - // Title: "ТЕСТ ОТ ГОУ АПИ 10/10", - // TypeID: "SALE", - // StageID: "NEW", - // CompanyID: companyResult, - // ContactIDs: []int32{contactResult}, - // Opened: "Y", - // AssignedByID: 1, - // CategoryID: 5, - // SourceID: "CALL", - // UtmSource: "UtmSource", - // UtmMedium: "UtmMedium", - // UtmCampaign: "UtmCampaign", - // UtmContent: "UtmContent", - // UtmTerm: "UtmTerm", - // }, - //} - // - //reqMap = models.FormattingToMap(&createDealReq, fieldAnswer) - //result, err := b.CreatingDeal(reqMap, "eb19f5660000071b00717f9200000001000007f6c1795b0c3c995cf4cbbae1a9d0394c", "b24-ld76ub.bitrix24.ru") - //if err != nil { - // fmt.Println(err) - //} + fieldAnswer := make(map[string]string) + fieldAnswer["UF_CRM_1727099993"] = "field1" + fieldAnswer["UF_CRM_1727099994"] = "field2" + fieldAnswer["UF_CRM_1727099994"] = "field3" + fieldAnswer["UF_CRM_1726835607006"] = "field4" + + createContactReq := models.CreateContactReq{ + Fields: models.ContactFields{ + Name: "Контакт фром апи", + SecondName: "SecondName", + LastName: "LastName", + Opened: "Y", + LeadID: 1, + UtmSource: "UtmSource", + UtmMedium: "UtmMedium", + UtmCampaign: "UtmCampaign", + UtmContent: "UtmContent", + UtmTerm: "UtmTerm", + }, + } + + reqMap := models.FormattingToMap(&createContactReq, fieldAnswer) + + contactResult, err := b.CreateContact(reqMap, "ad5df5660000071b00717f920000000100000783b6e19c671e64c3655e5c7aff197e14", "b24-ld76ub.bitrix24.ru") + if err != nil { + fmt.Println(err) + } + + createCompanyReq := models.CompanyReq{ + Fields: models.CompanyFields{ + Title: "TEST FORMATTER", + Opened: "Y", + LeadID: 1, + UtmSource: "UtmSource", + UtmMedium: "UtmMedium", + UtmCampaign: "UtmCampaign", + UtmContent: "UtmContent", + UtmTerm: "UtmTerm", + ContactID: contactResult, + }, + } + + reqMap = models.FormattingToMap(&createCompanyReq, fieldAnswer) + companyResult, err := b.CreateCompany(reqMap, "ad5df5660000071b00717f920000000100000783b6e19c671e64c3655e5c7aff197e14", "b24-ld76ub.bitrix24.ru") + if err != nil { + fmt.Println(err) + } + + createDealReq := models.CreatingDealReq{ + Fields: models.CreateDealFields{ + Title: "ТЕСТ ОТ ГОУ АПИ 10/10", + TypeID: "SALE", + StageID: "NEW", + CompanyID: companyResult, + ContactIDs: []int32{contactResult}, + Opened: "Y", + AssignedByID: 1, + CategoryID: 1, + SourceID: "CALL", + UtmSource: "UtmSource", + UtmMedium: "UtmMedium", + UtmCampaign: "UtmCampaign", + UtmContent: "UtmContent", + UtmTerm: "UtmTerm", + }, + } + + reqMap = models.FormattingToMap(&createDealReq, fieldAnswer) + result, err := b.CreatingDeal(reqMap, "ad5df5660000071b00717f920000000100000783b6e19c671e64c3655e5c7aff197e14", "b24-ld76ub.bitrix24.ru") + if err != nil { + fmt.Println(err) + } // //for _, tipe := range model.CategoryArr { - // result, err := b.GetListPipelines(tipe, "eb19f5660000071b00717f9200000001000007f6c1795b0c3c995cf4cbbae1a9d0394c", "b24-ld76ub.bitrix24.ru") + // result, err := b.GetListPipelines(tipe, "734ff5660000071b00717f9200000001000007e5dc2d31e224105aa808dcb596e057b0", "b24-ld76ub.bitrix24.ru") // if err != nil { // fmt.Println(err) // } @@ -124,7 +125,7 @@ func TestGetListFields(t *testing.T) { //} // //for _, tipe := range arr { - // result, err := b.GetListFields(tipe, "eb19f5660000071b00717f9200000001000007f6c1795b0c3c995cf4cbbae1a9d0394c", "b24-ld76ub.bitrix24.ru") + // result, err := b.GetListFields(tipe, "ad5df5660000071b00717f920000000100000783b6e19c671e64c3655e5c7aff197e14", "b24-ld76ub.bitrix24.ru") // if err != nil { // fmt.Println(err) // } @@ -134,12 +135,12 @@ func TestGetListFields(t *testing.T) { // fmt.Println(tipe) //} - result, err := b.GetUserList("f72df5660000071b00717f9200000001000007f76aef6d167ba810e1f10b38ccfef91b", "b24-ld76ub.bitrix24.ru") - if err != nil { - fmt.Println(err) - } - + //result, err := b.GetListSteps(model.DealStageStepsEntityID, "734ff5660000071b00717f9200000001000007e5dc2d31e224105aa808dcb596e057b0", "b24-ld76ub.bitrix24.ru") + //if err != nil { + // fmt.Println(err) + //} + // r, _ := json.Marshal(result) fmt.Println(string(r)) - + //"CATEGORY_ID":"1" }