This commit is contained in:
pasha1coil 2025-07-09 14:43:14 +03:00
parent ff8956355f
commit 2dd714b369
2 changed files with 4 additions and 24 deletions

@ -9,7 +9,6 @@ import (
"gitea.pena/SQuiz/common/dal"
"gitea.pena/SQuiz/common/healthchecks"
"gitea.pena/SQuiz/common/middleware"
"gitea.pena/SQuiz/common/utils"
"github.com/gofiber/fiber/v2"
"github.com/skeris/appInit"
"go.uber.org/zap"
@ -47,9 +46,6 @@ type Options struct {
CrtFile string `env:"CRT" default:"server.crt"`
KeyFile string `env:"KEY" default:"server.key"`
PostgresCredentials string `env:"PG_CRED" default:"host=localhost port=5432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
RedirectURL string `env:"REDIRECT_URL" default:"https://squiz.pena.digital"`
PubKey string `env:"PUBLIC_KEY"`
PrivKey string `env:"PRIVATE_KEY"`
}
func New(ctx context.Context, opts interface{}, ver appInit.Version) (appInit.CommonApp, error) {
@ -90,12 +86,8 @@ func New(ctx context.Context, opts interface{}, ver appInit.Version) (appInit.Co
zapLogger.Info("config", zap.Any("options", options))
encrypt := utils.NewEncrypt(options.PubKey, options.PrivKey)
svc, err := service.New(service.ServiceDeps{
Dal: pgdal,
Encrypt: encrypt,
RedirectURl: options.RedirectURL,
AiClient: clients.NewAiClient("https://alvatar.com/api/engine/send_answer"),
})
if err != nil {

@ -7,11 +7,9 @@ import (
quizdal "gitea.pena/SQuiz/common/dal"
"gitea.pena/SQuiz/common/middleware"
"gitea.pena/SQuiz/common/model"
"gitea.pena/SQuiz/common/utils"
"github.com/gofiber/fiber/v2"
"strconv"
"strings"
"sync"
"time"
"unicode/utf8"
@ -25,18 +23,12 @@ const (
type Service struct {
dal *quizdal.DAL
batch []model.Answer
m sync.Mutex
encrypt *utils.Encrypt
redirectURl string
aiClient *clients.AIClient
quizConfigData GetQuizDataResp
}
type ServiceDeps struct {
Dal *quizdal.DAL
Encrypt *utils.Encrypt
RedirectURl string
AiClient *clients.AIClient
}
@ -48,10 +40,6 @@ func New(deps ServiceDeps) (*Service, error) {
return &Service{
dal: deps.Dal,
m: sync.Mutex{},
batch: []model.Answer{},
encrypt: deps.Encrypt,
redirectURl: deps.RedirectURl,
aiClient: deps.AiClient,
quizConfigData: quizData,
}, nil