183 lines
3.4 KiB
Go
183 lines
3.4 KiB
Go
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
package models
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
strfmt "github.com/go-openapi/strfmt"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/swag"
|
|
)
|
|
|
|
// User user
|
|
// swagger:model User
|
|
type User struct {
|
|
|
|
// company
|
|
Company *UserCompany `json:"company,omitempty"`
|
|
|
|
// roles
|
|
Roles []*UserRolesItems0 `json:"roles"`
|
|
|
|
// user Id
|
|
UserID int64 `json:"userId,omitempty"`
|
|
|
|
// user name
|
|
UserName string `json:"userName,omitempty"`
|
|
}
|
|
|
|
// Validate validates this user
|
|
func (m *User) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
if err := m.validateCompany(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateRoles(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *User) validateCompany(formats strfmt.Registry) error {
|
|
|
|
if swag.IsZero(m.Company) { // not required
|
|
return nil
|
|
}
|
|
|
|
if m.Company != nil {
|
|
if err := m.Company.Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("company")
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *User) validateRoles(formats strfmt.Registry) error {
|
|
|
|
if swag.IsZero(m.Roles) { // not required
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < len(m.Roles); i++ {
|
|
if swag.IsZero(m.Roles[i]) { // not required
|
|
continue
|
|
}
|
|
|
|
if m.Roles[i] != nil {
|
|
if err := m.Roles[i].Validate(formats); err != nil {
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
return ve.ValidateName("roles" + "." + strconv.Itoa(i))
|
|
}
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *User) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *User) UnmarshalBinary(b []byte) error {
|
|
var res User
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|
|
|
|
// UserCompany user company
|
|
// swagger:model UserCompany
|
|
type UserCompany struct {
|
|
|
|
// code
|
|
Code string `json:"code,omitempty"`
|
|
|
|
// id
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
// name
|
|
Name string `json:"name,omitempty"`
|
|
}
|
|
|
|
// Validate validates this user company
|
|
func (m *UserCompany) Validate(formats strfmt.Registry) error {
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *UserCompany) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *UserCompany) UnmarshalBinary(b []byte) error {
|
|
var res UserCompany
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|
|
|
|
// UserRolesItems0 user roles items0
|
|
// swagger:model UserRolesItems0
|
|
type UserRolesItems0 struct {
|
|
|
|
// name
|
|
Name string `json:"name,omitempty"`
|
|
|
|
// rights
|
|
Rights []string `json:"rights"`
|
|
}
|
|
|
|
// Validate validates this user roles items0
|
|
func (m *UserRolesItems0) Validate(formats strfmt.Registry) error {
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *UserRolesItems0) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return swag.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *UserRolesItems0) UnmarshalBinary(b []byte) error {
|
|
var res UserRolesItems0
|
|
if err := swag.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|