queries added , validation added , structure updated
parent
6b2ac4b006
commit
fb6325c60b
|
@ -1,8 +1,10 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"netina/models"
|
m "netina/models"
|
||||||
|
c "netina/models/commands"
|
||||||
l "netina/repositories/license"
|
l "netina/repositories/license"
|
||||||
|
"netina/validation"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,8 +14,12 @@ type CreateLicenseHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func(r *CreateLicenseHandler) Handle (command models.CreateLicenseCommand) error {
|
func(r *CreateLicenseHandler) Handle (command c.CreateLicenseCommand) error {
|
||||||
license := &models.License{
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
license := &m.License{
|
||||||
Plan_id: command.Plan_id,
|
Plan_id: command.Plan_id,
|
||||||
Period: command.Period,
|
Period: command.Period,
|
||||||
Created_at: time.Now(),
|
Created_at: time.Now(),
|
||||||
|
@ -29,8 +35,13 @@ type UpdateLicenseHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *UpdateLicenseHandler) Handle (id uint , command models.UpdateLicenseCommand) (*models.License , error) {
|
func (r *UpdateLicenseHandler) Handle (id uint , command c.UpdateLicenseCommand) (*m.License , error) {
|
||||||
license := &models.License{
|
|
||||||
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return nil , err
|
||||||
|
}
|
||||||
|
|
||||||
|
license := &m.License{
|
||||||
Plan_id: command.Plan_id,
|
Plan_id: command.Plan_id,
|
||||||
Period: command.Period,
|
Period: command.Period,
|
||||||
Modified_by: command.Modified_by,
|
Modified_by: command.Modified_by,
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"netina/models"
|
m "netina/models"
|
||||||
|
c "netina/models/commands"
|
||||||
o "netina/repositories/owner"
|
o "netina/repositories/owner"
|
||||||
|
"netina/validation"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,8 +13,11 @@ type CreateOwnerHandler struct{
|
||||||
Repository o.OwnerCommandRepository
|
Repository o.OwnerCommandRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CreateOwnerHandler) Handle(command models.CreateOwnerCommand) error {
|
func (r *CreateOwnerHandler) Handle(command c.CreateOwnerCommand) error {
|
||||||
owner := &models.Owner{
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
owner := &m.Owner{
|
||||||
PhoneNumber: command.PhoneNumber,
|
PhoneNumber: command.PhoneNumber,
|
||||||
FirstName: command.FirstName,
|
FirstName: command.FirstName,
|
||||||
LastName: command.LastName,
|
LastName: command.LastName,
|
||||||
|
@ -30,8 +35,13 @@ type UpdateOwnerHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *UpdateOwnerHandler) Handle(id uint , command models.UpdateOwnerCommand)(*models.Owner , error) {
|
func (r *UpdateOwnerHandler) Handle(id uint , command c.UpdateOwnerCommand)(*m.Owner , error) {
|
||||||
owner := &models.Owner{
|
|
||||||
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return nil , err
|
||||||
|
}
|
||||||
|
|
||||||
|
owner := &m.Owner{
|
||||||
PhoneNumber: command.PhoneNumber,
|
PhoneNumber: command.PhoneNumber,
|
||||||
FirstName: command.FirstName,
|
FirstName: command.FirstName,
|
||||||
LastName: command.LastName,
|
LastName: command.LastName,
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"netina/models"
|
m "netina/models"
|
||||||
|
c "netina/models/commands"
|
||||||
p "netina/repositories/plan"
|
p "netina/repositories/plan"
|
||||||
|
"netina/validation"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,8 +14,13 @@ type CreatePlanHandler struct {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (r *CreatePlanHandler) Handle(command models.CreatePlanCommand) error {
|
func (r *CreatePlanHandler) Handle(command c.CreatePlanCommand) error {
|
||||||
plan := &models.Plan{
|
|
||||||
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
plan := &m.Plan{
|
||||||
Price: command.Price,
|
Price: command.Price,
|
||||||
Priod: command.Priod,
|
Priod: command.Priod,
|
||||||
Partnership: command.Partnership,
|
Partnership: command.Partnership,
|
||||||
|
@ -31,8 +38,12 @@ type UpdatePlanHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *UpdatePlanHandler) Handle (id uint , command models.UpdatePlanCommand)(*models.Plan , error) {
|
func (r *UpdatePlanHandler) Handle (id uint , command c.UpdatePlanCommand)(*m.Plan , error) {
|
||||||
plan := &models.Plan{
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return nil , err
|
||||||
|
}
|
||||||
|
|
||||||
|
plan := &m.Plan{
|
||||||
Price: command.Price,
|
Price: command.Price,
|
||||||
Priod: command.Priod,
|
Priod: command.Priod,
|
||||||
Partnership: command.Partnership,
|
Partnership: command.Partnership,
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"netina/models"
|
m "netina/models"
|
||||||
|
c "netina/models/commands"
|
||||||
s "netina/repositories/store"
|
s "netina/repositories/store"
|
||||||
|
"netina/validation"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,8 +14,13 @@ type CreateStoreHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *CreateStoreHandler) Handle (command models.CreateStoreCommand)error {
|
func (r *CreateStoreHandler) Handle (command c.CreateStoreCommand)error {
|
||||||
store := &models.Store{
|
|
||||||
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
store := &m.Store{
|
||||||
Owner_id: command.Owner_id,
|
Owner_id: command.Owner_id,
|
||||||
Name: command.Name,
|
Name: command.Name,
|
||||||
Address: command.Address,
|
Address: command.Address,
|
||||||
|
@ -38,8 +45,13 @@ type UpdateStoreHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (r *UpdateStoreHandler) Handle (id uint ,command models.UpdateStoreCommand)(*models.Store , error) {
|
func (r *UpdateStoreHandler) Handle (id uint ,command c.UpdateStoreCommand)(*m.Store , error) {
|
||||||
store := &models.Store{
|
|
||||||
|
if err := validation.ValidateStruct(command); err != nil {
|
||||||
|
return nil,err
|
||||||
|
}
|
||||||
|
|
||||||
|
store := &m.Store{
|
||||||
Owner_id: command.Owner_id,
|
Owner_id: command.Owner_id,
|
||||||
Name: command.Name,
|
Name: command.Name,
|
||||||
Address: command.Address,
|
Address: command.Address,
|
||||||
|
|
11
go.mod
11
go.mod
|
@ -9,11 +9,18 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||||
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
golang.org/x/crypto v0.14.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
golang.org/x/text v0.13.0 // indirect
|
golang.org/x/crypto v0.19.0 // indirect
|
||||||
|
golang.org/x/net v0.21.0 // indirect
|
||||||
|
golang.org/x/sys v0.17.0 // indirect
|
||||||
|
golang.org/x/text v0.14.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
18
go.sum
18
go.sum
|
@ -1,6 +1,14 @@
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||||
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
|
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||||
|
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||||
|
@ -13,6 +21,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
@ -22,8 +32,16 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
|
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||||
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
|
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
|
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||||
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|
|
@ -19,4 +19,4 @@ type Store struct {
|
||||||
Modified_at time.Time
|
Modified_at time.Time
|
||||||
Modified_by string
|
Modified_by string
|
||||||
Is_removed bool `gorm:"default:false"`
|
Is_removed bool `gorm:"default:false"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"netina/models"
|
||||||
|
l "netina/repositories/license"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type GetLicenseHandler struct {
|
||||||
|
Repository l.LicenseQueryRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (r *GetLicenseHandler) Handle (id uint)(*models.License ,error) {
|
||||||
|
return r.Repository.GetLicense(id)
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"netina/models"
|
||||||
|
o "netina/repositories/owner"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type GetOwnerHandler struct {
|
||||||
|
Repository o.OwnerQueryRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (r *GetOwnerHandler) Handle (id uint)(*models.Owner ,error) {
|
||||||
|
return r.Repository.GetOwner(id)
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"netina/models"
|
||||||
|
p "netina/repositories/plan"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type GetPlanHandler struct {
|
||||||
|
Repository p.PlanQueryRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (r *GetPlanHandler) Handle (id uint)(*models.Plan ,error) {
|
||||||
|
return r.Repository.GetPlan(id)
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package queries
|
||||||
|
|
||||||
|
import (
|
||||||
|
"netina/models"
|
||||||
|
s "netina/repositories/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type GetStoreHandler struct {
|
||||||
|
Repository s.StoreQueryRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (r *GetStoreHandler) Handle (id uint)(*models.Store ,error) {
|
||||||
|
return r.Repository.GetStore(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type GetStoreListHandler struct {
|
||||||
|
Repository s.StoreQueryRepository
|
||||||
|
}
|
||||||
|
|
||||||
|
// get owner id and return owner's stores
|
||||||
|
func (r *GetStoreListHandler) Handle (id uint)([]models.Store ,error) {
|
||||||
|
return r.Repository.GetStores(id)
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package validation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-playground/validator/v10"
|
||||||
|
)
|
||||||
|
|
||||||
|
var validate *validator.Validate
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
validate = validator.New()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ValidateStruct(s interface{}) error {
|
||||||
|
return validate.Struct(s)
|
||||||
|
}
|
Loading…
Reference in New Issue