mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2026-02-17 14:04:51 +08: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"`
|
||||
}
|
||||
37
http/request/api/peer.go
Normal file
37
http/request/api/peer.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package api
|
||||
|
||||
import "Gwen/model"
|
||||
|
||||
type AddressBookFormData struct {
|
||||
Tags []string `json:"tags"`
|
||||
Peers []*model.AddressBook `json:"peers"`
|
||||
TagColors string `json:"tag_colors"`
|
||||
}
|
||||
|
||||
type AddressBookForm struct {
|
||||
Data string `json:"data" example:"{\"tags\":[\"tag1\",\"tag2\",\"tag3\"],\"peers\":[{\"id\":\"abc\",\"username\":\"abv-l\",\"hostname\":\"\",\"platform\":\"Windows\",\"alias\":\"\",\"tags\":[\"tag1\",\"tag2\"],\"hash\":\"hash\"}],\"tag_colors\":\"{\\\"tag1\\\":4288585374,\\\"tag2\\\":4278238420,\\\"tag3\\\":4291681337}\"}"`
|
||||
}
|
||||
|
||||
type PeerForm struct {
|
||||
Cpu string `json:"cpu"`
|
||||
Hostname string `json:"hostname"`
|
||||
Id string `json:"id"`
|
||||
Memory string `json:"memory"`
|
||||
Os string `json:"os"`
|
||||
Username string `json:"username"`
|
||||
Uuid string `json:"uuid"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
func (pf *PeerForm) ToPeer() *model.Peer {
|
||||
return &model.Peer{
|
||||
Cpu: pf.Cpu,
|
||||
Hostname: pf.Hostname,
|
||||
Id: pf.Id,
|
||||
Memory: pf.Memory,
|
||||
Os: pf.Os,
|
||||
Username: pf.Username,
|
||||
Uuid: pf.Uuid,
|
||||
Version: pf.Version,
|
||||
}
|
||||
}
|
||||
41
http/request/api/user.go
Normal file
41
http/request/api/user.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package api
|
||||
|
||||
/*
|
||||
*
|
||||
|
||||
message LoginRequest {
|
||||
string username = 1;
|
||||
bytes password = 2;
|
||||
string my_id = 4;
|
||||
string my_name = 5;
|
||||
OptionMessage option = 6;
|
||||
oneof union {
|
||||
FileTransfer file_transfer = 7;
|
||||
PortForward port_forward = 8;
|
||||
}
|
||||
bool video_ack_required = 9;
|
||||
uint64 session_id = 10;
|
||||
string version = 11;
|
||||
OSLogin os_login = 12;
|
||||
string my_platform = 13;
|
||||
bytes hwid = 14;
|
||||
}
|
||||
*/
|
||||
type LoginForm struct {
|
||||
Username string `json:"username" validate:"required,gte=4,lte=10" label:"用户名"`
|
||||
Password string `json:"password,omitempty" validate:"gte=4,lte=20" label:"密码"`
|
||||
}
|
||||
|
||||
type UserListQuery struct {
|
||||
Page uint `json:"page" form:"page" validate:"required" label:"页码"`
|
||||
PageSize uint `json:"page_size" form:"page_size" validate:"required" label:"每页数量"`
|
||||
Status int `json:"status" form:"status" label:"状态"`
|
||||
Accessible string `json:"accessible" form:"accessible"`
|
||||
}
|
||||
|
||||
type PeerListQuery struct {
|
||||
Page uint `json:"page" form:"page" validate:"required" label:"页码"`
|
||||
PageSize uint `json:"page_size" form:"page_size" validate:"required" label:"每页数量"`
|
||||
Status int `json:"status" form:"status" label:"状态"`
|
||||
Accessible string `json:"accessible" form:"accessible"`
|
||||
}
|
||||
Reference in New Issue
Block a user