57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
|
package tools
|
||
|
|
||
|
import (
|
||
|
"penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/models"
|
||
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func ToPipeline(bitrixPipelines []models.Category, bitrixID string) []model.PipelineBitrix {
|
||
|
var pipelines []model.PipelineBitrix
|
||
|
for _, p := range bitrixPipelines {
|
||
|
pipelines = append(pipelines, model.PipelineBitrix{
|
||
|
BitrixID: p.ID,
|
||
|
Name: p.Name,
|
||
|
EntityTypeId: p.EntityTypeId,
|
||
|
AccountID: bitrixID,
|
||
|
})
|
||
|
}
|
||
|
return pipelines
|
||
|
}
|
||
|
|
||
|
func ToStep(bitrixPipelines []models.Steps, bitrixID string) ([]model.StepBitrix, error) {
|
||
|
var pipelines []model.StepBitrix
|
||
|
for _, p := range bitrixPipelines {
|
||
|
pipelineID, err := strconv.ParseInt(p.ID, 10, 64)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
pipelines = append(pipelines, model.StepBitrix{
|
||
|
BitrixID: p.ID,
|
||
|
AccountID: bitrixID,
|
||
|
EntityID: p.EntityID,
|
||
|
StatusID: p.StatusID,
|
||
|
Name: p.Name,
|
||
|
NameInit: p.NameInit,
|
||
|
Color: p.Color,
|
||
|
PipelineID: int32(pipelineID),
|
||
|
})
|
||
|
}
|
||
|
return pipelines, nil
|
||
|
}
|
||
|
|
||
|
func ToField(bitrixFields []models.Fields, bitrixID string) []model.BitrixField {
|
||
|
var fields []model.BitrixField
|
||
|
for _, f := range bitrixFields {
|
||
|
fields = append(fields, model.BitrixField{
|
||
|
AccountID: bitrixID,
|
||
|
BitrixID: f.ID,
|
||
|
EntityID: f.EntityID,
|
||
|
FieldName: f.FieldName,
|
||
|
EditFromLabel: f.EditFormLabel,
|
||
|
FieldType: f.UserTypeID,
|
||
|
})
|
||
|
}
|
||
|
return fields
|
||
|
}
|