add validate lead target type in post it
This commit is contained in:
parent
dcac16a2e8
commit
b4d95db30c
2
go.mod
2
go.mod
@ -18,7 +18,7 @@ require (
|
||||
google.golang.org/grpc v1.64.0
|
||||
google.golang.org/protobuf v1.34.1
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240611160822-0013810bb882
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240612083524-11882ffe22cf
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990
|
||||
)
|
||||
|
||||
|
4
go.sum
4
go.sum
@ -259,7 +259,7 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6 h1:oV+/HNX+JPoQ3/GUx08hio7d45WpY0AMGrFs7j70QlA=
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240611160822-0013810bb882 h1:Y64tHM2aEO1syR45bV4uiFBSauIrvEzA47XEf6v8Pq8=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240611160822-0013810bb882/go.mod h1:n66zm88Dh12+idyfqh0vU5nd9BZYxM6Pv0XYnmy0398=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240612083524-11882ffe22cf h1:cTmv0YZE1B+ofsWfHYEiNxzToWKMy12rVW3cPOrtp30=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240612083524-11882ffe22cf/go.mod h1:n66zm88Dh12+idyfqh0vU5nd9BZYxM6Pv0XYnmy0398=
|
||||
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=
|
||||
|
@ -245,6 +245,10 @@ func (s *Service) PostLeadTarget(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required")
|
||||
}
|
||||
|
||||
if _, ok := model.ValidLeadTargetTypes[req.Type]; !ok {
|
||||
return ctx.Status(fiber.StatusBadRequest).SendString("Invalid type")
|
||||
}
|
||||
|
||||
if req.Type == "" || req.Target == "" {
|
||||
return ctx.Status(fiber.StatusBadRequest).SendString("Type and Target don't be nil")
|
||||
}
|
||||
@ -252,7 +256,7 @@ func (s *Service) PostLeadTarget(ctx *fiber.Ctx) error {
|
||||
result, err := s.dal.AccountRepo.PostLeadTarget(ctx.Context(), model.LeadTarget{
|
||||
AccountID: accountID,
|
||||
Target: req.Target,
|
||||
Type: req.Type,
|
||||
Type: model.LeadTargetType(req.Type),
|
||||
QuizID: req.QuizID,
|
||||
})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user