From 4538561c40f396105fdcb5d6fd4928683f1f01f4 Mon Sep 17 00:00:00 2001 From: skeris Date: Sat, 19 Apr 2025 15:27:19 +0300 Subject: [PATCH] renamer --- .gitlab-ci.yml | 53 --------- Dockerfile | 7 +- Taskfile.dist.yml | 6 +- app/app.go | 34 +++--- go.mod | 47 ++++---- go.sum | 86 +++++++------- initialize/rpc_controllers.go | 16 +++ .../http_controllers/account/account.go | 105 +++++++----------- .../http_controllers/question/question.go | 44 ++++---- .../controllers/http_controllers/quiz/quiz.go | 57 +++++----- .../http_controllers/result/result.go | 49 ++++---- .../http_controllers/statistic/statistic.go | 25 ++--- .../http_controllers/telegram/telegram.go | 40 ++----- .../rpc_controllers/mail_notify.go | 16 +-- internal/server/grpc/rpc_server.go | 6 +- internal/tools/publishPriv.go | 2 +- internal/tools/tools.go | 2 +- internal/workers/tg_worker.go | 6 +- main.go | 11 ++ service/service.go | 8 +- tests/mailNotify_test.go | 4 +- tests/publish_test.go | 4 +- tests/smtp_test.go | 6 +- 23 files changed, 272 insertions(+), 362 deletions(-) delete mode 100644 .gitlab-ci.yml create mode 100644 initialize/rpc_controllers.go create mode 100644 main.go diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d79d3e9..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -include: - - project: "devops/pena-continuous-integration" - file: "/templates/docker/build-template.gitlab-ci.yml" - - project: "devops/pena-continuous-integration" - file: "/templates/docker/deploy-template.gitlab-ci.yml" - - project: "devops/pena-continuous-integration" - file: "/templates/docker/golint.gitlab-ci.yml" - - project: "devops/pena-continuous-integration" - file: "/templates/docker/service-discovery.gitlab-ci.yml" - -stages: - - lint - - build - - deploy - - service-discovery - -lint: - extends: .golint_template - -lint: - extends: .golint_template - -build-app: - stage: build - extends: .build_template - rules: - - if: "$CI_COMMIT_BRANCH == $STAGING_BRANCH || $CI_COMMIT_BRANCH == $PRODUCTION_BRANCH" - script: - - docker build -t $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH-core:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID --build-arg GITLAB_TOKEN=$GITLAB_TOKEN $CI_PROJECT_DIR - - docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH-core:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID - -deploy-staging: - stage: deploy - tags: - - staging - extends: .deploy_template - rules: - - if: "$CI_COMMIT_BRANCH == $STAGING_BRANCH" - after_script: - - docker ps -a - -deploy-prod: - stage: deploy - tags: - - prod - extends: .deploy_template - rules: - - if: "$CI_COMMIT_BRANCH == $PRODUCTION_BRANCH" - after_script: - - ls - -service-discovery: - extends: .sd_artefacts_template diff --git a/Dockerfile b/Dockerfile index 37a3ca9..c0337cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,11 @@ -FROM penahub.gitlab.yandexcloud.net:5050/devops/dockerhub-backup/golang as build +FROM gitea.pena/penadevops/container-images/golang:main as build WORKDIR /app RUN apk add git COPY . . -ARG GITLAB_TOKEN -ENV GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common -RUN git config --global url."https://buildToken:glpat-axA8ttckx3aPf_xd2Dym@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/" RUN go mod download RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o core -FROM penahub.gitlab.yandexcloud.net:5050/devops/dockerhub-backup/alpine as prod +FROM gitea.pena/penadevops/container-images/alpine:main COPY --from=build /app/core . COPY --from=build /app/schema /schema EXPOSE 1488 diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index c96d07c..efeeef7 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -1,10 +1,8 @@ -version: "3" - tasks: update-linter: cmds: - - go get -u penahub.gitlab.yandexcloud.net/devops/linters/golang.git + - go get -u gitea.pena/PenaSide/linters-golang lint: cmds: - task: update-linter - - cmd: golangci-lint run -v -c $(go list -f '{{"{{"}}.Dir{{"}}"}}' -m penahub.gitlab.yandexcloud.net/devops/linters/golang.git)/.golangci.yml + - cmd: golangci-lint run -v -c $(go list -f '{{"{{"}}.Dir{{"}}"}}' -m gitea.pena/PenaSide/linters-golang)/.golangci.yml diff --git a/app/app.go b/app/app.go index 70aa0a8..c9091e1 100644 --- a/app/app.go +++ b/app/app.go @@ -7,25 +7,25 @@ import ( "github.com/go-redis/redis/v8" "github.com/gofiber/fiber/v2" "github.com/skeris/appInit" - "github.com/themakers/hlog" "go.uber.org/zap" + "gitea.pena/PenaSide/hlog" "go.uber.org/zap/zapcore" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/privilege" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/healthchecks" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/brokers" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/clients/auth" - //"penahub.gitlab.yandexcloud.net/backend/quiz/core/clients/telegram" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/initialize" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/models" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/server" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/service" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/tools" - //"penahub.gitlab.yandexcloud.net/backend/quiz/core/workers" - "penahub.gitlab.yandexcloud.net/external/trashlog/wrappers/zaptrashlog" + "gitea.pena/PenaSide/common/log_mw" + "gitea.pena/PenaSide/common/privilege" + "gitea.pena/SQuiz/common/dal" + "gitea.pena/SQuiz/common/healthchecks" + "gitea.pena/SQuiz/common/middleware" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/core/brokers" + "gitea.pena/SQuiz/core/clients/auth" + //"gitea.pena/SQuiz/core/clients/telegram" + "gitea.pena/SQuiz/core/initialize" + "gitea.pena/SQuiz/core/models" + "gitea.pena/SQuiz/core/server" + "gitea.pena/SQuiz/core/service" + "gitea.pena/SQuiz/core/tools" + //"gitea.pena/SQuiz/core/workers" + "gitea.pena/PenaSide/trashlog/wrappers/zaptrashlog" "time" ) diff --git a/go.mod b/go.mod index 1ed5126..bd22aa6 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,13 @@ -module penahub.gitlab.yandexcloud.net/backend/quiz/core +module gitea.pena/SQuiz/core -go 1.22.0 +go 1.23.2 require ( + gitea.pena/PenaSide/common v0.0.0-20250103085335-91ea31fee517 + gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a + gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4 + gitea.pena/SQuiz/common v0.0.0-20250205160239-4ed00d74894b + gitea.pena/SQuiz/worker v0.0.0-20250205171832-dc46e3e23c1c github.com/go-redis/redis/v8 v8.11.5 github.com/gofiber/fiber/v2 v2.52.4 github.com/golang-jwt/jwt/v5 v5.2.1 @@ -10,62 +15,58 @@ require ( github.com/joho/godotenv v1.5.1 github.com/lib/pq v1.10.9 github.com/pioz/faker v1.7.3 - github.com/rs/xid v1.6.0 github.com/skeris/appInit v1.0.2 github.com/stretchr/testify v1.9.0 github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf - github.com/twmb/franz-go v1.16.1 + github.com/twmb/franz-go v1.18.0 github.com/xuri/excelize/v2 v2.8.1 go.uber.org/zap v1.27.0 google.golang.org/grpc v1.66.0 google.golang.org/protobuf v1.34.2 - penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c - penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990 - penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240829220549-d35409b619a3 - penahub.gitlab.yandexcloud.net/external/trashlog v0.1.6-0.20240827173635-78ce9878c387 ) require ( + gitea.pena/PenaSide/customer v0.0.0-20250111112441-6b06a95b8e24 // indirect + gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9 // indirect github.com/ClickHouse/clickhouse-go v1.5.4 // indirect github.com/andybalholm/brotli v1.1.0 // indirect - github.com/caarlos0/env/v8 v8.0.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/goccy/go-json v0.10.2 // indirect + github.com/go-ini/ini v1.67.0 // indirect + github.com/goccy/go-json v0.10.3 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.8 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/kr/pretty v0.3.1 // indirect + github.com/klauspost/compress v1.17.11 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/minio/md5-simd v1.1.2 // indirect - github.com/minio/minio-go/v7 v7.0.70 // indirect + github.com/minio/minio-go/v7 v7.0.81 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/msoleps v1.0.3 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/tealeg/xlsx v1.0.5 // indirect - github.com/twmb/franz-go/pkg/kmsg v1.8.0 // indirect + github.com/rs/xid v1.6.0 // indirect + github.com/twmb/franz-go/pkg/kmsg v1.9.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.53.0 // indirect + github.com/valyala/fasthttp v1.54.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect go.etcd.io/bbolt v1.3.11 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/text v0.18.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect - gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/tucnak/telebot.v2 v2.5.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ca9557a..5ae6890 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,18 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +gitea.pena/PenaSide/common v0.0.0-20250103085335-91ea31fee517 h1:EgBe8VcdPwmxbSzYLndncP+NmR73uYuXxkTeDlEttEE= +gitea.pena/PenaSide/common v0.0.0-20250103085335-91ea31fee517/go.mod h1:91EuBCgcqgJ6mG36n2pds8sPwwfaJytLWOzY3h2YFKU= +gitea.pena/PenaSide/customer v0.0.0-20250111112441-6b06a95b8e24 h1:En76y8iqNJb51AwSd+ptsl5Z/yu2nOmLE+UkEU+jddU= +gitea.pena/PenaSide/customer v0.0.0-20250111112441-6b06a95b8e24/go.mod h1:DDg6CQDhU+aSSTv8R/LbkNGegdCx+Q++DcgPfE2LbZU= +gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9 h1:tBkXWNIt8icmkMMnq8MA421RWkUy4OZh5P7C3q8uCu4= +gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9/go.mod h1:sanhSL8aEsfcq21P+eItYiAnKAre+B67nGJmDfk2cf0= +gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a h1:UySqMgaOKNsR42Y6GQXoM2wn/waYNc9cakMUSvbEEAg= +gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU= +gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4 h1:y9B4CSPIgiUoaXKyXLZxs1A9hxzDj26F9MH2R6uTkHQ= +gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4/go.mod h1:Bp5fJX0XsTV3QYximX6R2kCRvVKQAPwxjjCPm+ToTY8= +gitea.pena/SQuiz/common v0.0.0-20250205160239-4ed00d74894b h1:N3DdDWQyTXC0B5mI7OpjxHQuHtt6EJCK+vqRrLqcb1w= +gitea.pena/SQuiz/common v0.0.0-20250205160239-4ed00d74894b/go.mod h1:zCrUwDh0APpztKk6NUqTZv+zhjVbWpGBJiJ5z9dAH0U= +gitea.pena/SQuiz/worker v0.0.0-20250205171832-dc46e3e23c1c h1:MQqvgpJxcEIyL1DYkfmWTDgQqKfW509f75/YcVfXitQ= +gitea.pena/SQuiz/worker v0.0.0-20250205171832-dc46e3e23c1c/go.mod h1:dp5ZcO2EbRFOPZ2wwUovbFTJ/tdmt0VPf0iUw2jczQU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= @@ -7,8 +21,6 @@ github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer5 github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bkaradzic/go-lz4 v1.0.0 h1:RXc4wYsyz985CkXXeX04y4VnZFGG8Rd43pRaHsOXAKk= github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= -github.com/caarlos0/env/v8 v8.0.0 h1:POhxHhSpuxrLMIdvTGARuZqR4Jjm8AYmoi/JKlcScs0= -github.com/caarlos0/env/v8 v8.0.0/go.mod h1:7K4wMY9bH0esiXSSHlfHLX5xKGQMnkH5Fk4TDSSSzfo= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -16,7 +28,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -32,14 +43,16 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= +github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM= github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -66,14 +79,13 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= -github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -93,8 +105,8 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.70 h1:1u9NtMgfK1U42kUxcsl5v0yj6TEOPR497OAQxpJnn2g= -github.com/minio/minio-go/v7 v7.0.70/go.mod h1:4yBA8v80xGA30cfM3fz0DKYMXunWl/AV/6tWEs9ryzo= +github.com/minio/minio-go/v7 v7.0.81 h1:SzhMN0TQ6T/xSBu6Nvw3M5M8voM+Ht8RH3hE8S7zxaA= +github.com/minio/minio-go/v7 v7.0.81/go.mod h1:84gmIilaX4zcvAWWzJ5Z1WI5axN+hAbM5w25xf8xvC0= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= @@ -110,7 +122,6 @@ github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pioz/faker v1.7.3 h1:Tez8Emuq0UN+/d6mo3a9m/9ZZ/zdfJk0c5RtRatrceM= github.com/pioz/faker v1.7.3/go.mod h1:xSpay5w/oz1a6+ww0M3vfpe40pSIykeUPeWEc3TvVlc= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -126,8 +137,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -138,23 +149,23 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33 h1:N9f/Q+2Ssa+yDcbfaoLTYvXmdeyUUxsJKdPUVsjSmiA= github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33/go.mod h1:rpcH99JknBh8seZmlOlUg51gasZH6QH34oXNsIwYT6E= github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf h1:TJJm6KcBssmbWzplF5lzixXl1RBAi/ViPs1GaSOkhwo= github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf/go.mod h1:1FsorU3vnXO9xS9SrhUp8fRb/6H/Zfll0rPt1i4GWaA= -github.com/twmb/franz-go v1.16.1 h1:rpWc7fB9jd7TgmCyfxzenBI+QbgS8ZfJOUQE+tzPtbE= -github.com/twmb/franz-go v1.16.1/go.mod h1:/pER254UPPGp/4WfGqRi+SIRGE50RSQzVubQp6+N4FA= -github.com/twmb/franz-go/pkg/kmsg v1.8.0 h1:lAQB9Z3aMrIP9qF9288XcFf/ccaSxEitNA1CDTEIeTA= -github.com/twmb/franz-go/pkg/kmsg v1.8.0/go.mod h1:HzYEb8G3uu5XevZbtU0dVbkphaKTHk0X68N5ka4q6mU= +github.com/twmb/franz-go v1.18.0 h1:25FjMZfdozBywVX+5xrWC2W+W76i0xykKjTdEeD2ejw= +github.com/twmb/franz-go v1.18.0/go.mod h1:zXCGy74M0p5FbXsLeASdyvfLFsBvTubVqctIaa5wQ+I= +github.com/twmb/franz-go/pkg/kmsg v1.9.0 h1:JojYUph2TKAau6SBtErXpXGC7E3gg4vGZMv9xFU/B6M= +github.com/twmb/franz-go/pkg/kmsg v1.9.0/go.mod h1:CMbfazviCyY6HM0SXuG5t9vOwYDHRCSrJJyBAe5paqg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.53.0 h1:lW/+SUkOxCx2vlIu0iaImv4JLrVRnbbkpCoaawvA4zc= -github.com/valyala/fasthttp v1.53.0/go.mod h1:6dt4/8olwq9QARP/TDuPmWyWcl4byhpvTJ4AAtcz+QM= +github.com/valyala/fasthttp v1.54.0 h1:cCL+ZZR3z3HPLMVfEYVUMtJqVaui0+gu7Lx63unHwS0= +github.com/valyala/fasthttp v1.54.0/go.mod h1:6dt4/8olwq9QARP/TDuPmWyWcl4byhpvTJ4AAtcz+QM= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY= @@ -185,8 +196,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= @@ -205,8 +216,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -224,12 +235,12 @@ golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -264,12 +275,9 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tucnak/telebot.v2 v2.5.0 h1:i+NynLo443Vp+Zn3Gv9JBjh3Z/PaiKAQwcnhNI7y6Po= @@ -285,15 +293,3 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c h1:CWb4UcuNXhd1KTNOmy2U0TJO4+Qxgxrj5cwkyFqbgrk= -penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240711133242-0b8534fae5b2 h1:0t6pQHJvA3jMeBB3FPUmA+hw8rWlksTah8KJEtf2KD8= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240711133242-0b8534fae5b2/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240919124706-53cacd30903a h1:loD4hoCkx1ZTqw0mg/Br4RT2GI1vT2WvEh0I/j+DPo8= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240919124706-53cacd30903a/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0= -penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990 h1:jiO8GWO+3sCnDAV8/NAV8tQIUwae/I6/xiDilW7zf0o= -penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990/go.mod h1:zswBuTwmEsFHBVRu1nkG3/Fwylk5Vcm8OUm9iWxccSE= -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= -penahub.gitlab.yandexcloud.net/external/trashlog v0.1.6-0.20240827173635-78ce9878c387 h1:G+GIhkkvUsM9No2rf2D4kvQ2ExTw9KxlA8vsSnC0ywU= -penahub.gitlab.yandexcloud.net/external/trashlog v0.1.6-0.20240827173635-78ce9878c387/go.mod h1:30nezjpGpZuNThbQOCULIfa79RoJ5sray593jhfVP/Q= diff --git a/initialize/rpc_controllers.go b/initialize/rpc_controllers.go new file mode 100644 index 0000000..b7f40e5 --- /dev/null +++ b/initialize/rpc_controllers.go @@ -0,0 +1,16 @@ +package initialize + +import ( + "gitea.pena/SQuiz/common/dal" + "gitea.pena/SQuiz/core/rpc_service" +) + +type RpcRegister struct { + MailNotify *rpc_service.MailNotify +} + +func InitRpcControllers(dal *dal.DAL) *RpcRegister { + return &RpcRegister{ + MailNotify: rpc_service.NewMailNotify(dal), + } +} diff --git a/internal/controllers/http_controllers/account/account.go b/internal/controllers/http_controllers/account/account.go index 0ae231c..f0777ec 100644 --- a/internal/controllers/http_controllers/account/account.go +++ b/internal/controllers/http_controllers/account/account.go @@ -1,50 +1,21 @@ -package account +package service import ( "database/sql" "encoding/json" "errors" "fmt" - "github.com/go-redis/redis/v8" "github.com/gofiber/fiber/v2" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/pj_errors" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/brokers" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/clients/auth" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/models" + "gitea.pena/PenaSide/common/log_mw" + "gitea.pena/SQuiz/common/middleware" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/common/pj_errors" + "gitea.pena/SQuiz/core/brokers" + "gitea.pena/SQuiz/core/models" "strconv" "time" ) -type Deps struct { - Dal *dal.DAL - AuthClient *auth.AuthClient - Producer *brokers.Producer - ServiceName string - RedisClient *redis.Client -} - -type Account struct { - dal *dal.DAL - authClient *auth.AuthClient - producer *brokers.Producer - serviceName string - redisClient *redis.Client -} - -func NewAccountController(deps Deps) *Account { - return &Account{ - dal: deps.Dal, - authClient: deps.AuthClient, - producer: deps.Producer, - serviceName: deps.ServiceName, - redisClient: deps.RedisClient, - } -} - type CreateAccountReq struct { UserID string `json:"userId"` } @@ -80,13 +51,13 @@ type GetAccountsResp struct { } // getCurrentAccount обработчик для получения текущего аккаунта -func (r *Account) GetCurrentAccount(ctx *fiber.Ctx) error { +func (s *Service) getCurrentAccount(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") } - account, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) + account, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) if err != nil && err != sql.ErrNoRows { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -100,14 +71,14 @@ func (r *Account) GetCurrentAccount(ctx *fiber.Ctx) error { } // createAccount обработчик для создания нового аккаунта -func (r *Account) CreateAccount(ctx *fiber.Ctx) error { +func (s *Service) createAccount(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") } hlogger := log_mw.ExtractLogger(ctx) - existingAccount, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) + existingAccount, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) if err != nil && err != sql.ErrNoRows { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -115,7 +86,7 @@ func (r *Account) CreateAccount(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusConflict).SendString("user with this ID already exists") } - email, err := r.authClient.GetUserEmail(accountID) + email, err := s.authClient.GetUserEmail(accountID) if err != nil { return err } @@ -134,11 +105,11 @@ func (r *Account) CreateAccount(ctx *fiber.Ctx) error { }, } - createdAcc, err := r.dal.AccountRepo.CreateAccount(ctx.Context(), &newAccount) + createdAcc, err := s.dal.AccountRepo.CreateAccount(ctx.Context(), &newAccount) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } - _, err = r.dal.AccountRepo.PostLeadTarget(ctx.Context(), model.LeadTarget{ + _, err = s.dal.AccountRepo.PostLeadTarget(ctx.Context(), model.LeadTarget{ AccountID: accountID, Target: email, Type: model.LeadTargetEmail, @@ -153,10 +124,10 @@ func (r *Account) CreateAccount(ctx *fiber.Ctx) error { CtxAccountID: createdAcc.ID, }) - err = r.producer.ToMailNotify(ctx.Context(), brokers.Message{ + err = s.producer.ToMailNotify(ctx.Context(), brokers.Message{ AccountID: accountID, Email: email, - ServiceKey: r.serviceName, + ServiceKey: s.serviceName, SendAt: time.Now(), }) if err != nil { @@ -169,18 +140,18 @@ func (r *Account) CreateAccount(ctx *fiber.Ctx) error { } // deleteAccount обработчик для удаления текущего аккаунта -func (r *Account) DeleteAccount(ctx *fiber.Ctx) error { +func (s *Service) deleteAccount(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") } - account, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) + account, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } - if err := r.dal.AccountRepo.DeleteAccount(ctx.Context(), account.ID); err != nil { + if err := s.dal.AccountRepo.DeleteAccount(ctx.Context(), account.ID); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -190,13 +161,13 @@ func (r *Account) DeleteAccount(ctx *fiber.Ctx) error { } // getPrivilegeByUserID обработчик для получения привилегий аккаунта по ID пользователя -func (r *Account) GetPrivilegeByUserID(ctx *fiber.Ctx) error { +func (s *Service) getPrivilegeByUserID(ctx *fiber.Ctx) error { var req GetPrivilegeByUserIDReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } - privilege, err := r.dal.AccountRepo.GetPrivilegesByAccountID(ctx.Context(), req.UserID) + privilege, err := s.dal.AccountRepo.GetPrivilegesByAccountID(ctx.Context(), req.UserID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -205,13 +176,13 @@ func (r *Account) GetPrivilegeByUserID(ctx *fiber.Ctx) error { } // deleteAccountByUserID обработчик для удаления аккаунта по ID пользователя -func (r *Account) DeleteAccountByUserID(ctx *fiber.Ctx) error { +func (s *Service) deleteAccountByUserID(ctx *fiber.Ctx) error { var req DeleteAccountByUserIDReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } - existingAccount, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), req.UserID) + existingAccount, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), req.UserID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -220,7 +191,7 @@ func (r *Account) DeleteAccountByUserID(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusInternalServerError).SendString("user with this ID not found") } - if err := r.dal.AccountRepo.DeleteAccount(ctx.Context(), existingAccount.ID); err != nil { + if err := s.dal.AccountRepo.DeleteAccount(ctx.Context(), existingAccount.ID); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -230,7 +201,7 @@ func (r *Account) DeleteAccountByUserID(ctx *fiber.Ctx) error { } // getAccounts обработчик для получения списка аккаунтов с пагинацией -func (r *Account) GetAccounts(ctx *fiber.Ctx) error { +func (s *Service) getAccounts(ctx *fiber.Ctx) error { var req GetAccountsReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -241,7 +212,7 @@ func (r *Account) GetAccounts(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") } - accounts, totalCount, err := r.dal.AccountRepo.GetAccounts(ctx.Context(), req.Limit, req.Page) + accounts, totalCount, err := s.dal.AccountRepo.GetAccounts(ctx.Context(), req.Limit, req.Page) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -254,7 +225,7 @@ func (r *Account) GetAccounts(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(response) } -func (r *Account) ManualDone(ctx *fiber.Ctx) error { +func (s *Service) ManualDone(ctx *fiber.Ctx) error { var req struct { Id string `json:"id"` } @@ -266,7 +237,7 @@ func (r *Account) ManualDone(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("User id is required") } - err := r.dal.AccountRepo.ManualDone(ctx.Context(), req.Id) + err := s.dal.AccountRepo.ManualDone(ctx.Context(), req.Id) if err != nil { if errors.Is(err, pj_errors.ErrNotFound) { return ctx.Status(fiber.StatusNotFound).SendString("user don't have this privilege") @@ -277,7 +248,7 @@ func (r *Account) ManualDone(ctx *fiber.Ctx) error { return ctx.SendStatus(fiber.StatusOK) } -func (r *Account) PostLeadTarget(ctx *fiber.Ctx) error { +func (s *Service) PostLeadTarget(ctx *fiber.Ctx) error { var req struct { Type string `json:"type"` QuizID int32 `json:"quizID"` @@ -305,7 +276,7 @@ func (r *Account) PostLeadTarget(ctx *fiber.Ctx) error { switch req.Type { case "mail": - _, err := r.dal.AccountRepo.PostLeadTarget(ctx.Context(), model.LeadTarget{ + _, err := s.dal.AccountRepo.PostLeadTarget(ctx.Context(), model.LeadTarget{ AccountID: accountID, Target: req.Target, Type: model.LeadTargetType(req.Type), @@ -316,7 +287,7 @@ func (r *Account) PostLeadTarget(ctx *fiber.Ctx) error { } return ctx.SendStatus(fiber.StatusOK) case "telegram": - targets, err := r.dal.AccountRepo.GetLeadTarget(ctx.Context(), accountID, req.QuizID) + targets, err := s.dal.AccountRepo.GetLeadTarget(ctx.Context(), accountID, req.QuizID) if err != nil && !errors.Is(err, pj_errors.ErrNotFound) { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -340,7 +311,7 @@ func (r *Account) PostLeadTarget(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } - if err := r.redisClient.Set(ctx.Context(), taskKey, taskData, 0).Err(); err != nil { + if err := s.redisClient.Set(ctx.Context(), taskKey, taskData, 0).Err(); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } case "whatsapp": @@ -350,21 +321,21 @@ func (r *Account) PostLeadTarget(ctx *fiber.Ctx) error { return nil } -func (r *Account) DeleteLeadTarget(ctx *fiber.Ctx) error { +func (s *Service) DeleteLeadTarget(ctx *fiber.Ctx) error { leadIDStr := ctx.Params("id") leadID, err := strconv.ParseInt(leadIDStr, 10, 64) if err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid lead ID format") } - err = r.dal.AccountRepo.DeleteLeadTarget(ctx.Context(), leadID) + err = s.dal.AccountRepo.DeleteLeadTarget(ctx.Context(), leadID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } return ctx.SendStatus(fiber.StatusOK) } -func (r *Account) GetLeadTarget(ctx *fiber.Ctx) error { +func (s *Service) GetLeadTarget(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") @@ -376,7 +347,7 @@ func (r *Account) GetLeadTarget(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid quiz ID format") } - result, err := r.dal.AccountRepo.GetLeadTarget(ctx.Context(), accountID, int32(quizID)) + result, err := s.dal.AccountRepo.GetLeadTarget(ctx.Context(), accountID, int32(quizID)) if err != nil { switch { case errors.Is(err, pj_errors.ErrNotFound): @@ -389,7 +360,7 @@ func (r *Account) GetLeadTarget(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(result) } -func (r *Account) UpdateLeadTarget(ctx *fiber.Ctx) error { +func (s *Service) UpdateLeadTarget(ctx *fiber.Ctx) error { var req struct { ID int64 `json:"id"` Target string `json:"target"` @@ -403,7 +374,7 @@ func (r *Account) UpdateLeadTarget(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("ID and Target don't be nil") } - result, err := r.dal.AccountRepo.UpdateLeadTarget(ctx.Context(), model.LeadTarget{ + result, err := s.dal.AccountRepo.UpdateLeadTarget(ctx.Context(), model.LeadTarget{ ID: req.ID, Target: req.Target, }) diff --git a/internal/controllers/http_controllers/question/question.go b/internal/controllers/http_controllers/question/question.go index fb76581..7f1e65e 100644 --- a/internal/controllers/http_controllers/question/question.go +++ b/internal/controllers/http_controllers/question/question.go @@ -1,13 +1,12 @@ -package question +package service import ( "github.com/gofiber/fiber/v2" "github.com/lib/pq" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/models" + "gitea.pena/PenaSide/common/log_mw" + "gitea.pena/SQuiz/common/middleware" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/core/models" "unicode/utf8" ) @@ -36,7 +35,7 @@ type QuestionCreateReq struct { } // CreateQuestion service handler for creating question for quiz -func (r *Question) CreateQuestion(ctx *fiber.Ctx) error { +func (s *Service) CreateQuestion(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") @@ -77,7 +76,7 @@ func (r *Question) CreateQuestion(ctx *fiber.Ctx) error { Content: req.Content, } - questionID, err := r.dal.QuestionRepo.CreateQuestion(ctx.Context(), &result) + questionID, err := s.dal.QuestionRepo.CreateQuestion(ctx.Context(), &result) if err != nil { if e, ok := err.(*pq.Error); ok { if e.Constraint == "quiz_relation" { @@ -117,7 +116,7 @@ type GetQuestionListResp struct { } // GetQuestionList handler for paginated list question -func (r *Question) GetQuestionList(ctx *fiber.Ctx) error { +func (s *Service) GetQuestionList(ctx *fiber.Ctx) error { var req GetQuestionListReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -140,7 +139,7 @@ func (r *Question) GetQuestionList(ctx *fiber.Ctx) error { "'test','none','file', 'button','select','checkbox'") } - res, cnt, err := r.dal.QuestionRepo.GetQuestionList(ctx.Context(), + res, cnt, err := s.dal.QuestionRepo.GetQuestionList(ctx.Context(), req.Limit, req.Page*req.Limit, uint64(req.From), @@ -178,7 +177,7 @@ type UpdateResp struct { } // UpdateQuestion handler for update question -func (r *Question) UpdateQuestion(ctx *fiber.Ctx) error { +func (s *Service) UpdateQuestion(ctx *fiber.Ctx) error { var req UpdateQuestionReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -208,7 +207,7 @@ func (r *Question) UpdateQuestion(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusNotAcceptable).SendString("type must be only test,button,file,checkbox,select, none or empty string") } - question, err := r.dal.QuestionRepo.MoveToHistoryQuestion(ctx.Context(), req.Id) + question, err := s.dal.QuestionRepo.MoveToHistoryQuestion(ctx.Context(), req.Id) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -240,7 +239,7 @@ func (r *Question) UpdateQuestion(ctx *fiber.Ctx) error { question.Content = req.Content } - if err := r.dal.QuestionRepo.UpdateQuestion(ctx.Context(), question); err != nil { + if err := s.dal.QuestionRepo.UpdateQuestion(ctx.Context(), question); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -256,7 +255,7 @@ type CopyQuestionReq struct { } // CopyQuestion handler for copy question -func (r *Question) CopyQuestion(ctx *fiber.Ctx) error { +func (s *Service) CopyQuestion(ctx *fiber.Ctx) error { var req CopyQuestionReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -266,7 +265,7 @@ func (r *Question) CopyQuestion(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("no id provided") } - question, err := r.dal.QuestionRepo.CopyQuestion(ctx.Context(), req.Id, req.QuizId) + question, err := s.dal.QuestionRepo.CopyQuestion(ctx.Context(), req.Id, req.QuizId) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -284,8 +283,8 @@ type GetQuestionHistoryReq struct { } // GetQuestionHistory handler for history of quiz -func (r *Question) GetQuestionHistory(ctx *fiber.Ctx) error { - var req GetQuestionHistoryReq +func (s *Service) GetQuestionHistory(ctx *fiber.Ctx) error { + var req GetQuizHistoryReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } @@ -294,7 +293,7 @@ func (r *Question) GetQuestionHistory(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("no id provided") } - history, err := r.dal.QuestionRepo.QuestionHistory(ctx.Context(), req.Id, req.Limit, req.Page*req.Limit) + history, err := s.dal.QuestionRepo.QuestionHistory(ctx.Context(), req.Id, req.Limit, req.Page*req.Limit) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -307,17 +306,14 @@ type DeactivateResp struct { } // DeleteQuestion handler for fake delete question -func (r *Question) DeleteQuestion(ctx *fiber.Ctx) error { +func (s *Service) DeleteQuestion(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") } hlogger := log_mw.ExtractLogger(ctx) - var req struct { - Id uint64 `json:"id"` - } - + var req DeactivateReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } @@ -326,7 +322,7 @@ func (r *Question) DeleteQuestion(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("id for deleting question is required") } - deleted, err := r.dal.QuestionRepo.DeleteQuestion(ctx.Context(), req.Id) + deleted, err := s.dal.QuestionRepo.DeleteQuestion(ctx.Context(), req.Id) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } diff --git a/internal/controllers/http_controllers/quiz/quiz.go b/internal/controllers/http_controllers/quiz/quiz.go index 21e6736..616203a 100644 --- a/internal/controllers/http_controllers/quiz/quiz.go +++ b/internal/controllers/http_controllers/quiz/quiz.go @@ -1,16 +1,15 @@ -package quiz +package service import ( - "fmt" "github.com/gofiber/fiber/v2" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/repository/quiz" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/models" + "gitea.pena/PenaSide/common/log_mw" + "gitea.pena/SQuiz/common/middleware" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/common/repository/quiz" + "gitea.pena/SQuiz/core/models" "time" "unicode/utf8" + "fmt" ) type Deps struct { @@ -49,7 +48,7 @@ type CreateQuizReq struct { } // CreateQuiz handler for quiz creating request -func (r *Quiz) CreateQuiz(ctx *fiber.Ctx) error { +func (s *Service) CreateQuiz(ctx *fiber.Ctx) error { var req CreateQuizReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -108,7 +107,7 @@ func (r *Quiz) CreateQuiz(ctx *fiber.Ctx) error { GroupId: req.GroupId, } - quizID, err := r.dal.QuizRepo.CreateQuiz(ctx.Context(), &record) + quizID, err := s.dal.QuizRepo.CreateQuiz(ctx.Context(), &record) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -142,7 +141,7 @@ type GetQuizListResp struct { } // GetQuizList handler for paginated list quiz -func (r *Quiz) GetQuizList(ctx *fiber.Ctx) error { +func (s *Service) GetQuizList(ctx *fiber.Ctx) error { var req GetQuizListReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -164,7 +163,7 @@ func (r *Quiz) GetQuizList(ctx *fiber.Ctx) error { "'stop','start','draft', 'template','timeout','offlimit'") } - res, cnt, err := r.dal.QuizRepo.GetQuizList(ctx.Context(), + res, cnt, err := s.dal.QuizRepo.GetQuizList(ctx.Context(), quiz.GetQuizListDeps{ Limit: req.Limit, Offset: req.Limit * req.Page, @@ -208,11 +207,7 @@ type UpdateQuizReq struct { GroupId uint64 `json:"group_id"` } -type UpdateResp struct { - Updated uint64 `json:"updated"` -} - -func (r *Quiz) UpdateQuiz(ctx *fiber.Ctx) error { +func (s *Service) UpdateQuiz(ctx *fiber.Ctx) error { var req UpdateQuizReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -253,7 +248,7 @@ func (r *Quiz) UpdateQuiz(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusConflict).SendString("you can pause quiz only if it has deadline for passing") } - quiz, err := r.dal.QuizRepo.MoveToHistoryQuiz(ctx.Context(), req.Id, accountId) + quiz, err := s.dal.QuizRepo.MoveToHistoryQuiz(ctx.Context(), req.Id, accountId) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -325,7 +320,7 @@ func (r *Quiz) UpdateQuiz(ctx *fiber.Ctx) error { quiz.ParentIds = append(quiz.ParentIds, int32(quiz.Id)) - if err := r.dal.QuizRepo.UpdateQuiz(ctx.Context(), accountId, quiz); err != nil { + if err := s.dal.QuizRepo.UpdateQuiz(ctx.Context(), accountId, quiz); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -353,7 +348,7 @@ type CopyQuizReq struct { } // CopyQuiz request handler for copy quiz -func (r *Quiz) CopyQuiz(ctx *fiber.Ctx) error { +func (s *Service) CopyQuiz(ctx *fiber.Ctx) error { var req CopyQuizReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -368,7 +363,7 @@ func (r *Quiz) CopyQuiz(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("no id provided") } - quiz, err := r.dal.QuizRepo.CopyQuiz(ctx.Context(), accountId, req.Id) + quiz, err := s.dal.QuizRepo.CopyQuiz(ctx.Context(), accountId, req.Id) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -386,7 +381,7 @@ type GetQuizHistoryReq struct { } // GetQuizHistory handler for history of quiz -func (r *Quiz) GetQuizHistory(ctx *fiber.Ctx) error { +func (s *Service) GetQuizHistory(ctx *fiber.Ctx) error { var req GetQuizHistoryReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -400,7 +395,7 @@ func (r *Quiz) GetQuizHistory(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("no id provided") } - history, err := r.dal.QuizRepo.QuizHistory(ctx.Context(), quiz.QuizHistoryDeps{ + history, err := s.dal.QuizRepo.QuizHistory(ctx.Context(), quiz.QuizHistoryDeps{ Id: req.Id, Limit: req.Limit, Offset: req.Page * req.Limit, @@ -423,7 +418,7 @@ type DeactivateResp struct { } // DeleteQuiz handler for fake delete quiz -func (r *Quiz) DeleteQuiz(ctx *fiber.Ctx) error { +func (s *Service) DeleteQuiz(ctx *fiber.Ctx) error { var req DeactivateReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -439,7 +434,7 @@ func (r *Quiz) DeleteQuiz(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("id for deleting is required") } - deleted, err := r.dal.QuizRepo.DeleteQuiz(ctx.Context(), accountId, req.Id) + deleted, err := s.dal.QuizRepo.DeleteQuiz(ctx.Context(), accountId, req.Id) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -455,7 +450,7 @@ func (r *Quiz) DeleteQuiz(ctx *fiber.Ctx) error { } // ArchiveQuiz handler for archiving quiz -func (r *Quiz) ArchiveQuiz(ctx *fiber.Ctx) error { +func (s *Service) ArchiveQuiz(ctx *fiber.Ctx) error { var req DeactivateReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -470,7 +465,7 @@ func (r *Quiz) ArchiveQuiz(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusFailedDependency).SendString("id for archive quiz is required") } - archived, err := r.dal.QuizRepo.DeleteQuiz(ctx.Context(), accountId, req.Id) + archived, err := s.dal.QuizRepo.DeleteQuiz(ctx.Context(), accountId, req.Id) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -484,7 +479,7 @@ type QuizMoveReq struct { Qid, AccountID string } -func (r *Quiz) QuizMove(ctx *fiber.Ctx) error { +func (s *Service) QuizMove(ctx *fiber.Ctx) error { var req QuizMoveReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -494,7 +489,7 @@ func (r *Quiz) QuizMove(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request qid and accountID is required") } - resp, err := r.dal.QuizRepo.QuizMove(ctx.Context(), req.Qid, req.AccountID) + resp, err := s.dal.QuizRepo.QuizMove(ctx.Context(), req.Qid, req.AccountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -502,7 +497,7 @@ func (r *Quiz) QuizMove(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(resp) } -func (r *Quiz) TemplateCopy(ctx *fiber.Ctx) error { +func (s *Service) TemplateCopy(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") @@ -521,7 +516,7 @@ func (r *Quiz) TemplateCopy(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request qid is required") } - qizID, err := r.dal.QuizRepo.TemplateCopy(ctx.Context(), accountID, req.Qid) + qizID, err := s.dal.QuizRepo.TemplateCopy(ctx.Context(), accountID, req.Qid) if err != nil { fmt.Println("TEMPLERR", err) return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) diff --git a/internal/controllers/http_controllers/result/result.go b/internal/controllers/http_controllers/result/result.go index 5902b30..0f68f45 100644 --- a/internal/controllers/http_controllers/result/result.go +++ b/internal/controllers/http_controllers/result/result.go @@ -1,13 +1,12 @@ -package result +package service import ( "bytes" "github.com/gofiber/fiber/v2" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/middleware" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/repository/result" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/tools" + "gitea.pena/SQuiz/common/middleware" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/common/repository/result" + "gitea.pena/SQuiz/core/tools" "strconv" "time" ) @@ -41,7 +40,7 @@ type ReqExportResponse struct { Results []model.AnswerExport `json:"results"` } -func (r *Result) GetResultsByQuizID(ctx *fiber.Ctx) error { +func (s *Service) GetResultsByQuizID(ctx *fiber.Ctx) error { payment := true // параметр для определения существования текущих привилегий юзера accountID, ok := middleware.GetAccountId(ctx) @@ -60,7 +59,7 @@ func (r *Result) GetResultsByQuizID(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid quiz ID format") } - account, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) + account, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -70,7 +69,7 @@ func (r *Result) GetResultsByQuizID(ctx *fiber.Ctx) error { } } - results, totalCount, err := r.dal.ResultRepo.GetQuizResults(ctx.Context(), quizID, result.GetQuizResDeps{ + results, totalCount, err := s.dal.ResultRepo.GetQuizResults(ctx.Context(), quizID, result.GetQuizResDeps{ To: req.To, From: req.From, New: req.New, @@ -89,7 +88,7 @@ func (r *Result) GetResultsByQuizID(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(resp) } -func (r *Result) DelResultByID(ctx *fiber.Ctx) error { +func (s *Service) DelResultByID(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("could not get account ID from token") @@ -101,7 +100,7 @@ func (r *Result) DelResultByID(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid result ID format") } - isOwner, err := r.dal.ResultRepo.CheckResultOwner(ctx.Context(), resultID, accountID) + isOwner, err := s.dal.ResultRepo.CheckResultOwner(ctx.Context(), resultID, accountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -110,7 +109,7 @@ func (r *Result) DelResultByID(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusUnauthorized).SendString("not the owner of the result") } - if err := r.dal.ResultRepo.SoftDeleteResultByID(ctx.Context(), resultID); err != nil { + if err := s.dal.ResultRepo.SoftDeleteResultByID(ctx.Context(), resultID); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -122,7 +121,7 @@ type ReqSeen struct { Answers []int64 } -func (r *Result) SetStatus(ctx *fiber.Ctx) error { +func (s *Service) SetStatus(ctx *fiber.Ctx) error { var req ReqSeen if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -133,7 +132,7 @@ func (r *Result) SetStatus(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusUnauthorized).SendString("could not get account ID from token") } - answers, err := r.dal.ResultRepo.CheckResultsOwner(ctx.Context(), req.Answers, accountID) + answers, err := s.dal.ResultRepo.CheckResultsOwner(ctx.Context(), req.Answers, accountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -142,14 +141,14 @@ func (r *Result) SetStatus(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusNotAcceptable).SendString("could not update some answers because you don't have rights") } - if err := r.dal.ResultRepo.UpdateAnswersStatus(ctx.Context(), accountID, answers); err != nil { + if err := s.dal.ResultRepo.UpdateAnswersStatus(ctx.Context(), accountID, answers); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } return ctx.Status(fiber.StatusOK).JSON(nil) } -func (r *Result) ExportResultsToCSV(ctx *fiber.Ctx) error { +func (s *Service) ExportResultsToCSV(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") @@ -166,7 +165,7 @@ func (r *Result) ExportResultsToCSV(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("invalid request body") } - account, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) + account, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -177,17 +176,17 @@ func (r *Result) ExportResultsToCSV(ctx *fiber.Ctx) error { } } - quiz, err := r.dal.QuizRepo.GetQuizById(ctx.Context(), accountID, quizID) + quiz, err := s.dal.QuizRepo.GetQuizById(ctx.Context(), accountID, quizID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("failed to get quiz") } - questions, err := r.dal.ResultRepo.GetQuestions(ctx.Context(), quizID) + questions, err := s.dal.ResultRepo.GetQuestions(ctx.Context(), quizID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("failed to get questions") } - answers, err := r.dal.ResultRepo.GetQuizResultsCSV(ctx.Context(), quizID, result.GetQuizResDeps{ + answers, err := s.dal.ResultRepo.GetQuizResultsCSV(ctx.Context(), quizID, result.GetQuizResDeps{ To: req.To, From: req.From, New: req.New, @@ -200,7 +199,7 @@ func (r *Result) ExportResultsToCSV(ctx *fiber.Ctx) error { buffer := new(bytes.Buffer) - if err := tools.WriteDataToExcel(buffer, questions, answers, r.s3Prefix+quiz.Qid+"/"); err != nil { + if err := tools.WriteDataToExcel(buffer, questions, answers, s.s3Prefix + quiz.Qid + "/"); err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("failed to write data to Excel") } @@ -210,7 +209,7 @@ func (r *Result) ExportResultsToCSV(ctx *fiber.Ctx) error { return ctx.Send(buffer.Bytes()) } -func (r *Result) GetResultAnswers(ctx *fiber.Ctx) error { +func (s *Service) GetResultAnswers(ctx *fiber.Ctx) error { accountID, ok := middleware.GetAccountId(ctx) if !ok { return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") @@ -221,7 +220,7 @@ func (r *Result) GetResultAnswers(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("invalid quiz ID") } - account, err := r.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) + account, err := s.dal.AccountRepo.GetAccountByID(ctx.Context(), accountID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -232,11 +231,11 @@ func (r *Result) GetResultAnswers(ctx *fiber.Ctx) error { } } - answers, err := r.dal.ResultRepo.GetResultAnswers(ctx.Context(), resultID) + answers, err := s.dal.ResultRepo.GetResultAnswers(ctx.Context(), resultID) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("failed to get result answers") } - sortedAnswers, err := r.dal.QuestionRepo.ForSortingResults(ctx.Context(), answers) + sortedAnswers, err := s.dal.QuestionRepo.ForSortingResults(ctx.Context(), answers) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString("failed sort result answers") } diff --git a/internal/controllers/http_controllers/statistic/statistic.go b/internal/controllers/http_controllers/statistic/statistic.go index e4c2572..930f792 100644 --- a/internal/controllers/http_controllers/statistic/statistic.go +++ b/internal/controllers/http_controllers/statistic/statistic.go @@ -1,9 +1,8 @@ -package statistic +package service import ( "github.com/gofiber/fiber/v2" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/repository/statistics" + "gitea.pena/SQuiz/common/repository/statistics" "strconv" ) @@ -29,7 +28,7 @@ type DeviceStatReq struct { To uint64 } -func (r *Statistic) GetDeviceStatistics(ctx *fiber.Ctx) error { +func (s *Service) GetDeviceStatistics(ctx *fiber.Ctx) error { quizIDStr := ctx.Params("quizID") quizID, err := strconv.ParseInt(quizIDStr, 10, 64) @@ -42,7 +41,7 @@ func (r *Statistic) GetDeviceStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } - deviceStats, err := r.dal.StatisticsRepo.GetDeviceStatistics(ctx.Context(), statistics.DeviceStatReq{ + deviceStats, err := s.dal.StatisticsRepo.GetDeviceStatistics(ctx.Context(), statistics.DeviceStatReq{ QuizId: quizID, From: req.From, To: req.To, @@ -58,7 +57,7 @@ type GeneralStatsResp struct { Open, Result, AvTime, Conversion map[uint64]uint64 } -func (r *Statistic) GetGeneralStatistics(ctx *fiber.Ctx) error { +func (s *Service) GetGeneralStatistics(ctx *fiber.Ctx) error { quizIDStr := ctx.Params("quizID") quizID, err := strconv.ParseInt(quizIDStr, 10, 64) if err != nil { @@ -70,7 +69,7 @@ func (r *Statistic) GetGeneralStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } - generalStats, err := r.dal.StatisticsRepo.GetGeneralStatistics(ctx.Context(), statistics.DeviceStatReq{ + generalStats, err := s.dal.StatisticsRepo.GetGeneralStatistics(ctx.Context(), statistics.DeviceStatReq{ QuizId: quizID, From: req.From, To: req.To, @@ -82,7 +81,7 @@ func (r *Statistic) GetGeneralStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(generalStats) } -func (r *Statistic) GetQuestionsStatistics(ctx *fiber.Ctx) error { +func (s *Service) GetQuestionsStatistics(ctx *fiber.Ctx) error { quizIDStr := ctx.Params("quizID") quizID, err := strconv.ParseInt(quizIDStr, 0, 64) if err != nil { @@ -94,7 +93,7 @@ func (r *Statistic) GetQuestionsStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } - questionsStats, err := r.dal.StatisticsRepo.GetQuestionsStatistics(ctx.Context(), statistics.DeviceStatReq{ + questionsStats, err := s.dal.StatisticsRepo.GetQuestionsStatistics(ctx.Context(), statistics.DeviceStatReq{ QuizId: quizID, From: req.From, To: req.To, @@ -110,13 +109,13 @@ type StatisticReq struct { From, To uint64 // временные границы выбора статистики } -func (r *Statistic) AllServiceStatistics(ctx *fiber.Ctx) error { +func (s *Service) AllServiceStatistics(ctx *fiber.Ctx) error { var req StatisticReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } - allSvcStats, err := r.dal.StatisticsRepo.AllServiceStatistics(ctx.Context(), req.From, req.To) + allSvcStats, err := s.dal.StatisticsRepo.AllServiceStatistics(ctx.Context(), req.From, req.To) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } @@ -124,7 +123,7 @@ func (r *Statistic) AllServiceStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(allSvcStats) } -func (r *Statistic) GetPipelinesStatistics(ctx *fiber.Ctx) error { +func (s *Service) GetPipelinesStatistics(ctx *fiber.Ctx) error { var req StatisticReq if err := ctx.BodyParser(&req); err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") @@ -136,7 +135,7 @@ func (r *Statistic) GetPipelinesStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).SendString("Invalid quiz ID format") } - result, err := r.chDAL.StatisticClickRepo.GetPipelinesStatistics(ctx.Context(), quizID, req.From, req.To) + result, err := s.chDAL.StatisticClickRepo.GetPipelinesStatistics(ctx.Context(), quizID, req.From, req.To) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } diff --git a/internal/controllers/http_controllers/telegram/telegram.go b/internal/controllers/http_controllers/telegram/telegram.go index d0989d0..2dc1cc0 100644 --- a/internal/controllers/http_controllers/telegram/telegram.go +++ b/internal/controllers/http_controllers/telegram/telegram.go @@ -1,42 +1,25 @@ -package telegram +package service import ( "errors" //"fmt" "github.com/gofiber/fiber/v2" - // "github.com/rs/xid" +// "github.com/rs/xid" //"path/filepath" - // "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/pj_errors" - // "penahub.gitlab.yandexcloud.net/backend/quiz/core/clients/telegram" - // "penahub.gitlab.yandexcloud.net/backend/tdlib/client" +// "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/common/pj_errors" +// "gitea.pena/SQuiz/core/clients/telegram" +// "penahub.gitlab.yandexcloud.net/backend/tdlib/client" "strconv" ) -type Deps struct { - DAL *dal.DAL - TelegramClient *telegram.TelegramClient -} - -type Telegram struct { - dal *dal.DAL - telegramClient *telegram.TelegramClient -} - -func NewTelegramController(deps Deps) *Telegram { - return &Telegram{ - dal: deps.DAL, - telegramClient: deps.TelegramClient, - } -} - type Message struct { Type string `json:"type"` Data string `json:"data"` } -func (r *Telegram) GetPoolTgAccounts(ctx *fiber.Ctx) error { - allAccounts, err := r.dal.TgRepo.GetAllTgAccounts(ctx.Context()) +func (s *Service) GetPoolTgAccounts(ctx *fiber.Ctx) error { + allAccounts, err := s.dal.TgRepo.GetAllTgAccounts(ctx.Context()) if err != nil { switch { case errors.Is(err, pj_errors.ErrNotFound): @@ -132,7 +115,7 @@ func (s *Service) AddingTgAccount(ctx *fiber.Ctx) error { return nil } -func (r *Telegram) SettingTgCode(ctx *fiber.Ctx) error { +func (s *Service) SettingTgCode(ctx *fiber.Ctx) error { var req struct { Code string `json:"code"` Signature string `json:"signature"` @@ -144,6 +127,7 @@ func (r *Telegram) SettingTgCode(ctx *fiber.Ctx) error { if req.Code == "" || req.Signature == "" { return ctx.Status(fiber.StatusBadRequest).SendString("empty required fields") } + // data, ok := s.telegramClient.GetFromMap(req.Signature) // if !ok { // return ctx.Status(fiber.StatusBadRequest).SendString("Invalid id, don't have data") @@ -178,12 +162,12 @@ func (r *Telegram) SettingTgCode(ctx *fiber.Ctx) error { // } } -func (r *Telegram) DeleteTgAccountByID(ctx *fiber.Ctx) error { +func (s *Service) DeleteTgAccountByID(ctx *fiber.Ctx) error { id, err := strconv.ParseInt(ctx.Params("id"), 10, 64) if err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("invalid id format") } - err = r.dal.TgRepo.SoftDeleteTgAccount(ctx.Context(), id) + err = s.dal.TgRepo.SoftDeleteTgAccount(ctx.Context(), id) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(err.Error()) } diff --git a/internal/controllers/rpc_controllers/mail_notify.go b/internal/controllers/rpc_controllers/mail_notify.go index 23f87bc..8a76e2f 100644 --- a/internal/controllers/rpc_controllers/mail_notify.go +++ b/internal/controllers/rpc_controllers/mail_notify.go @@ -1,13 +1,13 @@ -package rpc_controllers +package rpc_service import ( "context" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - notifyer2 "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/proto/notifyer" + "gitea.pena/SQuiz/common/dal" + "gitea.pena/SQuiz/core/proto/notifyer" ) type MailNotify struct { - notifyer2.UnimplementedQuizServiceServer + notifyer.UnimplementedQuizServiceServer dal *dal.DAL } @@ -17,23 +17,23 @@ func NewMailNotify(dal *dal.DAL) *MailNotify { } } -func (m *MailNotify) GetQuizzes(ctx context.Context, in *notifyer2.GetQuizzesRequest) (*notifyer2.GetQuizzesResponse, error) { +func (m *MailNotify) GetQuizzes(ctx context.Context, in *notifyer.GetQuizzesRequest) (*notifyer.GetQuizzesResponse, error) { ids, err := m.dal.QuizRepo.GetAllQuizzesID(ctx, in.AccountId) if err != nil { return nil, err } - resp := ¬ifyer2.GetQuizzesResponse{ + resp := ¬ifyer.GetQuizzesResponse{ QuizIds: ids, } return resp, nil } -func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer2.GetStartedQuizzesRequest) (*notifyer2.GetStartedQuizzesResponse, error) { +func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer.GetStartedQuizzesRequest) (*notifyer.GetStartedQuizzesResponse, error) { ids, err := m.dal.QuizRepo.GetStartedQuizzesID(ctx, in.AccountId) if err != nil { return nil, err } - resp := ¬ifyer2.GetStartedQuizzesResponse{ + resp := ¬ifyer.GetStartedQuizzesResponse{ QuizIds: ids, } return resp, nil diff --git a/internal/server/grpc/rpc_server.go b/internal/server/grpc/rpc_server.go index 69ff851..63caa6e 100644 --- a/internal/server/grpc/rpc_server.go +++ b/internal/server/grpc/rpc_server.go @@ -9,8 +9,8 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "net" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/initialize" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/proto/notifyer" + "gitea.pena/SQuiz/core/initialize" + "gitea.pena/SQuiz/core/proto/notifyer" "time" ) @@ -58,7 +58,7 @@ func (g *GRPC) Stop(_ context.Context) error { return nil } -func (g *GRPC) Register(reg initialize.GRpcControllers) *GRPC { +func (g *GRPC) Register(reg *initialize.RpcRegister) *GRPC { notifyer.RegisterQuizServiceServer(g.grpc, reg.MailNotify) // another return g diff --git a/internal/tools/publishPriv.go b/internal/tools/publishPriv.go index 6326e5b..fe899ff 100644 --- a/internal/tools/publishPriv.go +++ b/internal/tools/publishPriv.go @@ -2,7 +2,7 @@ package tools import ( "fmt" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/privilege" + "gitea.pena/PenaSide/common/privilege" "time" ) diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 88cbc68..d4b8116 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -12,7 +12,7 @@ import ( "net/http" "net/url" "path/filepath" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" + "gitea.pena/SQuiz/common/model" "regexp" "sort" "strconv" diff --git a/internal/workers/tg_worker.go b/internal/workers/tg_worker.go index 51d5894..88ff15a 100644 --- a/internal/workers/tg_worker.go +++ b/internal/workers/tg_worker.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" "github.com/go-redis/redis/v8" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/clients/telegram" + "gitea.pena/SQuiz/common/dal" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/core/clients/telegram" "strconv" "time" ) diff --git a/main.go b/main.go new file mode 100644 index 0000000..7c600a2 --- /dev/null +++ b/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "github.com/skeris/appInit" + "gitea.pena/SQuiz/core/app" + _ "gitea.pena/PenaSide/linters-golang/pkg/dummy" +) + +func main() { + appInit.Initialize(app.New, app.Options{}) +} diff --git a/service/service.go b/service/service.go index 08c40df..a5fbd0a 100644 --- a/service/service.go +++ b/service/service.go @@ -3,10 +3,10 @@ package service import ( "github.com/go-redis/redis/v8" "github.com/gofiber/fiber/v2" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/brokers" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/clients/auth" -// "penahub.gitlab.yandexcloud.net/backend/quiz/core/clients/telegram" + "gitea.pena/SQuiz/common/dal" + "gitea.pena/SQuiz/core/brokers" + "gitea.pena/SQuiz/core/clients/auth" +// "gitea.pena/SQuiz/core/clients/telegram" ) // Service is an entity for http requests handling diff --git a/tests/mailNotify_test.go b/tests/mailNotify_test.go index 2c76b14..d125f83 100644 --- a/tests/mailNotify_test.go +++ b/tests/mailNotify_test.go @@ -5,8 +5,8 @@ import ( "github.com/pioz/faker" "go.uber.org/zap" "log" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/initialize" - "penahub.gitlab.yandexcloud.net/backend/quiz/core/internal/brokers" + "gitea.pena/SQuiz/core/brokers" + "gitea.pena/SQuiz/core/initialize" "testing" "time" ) diff --git a/tests/publish_test.go b/tests/publish_test.go index dbbe308..6b99aa0 100644 --- a/tests/publish_test.go +++ b/tests/publish_test.go @@ -3,8 +3,8 @@ package tests import ( "github.com/gofiber/fiber/v2" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/backend/penahub_common/privilege" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" + "gitea.pena/PenaSide/common/privilege" + "gitea.pena/SQuiz/common/model" "testing" ) diff --git a/tests/smtp_test.go b/tests/smtp_test.go index 1df738d..02631ee 100644 --- a/tests/smtp_test.go +++ b/tests/smtp_test.go @@ -5,9 +5,9 @@ import ( "github.com/gofiber/fiber/v2" "github.com/pioz/faker" "github.com/stretchr/testify/assert" - "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model" - "penahub.gitlab.yandexcloud.net/backend/quiz/worker.git/answerwc" - "penahub.gitlab.yandexcloud.net/backend/quiz/worker.git/clients/mailclient" + "gitea.pena/SQuiz/common/model" + "gitea.pena/SQuiz/worker/answerwc" + "gitea.pena/SQuiz/common/clients" "testing" "time" )