| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package admin
- import (
- "encoding/json"
- "github.com/lejianwen/rustdesk-api/model"
- )
- 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"`
- UserIds []uint `json:"user_ids"`
- ForceAlwaysRelay bool `json:"forceAlwaysRelay"`
- RdpPort string `json:"rdpPort"`
- RdpUsername string `json:"rdpUsername"`
- Online bool `json:"online"`
- LoginName string `json:"loginName" `
- SameServer bool `json:"sameServer"`
- CollectionId uint `json:"collection_id"`
- }
- 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,
- CollectionId: a.CollectionId,
- }
- }
- func (a AddressBookForm) ToAddressBooks() []*model.AddressBook {
- //tags转换
- tags, _ := json.Marshal(a.Tags)
- abs := make([]*model.AddressBook, 0, len(a.UserIds))
- for _, userId := range a.UserIds {
- abs = append(abs, &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: userId,
- ForceAlwaysRelay: a.ForceAlwaysRelay,
- RdpPort: a.RdpPort,
- RdpUsername: a.RdpUsername,
- Online: a.Online,
- LoginName: a.LoginName,
- SameServer: a.SameServer,
- CollectionId: a.CollectionId,
- })
- }
- return abs
- }
- type AddressBookQuery struct {
- UserId int `form:"user_id"`
- CollectionId *int `form:"collection_id"`
- IsMy int `form:"is_my"`
- Username string `form:"username"`
- Hostname string `form:"hostname"`
- Id string `form:"id"`
- PageQuery
- }
- type ShareByWebClientForm struct {
- Id string `json:"id" validate:"required"`
- PasswordType string `json:"password_type" validate:"required,oneof=once fixed"` //只能是once,fixed
- Password string `json:"password" validate:"required"`
- Expire int64 `json:"expire"`
- }
- func (sbwcf ShareByWebClientForm) ToShareRecord() *model.ShareRecord {
- return &model.ShareRecord{
- UserId: 0,
- PeerId: sbwcf.Id,
- PasswordType: sbwcf.PasswordType,
- Password: sbwcf.Password,
- Expire: sbwcf.Expire,
- }
- }
- type AddressBookCollectionQuery struct {
- UserId int `form:"user_id"`
- IsMy int `form:"is_my"`
- PageQuery
- }
- type AddressBookCollectionSimpleListQuery struct {
- UserIds []uint `form:"user_ids"`
- }
- type AddressBookCollectionRuleQuery struct {
- UserId int `form:"user_id"`
- CollectionId int `form:"collection_id"`
- IsMy int `form:"is_my"`
- PageQuery
- }
- type BatchCreateFromPeersForm struct {
- CollectionId uint `json:"collection_id"`
- PeerIds []uint `json:"peer_ids"`
- Tags []string `json:"tags"`
- UserId uint `json:"user_id"`
- }
- type BatchUpdateTagsForm struct {
- RowIds []uint `json:"row_ids"`
- Tags []string `json:"tags"`
- }
|