usermngmt/model/role_request.go

56 lines
936 B
Go
Raw Permalink Normal View History

2021-11-10 04:01:39 +00:00
package model
2021-11-10 07:50:43 +00:00
import (
"errors"
2022-10-10 08:55:47 +00:00
"git.selly.red/Selly-Modules/logger"
"git.selly.red/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{
"payload": co,
})
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{
"payload": co,
})
2021-12-07 07:28:52 +00:00
return errors.New(internal.ErrorInvalidName)
2021-11-10 07:50:43 +00:00
}
return nil
}