usermngmt/model/role_request.go

60 lines
1.1 KiB
Go
Raw Normal View History

2021-11-10 04:01:39 +00:00
package model
2021-11-10 07:50:43 +00:00
import (
"errors"
"github.com/Selly-Modules/logger"
2021-12-07 07:28:52 +00:00
"github.com/Selly-Modules/usermngmt/internal"
2021-11-10 07:50:43 +00:00
)
2021-11-10 04:01:39 +00:00
// RoleCreateOptions ...
type RoleCreateOptions struct {
2021-11-19 02:59:33 +00:00
Name string
Level int
IsAdmin bool
2021-11-10 04:01:39 +00:00
}
2021-11-10 07:50:43 +00:00
// RoleUpdateOptions ...
type RoleUpdateOptions struct {
2021-11-19 02:59:33 +00:00
Name string
Level int
IsAdmin bool
2021-11-10 07:50:43 +00:00
}
// RoleAllQuery ...
type RoleAllQuery struct {
Page int64
Limit int64
2021-11-16 07:26:50 +00:00
Sort interface{}
2021-11-10 07:50:43 +00:00
}
// Validate ...
func (co RoleCreateOptions) Validate() error {
// Name
if co.Name == "" {
logger.Error("usermngmt - Role - Create: no name data", logger.LogData{
2022-10-05 10:59:08 +00:00
Source: "usermngmt.Validate",
Message: "usermngmt - Role - Create: no name data",
Data: co,
2021-11-10 07:50:43 +00:00
})
2021-12-07 07:28:52 +00:00
return errors.New(internal.ErrorInvalidName)
2021-11-10 07:50:43 +00:00
}
return nil
}
// Validate ...
func (co RoleUpdateOptions) Validate() error {
// Name
if co.Name == "" {
logger.Error("usermngmt - Role - Update: no name data", logger.LogData{
2022-10-05 10:59:08 +00:00
Source: "usermngmt.Validate",
Message: "usermngmt - Role - Update: no name data",
Data: co,
2021-11-10 07:50:43 +00:00
})
2021-12-07 07:28:52 +00:00
return errors.New(internal.ErrorInvalidName)
2021-11-10 07:50:43 +00:00
}
return nil
}