This commit is contained in:
ljw
2024-09-13 15:57:29 +08:00
commit c53df223d1
112 changed files with 14353 additions and 0 deletions

9
http/response/api/ab.go Normal file
View File

@@ -0,0 +1,9 @@
package api
import "Gwen/model"
type AbList struct {
Peers []*model.AddressBook `json:"peers,omitempty"`
Tags []string `json:"tags,omitempty"`
TagColors string `json:"tag_colors,omitempty"`
}

74
http/response/api/peer.go Normal file
View File

@@ -0,0 +1,74 @@
package api
import "Gwen/model"
/*
GroupPeerPayload
https://github.com/rustdesk/rustdesk/blob/master/flutter/lib/common/hbbs/hbbs.dart#L64
String id = '';
Map<String, dynamic> info = {};
int? status;
String user = '';
String user_name = '';
String note = '';
PeerPayload.fromJson(Map<String, dynamic> json)
: id = json['id'] ?? '',
info = (json['info'] is Map<String, dynamic>) ? json['info'] : {},
status = json['status'],
user = json['user'] ?? '',
user_name = json['user_name'] ?? '',
note = json['note'] ?? '';
static Peer toPeer(GroupPeerPayload p) {
return Peer.fromJson({
"id": p.id,
'loginName': p.user_name,
"username": p.info['username'] ?? '',
"platform": _platform(p.info['os']),
"hostname": p.info['device_name'],
});
}
*/
type GroupPeerPayload struct {
Id string `json:"id"`
Info *PeerPayloadInfo `json:"info"`
Status int `json:"status"`
User string `json:"user"`
UserName string `json:"user_name"`
Note string `json:"note"`
}
type PeerPayloadInfo struct {
DeviceName string `json:"device_name"`
Os string `json:"os"`
Username string `json:"username"`
}
func (gpp *GroupPeerPayload) FromAddressBook(a *model.AddressBook, username string) {
gpp.Id = a.Id
os := a.Platform
if a.Platform == "Mac OS" {
os = "MacOS"
}
gpp.Info = &PeerPayloadInfo{
DeviceName: a.Hostname,
Os: os,
Username: a.Username,
}
gpp.UserName = username
}
//func (gpp *GroupPeerPayload) FromPeer(p *model.Peer) {
// gpp.Id = p.Id
// gpp.Info = &PeerPayloadInfo{
// DeviceName: p.Hostname,
// Os: p.Os,
// Username: p.Username,
// }
// gpp.Note = ""
// if p.User.Id != 0 {
// //gpp.User = p.User.Username
// gpp.UserName = p.User.Username
// }
//}

55
http/response/api/user.go Normal file
View File

@@ -0,0 +1,55 @@
package api
import "Gwen/model"
/*
pub enum UserStatus {
Disabled = 0,
Normal = 1,
Unverified = -1,
}
*/
/*
UserPayload
String name = ”;
String email = ”;
String note = ”;
UserStatus status;
bool isAdmin = false;
*/
type UserPayload struct {
Name string `json:"name"`
Email string `json:"email"`
Note string `json:"note"`
IsAdmin *bool `json:"is_admin"`
Status int `json:"status"`
}
func (up *UserPayload) FromUser(user *model.User) *UserPayload {
up.Name = user.Username
up.IsAdmin = user.IsAdmin
up.Status = int(user.Status)
return up
}
/*
class HttpType {
static const kAuthReqTypeAccount = "account";
static const kAuthReqTypeMobile = "mobile";
static const kAuthReqTypeSMSCode = "sms_code";
static const kAuthReqTypeEmailCode = "email_code";
static const kAuthReqTypeTfaCode = "tfa_code";
static const kAuthResTypeToken = "access_token";
static const kAuthResTypeEmailCheck = "email_check";
static const kAuthResTypeTfaCheck = "tfa_check";
}
*/
type LoginRes struct {
Type string `json:"type"`
AccessToken string `json:"access_token"`
User UserPayload `json:"user"`
Secret string `json:"secret"`
TfaType string `json:"tfa_type"`
}

View File

@@ -0,0 +1,55 @@
package api
import (
"Gwen/model"
"time"
)
// type T struct {
// Field1 struct {
// ViewStyle string `json:"view-style"`
// Tm int64 `json:"tm"`
// Info struct {
// Username string `json:"username"`
// Hostname string `json:"hostname"`
// Platform string `json:"platform"`
// Displays []struct {
// X int `json:"x"`
// Y int `json:"y"`
// Width int `json:"width"`
// Height int `json:"height"`
// Name string `json:"name"`
// Online bool `json:"online"`
// } `json:"displays"`
// CurrentDisplay int `json:"current_display"`
// SasEnabled bool `json:"sas_enabled"`
// Version string `json:"version"`
// ConnId int `json:"conn_id"`
// Features struct {
// PrivacyMode bool `json:"privacy_mode"`
// } `json:"features"`
// } `json:"info"`
// } `json:"1799928825"`
// }
type WebClientPeerPayload struct {
ViewStyle string `json:"view-style"`
Tm int64 `json:"tm"`
Info WebClientPeerInfoPayload `json:"info"`
}
type WebClientPeerInfoPayload struct {
Username string `json:"username"`
Hostname string `json:"hostname"`
Platform string `json:"platform"`
}
func (wcpp *WebClientPeerPayload) FromAddressBook(a *model.AddressBook) {
wcpp.ViewStyle = "shrink"
wcpp.Tm = time.Now().UnixNano()
wcpp.Info = WebClientPeerInfoPayload{
Username: a.Username,
Hostname: a.Hostname,
Platform: a.Platform,
}
}