Files
server/model/user.go
饺子w (Yumechi) 496c166981 chore: Migrate github.com/jinzhu/gorm to gorm.io/gorm (#863)
* chore: Migrate github.com/jinzhu/gorm to gorm.io/gorm

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* chore: drop singleton connection limit on sqlite3 backend

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* enhance: database logging

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* Revert "chore: drop singleton connection limit on sqlite3 backend"

This reverts commit b494a3bd1f.

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* typo

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* rename unique_index -> uniqueIndex

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* drop uniqueIndex on primary key

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* migrate fully to new gorm tag format

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* specify unique index name

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* remove pluginConf duplicate index

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* disable auto migrate FK

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

---------

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2025-10-29 22:23:10 +00:00

95 lines
2.3 KiB
Go

package model
// The User holds information about the credentials of a user and its application and client tokens.
type User struct {
ID uint `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"type:varchar(180);uniqueIndex:uix_users_name"`
Pass []byte
Admin bool
Applications []Application
Clients []Client
Plugins []PluginConf
}
// UserExternal Model
//
// The User holds information about permission and other stuff.
//
// swagger:model User
type UserExternal struct {
// The user id.
//
// read only: true
// required: true
// example: 25
ID uint `json:"id"`
// The user name. For login.
//
// required: true
// example: unicorn
Name string `binding:"required" json:"name" query:"name" form:"name"`
// If the user is an administrator.
//
// required: true
// example: true
Admin bool `json:"admin" form:"admin" query:"admin"`
}
// CreateUserExternal Model
//
// Used for user creation.
//
// swagger:model CreateUserExternal
type CreateUserExternal struct {
// The user name. For login.
//
// required: true
// example: unicorn
Name string `binding:"required" json:"name" query:"name" form:"name"`
// If the user is an administrator.
//
// required: true
// example: true
Admin bool `json:"admin" form:"admin" query:"admin"`
// The user password. For login.
//
// required: true
// example: nrocinu
Pass string `json:"pass,omitempty" form:"pass" query:"pass" binding:"required"`
}
// UpdateUserExternal Model
//
// Used for updating a user.
//
// swagger:model UpdateUserExternal
type UpdateUserExternal struct {
// The user name. For login.
//
// required: true
// example: unicorn
Name string `binding:"required" json:"name" query:"name" form:"name"`
// If the user is an administrator.
//
// required: true
// example: true
Admin bool `json:"admin" form:"admin" query:"admin"`
// The user password. For login. Empty for using old password
//
// example: nrocinu
Pass string `json:"pass,omitempty" form:"pass" query:"pass"`
}
// UserExternalPass Model
//
// The Password for updating the user.
//
// swagger:model UserPass
type UserExternalPass struct {
// The user password. For login.
//
// required: true
// example: nrocinu
Pass string `json:"pass,omitempty" form:"pass" query:"pass" binding:"required"`
}