delete base user log data and movw mw to common pj
This commit is contained in:
parent
ff445db1a6
commit
bbb0505662
2
go.mod
2
go.mod
@ -14,7 +14,7 @@ require (
|
||||
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf
|
||||
go.mongodb.org/mongo-driver v1.14.0
|
||||
go.uber.org/zap v1.27.0
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a
|
||||
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31
|
||||
penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240526134522-aab18dfcec46
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -245,6 +245,8 @@ penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527155320-a234
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527155320-a234eec54383/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c h1:jxnyIeC2CNDNmfdFx2qnLS4Qd0v5ocYrY9X+OL9qsvc=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240527160654-bd1c2126bc6c/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a h1:dGW8ErUVdwGJBq6uc5AHYn6Yt10CDNkMIpV+yrDDTLs=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607142502-8257e6c4aa5a/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE=
|
||||
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31 h1:WlRVJnzU0sti+qBq/JTCgFPU0RoxIqGHu7hzDirxE2k=
|
||||
penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240523172059-9bbe8a9faa31/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4=
|
||||
penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240526134522-aab18dfcec46 h1:AX5HxEjjOf6YajMmi2vAB8hErBGEGouPB8ei9VVmdmo=
|
||||
|
@ -2,12 +2,11 @@ package admin
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/themakers/hlog"
|
||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/repository"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/pkg/validate_controllers"
|
||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/customer_clients"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type VerifyAdminControllerDeps struct {
|
||||
@ -29,7 +28,7 @@ func NewVerificationAdminController(deps VerifyAdminControllerDeps) *VerifyAdmin
|
||||
|
||||
func (r *VerifyAdminController) SetVerificationStatus(c *fiber.Ctx) error {
|
||||
var req models.ReqSetVerification
|
||||
hloger := c.Locals(models.HlogCtxKey).(hlog.Logger)
|
||||
hloger := log_mw.ExtractLogger(c)
|
||||
err := c.BodyParser(&req)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
@ -58,10 +57,6 @@ func (r *VerifyAdminController) SetVerificationStatus(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
hloger.Emit(models.InfoVerificationAccepted{
|
||||
CtxUserIP: c.IP(),
|
||||
CtxUserPort: c.Port(),
|
||||
KeyDomain: strings.Join(c.Subdomains(), "/"),
|
||||
KeyPath: c.Path(),
|
||||
CtxID: updated.ID,
|
||||
KeyStatus: updated.Status,
|
||||
CtxTaxNumber: updated.TaxNumber,
|
||||
@ -70,13 +65,9 @@ func (r *VerifyAdminController) SetVerificationStatus(c *fiber.Ctx) error {
|
||||
|
||||
if !req.Accepted {
|
||||
hloger.Emit(models.InfoVerificationDeclined{
|
||||
CtxUserIP: c.IP(),
|
||||
CtxUserPort: c.Port(),
|
||||
KeyDomain: strings.Join(c.Subdomains(), "/"),
|
||||
KeyPath: c.Path(),
|
||||
CtxID: updated.ID,
|
||||
KeyStatus: updated.Status,
|
||||
CtxComment: updated.Comment,
|
||||
CtxID: updated.ID,
|
||||
KeyStatus: updated.Status,
|
||||
CtxComment: updated.Comment,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,13 @@ package user
|
||||
import (
|
||||
"errors"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/themakers/hlog"
|
||||
"github.com/valyala/fasthttp"
|
||||
"mime/multipart"
|
||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/client"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/repository"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/pkg/validate_controllers"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type VerifyUserControllerDeps struct {
|
||||
@ -51,7 +50,7 @@ func (r *VerifyUserController) GetVerification(c *fiber.Ctx) error {
|
||||
func (r *VerifyUserController) CreateVerification(c *fiber.Ctx) error {
|
||||
var req models.ReqCreateVerification
|
||||
baseURL := c.BaseURL()
|
||||
hloger := c.Locals(models.HlogCtxKey).(hlog.Logger)
|
||||
hloger := log_mw.ExtractLogger(c)
|
||||
|
||||
userID := c.Locals(models.UserCtxKey).(string)
|
||||
if userID == "" {
|
||||
@ -116,12 +115,8 @@ func (r *VerifyUserController) CreateVerification(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
hloger.Emit(models.InfoVerificationRequested{
|
||||
CtxUserIP: c.IP(),
|
||||
CtxUserPort: c.Port(),
|
||||
KeyDomain: strings.Join(c.Subdomains(), "/"),
|
||||
KeyPath: c.Path(),
|
||||
CtxID: result.ID,
|
||||
KeyStatus: result.Status,
|
||||
CtxID: result.ID,
|
||||
KeyStatus: result.Status,
|
||||
})
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(result)
|
||||
@ -129,7 +124,7 @@ func (r *VerifyUserController) CreateVerification(c *fiber.Ctx) error {
|
||||
|
||||
func (r *VerifyUserController) SetVerificationFile(c *fiber.Ctx) error {
|
||||
baseURL := c.BaseURL()
|
||||
hloger := c.Locals(models.HlogCtxKey).(hlog.Logger)
|
||||
hloger := log_mw.ExtractLogger(c)
|
||||
|
||||
userID := c.Locals(models.UserCtxKey).(string)
|
||||
if userID == "" {
|
||||
@ -164,12 +159,8 @@ func (r *VerifyUserController) SetVerificationFile(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
hloger.Emit(models.InfoVerificationRequested{
|
||||
CtxUserIP: c.IP(),
|
||||
CtxUserPort: c.Port(),
|
||||
KeyDomain: strings.Join(c.Subdomains(), "/"),
|
||||
KeyPath: c.Path(),
|
||||
CtxID: result.ID,
|
||||
KeyStatus: result.Status,
|
||||
CtxID: result.ID,
|
||||
KeyStatus: result.Status,
|
||||
})
|
||||
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
|
@ -12,27 +12,15 @@ type AllFields struct {
|
||||
}
|
||||
|
||||
type InfoVerificationRequested struct { //эмиттить при подаче на верификацию и при замене файла
|
||||
CtxUserIP string
|
||||
CtxUserPort string
|
||||
KeyDomain string
|
||||
KeyPath string
|
||||
CtxID string // - айдишник верификации
|
||||
KeyStatus string // статус, который пользователь хочет обрести после верификации
|
||||
CtxID string // - айдишник верификации
|
||||
KeyStatus string // статус, который пользователь хочет обрести после верификации
|
||||
}
|
||||
type InfoVerificationDeclined struct {
|
||||
CtxUserIP string
|
||||
CtxUserPort string
|
||||
KeyDomain string
|
||||
KeyPath string
|
||||
CtxID string // - айдишник верификации
|
||||
KeyStatus string // статус, который пользователь хочет обрести после верификации
|
||||
CtxComment string // комментарий при отклонении
|
||||
CtxID string // - айдишник верификации
|
||||
KeyStatus string // статус, который пользователь хочет обрести после верификации
|
||||
CtxComment string // комментарий при отклонении
|
||||
}
|
||||
type InfoVerificationAccepted struct {
|
||||
CtxUserIP string
|
||||
CtxUserPort string
|
||||
KeyDomain string
|
||||
KeyPath string
|
||||
CtxID string // - айдишник верификации
|
||||
KeyStatus string // статус, который пользователь хочет обрести после верификации
|
||||
CtxTaxNumber string
|
||||
|
@ -8,4 +8,3 @@ type RespErrorValidate struct {
|
||||
|
||||
const UserCtxKey = "userID"
|
||||
const TokenCtxKey = "token"
|
||||
const HlogCtxKey = "logger"
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
"github.com/themakers/hlog"
|
||||
"go.uber.org/zap"
|
||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
|
||||
)
|
||||
|
||||
type ServerConfig struct {
|
||||
@ -34,7 +35,7 @@ func NewHTTP(cfg ServerConfig) *Server {
|
||||
fiberzap.New(fiberzap.Config{Logger: cfg.Logger}),
|
||||
LocalJwt(),
|
||||
Jwt(),
|
||||
ContextLogger(cfg.HLogger),
|
||||
log_mw.ContextLogger(cfg.HLogger),
|
||||
)
|
||||
|
||||
s := &Server{
|
||||
|
@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/themakers/hlog"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"strings"
|
||||
|
||||
@ -45,10 +44,3 @@ func Jwt() fiber.Handler {
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func ContextLogger(logger hlog.Logger) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
c.Locals(models.HlogCtxKey, logger)
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user