2024-04-17 09:30:19 +00:00
|
|
|
package amo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
2024-04-17 17:42:13 +00:00
|
|
|
"encoding/json"
|
2024-04-17 09:30:19 +00:00
|
|
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal/sqlcgen"
|
|
|
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AmoRepository struct {
|
|
|
|
queries *sqlcgen.Queries
|
|
|
|
pool *sql.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
type Deps struct {
|
|
|
|
Queries *sqlcgen.Queries
|
|
|
|
Pool *sql.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewAmoRepository(deps Deps) *AmoRepository {
|
|
|
|
return &AmoRepository{
|
|
|
|
queries: deps.Queries,
|
|
|
|
pool: deps.Pool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы пользователя
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateListUsers(ctx context.Context) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-17 17:42:13 +00:00
|
|
|
func (r *AmoRepository) GettingUserWithPagination(ctx context.Context, req *model.PaginationReq) (*model.UserListResp, error) {
|
|
|
|
rows, err := r.queries.GetUsersWithPagination(ctx, sqlcgen.GetUsersWithPaginationParams{
|
|
|
|
Column1: req.Page,
|
|
|
|
Limit: int32(req.Size),
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var users []model.User
|
|
|
|
for _, row := range rows {
|
|
|
|
user := model.User{
|
|
|
|
ID: row.ID,
|
|
|
|
Accountid: row.Accountid,
|
|
|
|
AmoID: row.Amoid,
|
|
|
|
Name: row.Name,
|
|
|
|
Email: row.Email,
|
|
|
|
Role: row.Role,
|
|
|
|
Createdat: row.Createdat.Time.Unix(),
|
|
|
|
Subdomain: row.Subdomain,
|
|
|
|
Amouserid: row.Amouserid,
|
|
|
|
Country: row.Country,
|
|
|
|
}
|
|
|
|
var group []model.UserGroups
|
|
|
|
if !row.Group.Valid {
|
|
|
|
err := json.Unmarshal(row.Group.RawMessage, &group)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
user.Group = group
|
|
|
|
|
|
|
|
users = append(users, user)
|
|
|
|
}
|
|
|
|
|
|
|
|
resp := model.UserListResp{}
|
|
|
|
|
|
|
|
return users, nil
|
2024-04-17 09:30:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) SoftDeleteAccount(ctx context.Context, accountID string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GetCurrentAccount(ctx context.Context, accountID string) (*model.User, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2024-04-17 17:14:12 +00:00
|
|
|
func (r *AmoRepository) CreateAccount(ctx context.Context, accountID string, userInfo model.User) error {
|
2024-04-17 09:30:19 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) CheckUsers(ctx context.Context, amouserid int, user model.User) error {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы webhook
|
|
|
|
|
|
|
|
func (r *AmoRepository) WebhookCreate(ctx context.Context, tokens model.Token) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) WebhookUpdate(ctx context.Context, tokens model.Token) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// воркер запускается каждые 5 минут, поэтомму ищем токены котторые исекают менее чем через 10 минут отдаем их на обноление
|
|
|
|
func (r *AmoRepository) CheckExpired(ctx context.Context) ([]model.Token, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GetAllTokens(ctx context.Context) ([]model.Token, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) WebhookDelete(ctx context.Context) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы pipelines
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateListPipelines(ctx context.Context) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GettingPipelinesFromCash(ctx context.Context, req *model.PaginationReq) (*model.UserListPipelinesResp, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) CheckPipelines(ctx context.Context, accountID string, pipelines []model.Pipeline) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GetPipelineByID(ctx context.Context, accountID string, amoid int) (*model.Pipeline, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdatePipeline(ctx context.Context, pipeline *model.Pipeline) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) InsertPipeline(ctx context.Context, pipeline *model.Pipeline) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы steps
|
|
|
|
|
|
|
|
func (r *AmoRepository) GettingStepsFromCash(ctx context.Context, req *model.PaginationReq) (*model.UserListStepsResp, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateListSteps(ctx context.Context) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) CheckSteps(ctx context.Context, accountID string, steps []model.Step) error {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GetStepByID(ctx context.Context, accountID string, amoid int) (*model.Step, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateStep(ctx context.Context, step *model.Step) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) InsertStep(ctx context.Context, step *model.Step) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы tags
|
|
|
|
|
|
|
|
func (r *AmoRepository) GettingTagsFromCash(ctx context.Context, req *model.PaginationReq) (*model.UserListTagsResp, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateListTags(ctx context.Context) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-17 12:01:01 +00:00
|
|
|
func (r *AmoRepository) CheckTags(ctx context.Context, tags []model.Tag, tokenID string) error {
|
2024-04-17 09:30:19 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GetTagByID(ctx context.Context, accountID string, amoid int, entity model.EntityType) (*model.Tag, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateTag(ctx context.Context, tag *model.Tag) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) InsertTag(ctx context.Context, tag *model.Tag) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы fields
|
|
|
|
|
|
|
|
func (r *AmoRepository) GettingFieldsFromCash(ctx context.Context, req *model.PaginationReq) (*model.UserListFieldsResp, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateListCustom(ctx context.Context) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-17 12:01:01 +00:00
|
|
|
func (r *AmoRepository) CheckFields(ctx context.Context, Fields []model.Field, tokenID string) error {
|
2024-04-17 09:30:19 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GetFieldByID(ctx context.Context, accountID string, amoid int, entity model.EntityType) (*model.Field, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) UpdateField(ctx context.Context, field *model.Field) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) InsertField(ctx context.Context, field *model.Field) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы rules
|
|
|
|
|
|
|
|
func (r *AmoRepository) ChangeQuizSettings(ctx context.Context, request *model.RulesReq) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) SetQuizSettings(ctx context.Context, request *model.RulesReq) error {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GettingQuizRules(ctx context.Context) (*model.Rule, error) {
|
|
|
|
//TODO:IMPLEMENT ME
|
|
|
|
|
|
|
|
return &model.Rule{}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// методы UTMs
|
|
|
|
|
|
|
|
func (r *AmoRepository) DeletingUserUtm(ctx context.Context, request *model.ListDeleteUTMIDsReq) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) SavingUserUtm(ctx context.Context, request *model.SaveUserListUTMReq, accountID string, quizID int) (*model.ListSavedIDUTMResp, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *AmoRepository) GettingUserUtm(ctx context.Context, request *model.PaginationReq, accountID string, quizID int) (*model.GetListUserUTMResp, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|