mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-12-05 15:31:25 +00:00
first
This commit is contained in:
56
http/request/admin/addressBook.go
Normal file
56
http/request/admin/addressBook.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"Gwen/model"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type AddressBookForm struct {
|
||||
RowId uint `json:"row_id"`
|
||||
Id string `json:"id" validate:"required"`
|
||||
Username string `json:"username" `
|
||||
Password string `json:"password" `
|
||||
Hostname string `json:"hostname" `
|
||||
Alias string `json:"alias" `
|
||||
Platform string `json:"platform" `
|
||||
Tags []string `json:"tags"`
|
||||
Hash string `json:"hash"`
|
||||
UserId uint `json:"user_id"`
|
||||
ForceAlwaysRelay bool `json:"force_always_relay"`
|
||||
RdpPort string `json:"rdp_port"`
|
||||
RdpUsername string `json:"rdp_username"`
|
||||
Online bool `json:"online"`
|
||||
LoginName string `json:"login_name" `
|
||||
SameServer bool `json:"same_server"`
|
||||
}
|
||||
|
||||
func (a AddressBookForm) ToAddressBook() *model.AddressBook {
|
||||
//tags转换
|
||||
tags, _ := json.Marshal(a.Tags)
|
||||
|
||||
return &model.AddressBook{
|
||||
RowId: a.RowId,
|
||||
Id: a.Id,
|
||||
Username: a.Username,
|
||||
Password: a.Password,
|
||||
Hostname: a.Hostname,
|
||||
Alias: a.Alias,
|
||||
Platform: a.Platform,
|
||||
Tags: tags,
|
||||
Hash: a.Hash,
|
||||
UserId: a.UserId,
|
||||
ForceAlwaysRelay: a.ForceAlwaysRelay,
|
||||
RdpPort: a.RdpPort,
|
||||
RdpUsername: a.RdpUsername,
|
||||
Online: a.Online,
|
||||
LoginName: a.LoginName,
|
||||
SameServer: a.SameServer,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type AddressBookQuery struct {
|
||||
UserId int `form:"user_id"`
|
||||
IsMy int `form:"is_my"`
|
||||
PageQuery
|
||||
}
|
||||
21
http/request/admin/group.go
Normal file
21
http/request/admin/group.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package admin
|
||||
|
||||
import "Gwen/model"
|
||||
|
||||
type GroupForm struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
func (gf *GroupForm) FromGroup(group *model.Group) *GroupForm {
|
||||
gf.Id = group.Id
|
||||
gf.Name = group.Name
|
||||
return gf
|
||||
}
|
||||
|
||||
func (gf *GroupForm) ToGroup() *model.Group {
|
||||
group := &model.Group{}
|
||||
group.Id = gf.Id
|
||||
group.Name = gf.Name
|
||||
return group
|
||||
}
|
||||
6
http/request/admin/login.go
Normal file
6
http/request/admin/login.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package admin
|
||||
|
||||
type Login struct {
|
||||
Username string `json:"username" validate:"required" label:"用户名"`
|
||||
Password string `json:"password,omitempty" validate:"required" label:"密码"`
|
||||
}
|
||||
30
http/request/admin/peer.go
Normal file
30
http/request/admin/peer.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package admin
|
||||
|
||||
import "Gwen/model"
|
||||
|
||||
type PeerForm struct {
|
||||
RowId uint `json:"row_id" `
|
||||
Id string `json:"id"`
|
||||
Cpu string `json:"cpu"`
|
||||
Hostname string `json:"hostname"`
|
||||
Memory string `json:"memory"`
|
||||
Os string `json:"os"`
|
||||
Username string `json:"username"`
|
||||
Uuid string `json:"uuid"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// ToPeer
|
||||
func (f *PeerForm) ToPeer() *model.Peer {
|
||||
return &model.Peer{
|
||||
RowId: f.RowId,
|
||||
Id: f.Id,
|
||||
Cpu: f.Cpu,
|
||||
Hostname: f.Hostname,
|
||||
Memory: f.Memory,
|
||||
Os: f.Os,
|
||||
Username: f.Username,
|
||||
Uuid: f.Uuid,
|
||||
Version: f.Version,
|
||||
}
|
||||
}
|
||||
33
http/request/admin/tag.go
Normal file
33
http/request/admin/tag.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package admin
|
||||
|
||||
import "Gwen/model"
|
||||
|
||||
type TagForm struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Color uint `json:"color" validate:"required"`
|
||||
UserId uint `json:"user_id" validate:"required"`
|
||||
}
|
||||
|
||||
func (f *TagForm) FromTag(group *model.Tag) *TagForm {
|
||||
f.Id = group.Id
|
||||
f.Name = group.Name
|
||||
f.Color = group.Color
|
||||
f.UserId = group.UserId
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *TagForm) ToTag() *model.Tag {
|
||||
i := &model.Tag{}
|
||||
i.Id = f.Id
|
||||
i.Name = f.Name
|
||||
i.Color = f.Color
|
||||
i.UserId = f.UserId
|
||||
return i
|
||||
}
|
||||
|
||||
type TagQuery struct {
|
||||
UserId int `form:"user_id"`
|
||||
IsMy int `form:"is_my"`
|
||||
PageQuery
|
||||
}
|
||||
57
http/request/admin/user.go
Normal file
57
http/request/admin/user.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"Gwen/model"
|
||||
)
|
||||
|
||||
type UserForm struct {
|
||||
Id uint `json:"id"`
|
||||
Username string `json:"username" validate:"required,gte=4,lte=10"`
|
||||
//Password string `json:"password" validate:"required,gte=4,lte=20"`
|
||||
Nickname string `json:"nickname" validate:"required"`
|
||||
Avatar string `json:"avatar"`
|
||||
GroupId uint `json:"group_id" validate:"required"`
|
||||
IsAdmin *bool `json:"is_admin" `
|
||||
Status model.StatusCode `json:"status" validate:"required,gte=0"`
|
||||
}
|
||||
|
||||
func (uf *UserForm) FromUser(user *model.User) *UserForm {
|
||||
uf.Id = user.Id
|
||||
uf.Username = user.Username
|
||||
uf.Nickname = user.Nickname
|
||||
uf.Avatar = user.Avatar
|
||||
uf.GroupId = user.GroupId
|
||||
uf.IsAdmin = user.IsAdmin
|
||||
uf.Status = user.Status
|
||||
return uf
|
||||
}
|
||||
func (uf *UserForm) ToUser() *model.User {
|
||||
user := &model.User{}
|
||||
user.Id = uf.Id
|
||||
user.Username = uf.Username
|
||||
user.Nickname = uf.Nickname
|
||||
user.Avatar = uf.Avatar
|
||||
user.GroupId = uf.GroupId
|
||||
user.IsAdmin = uf.IsAdmin
|
||||
user.Status = uf.Status
|
||||
return user
|
||||
}
|
||||
|
||||
type PageQuery struct {
|
||||
Page uint `form:"page"`
|
||||
PageSize uint `form:"page_size"`
|
||||
}
|
||||
|
||||
type UserQuery struct {
|
||||
PageQuery
|
||||
Username string `form:"username"`
|
||||
}
|
||||
type UserPasswordForm struct {
|
||||
Id uint `json:"id" validate:"required"`
|
||||
Password string `json:"password" validate:"required,gte=4,lte=20"`
|
||||
}
|
||||
|
||||
type ChangeCurPasswordForm struct {
|
||||
OldPassword string `json:"old_password" validate:"required,gte=4,lte=20"`
|
||||
NewPassword string `json:"new_password" validate:"required,gte=4,lte=20"`
|
||||
}
|
||||
Reference in New Issue
Block a user