commented utms methods
This commit is contained in:
parent
b898091905
commit
6bd772ee23
36
model/amo.go
36
model/amo.go
@ -141,7 +141,7 @@ type Rule struct {
|
||||
/* - айдишник этапа*/
|
||||
Stepid int32 `json:"StepID"`
|
||||
/* - список UTM для этого опроса*/
|
||||
Utms []int32 `json:"UTMs"`
|
||||
//Utms []int32 `json:"UTMs"`
|
||||
/* - правила заполнения полей сущностей в амо*/
|
||||
Fieldsrule Fieldsrule `json:"FieldsRule"`
|
||||
/* - флаг мягкого удаления*/
|
||||
@ -197,22 +197,22 @@ const (
|
||||
TypeContactAddress ContactQuizConfig = "address"
|
||||
)
|
||||
|
||||
type UTM struct {
|
||||
/* - айдишник в нашей системе Primary Key*/
|
||||
ID int64 `json:"ID"`
|
||||
/* - айдишник кастомного поля в амо*/
|
||||
Amofieldid int32 `json:"AmoFieldID"`
|
||||
/* - айдишник квиза*/
|
||||
Quizid int32 `json:"QuizID"`
|
||||
/* - связь с аккаунтом в интеграции амо id амо*/
|
||||
Accountid int32 `json:"AccountID"`
|
||||
/* - название тега в амо*/
|
||||
Name string `json:"Name"`
|
||||
/* - флаг мягкого удаления*/
|
||||
Deleted bool `json:"Deleted"`
|
||||
/* - таймштамп создания тега в нашей системе*/
|
||||
Createdat int64 `json:"CreatedAt"`
|
||||
}
|
||||
//type UTM struct {
|
||||
// /* - айдишник в нашей системе Primary Key*/
|
||||
// ID int64 `json:"ID"`
|
||||
// /* - айдишник кастомного поля в амо*/
|
||||
// Amofieldid int32 `json:"AmoFieldID"`
|
||||
// /* - айдишник квиза*/
|
||||
// Quizid int32 `json:"QuizID"`
|
||||
// /* - связь с аккаунтом в интеграции амо id амо*/
|
||||
// Accountid int32 `json:"AccountID"`
|
||||
// /* - название тега в амо*/
|
||||
// Name string `json:"Name"`
|
||||
// /* - флаг мягкого удаления*/
|
||||
// Deleted bool `json:"Deleted"`
|
||||
// /* - таймштамп создания тега в нашей системе*/
|
||||
// Createdat int64 `json:"CreatedAt"`
|
||||
//}
|
||||
|
||||
type FieldType string
|
||||
|
||||
@ -268,7 +268,7 @@ type AmoUsersTrueResults struct {
|
||||
Session string
|
||||
AccessToken string
|
||||
AmoAccountID int32
|
||||
UTMs []int32
|
||||
UTMs UTMSavingMap
|
||||
FieldsRule Fieldsrule
|
||||
PerformerID int32
|
||||
StepID int32
|
||||
|
@ -13,14 +13,14 @@ type PaginationReq struct {
|
||||
}
|
||||
|
||||
type RulesReq struct {
|
||||
PerformerID int32 // айдишник ответственного за сделку
|
||||
PipelineID int32 // айдишник воронки
|
||||
StepID int32 // айдишник этапа
|
||||
Utms []int32 // список UTM для этого опроса
|
||||
Fieldsrule Fieldsrule // правила заполнения полей сущностей в амо
|
||||
PerformerID int32 // айдишник ответственного за сделку
|
||||
PipelineID int32 // айдишник воронки
|
||||
StepID int32 // айдишник этапа
|
||||
//Utms []int32 // список UTM для этого опроса
|
||||
Fieldsrule Fieldsrule // правила заполнения полей сущностей в амо
|
||||
}
|
||||
|
||||
type SaveUserListUTMReq struct {
|
||||
/* - список utm для сохранения. сохранять только те, которых в этом аккаунте ещё нет*/
|
||||
Utms []UTM `json:"utms"`
|
||||
}
|
||||
//type SaveUserListUTMReq struct {
|
||||
// /* - список utm для сохранения. сохранять только те, которых в этом аккаунте ещё нет*/
|
||||
// Utms []UTM `json:"utms"`
|
||||
//}
|
||||
|
@ -24,12 +24,12 @@ type GetCurrentAccountResp struct {
|
||||
Createdat int64 `json:"CreatedAt"`
|
||||
}
|
||||
|
||||
type GetListUserUTMResp struct {
|
||||
/* - общее количество юзеров, которые у нас закешированы для этого пользователя*/
|
||||
Count int64 `json:"count"`
|
||||
/* - список юзеров, которые были закешированы нашим сервисом*/
|
||||
Items []UTM `json:"items"`
|
||||
}
|
||||
//type GetListUserUTMResp struct {
|
||||
// /* - общее количество юзеров, которые у нас закешированы для этого пользователя*/
|
||||
// Count int64 `json:"count"`
|
||||
// /* - список юзеров, которые были закешированы нашим сервисом*/
|
||||
// Items []UTM `json:"items"`
|
||||
//}
|
||||
|
||||
type ListSavedIDUTMResp struct {
|
||||
/* - список айдишников сохранённых меток*/
|
||||
|
@ -899,110 +899,109 @@ func (r *AmoRepository) DeletingUserUtm(ctx context.Context, request *model.List
|
||||
}
|
||||
|
||||
// todo нужно ли тут ограничивать индексом что то
|
||||
func (r *AmoRepository) SavingUserUtm(ctx context.Context, utms []model.UTM, accountID string) (*model.ListSavedIDUTMResp, error) {
|
||||
//column2, err := json.Marshal(utms)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//rows, err := r.queries.SaveUTMs(ctx, sqlcgen.SaveUTMsParams{
|
||||
// Accountid: accountID,
|
||||
// Column2: column2,
|
||||
//})
|
||||
//
|
||||
//var ids []int64
|
||||
//
|
||||
//for _, row := range rows {
|
||||
// ids = append(ids, row.ID)
|
||||
//}
|
||||
//
|
||||
//return &model.ListSavedIDUTMResp{
|
||||
// Ids: ids,
|
||||
//}, nil
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) GettingUserUtm(ctx context.Context, request *model.PaginationReq, accountID string, quizID int) (*model.GetListUserUTMResp, error) {
|
||||
//rows, err := r.queries.GetUTMsWithPagination(ctx, sqlcgen.GetUTMsWithPaginationParams{
|
||||
// Accountid: accountID,
|
||||
// Column2: request.Page,
|
||||
// Limit: request.Size,
|
||||
// Quizid: int32(quizID),
|
||||
//})
|
||||
//
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//
|
||||
//var count int64
|
||||
//var utmS []model.UTM
|
||||
//
|
||||
//for _, row := range rows {
|
||||
// count = row.TotalCount
|
||||
// utm := model.UTM{
|
||||
// ID: row.ID,
|
||||
// Amofieldid: row.Amofieldid,
|
||||
// Quizid: row.Quizid,
|
||||
// Accountid: row.Accountid,
|
||||
// Name: row.Name,
|
||||
// Deleted: row.Deleted,
|
||||
// Createdat: row.Createdat.Time.Unix(),
|
||||
// }
|
||||
//
|
||||
// utmS = append(utmS, utm)
|
||||
//}
|
||||
//
|
||||
//return &model.GetListUserUTMResp{
|
||||
// Count: count,
|
||||
// Items: utmS,
|
||||
//}, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) GetUtmsByID(ctx context.Context, ids []int32) ([]model.UTM, error) {
|
||||
//rows, err := r.queries.GetUtmsByID(ctx, ids)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//
|
||||
//var utmS []model.UTM
|
||||
//for _, row := range rows {
|
||||
// utm := model.UTM{
|
||||
// ID: row.ID,
|
||||
// Amofieldid: row.Amofieldid,
|
||||
// Quizid: row.Quizid,
|
||||
// Accountid: row.Accountid,
|
||||
// Name: row.Name,
|
||||
// }
|
||||
//
|
||||
// utmS = append(utmS, utm)
|
||||
//}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) UpdateUTMs(ctx context.Context, utms []model.UTM) error {
|
||||
//dollar1, err := json.Marshal(utms)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//err = r.queries.UpdateUtms(ctx, dollar1)
|
||||
//
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) UpdateUtmsFields(ctx context.Context, ids []int32) error {
|
||||
//err := r.queries.UpdateUtmsFields(ctx, ids)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
return nil
|
||||
}
|
||||
//func (r *AmoRepository) SavingUserUtm(ctx context.Context, utms []model.UTM, accountID string) (*model.ListSavedIDUTMResp, error) {
|
||||
// column2, err := json.Marshal(utms)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// rows, err := r.queries.SaveUTMs(ctx, sqlcgen.SaveUTMsParams{
|
||||
// Accountid: accountID,
|
||||
// Column2: column2,
|
||||
// })
|
||||
//
|
||||
// var ids []int64
|
||||
//
|
||||
// for _, row := range rows {
|
||||
// ids = append(ids, row.ID)
|
||||
// }
|
||||
//
|
||||
// return &model.ListSavedIDUTMResp{
|
||||
// Ids: ids,
|
||||
// }, nil
|
||||
//
|
||||
// return nil, nil
|
||||
//}
|
||||
//
|
||||
//func (r *AmoRepository) GettingUserUtm(ctx context.Context, request *model.PaginationReq, accountID string, quizID int) (*model.GetListUserUTMResp, error) {
|
||||
// rows, err := r.queries.GetUTMsWithPagination(ctx, sqlcgen.GetUTMsWithPaginationParams{
|
||||
// Accountid: accountID,
|
||||
// Column2: request.Page,
|
||||
// Limit: request.Size,
|
||||
// Quizid: int32(quizID),
|
||||
// })
|
||||
//
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// var count int64
|
||||
// var utmS []model.UTM
|
||||
//
|
||||
// for _, row := range rows {
|
||||
// count = row.TotalCount
|
||||
// utm := model.UTM{
|
||||
// ID: row.ID,
|
||||
// Amofieldid: row.Amofieldid,
|
||||
// Quizid: row.Quizid,
|
||||
// Accountid: row.Accountid,
|
||||
// Name: row.Name,
|
||||
// Deleted: row.Deleted,
|
||||
// Createdat: row.Createdat.Time.Unix(),
|
||||
// }
|
||||
//
|
||||
// utmS = append(utmS, utm)
|
||||
// }
|
||||
//
|
||||
// return &model.GetListUserUTMResp{
|
||||
// Count: count,
|
||||
// Items: utmS,
|
||||
// }, nil
|
||||
//}
|
||||
//
|
||||
//func (r *AmoRepository) GetUtmsByID(ctx context.Context, ids []int32) ([]model.UTM, error) {
|
||||
// rows, err := r.queries.GetUtmsByID(ctx, ids)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// var utmS []model.UTM
|
||||
// for _, row := range rows {
|
||||
// utm := model.UTM{
|
||||
// ID: row.ID,
|
||||
// Amofieldid: row.Amofieldid,
|
||||
// Quizid: row.Quizid,
|
||||
// Accountid: row.Accountid,
|
||||
// Name: row.Name,
|
||||
// }
|
||||
//
|
||||
// utmS = append(utmS, utm)
|
||||
// }
|
||||
//
|
||||
// return utmS, nil
|
||||
//}
|
||||
//
|
||||
//func (r *AmoRepository) UpdateUTMs(ctx context.Context, utms []model.UTM) error {
|
||||
// dollar1, err := json.Marshal(utms)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// err = r.queries.UpdateUtms(ctx, dollar1)
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// return nil
|
||||
//}
|
||||
//
|
||||
//func (r *AmoRepository) UpdateUtmsFields(ctx context.Context, ids []int32) error {
|
||||
// err := r.queries.UpdateUtmsFields(ctx, ids)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// return nil
|
||||
//}
|
||||
|
||||
func (r *AmoRepository) GettingAmoUsersTrueResults(ctx context.Context) ([]model.AmoUsersTrueResults, error) {
|
||||
rows, err := r.queries.GettingAmoUsersTrueResults(ctx)
|
||||
@ -1018,16 +1017,23 @@ func (r *AmoRepository) GettingAmoUsersTrueResults(ctx context.Context) ([]model
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var utm model.UTMSavingMap
|
||||
err = json.Unmarshal(row.Utm, &utm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := model.AmoUsersTrueResults{
|
||||
QuizID: row.QuizID,
|
||||
AnswerID: row.ID,
|
||||
Result: row.Result.Bool,
|
||||
QuestionID: row.QuestionID,
|
||||
Content: row.Content.String,
|
||||
Session: row.Session.String,
|
||||
AccessToken: row.Accesstoken,
|
||||
AmoAccountID: row.Accountid,
|
||||
//UTMs: row.Utms,
|
||||
QuizID: row.QuizID,
|
||||
AnswerID: row.ID,
|
||||
Result: row.Result.Bool,
|
||||
QuestionID: row.QuestionID,
|
||||
Content: row.Content.String,
|
||||
Session: row.Session.String,
|
||||
AccessToken: row.Accesstoken,
|
||||
AmoAccountID: row.Accountid,
|
||||
UTMs: utm,
|
||||
FieldsRule: fieldsRule,
|
||||
PerformerID: row.Performerid,
|
||||
StepID: row.Stepid,
|
||||
|
Loading…
Reference in New Issue
Block a user