66 lines
2.3 KiB
Go
66 lines
2.3 KiB
Go
package models
|
|
|
|
import (
|
|
"github.com/rs/xid"
|
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
|
"strings"
|
|
)
|
|
|
|
type FieldsResponse struct {
|
|
Result []Fields `json:"result"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
type Fields struct {
|
|
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 {
|
|
FieldName string `json:"FIELD_NAME"`
|
|
EditFormLabel string `json:"EDIT_FORM_LABEL"`
|
|
ListColumnLabel string `json:"LIST_COLUMN_LABEL"`
|
|
UserTypeID model.CustomFieldsType `json:"USER_TYPE_ID"` // Тип поля
|
|
XMLID string `json:"XML_ID"`
|
|
Settings map[string]interface{} `json:"SETTINGS"`
|
|
Mandatory string `json:"MANDATORY"`
|
|
}
|
|
|
|
func (a *AddFields) GenFieldName() {
|
|
guid := xid.New()
|
|
guidGen := guid.String()
|
|
// todo и так и так работает обдумать стоит
|
|
// https://dev.1c-bitrix.ru/rest_help/crm/cdeals/crm_deal_userfield_add.php
|
|
//a.FieldName = guidGen[:13]
|
|
//a.XMLID = guidGen[:13]
|
|
|
|
a.FieldName = strings.ToUpper(guidGen)
|
|
a.XMLID = strings.ToUpper(guidGen)
|
|
a.Mandatory = "Y"
|
|
}
|
|
|
|
type FileField struct {
|
|
FileData []string `json:"fileData"`
|
|
}
|
|
|
|
type UserFieldTypeAddReq struct {
|
|
UserTypeID string `json:"USER_TYPE_ID"`
|
|
Handler string `json:"HANDLER"`
|
|
Title string `json:"TITLE"`
|
|
Description string `json:"DESCRIPTION"`
|
|
}
|