i18n: Translate all Chinese to English across the codebase

Translate Chinese comments, log/error messages, validator labels and
Swagger annotations to English throughout the source code, generated
Swagger docs, config files and CI workflows.

Make the English README primary: README.md now holds the English docs
and README_EN.md holds the Chinese version, with cross-language links
updated accordingly.

Note: the generated docs/ swagger files were translated in place; run
`go generate ./...` (swag init) to regenerate them from the now-English
annotations when a Go toolchain is available.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 12:17:04 +02:00
co-authored by Claude Opus 4.8
parent c5687e1506
commit 16e97c8efa
103 changed files with 3088 additions and 3086 deletions
+39 -39
View File
@@ -15,10 +15,10 @@ import (
type AddressBook struct {
}
// Detail 地址簿
// @Tags 地址簿
// @Summary 地址簿详情
// @Description 地址簿详情
// Detail address book
// @Tags address book
// @Summary address book details
// @Description address book details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -38,13 +38,13 @@ func (ct *AddressBook) Detail(c *gin.Context) {
return
}
// Create 创建地址簿
// @Tags 地址簿
// @Summary 创建地址簿
// @Description 创建地址簿
// Create create address book
// @Tags address book
// @Summary create address book
// @Description create address book
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response{data=model.AddressBook}
// @Failure 500 {object} response.Response
// @Router /admin/address_book/create [post]
@@ -84,13 +84,13 @@ func (ct *AddressBook) Create(c *gin.Context) {
response.Success(c, nil)
}
// BatchCreate 批量创建地址簿
// @Tags 地址簿
// @Summary 批量创建地址簿
// @Description 批量创建地址簿
// BatchCreate batch create address books
// @Tags address book
// @Summary batch create address books
// @Description batch create address books
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response{data=model.AddressBook}
// @Failure 500 {object} response.Response
// @Router /admin/address_book/batchCreate [post]
@@ -113,13 +113,13 @@ func (ct *AddressBook) BatchCreate(c *gin.Context) {
return
}
if ul > 1 {
//多用户置空标签
//clear tags in multi-user mode
f.Tags = []string{}
//多用户只能创建到默认地址簿
//in multi-user mode, can only create in the default address book
f.CollectionId = 0
}
//创建标签
//create tag
/*for _, fu := range f.UserIds {
if fu == 0 {
continue
@@ -148,16 +148,16 @@ func (ct *AddressBook) BatchCreate(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 地址簿
// @Summary 地址簿列表
// @Description 地址簿列表
// List list
// @Tags address book
// @Summary address book list
// @Description address book list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param user_id query int false "用户id"
// @Param is_my query int false "是否是我的"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param user_id query int false "userid"
// @Param is_my query int false "whether it is mine"
// @Success 200 {object} response.Response{data=model.AddressBookList}
// @Failure 500 {object} response.Response
// @Router /admin/address_book/list [get]
@@ -196,13 +196,13 @@ func (ct *AddressBook) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 地址簿
// @Summary 地址簿编辑
// @Description 地址簿编辑
// Update edit
// @Tags address book
// @Summary edit address book
// @Description edit address book
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response{data=model.AddressBook}
// @Failure 500 {object} response.Response
// @Router /admin/address_book/update [post]
@@ -240,13 +240,13 @@ func (ct *AddressBook) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 地址簿
// @Summary 地址簿删除
// @Description 地址簿删除
// Delete delete
// @Tags address book
// @Summary delete address book
// @Description delete address book
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/address_book/delete [post]
@@ -277,12 +277,12 @@ func (ct *AddressBook) Delete(c *gin.Context) {
}
// ShareByWebClient
// @Tags 地址簿
// @Summary 地址簿分享
// @Description 地址簿分享
// @Tags address book
// @Summary share address book
// @Description share address book
// @Accept json
// @Produce json
// @Param body body admin.ShareByWebClientForm true "地址簿信息"
// @Param body body admin.ShareByWebClientForm true "address book info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/address_book/share [post]
+27 -27
View File
@@ -14,10 +14,10 @@ import (
type AddressBookCollection struct {
}
// Detail 地址簿名称
// @Tags 地址簿名称
// @Summary 地址簿名称详情
// @Description 地址簿名称详情
// Detail address book name
// @Tags address book name
// @Summary address book name details
// @Description address book name details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -37,13 +37,13 @@ func (abc *AddressBookCollection) Detail(c *gin.Context) {
return
}
// Create 创建地址簿名称
// @Tags 地址簿名称
// @Summary 创建地址簿名称
// @Description 创建地址簿名称
// Create create address book name
// @Tags address book name
// @Summary create address book name
// @Description create address book name
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollection true "地址簿名称信息"
// @Param body body model.AddressBookCollection true "address book name info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection/create [post]
@@ -72,16 +72,16 @@ func (abc *AddressBookCollection) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 地址簿名称
// @Summary 地址簿名称列表
// @Description 地址簿名称列表
// List list
// @Tags address book name
// @Summary address book name list
// @Description address book name list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param is_my query int false "是否是我的"
// @Param user_id query int false "用户id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param is_my query int false "whether it is mine"
// @Param user_id query int false "userid"
// @Success 200 {object} response.Response{data=model.AddressBookCollectionList}
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection/list [get]
@@ -100,13 +100,13 @@ func (abc *AddressBookCollection) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 地址簿名称
// @Summary 地址簿名称编辑
// @Description 地址簿名称编辑
// Update edit
// @Tags address book name
// @Summary edit address book name
// @Description edit address book name
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollection true "地址簿名称信息"
// @Param body body model.AddressBookCollection true "address book name info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection/update [post]
@@ -135,13 +135,13 @@ func (abc *AddressBookCollection) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 地址簿名称
// @Summary 地址簿名称删除
// @Description 地址簿名称删除
// Delete delete
// @Tags address book name
// @Summary delete address book name
// @Description delete address book name
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollection true "地址簿名称信息"
// @Param body body model.AddressBookCollection true "address book name info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection/delete [post]
@@ -14,17 +14,17 @@ import (
type AddressBookCollectionRule struct {
}
// List 列表
// @Tags 地址簿规则
// @Summary 地址簿规则列表
// @Description 地址簿规则列表
// List list
// @Tags address book rules
// @Summary address book rule list
// @Description address book rule list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param is_my query int false "是否是我的"
// @Param user_id query int false "用户id"
// @Param collection_id query int false "地址簿集合id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param is_my query int false "whether it is mine"
// @Param user_id query int false "userid"
// @Param collection_id query int false "address book collectionid"
// @Success 200 {object} response.Response{data=model.AddressBookCollectionList}
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection_rule/list [get]
@@ -47,10 +47,10 @@ func (abcr *AddressBookCollectionRule) List(c *gin.Context) {
response.Success(c, res)
}
// Detail 地址簿规则
// @Tags 地址簿规则
// @Summary 地址簿规则详情
// @Description 地址簿规则详情
// Detail address book rules
// @Tags address book rules
// @Summary address book rule details
// @Description address book rule details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -69,13 +69,13 @@ func (abcr *AddressBookCollectionRule) Detail(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// Create 创建地址簿规则
// @Tags 地址簿规则
// @Summary 创建地址簿规则
// @Description 创建地址簿规则
// Create create address book rule
// @Tags address book rules
// @Summary create address book rule
// @Description create address book rule
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollectionRule true "地址簿规则信息"
// @Param body body model.AddressBookCollectionRule true "address book rule info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection_rule/create [post]
@@ -134,7 +134,7 @@ func (abcr *AddressBookCollectionRule) CheckForm(t *model.AddressBookCollectionR
} else {
return "ParamsError", false
}
// 重复检查
// duplicate check
ex := service.AllService.AddressBookService.RuleInfoByToIdAndCid(t.Type, t.ToId, t.CollectionId)
if t.Id == 0 && ex.Id > 0 {
return "ItemExists", false
@@ -145,13 +145,13 @@ func (abcr *AddressBookCollectionRule) CheckForm(t *model.AddressBookCollectionR
return "", true
}
// Update 编辑
// @Tags 地址簿规则
// @Summary 地址簿规则编辑
// @Description 地址簿规则编辑
// Update edit
// @Tags address book rules
// @Summary edit address book rule
// @Description edit address book rule
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollectionRule true "地址簿规则信息"
// @Param body body model.AddressBookCollectionRule true "address book rule info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection_rule/update [post]
@@ -185,13 +185,13 @@ func (abcr *AddressBookCollectionRule) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 地址簿规则
// @Summary 地址簿规则删除
// @Description 地址簿规则删除
// Delete delete
// @Tags address book rules
// @Summary delete address book rule
// @Description delete address book rule
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollectionRule true "地址簿规则信息"
// @Param body body model.AddressBookCollectionRule true "address book rule info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/address_book_collection_rule/delete [post]
+36 -36
View File
@@ -13,16 +13,16 @@ import (
type Audit struct {
}
// ConnList 列表
// @Tags 链接日志
// @Summary 链接日志列表
// @Description 链接日志列表
// ConnList list
// @Tags connection log
// @Summary connection log list
// @Description connection log list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param peer_id query int false "目标设备"
// @Param from_peer query int false "来源设备"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param peer_id query int false "target device"
// @Param from_peer query int false "source device"
// @Success 200 {object} response.Response{data=model.AuditConnList}
// @Failure 500 {object} response.Response
// @Router /admin/audit_conn/list [get]
@@ -45,13 +45,13 @@ func (a *Audit) ConnList(c *gin.Context) {
response.Success(c, res)
}
// ConnDelete 删除
// @Tags 链接日志
// @Summary 链接日志删除
// @Description 链接日志删除
// ConnDelete delete
// @Tags connection log
// @Summary delete connection log
// @Description delete connection log
// @Accept json
// @Produce json
// @Param body body model.AuditConn true "链接日志信息"
// @Param body body model.AuditConn true "connection log info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/audit_conn/delete [post]
@@ -81,13 +81,13 @@ func (a *Audit) ConnDelete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// BatchConnDelete 删除
// @Tags 链接日志
// @Summary 链接日志批量删除
// @Description 链接日志批量删除
// BatchConnDelete delete
// @Tags connection log
// @Summary batch delete connection logs
// @Description batch delete connection logs
// @Accept json
// @Produce json
// @Param body body admin.AuditConnLogIds true "链接日志"
// @Param body body admin.AuditConnLogIds true "connection log"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/audit_conn/batchDelete [post]
@@ -112,16 +112,16 @@ func (a *Audit) BatchConnDelete(c *gin.Context) {
return
}
// FileList 列表
// @Tags 文件日志
// @Summary 文件日志列表
// @Description 文件日志列表
// FileList list
// @Tags file log
// @Summary file log list
// @Description file log list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param peer_id query int false "目标设备"
// @Param from_peer query int false "来源设备"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param peer_id query int false "target device"
// @Param from_peer query int false "source device"
// @Success 200 {object} response.Response{data=model.AuditFileList}
// @Failure 500 {object} response.Response
// @Router /admin/audit_file/list [get]
@@ -144,13 +144,13 @@ func (a *Audit) FileList(c *gin.Context) {
response.Success(c, res)
}
// FileDelete 删除
// @Tags 文件日志
// @Summary 文件日志删除
// @Description 文件日志删除
// FileDelete delete
// @Tags file log
// @Summary delete file log
// @Description delete file log
// @Accept json
// @Produce json
// @Param body body model.AuditFile true "文件日志信息"
// @Param body body model.AuditFile true "file log info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/audit_file/delete [post]
@@ -180,13 +180,13 @@ func (a *Audit) FileDelete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// BatchFileDelete 删除
// @Tags 文件日志
// @Summary 文件日志批量删除
// @Description 文件日志批量删除
// BatchFileDelete delete
// @Tags file log
// @Summary batch delete file logs
// @Description batch delete file logs
// @Accept json
// @Produce json
// @Param body body admin.AuditFileLogIds true "文件日志"
// @Param body body admin.AuditFileLogIds true "file log"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/audit_file/batchDelete [post]
+9 -9
View File
@@ -13,10 +13,10 @@ import (
type Config struct {
}
// ServerConfig RUSTDESK服务配置
// ServerConfig RUSTDESKservice config
// @Tags ADMIN
// @Summary RUSTDESK服务配置
// @Description 服务配置,给webclient提供api-server
// @Summary RUSTDESKservice config
// @Description service config, provides an api-server for the webclient
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -33,10 +33,10 @@ func (co *Config) ServerConfig(c *gin.Context) {
response.Success(c, cf)
}
// AppConfig APP服务配置
// AppConfig APPservice config
// @Tags ADMIN
// @Summary APP服务配置
// @Description APP服务配置
// @Summary APPservice config
// @Description APPservice config
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -49,10 +49,10 @@ func (co *Config) AppConfig(c *gin.Context) {
})
}
// AdminConfig ADMIN服务配置
// AdminConfig ADMINservice config
// @Tags ADMIN
// @Summary ADMIN服务配置
// @Description ADMIN服务配置
// @Summary ADMINservice config
// @Description ADMINservice config
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
+25 -25
View File
@@ -12,10 +12,10 @@ import (
type DeviceGroup struct {
}
// Detail 设备群组
// @Tags 设备群组
// @Summary 设备群组详情
// @Description 设备群组详情
// Detail device group
// @Tags device group
// @Summary device group details
// @Description device group details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -35,13 +35,13 @@ func (ct *DeviceGroup) Detail(c *gin.Context) {
return
}
// Create 创建设备群组
// @Tags 设备群组
// @Summary 创建设备群组
// @Description 创建设备群组
// Create create device group
// @Tags device group
// @Summary create device group
// @Description create device group
// @Accept json
// @Produce json
// @Param body body admin.DeviceGroupForm true "设备群组信息"
// @Param body body admin.DeviceGroupForm true "device group info"
// @Success 200 {object} response.Response{data=model.DeviceGroup}
// @Failure 500 {object} response.Response
// @Router /admin/device_group/create [post]
@@ -66,14 +66,14 @@ func (ct *DeviceGroup) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 群组
// @Summary 群组列表
// @Description 群组列表
// List list
// @Tags group
// @Summary group list
// @Description group list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} response.Response{data=model.GroupList}
// @Failure 500 {object} response.Response
// @Router /admin/device_group/list [get]
@@ -88,13 +88,13 @@ func (ct *DeviceGroup) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 设备群组
// @Summary 设备群组编辑
// @Description 设备群组编辑
// Update edit
// @Tags device group
// @Summary edit device group
// @Description edit device group
// @Accept json
// @Produce json
// @Param body body admin.DeviceGroupForm true "群组信息"
// @Param body body admin.DeviceGroupForm true "group info"
// @Success 200 {object} response.Response{data=model.Group}
// @Failure 500 {object} response.Response
// @Router /admin/device_group/update [post]
@@ -123,13 +123,13 @@ func (ct *DeviceGroup) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 设备群组
// @Summary 设备群组删除
// @Description 设备群组删除
// Delete delete
// @Tags device group
// @Summary delete device group
// @Description delete device group
// @Accept json
// @Produce json
// @Param body body admin.DeviceGroupForm true "群组信息"
// @Param body body admin.DeviceGroupForm true "group info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/device_group/delete [post]
+12 -12
View File
@@ -13,10 +13,10 @@ import (
type File struct {
}
// OssToken 文件
// @Tags 文件
// @Summary 获取ossToken
// @Description 获取ossToken
// OssToken file
// @Tags file
// @Summary getossToken
// @Description getossToken
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -33,7 +33,7 @@ type FileBack struct {
Url string `json:"url"`
}
// Notify 上传成功后回调
// Notify callback after successful upload
func (f *File) Notify(c *gin.Context) {
res := global.Oss.Verify(c.Request)
@@ -50,13 +50,13 @@ func (f *File) Notify(c *gin.Context) {
}
// Upload 上传文件到本地
// @Tags 文件
// @Summary 上传文件到本地
// @Description 上传文件到本地
// Upload upload file to local
// @Tags file
// @Summary upload file to local
// @Description upload file to local
// @Accept multipart/form-data
// @Produce json
// @Param file formData file true "上传文件示例"
// @Param file formData file true "file upload example"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/file/upload [post]
@@ -71,12 +71,12 @@ func (f *File) Upload(c *gin.Context) {
if err != nil {
return
}
// 上传文件至指定目录
// upload the file to the specified directory
err = c.SaveUploadedFile(file, dst)
if err != nil {
return
}
// 返回文件web地址
// return filewebaddress
response.Success(c, gin.H{
"url": webPath + file.Filename,
})
+25 -25
View File
@@ -12,10 +12,10 @@ import (
type Group struct {
}
// Detail 群组
// @Tags 群组
// @Summary 群组详情
// @Description 群组详情
// Detail group
// @Tags group
// @Summary group details
// @Description group details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -35,13 +35,13 @@ func (ct *Group) Detail(c *gin.Context) {
return
}
// Create 创建群组
// @Tags 群组
// @Summary 创建群组
// @Description 创建群组
// Create create group
// @Tags group
// @Summary create group
// @Description create group
// @Accept json
// @Produce json
// @Param body body admin.GroupForm true "群组信息"
// @Param body body admin.GroupForm true "group info"
// @Success 200 {object} response.Response{data=model.Group}
// @Failure 500 {object} response.Response
// @Router /admin/group/create [post]
@@ -66,14 +66,14 @@ func (ct *Group) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 群组
// @Summary 群组列表
// @Description 群组列表
// List list
// @Tags group
// @Summary group list
// @Description group list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} response.Response{data=model.GroupList}
// @Failure 500 {object} response.Response
// @Router /admin/group/list [get]
@@ -88,13 +88,13 @@ func (ct *Group) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 群组
// @Summary 群组编辑
// @Description 群组编辑
// Update edit
// @Tags group
// @Summary edit group
// @Description edit group
// @Accept json
// @Produce json
// @Param body body admin.GroupForm true "群组信息"
// @Param body body admin.GroupForm true "group info"
// @Success 200 {object} response.Response{data=model.Group}
// @Failure 500 {object} response.Response
// @Router /admin/group/update [post]
@@ -123,13 +123,13 @@ func (ct *Group) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 群组
// @Summary 群组删除
// @Description 群组删除
// Delete delete
// @Tags group
// @Summary delete group
// @Description delete group
// @Accept json
// @Produce json
// @Param body body admin.GroupForm true "群组信息"
// @Param body body admin.GroupForm true "group info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/group/delete [post]
+15 -15
View File
@@ -17,13 +17,13 @@ import (
type Login struct {
}
// Login 登录
// @Tags 登录
// @Summary 登录
// @Description 登录
// Login login
// @Tags login
// @Summary login
// @Description login
// @Accept json
// @Produce json
// @Param body body admin.Login true "登录信息"
// @Param body body admin.Login true "login info"
// @Success 200 {object} response.Response{data=adResp.LoginPayload}
// @Failure 500 {object} response.Response
// @Router /admin/login [post]
@@ -34,7 +34,7 @@ func (ct *Login) Login(c *gin.Context) {
return
}
// 检查登录限制
// check login limit
loginLimiter := global.LoginLimiter
clientIp := c.ClientIP()
_, needCaptcha := loginLimiter.CheckSecurityStatus(clientIp)
@@ -56,7 +56,7 @@ func (ct *Login) Login(c *gin.Context) {
return
}
// 检查是否需要验证码
// check whether a captcha is required
if needCaptcha {
if f.CaptchaId == "" || f.Captcha == "" || !loginLimiter.VerifyCaptcha(f.CaptchaId, f.Captcha) {
response.Fail(c, 101, response.TranslateMsg(c, "CaptchaError"))
@@ -95,7 +95,7 @@ func (ct *Login) Login(c *gin.Context) {
Platform: f.Platform,
})
// 登录成功,清除登录限制
// login successful, clear the login limit
loginLimiter.RemoveAttempts(clientIp)
responseLoginSuccess(c, u, ut.Token)
}
@@ -129,10 +129,10 @@ func (ct *Login) Captcha(c *gin.Context) {
})
}
// Logout 登出
// @Tags 登录
// @Summary 登出
// @Description 登出
// Logout logout
// @Tags login
// @Summary logout
// @Description logout
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -148,9 +148,9 @@ func (ct *Login) Logout(c *gin.Context) {
}
// LoginOptions
// @Tags 登录
// @Summary 登录选项
// @Description 登录选项
// @Tags login
// @Summary login options
// @Description login options
// @Accept json
// @Produce json
// @Success 200 {object} []string
+21 -21
View File
@@ -14,10 +14,10 @@ import (
type LoginLog struct {
}
// Detail 登录日志
// @Tags 登录日志
// @Summary 登录日志详情
// @Description 登录日志详情
// Detail login log
// @Tags login log
// @Summary login log details
// @Description login log details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -37,15 +37,15 @@ func (ct *LoginLog) Detail(c *gin.Context) {
return
}
// List 列表
// @Tags 登录日志
// @Summary 登录日志列表
// @Description 登录日志列表
// List list
// @Tags login log
// @Summary login log list
// @Description login log list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param user_id query int false "用户ID"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param user_id query int false "userID"
// @Success 200 {object} response.Response{data=model.LoginLogList}
// @Failure 500 {object} response.Response
// @Router /admin/login_log/list [get]
@@ -65,13 +65,13 @@ func (ct *LoginLog) List(c *gin.Context) {
response.Success(c, res)
}
// Delete 删除
// @Tags 登录日志
// @Summary 登录日志删除
// @Description 登录日志删除
// Delete delete
// @Tags login log
// @Summary delete login log
// @Description delete login log
// @Accept json
// @Produce json
// @Param body body model.LoginLog true "登录日志信息"
// @Param body body model.LoginLog true "login log info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/login_log/delete [post]
@@ -101,13 +101,13 @@ func (ct *LoginLog) Delete(c *gin.Context) {
response.Fail(c, 101, err.Error())
}
// BatchDelete 删除
// @Tags 登录日志
// @Summary 登录日志批量删除
// @Description 登录日志批量删除
// BatchDelete delete
// @Tags login log
// @Summary batch delete login logs
// @Description batch delete login logs
// @Accept json
// @Produce json
// @Param body body admin.LoginLogIds true "登录日志"
// @Param body body admin.LoginLogIds true "login log"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/login_log/batchDelete [post]
+23 -23
View File
@@ -12,15 +12,15 @@ import (
type AddressBook struct{}
// List 列表
// @Tags 我的地址簿
// @Summary 地址簿列表
// @Description 地址簿列表
// List list
// @Tags my address book
// @Summary address book list
// @Description address book list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param user_id query int false "用户id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param user_id query int false "userid"
// @Success 200 {object} response.Response{data=model.AddressBookList}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book/list [get]
@@ -34,7 +34,7 @@ func (ct *AddressBook) List(c *gin.Context) {
u := service.AllService.UserService.CurUser(c)
query.UserId = int(u.Id)
res := service.AllService.AddressBookService.List(query.Page, query.PageSize, func(tx *gorm.DB) {
//预加载地址簿名称
//preload address book name
tx.Preload("Collection", func(txc *gorm.DB) *gorm.DB {
return txc.Select("id,name")
})
@@ -60,13 +60,13 @@ func (ct *AddressBook) List(c *gin.Context) {
response.Success(c, res)
}
// Create 创建地址簿
// @Tags 我的地址簿
// @Summary 创建地址簿
// @Description 创建地址簿
// Create create address book
// @Tags my address book
// @Summary create address book
// @Description create address book
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response{data=model.AddressBook}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book/create [post]
@@ -104,13 +104,13 @@ func (ct *AddressBook) Create(c *gin.Context) {
response.Success(c, nil)
}
// Update 编辑
// @Tags 我的地址簿
// @Summary 地址簿编辑
// @Description 地址簿编辑
// Update edit
// @Tags my address book
// @Summary edit address book
// @Description edit address book
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response{data=model.AddressBook}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book/update [post]
@@ -158,13 +158,13 @@ func (ct *AddressBook) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 我的地址簿
// @Summary 地址簿删除
// @Description 地址簿删除
// Delete delete
// @Tags my address book
// @Summary delete address book
// @Description delete address book
// @Accept json
// @Produce json
// @Param body body admin.AddressBookForm true "地址簿信息"
// @Param body body admin.AddressBookForm true "address book info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book/delete [post]
@@ -13,13 +13,13 @@ import (
type AddressBookCollection struct {
}
// Create 创建地址簿名称
// @Tags 我的地址簿名称
// @Summary 创建地址簿名称
// @Description 创建地址簿名称
// Create create address book name
// @Tags my address book name
// @Summary create address book name
// @Description create address book name
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollection true "地址簿名称信息"
// @Param body body model.AddressBookCollection true "address book name info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection/create [post]
@@ -45,14 +45,14 @@ func (abc *AddressBookCollection) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 我的地址簿名称
// @Summary 地址簿名称列表
// @Description 地址簿名称列表
// List list
// @Tags my address book name
// @Summary address book name list
// @Description address book name list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} response.Response{data=model.AddressBookCollectionList}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection/list [get]
@@ -71,13 +71,13 @@ func (abc *AddressBookCollection) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 我的地址簿名称
// @Summary 地址簿名称编辑
// @Description 地址簿名称编辑
// Update edit
// @Tags my address book name
// @Summary edit address book name
// @Description edit address book name
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollection true "地址簿名称信息"
// @Param body body model.AddressBookCollection true "address book name info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection/update [post]
@@ -120,13 +120,13 @@ func (abc *AddressBookCollection) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 我的地址簿名称
// @Summary 地址簿名称删除
// @Description 地址簿名称删除
// Delete delete
// @Tags my address book name
// @Summary delete address book name
// @Description delete address book name
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollection true "地址簿名称信息"
// @Param body body model.AddressBookCollection true "address book name info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection/delete [post]
@@ -13,17 +13,17 @@ import (
type AddressBookCollectionRule struct {
}
// List 列表
// @Tags 我的地址簿规则
// @Summary 地址簿规则列表
// @Description 地址簿规则列表
// List list
// @Tags my address book rules
// @Summary address book rule list
// @Description address book rule list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param is_my query int false "是否是我的"
// @Param user_id query int false "用户id"
// @Param collection_id query int false "地址簿集合id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param is_my query int false "whether it is mine"
// @Param user_id query int false "userid"
// @Param collection_id query int false "address book collectionid"
// @Success 200 {object} response.Response{data=model.AddressBookCollectionList}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection_rule/list [get]
@@ -46,13 +46,13 @@ func (abcr *AddressBookCollectionRule) List(c *gin.Context) {
response.Success(c, res)
}
// Create 创建地址簿规则
// @Tags 我的地址簿规则
// @Summary 创建地址簿规则
// @Description 创建地址簿规则
// Create create address book rule
// @Tags my address book rules
// @Summary create address book rule
// @Description create address book rule
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollectionRule true "地址簿规则信息"
// @Param body body model.AddressBookCollectionRule true "address book rule info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection_rule/create [post]
@@ -106,12 +106,12 @@ func (abcr *AddressBookCollectionRule) CheckForm(u *model.User, t *model.Address
if tou.Id == 0 {
return "ItemNotFound", false
}
//非管理员不能分享给非本组织用户
//non-admins cannot share with users outside their own organization
//if tou.GroupId != u.GroupId {
// return "NoAccess", false
//}
} else if t.Type == model.ShareAddressBookRuleTypeGroup {
//非管理员不能分享给其他组
//non-admins cannot share with other groups
//if t.ToId != u.GroupId {
// return "NoAccess", false
//}
@@ -123,7 +123,7 @@ func (abcr *AddressBookCollectionRule) CheckForm(u *model.User, t *model.Address
} else {
return "ParamsError", false
}
// 重复检查
// duplicate check
ex := service.AllService.AddressBookService.RuleInfoByToIdAndCid(t.Type, t.ToId, t.CollectionId)
if t.Id == 0 && ex.Id > 0 {
return "ItemExists", false
@@ -134,13 +134,13 @@ func (abcr *AddressBookCollectionRule) CheckForm(u *model.User, t *model.Address
return "", true
}
// Update 编辑
// @Tags 我的地址簿规则
// @Summary 地址簿规则编辑
// @Description 地址簿规则编辑
// Update edit
// @Tags my address book rules
// @Summary edit address book rule
// @Description edit address book rule
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollectionRule true "地址簿规则信息"
// @Param body body model.AddressBookCollectionRule true "address book rule info"
// @Success 200 {object} response.Response{data=model.AddressBookCollection}
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection_rule/update [post]
@@ -185,13 +185,13 @@ func (abcr *AddressBookCollectionRule) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 我的地址簿规则
// @Summary 地址簿规则删除
// @Description 地址簿规则删除
// Delete delete
// @Tags my address book rules
// @Summary delete address book rule
// @Description delete address book rule
// @Accept json
// @Produce json
// @Param body body model.AddressBookCollectionRule true "地址簿规则信息"
// @Param body body model.AddressBookCollectionRule true "address book rule info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/address_book_collection_rule/delete [post]
+17 -17
View File
@@ -13,15 +13,15 @@ import (
type LoginLog struct {
}
// List 列表
// @Tags 我的登录日志
// @Summary 登录日志列表
// @Description 登录日志列表
// List list
// @Tags my login logs
// @Summary login log list
// @Description login log list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param user_id query int false "用户ID"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param user_id query int false "userID"
// @Success 200 {object} response.Response{data=model.LoginLogList}
// @Failure 500 {object} response.Response
// @Router /admin/my/login_log/list [get]
@@ -40,13 +40,13 @@ func (ct *LoginLog) List(c *gin.Context) {
response.Success(c, res)
}
// Delete 删除
// @Tags 我的登录日志
// @Summary 登录日志删除
// @Description 登录日志删除
// Delete delete
// @Tags my login logs
// @Summary delete login log
// @Description delete login log
// @Accept json
// @Produce json
// @Param body body model.LoginLog true "登录日志信息"
// @Param body body model.LoginLog true "login log info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/login_log/delete [post]
@@ -81,13 +81,13 @@ func (ct *LoginLog) Delete(c *gin.Context) {
response.Fail(c, 101, err.Error())
}
// BatchDelete 删除
// @Tags 我的登录日志
// @Summary 登录日志批量删除
// @Description 登录日志批量删除
// BatchDelete delete
// @Tags my login logs
// @Summary batch delete login logs
// @Description batch delete login logs
// @Accept json
// @Produce json
// @Param body body admin.LoginLogIds true "登录日志"
// @Param body body admin.LoginLogIds true "login log"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/login_log/batchDelete [post]
+9 -9
View File
@@ -12,18 +12,18 @@ import (
type Peer struct {
}
// List 列表
// @Tags 我的设备
// @Summary 设备列表
// @Description 设备列表
// List list
// @Tags my devices
// @Summary device list
// @Description device list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param time_ago query int false "时间"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param time_ago query int false "time"
// @Param id query string false "ID"
// @Param hostname query string false "主机名"
// @Param uuids query string false "uuids 用逗号分隔"
// @Param hostname query string false "hostname"
// @Param uuids query string false "uuids separated by commas"
// @Success 200 {object} response.Response{data=model.PeerList}
// @Failure 500 {object} response.Response
// @Router /admin/my/peer/list [get]
+15 -15
View File
@@ -12,14 +12,14 @@ import (
type ShareRecord struct {
}
// List 分享记录列表
// @Tags 我的分享记录
// @Summary 分享记录列表
// @Description 分享记录列表
// List share record list
// @Tags my share records
// @Summary share record list
// @Description share record list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/share_record/list [get]
@@ -37,13 +37,13 @@ func (sr *ShareRecord) List(c *gin.Context) {
response.Success(c, res)
}
// Delete 分享记录删除
// @Tags 我的分享记录
// @Summary 分享记录删除
// @Description 分享记录删除
// Delete delete share record
// @Tags my share records
// @Summary delete share record
// @Description delete share record
// @Accept json
// @Produce json
// @Param body body admin.ShareRecordForm true "分享记录信息"
// @Param body body admin.ShareRecordForm true "share record info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/share_record/delete [post]
@@ -78,10 +78,10 @@ func (sr *ShareRecord) Delete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "OperationFailed")+err.Error())
}
// BatchDelete 批量删除我的分享记录
// @Tags 我的
// @Summary 批量删除我的分享记录
// @Description 批量删除我的分享记录
// BatchDelete batch delete my share records
// @Tags my
// @Summary batch delete my share records
// @Description batch delete my share records
// @Accept json
// @Produce json
// @Param body body admin.PeerShareRecordBatchDeleteForm true "id"
+23 -23
View File
@@ -11,16 +11,16 @@ import (
type Tag struct{}
// List 列表
// @Tags 我的标签
// @Summary 标签列表
// @Description 标签列表
// List list
// @Tags my tags
// @Summary tag list
// @Description tag list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param is_my query int false "是否是我的"
// @Param user_id query int false "用户id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param is_my query int false "whether it is mine"
// @Param user_id query int false "userid"
// @Success 200 {object} response.Response{data=model.TagList}
// @Failure 500 {object} response.Response
// @Router /admin/my/tag/list [get]
@@ -45,13 +45,13 @@ func (ct *Tag) List(c *gin.Context) {
response.Success(c, res)
}
// Create 创建标签
// @Tags 我的标签
// @Summary 创建标签
// @Description 创建标签
// Create create tag
// @Tags my tags
// @Summary create tag
// @Description create tag
// @Accept json
// @Produce json
// @Param body body admin.TagForm true "标签信息"
// @Param body body admin.TagForm true "tag info"
// @Success 200 {object} response.Response{data=model.Tag}
// @Failure 500 {object} response.Response
// @Router /admin/my/tag/create [post]
@@ -78,13 +78,13 @@ func (ct *Tag) Create(c *gin.Context) {
response.Success(c, nil)
}
// Update 编辑
// @Tags 我的标签
// @Summary 标签编辑
// @Description 标签编辑
// Update edit
// @Tags my tags
// @Summary edit tag
// @Description edit tag
// @Accept json
// @Produce json
// @Param body body admin.TagForm true "标签信息"
// @Param body body admin.TagForm true "tag info"
// @Success 200 {object} response.Response{data=model.Tag}
// @Failure 500 {object} response.Response
// @Router /admin/my/tag/update [post]
@@ -133,13 +133,13 @@ func (ct *Tag) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 标签
// @Summary 标签删除
// @Description 标签删除
// Delete delete
// @Tags tag
// @Summary delete tag
// @Description delete tag
// @Accept json
// @Produce json
// @Param body body admin.TagForm true "标签信息"
// @Param body body admin.TagForm true "tag info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/my/tag/delete [post]
+20 -20
View File
@@ -64,7 +64,7 @@ func (o *Oauth) ToBind(c *gin.Context) {
})
}
// Confirm 确认授权登录
// Confirm confirm authorized login
func (o *Oauth) Confirm(c *gin.Context) {
j := &adminReq.OauthConfirmForm{}
err := c.ShouldBindJSON(j)
@@ -140,8 +140,8 @@ func (o *Oauth) Unbind(c *gin.Context) {
// Detail Oauth
// @Tags Oauth
// @Summary Oauth详情
// @Description Oauth详情
// @Summary Oauthdetails
// @Description Oauthdetails
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -161,13 +161,13 @@ func (o *Oauth) Detail(c *gin.Context) {
return
}
// Create 创建Oauth
// Create createOauth
// @Tags Oauth
// @Summary 创建Oauth
// @Description 创建Oauth
// @Summary createOauth
// @Description createOauth
// @Accept json
// @Produce json
// @Param body body admin.OauthForm true "Oauth信息"
// @Param body body admin.OauthForm true "Oauthinfo"
// @Success 200 {object} response.Response{data=model.Oauth}
// @Failure 500 {object} response.Response
// @Router /admin/oauth/create [post]
@@ -202,14 +202,14 @@ func (o *Oauth) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// List list
// @Tags Oauth
// @Summary Oauth列表
// @Description Oauth列表
// @Summary Oauthlist
// @Description Oauthlist
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} response.Response{data=model.OauthList}
// @Failure 500 {object} response.Response
// @Router /admin/oauth/list [get]
@@ -224,13 +224,13 @@ func (o *Oauth) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// Update edit
// @Tags Oauth
// @Summary Oauth编辑
// @Description Oauth编辑
// @Summary Oauthedit
// @Description Oauthedit
// @Accept json
// @Produce json
// @Param body body admin.OauthForm true "Oauth信息"
// @Param body body admin.OauthForm true "Oauthinfo"
// @Success 200 {object} response.Response{data=model.OauthList}
// @Failure 500 {object} response.Response
// @Router /admin/oauth/update [post]
@@ -259,13 +259,13 @@ func (o *Oauth) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// Delete delete
// @Tags Oauth
// @Summary Oauth删除
// @Description Oauth删除
// @Summary Oauthdelete
// @Description Oauthdelete
// @Accept json
// @Produce json
// @Param body body admin.OauthForm true "Oauth信息"
// @Param body body admin.OauthForm true "Oauthinfo"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/oauth/delete [post]
+34 -34
View File
@@ -14,10 +14,10 @@ import (
type Peer struct {
}
// Detail 设备
// @Tags 设备
// @Summary 设备详情
// @Description 设备详情
// Detail device
// @Tags device
// @Summary device details
// @Description device details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -37,13 +37,13 @@ func (ct *Peer) Detail(c *gin.Context) {
return
}
// Create 创建设备
// @Tags 设备
// @Summary 创建设备
// @Description 创建设备
// Create create device
// @Tags device
// @Summary create device
// @Description create device
// @Accept json
// @Produce json
// @Param body body admin.PeerForm true "设备信息"
// @Param body body admin.PeerForm true "device info"
// @Success 200 {object} response.Response{data=model.Peer}
// @Failure 500 {object} response.Response
// @Router /admin/peer/create [post]
@@ -68,18 +68,18 @@ func (ct *Peer) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 设备
// @Summary 设备列表
// @Description 设备列表
// List list
// @Tags device
// @Summary device list
// @Description device list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param time_ago query int false "时间"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param time_ago query int false "time"
// @Param id query string false "ID"
// @Param hostname query string false "主机名"
// @Param uuids query string false "uuids 用逗号分隔"
// @Param hostname query string false "hostname"
// @Param uuids query string false "uuids separated by commas"
// @Success 200 {object} response.Response{data=model.PeerList}
// @Failure 500 {object} response.Response
// @Router /admin/peer/list [get]
@@ -121,13 +121,13 @@ func (ct *Peer) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 设备
// @Summary 设备编辑
// @Description 设备编辑
// Update edit
// @Tags device
// @Summary edit device
// @Description edit device
// @Accept json
// @Produce json
// @Param body body admin.PeerForm true "设备信息"
// @Param body body admin.PeerForm true "device info"
// @Success 200 {object} response.Response{data=model.Peer}
// @Failure 500 {object} response.Response
// @Router /admin/peer/update [post]
@@ -156,13 +156,13 @@ func (ct *Peer) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 设备
// @Summary 设备删除
// @Description 设备删除
// Delete delete
// @Tags device
// @Summary delete device
// @Description delete device
// @Accept json
// @Produce json
// @Param body body admin.PeerForm true "设备信息"
// @Param body body admin.PeerForm true "device info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/peer/delete [post]
@@ -192,13 +192,13 @@ func (ct *Peer) Delete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// BatchDelete 批量删除
// @Tags 设备
// @Summary 批量设备删除
// @Description 批量设备删除
// BatchDelete batch delete
// @Tags device
// @Summary batch delete devices
// @Description batch delete devices
// @Accept json
// @Produce json
// @Param body body admin.PeerBatchDeleteForm true "设备id"
// @Param body body admin.PeerBatchDeleteForm true "deviceid"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/peer/batchDelete [post]
@@ -232,7 +232,7 @@ func (ct *Peer) SimpleData(c *gin.Context) {
return
}
res := service.AllService.PeerService.List(1, 99999, func(tx *gorm.DB) {
//可以公开的情报
//information that can be made public
tx.Select("id,version")
tx.Where("id in (?)", f.Ids)
})
+1 -1
View File
@@ -25,7 +25,7 @@ func (r *Rustdesk) CmdList(c *gin.Context) {
return
}
res := service.AllService.ServerCmdService.List(q.Page, 9999)
//在列表前添加系统命令
//add system commands before the list
list := make([]*model.ServerCmd, 0)
list = append(list, model.SysIdServerCmds...)
list = append(list, model.SysRelayServerCmds...)
+16 -16
View File
@@ -12,15 +12,15 @@ import (
type ShareRecord struct {
}
// List 列表
// @Tags 分享记录
// @Summary 分享记录列表
// @Description 分享记录列表
// List list
// @Tags share record
// @Summary share record list
// @Description share record list
// @Accept json
// @Produce json
// @Param user_id query int false "用户ID"
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param user_id query int false "userID"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/share_record/list [get]
@@ -39,13 +39,13 @@ func (sr *ShareRecord) List(c *gin.Context) {
response.Success(c, res)
}
// Delete 删除
// @Tags 分享记录
// @Summary 分享记录删除
// @Description 分享记录删除
// Delete delete
// @Tags share record
// @Summary delete share record
// @Description delete share record
// @Accept json
// @Produce json
// @Param body body admin.ShareRecordForm true "分享记录信息"
// @Param body body admin.ShareRecordForm true "share record info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/share_record/delete [post]
@@ -75,10 +75,10 @@ func (sr *ShareRecord) Delete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// BatchDelete 批量删除
// @Tags 分享记录
// @Summary 批量分享记录
// @Description 批量分享记录
// BatchDelete batch delete
// @Tags share record
// @Summary batch share records
// @Description batch share records
// @Accept json
// @Produce json
// @Param body body admin.PeerShareRecordBatchDeleteForm true "id"
+27 -27
View File
@@ -13,10 +13,10 @@ import (
type Tag struct {
}
// Detail 标签
// @Tags 标签
// @Summary 标签详情
// @Description 标签详情
// Detail tag
// @Tags tag
// @Summary tag details
// @Description tag details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -41,13 +41,13 @@ func (ct *Tag) Detail(c *gin.Context) {
return
}
// Create 创建标签
// @Tags 标签
// @Summary 创建标签
// @Description 创建标签
// Create create tag
// @Tags tag
// @Summary create tag
// @Description create tag
// @Accept json
// @Produce json
// @Param body body admin.TagForm true "标签信息"
// @Param body body admin.TagForm true "tag info"
// @Success 200 {object} response.Response{data=model.Tag}
// @Failure 500 {object} response.Response
// @Router /admin/tag/create [post]
@@ -76,16 +76,16 @@ func (ct *Tag) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 标签
// @Summary 标签列表
// @Description 标签列表
// List list
// @Tags tag
// @Summary tag list
// @Description tag list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param is_my query int false "是否是我的"
// @Param user_id query int false "用户id"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param is_my query int false "whether it is mine"
// @Param user_id query int false "userid"
// @Success 200 {object} response.Response{data=model.TagList}
// @Failure 500 {object} response.Response
// @Router /admin/tag/list [get]
@@ -110,13 +110,13 @@ func (ct *Tag) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 标签
// @Summary 标签编辑
// @Description 标签编辑
// Update edit
// @Tags tag
// @Summary edit tag
// @Description edit tag
// @Accept json
// @Produce json
// @Param body body admin.TagForm true "标签信息"
// @Param body body admin.TagForm true "tag info"
// @Success 200 {object} response.Response{data=model.Tag}
// @Failure 500 {object} response.Response
// @Router /admin/tag/update [post]
@@ -150,13 +150,13 @@ func (ct *Tag) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 标签
// @Summary 标签删除
// @Description 标签删除
// Delete delete
// @Tags tag
// @Summary delete tag
// @Description delete tag
// @Accept json
// @Produce json
// @Param body body admin.TagForm true "标签信息"
// @Param body body admin.TagForm true "tag info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/tag/delete [post]
+46 -46
View File
@@ -16,10 +16,10 @@ import (
type User struct {
}
// Detail 管理员
// @Tags 用户
// @Summary 管理员详情
// @Description 管理员详情
// Detail administrator
// @Tags user
// @Summary administrator details
// @Description administrator details
// @Accept json
// @Produce json
// @Param id path int true "ID"
@@ -39,13 +39,13 @@ func (ct *User) Detail(c *gin.Context) {
return
}
// Create 管理员
// @Tags 用户
// @Summary 创建管理员
// @Description 创建管理员
// Create administrator
// @Tags user
// @Summary create administrator
// @Description create administrator
// @Accept json
// @Produce json
// @Param body body admin.UserForm true "管理员信息"
// @Param body body admin.UserForm true "administrator info"
// @Success 200 {object} response.Response{data=model.User}
// @Failure 500 {object} response.Response
// @Router /admin/user/create [post]
@@ -70,15 +70,15 @@ func (ct *User) Create(c *gin.Context) {
response.Success(c, nil)
}
// List 列表
// @Tags 用户
// @Summary 管理员列表
// @Description 管理员列表
// List list
// @Tags user
// @Summary administrator list
// @Description administrator list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param username query int false "账户"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param username query int false "account"
// @Success 200 {object} response.Response{data=model.UserList}
// @Failure 500 {object} response.Response
// @Router /admin/user/list [get]
@@ -97,13 +97,13 @@ func (ct *User) List(c *gin.Context) {
response.Success(c, res)
}
// Update 编辑
// @Tags 用户
// @Summary 管理员编辑
// @Description 管理员编辑
// Update edit
// @Tags user
// @Summary edit administrator
// @Description edit administrator
// @Accept json
// @Produce json
// @Param body body admin.UserForm true "用户信息"
// @Param body body admin.UserForm true "user info"
// @Success 200 {object} response.Response{data=model.User}
// @Failure 500 {object} response.Response
// @Router /admin/user/update [post]
@@ -132,13 +132,13 @@ func (ct *User) Update(c *gin.Context) {
response.Success(c, nil)
}
// Delete 删除
// @Tags 用户
// @Summary 管理员删除
// @Description 管理员编删除
// Delete delete
// @Tags user
// @Summary delete administrator
// @Description delete administrator
// @Accept json
// @Produce json
// @Param body body admin.UserForm true "用户信息"
// @Param body body admin.UserForm true "user info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/user/delete [post]
@@ -168,13 +168,13 @@ func (ct *User) Delete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// UpdatePassword 修改密码
// @Tags 用户
// @Summary 修改密码
// @Description 修改密码
// UpdatePassword change password
// @Tags user
// @Summary change password
// @Description change password
// @Accept json
// @Produce json
// @Param body body admin.UserPasswordForm true "用户信息"
// @Param body body admin.UserPasswordForm true "user info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/user/updatePassword [post]
@@ -203,10 +203,10 @@ func (ct *User) UpdatePassword(c *gin.Context) {
response.Success(c, nil)
}
// Current 当前用户
// @Tags 用户
// @Summary 当前用户
// @Description 当前用户
// Current current user
// @Tags user
// @Summary current user
// @Description current user
// @Accept json
// @Produce json
// @Success 200 {object} response.Response{data=adResp.LoginPayload}
@@ -220,13 +220,13 @@ func (ct *User) Current(c *gin.Context) {
responseLoginSuccess(c, u, t)
}
// ChangeCurPwd 修改当前用户密码
// @Tags 用户
// @Summary 修改当前用户密码
// @Description 修改当前用户密码
// ChangeCurPwd change the current user's password
// @Tags user
// @Summary change the current user's password
// @Description change the current user's password
// @Accept json
// @Produce json
// @Param body body admin.ChangeCurPasswordForm true "用户信息"
// @Param body body admin.ChangeCurPasswordForm true "user info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/user/changeCurPwd [post]
@@ -261,9 +261,9 @@ func (ct *User) ChangeCurPwd(c *gin.Context) {
}
// MyOauth
// @Tags 用户
// @Summary 我的授权
// @Description 我的授权
// @Tags user
// @Summary my authorizations
// @Description my authorizations
// @Accept json
// @Produce json
// @Success 200 {object} response.Response{data=[]adResp.UserOauthItem}
@@ -321,7 +321,7 @@ func (ct *User) Register(c *gin.Context) {
return
}
regStatus := model.StatusCode(global.Config.App.RegisterStatus)
// 注册状态可能未配置,默认启用
// the registration status may not be configured; enabled by default
if regStatus != model.COMMON_STATUS_DISABLED && regStatus != model.COMMON_STATUS_ENABLE {
regStatus = model.COMMON_STATUS_ENABLE
}
@@ -332,11 +332,11 @@ func (ct *User) Register(c *gin.Context) {
return
}
if regStatus == model.COMMON_STATUS_DISABLED {
// 需要管理员审核
// requires administrator approval
response.Fail(c, 101, response.TranslateMsg(c, "RegisterSuccessWaitAdminConfirm"))
return
}
// 注册成功后自动登录
// automatically log in after successful registration
ut := service.AllService.UserService.Login(u, &model.LoginLog{
UserId: u.Id,
Client: model.LoginLogClientWebAdmin,
+17 -17
View File
@@ -13,15 +13,15 @@ import (
type UserToken struct {
}
// List 列表
// @Tags 登录凭证
// @Summary 登录凭证列表
// @Description 登录凭证列表
// List list
// @Tags login credential
// @Summary login credential list
// @Description login credential list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param page_size query int false "页大小"
// @Param user_id query int false "用户ID"
// @Param page query int false "page number"
// @Param page_size query int false "page size"
// @Param user_id query int false "userID"
// @Success 200 {object} response.Response{data=model.UserTokenList}
// @Failure 500 {object} response.Response
// @Router /admin/user_token/list [get]
@@ -41,13 +41,13 @@ func (ct *UserToken) List(c *gin.Context) {
response.Success(c, res)
}
// Delete 删除
// @Tags 登录凭证
// @Summary 登录凭证删除
// @Description 登录凭证删除
// Delete delete
// @Tags login credential
// @Summary delete login credential
// @Description delete login credential
// @Accept json
// @Produce json
// @Param body body model.UserToken true "登录凭证信息"
// @Param body body model.UserToken true "login credential info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/user_token/delete [post]
@@ -82,13 +82,13 @@ func (ct *UserToken) Delete(c *gin.Context) {
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
}
// BatchDelete 批量删除
// @Tags 登录凭证
// @Summary 登录凭证批量删除
// @Description 登录凭证批量删除
// BatchDelete batch delete
// @Tags login credential
// @Summary batch delete login credentials
// @Description batch delete login credentials
// @Accept json
// @Produce json
// @Param body body admin.UserTokenBatchDeleteForm true "登录凭证信息"
// @Param body body admin.UserTokenBatchDeleteForm true "login credential info"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /admin/user_token/batchDelete [post]
+58 -58
View File
@@ -20,9 +20,9 @@ type Ab struct {
}
// Ab
// @Tags 地址
// @Summary 地址列表
// @Description 地址列表
// @Tags address
// @Summary address list
// @Description address list
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -36,7 +36,7 @@ func (a *Ab) Ab(c *gin.Context) {
tags := service.AllService.TagService.ListByUserIdAndCollectionId(user.Id, 0)
tagColors := map[string]uint{}
//将tags中的name转成一个以逗号分割的字符串
// convert the name in tags into a comma-separated string
var tagNames []string
for _, tag := range tags.Tags {
tagNames = append(tagNames, tag.Name)
@@ -56,12 +56,12 @@ func (a *Ab) Ab(c *gin.Context) {
}
// UpAb
// @Tags 地址
// @Summary 地址更新
// @Description 地址更新
// @Tags address
// @Summary address update
// @Description address update
// @Accept json
// @Produce json
// @Param body body requstform.AddressBookForm true "地址表单"
// @Param body body requstform.AddressBookForm true "address form"
// @Success 200 {string} string "null"
// @Failure 500 {object} response.ErrorResponse
// @Router /ab [post]
@@ -99,9 +99,9 @@ func (a *Ab) UpAb(c *gin.Context) {
}
// PTags
// @Tags 地址[Personal]
// @Summary 标签
// @Description 标签
// @Tags address[Personal]
// @Summary tag
// @Description tag
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -128,9 +128,9 @@ func (a *Ab) PTags(c *gin.Context) {
}
// TagAdd
// @Tags 地址[Personal]
// @Summary 标签添加
// @Description 标签
// @Tags address[Personal]
// @Summary add tag
// @Description tag
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -177,9 +177,9 @@ func (a *Ab) TagAdd(c *gin.Context) {
}
// TagRename
// @Tags 地址[Personal]
// @Summary 标签重命名
// @Description 标签
// @Tags address[Personal]
// @Summary rename tag
// @Description tag
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -229,9 +229,9 @@ func (a *Ab) TagRename(c *gin.Context) {
}
// TagUpdate
// @Tags 地址[Personal]
// @Summary 标签修改颜色
// @Description 标签
// @Tags address[Personal]
// @Summary change tag color
// @Description tag
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -275,9 +275,9 @@ func (a *Ab) TagUpdate(c *gin.Context) {
}
// TagDel
// @Tags 地址[Personal]
// @Summary 标签删除
// @Description 标签
// @Tags address[Personal]
// @Summary delete tag
// @Description tag
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -324,9 +324,9 @@ func (a *Ab) TagDel(c *gin.Context) {
}
// Personal
// @Tags 地址[Personal]
// @Summary 个人地址
// @Description 个人地址
// @Tags address[Personal]
// @Summary personal address
// @Description personal address
// @Accept json
// @Produce json
// @Param string body string false "string valid"
@@ -345,7 +345,7 @@ func (a *Ab) Personal(c *gin.Context) {
*/
if global.Config.Rustdesk.Personal == 1 {
guid := a.ComposeGuid(user.GroupId, user.Id, 0)
//如果返回了guid,后面的请求会有变化
//if it returns guid, subsequent requests will change
c.JSON(http.StatusOK, gin.H{
"guid": guid,
"name": user.Username,
@@ -358,9 +358,9 @@ func (a *Ab) Personal(c *gin.Context) {
}
// Settings
// @Tags 地址[Personal]
// @Summary 设置
// @Description 设置
// @Tags address[Personal]
// @Summary settings
// @Description settings
// @Accept json
// @Produce json
// @Param string body string false "string valid"
@@ -370,18 +370,18 @@ func (a *Ab) Personal(c *gin.Context) {
// @Security BearerAuth
func (a *Ab) Settings(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"max_peer_one_ab": 0, //最大peer数,0表示不限制
"max_peer_one_ab": 0, //max peer count, 0 means no limit
})
}
// SharedProfiles
// @Tags 地址[Personal]
// @Summary 共享地址簿
// @Description 共享
// @Tags address[Personal]
// @Summary shared address book
// @Description shared
// @Accept json
// @Produce json
// @Param current query int false "页码"
// @Param pageSize query int false "每页数量"
// @Param current query int false "page number"
// @Param pageSize query int false "items per page"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /ab/shared/profiles [post]
@@ -401,14 +401,14 @@ func (a *Ab) SharedProfiles(c *gin.Context) {
})
}
allAbIds := make(map[uint]int) //用map去重,并保留最大Rule
allAbIds := make(map[uint]int) //use map to deduplicate and keep the maximum Rule
allUserIds := make(map[uint]*model.User)
rules := service.AllService.AddressBookService.CollectionReadRules(user)
for _, rule := range rules {
//先判断是否存在
//first check whether it exists
r, ok := allAbIds[rule.CollectionId]
if ok {
//再判断权限大小
//then check the permission level
if r < rule.Rule {
allAbIds[rule.CollectionId] = rule.Rule
}
@@ -448,7 +448,7 @@ func (a *Ab) SharedProfiles(c *gin.Context) {
// ParseGuid
func (a *Ab) ParseGuid(guid string) (gid, uid, cid uint) {
//用-切割 guid
// split guid by -
guids := strings.Split(guid, "-")
if len(guids) < 2 {
return 0, 0, 0
@@ -521,13 +521,13 @@ func (a *Ab) CheckGuid(cu *model.User, guid string) (gid, uid, cid uint, err err
}
// Peers
// @Tags 地址[Personal]
// @Summary 地址列表
// @Description 地址
// @Tags address[Personal]
// @Summary address list
// @Description address
// @Accept json
// @Produce json
// @Param current query int false "页码"
// @Param pageSize query int false "每页数量"
// @Param current query int false "page number"
// @Param pageSize query int false "items per page"
// @Param ab query string false "guid"
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
@@ -557,9 +557,9 @@ func (a *Ab) Peers(c *gin.Context) {
}
// PeerAdd
// @Tags 地址[Personal]
// @Summary 添加地址
// @Description 添加地址
// @Tags address[Personal]
// @Summary add address
// @Description add address
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -568,7 +568,7 @@ func (a *Ab) Peers(c *gin.Context) {
// @Router /ab/peer/add/{guid} [post]
// @Security BearerAuth
func (a *Ab) PeerAdd(c *gin.Context) {
// forceAlwaysRelay永远是字符串"false"
// forceAlwaysRelay is always the string "false"
//f := &gin.H{}
f := &requstform.PersonalAddressBookForm{}
err := c.ShouldBindJSON(f)
@@ -613,9 +613,9 @@ func (a *Ab) PeerAdd(c *gin.Context) {
}
// PeerDel
// @Tags 地址[Personal]
// @Summary 删除地址
// @Description 删除地址
// @Tags address[Personal]
// @Summary delete address
// @Description delete address
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -661,9 +661,9 @@ func (a *Ab) PeerDel(c *gin.Context) {
}
// PeerUpdate
// @Tags 地址[Personal]
// @Summary 更新地址
// @Description 更新地址
// @Tags address[Personal]
// @Summary update address
// @Description update address
// @Accept json
// @Produce json
// @Param guid path string true "guid"
@@ -693,7 +693,7 @@ func (a *Ab) PeerUpdate(c *gin.Context) {
return
}
//fmt.Println(f)
//判断f["Id"]是否存在
// determine whether f["Id"] exists
fid, ok := f["id"]
if !ok {
response.Error(c, response.TranslateMsg(c, "ParamsError"))
@@ -706,9 +706,9 @@ func (a *Ab) PeerUpdate(c *gin.Context) {
response.Error(c, response.TranslateMsg(c, "ItemNotFound"))
return
}
//允许的字段
//allowed fields
allowUp := []string{"password", "hash", "tags", "alias"}
//f中的字段如果不在allowUp中,就删除
// if a field in f is not in allowUp, delete it
for k := range f {
if !utils.InArray(k, allowUp) {
delete(f, k)
+8 -8
View File
@@ -14,12 +14,12 @@ type Audit struct {
}
// AuditConn
// @Tags 审计
// @Summary 审计连接
// @Description 审计连接
// @Tags audit
// @Summary audit connection
// @Description audit connection
// @Accept json
// @Produce json
// @Param body body request.AuditConnForm true "审计连接"
// @Param body body request.AuditConnForm true "audit connection"
// @Success 200 {string} string ""
// @Failure 500 {object} response.Response
// @Router /audit/conn [post]
@@ -59,12 +59,12 @@ func (a *Audit) AuditConn(c *gin.Context) {
}
// AuditFile
// @Tags 审计
// @Summary 审计文件
// @Description 审计文件
// @Tags audit
// @Summary audit file
// @Description audit file
// @Accept json
// @Produce json
// @Param body body request.AuditFileForm true "审计文件"
// @Param body body request.AuditFileForm true "audit file"
// @Success 200 {string} string ""
// @Failure 500 {object} response.Response
// @Router /audit/file [post]
+21 -21
View File
@@ -13,15 +13,15 @@ import (
type Group struct {
}
// Users 用户列表
// @Tags 群组
// @Summary 用户列表
// @Description 用户列表
// Users user list
// @Tags group
// @Summary user list
// @Description user list
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param pageSize query int false "每页数量"
// @Param status query int false "状态"
// @Param page query int false "page number"
// @Param pageSize query int false "items per page"
// @Param status query int false "status"
// @Param accessible query string false "accessible"
// @Success 200 {object} response.DataResponse{data=[]apiResp.UserPayload}
// @Failure 500 {object} response.ErrorResponse
@@ -38,7 +38,7 @@ func (g *Group) Users(c *gin.Context) {
gr := service.AllService.GroupService.InfoById(u.GroupId)
userList := &model.UserList{}
if !*u.IsAdmin && gr.Type != model.GroupTypeShare {
//仅能获取到自己
//can only retrieve one's own
userList.Users = append(userList.Users, u)
userList.Total = 1
} else {
@@ -58,14 +58,14 @@ func (g *Group) Users(c *gin.Context) {
}
// Peers
// @Tags 群组
// @Summary 机器
// @Description 机器
// @Tags group
// @Summary machine
// @Description machine
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param pageSize query int false "每页数量"
// @Param status query int false "状态"
// @Param page query int false "page number"
// @Param pageSize query int false "items per page"
// @Param status query int false "status"
// @Param accessible query string false "accessible"
// @Success 200 {object} response.DataResponse
// @Failure 500 {object} response.Response
@@ -82,7 +82,7 @@ func (g *Group) Peers(c *gin.Context) {
gr := service.AllService.GroupService.InfoById(u.GroupId)
users := make([]*model.User, 0, 1)
if !*u.IsAdmin && gr.Type != model.GroupTypeShare {
//仅能获取到自己
//can only retrieve one's own
users = append(users, u)
} else {
users = service.AllService.UserService.ListIdAndNameByGroupId(u.GroupId)
@@ -122,14 +122,14 @@ func (g *Group) Peers(c *gin.Context) {
}
// Device
// @Tags 群组
// @Summary 设备
// @Description 机器
// @Tags group
// @Summary device
// @Description machine
// @Accept json
// @Produce json
// @Param page query int false "页码"
// @Param pageSize query int false "每页数量"
// @Param status query int false "状态"
// @Param page query int false "page number"
// @Param pageSize query int false "items per page"
// @Param status query int false "status"
// @Param accessible query string false "accessible"
// @Success 200 {object} response.DataResponse
// @Failure 500 {object} response.Response
+14 -14
View File
@@ -13,10 +13,10 @@ import (
type Index struct {
}
// Index 首页
// @Tags 首页
// @Summary 首页
// @Description 首页
// Index home
// @Tags home
// @Summary home
// @Description home
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -29,10 +29,10 @@ func (i *Index) Index(c *gin.Context) {
)
}
// Heartbeat 心跳
// @Tags 首页
// @Summary 心跳
// @Description 心跳
// Heartbeat heartbeat
// @Tags home
// @Summary heartbeat
// @Description heartbeat
// @Accept json
// @Produce json
// @Success 200 {object} nil
@@ -54,7 +54,7 @@ func (i *Index) Heartbeat(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
return
}
//如果在40s以内则不更新
// do not update if within 40s
if time.Now().Unix()-peer.LastOnlineTime >= 30 {
upp := &model.Peer{RowId: peer.RowId, LastOnlineTime: time.Now().Unix(), LastOnlineIp: c.ClientIP()}
service.AllService.PeerService.Update(upp)
@@ -62,17 +62,17 @@ func (i *Index) Heartbeat(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
// Version 版本
// @Tags 首页
// @Summary 版本
// @Description 版本
// Version version
// @Tags home
// @Summary version
// @Description version
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
// @Failure 500 {object} response.Response
// @Router /version [get]
func (i *Index) Version(c *gin.Context) {
//读取resources/version文件
// read the resources/version file
v := service.AllService.AppService.GetAppVersion()
response.Success(
c,
+13 -13
View File
@@ -16,13 +16,13 @@ import (
type Login struct {
}
// Login 登录
// @Tags 登录
// @Summary 登录
// @Description 登录
// Login login
// @Tags login
// @Summary login
// @Description login
// @Accept json
// @Produce json
// @Param body body api.LoginForm true "登录表单"
// @Param body body api.LoginForm true "login form"
// @Success 200 {object} apiResp.LoginRes
// @Failure 500 {object} response.ErrorResponse
// @Router /login [post]
@@ -32,7 +32,7 @@ func (l *Login) Login(c *gin.Context) {
return
}
// 检查登录限制
// check login limit
loginLimiter := global.LoginLimiter
clientIp := c.ClientIP()
@@ -68,7 +68,7 @@ func (l *Login) Login(c *gin.Context) {
return
}
//根据refer判断是webclient还是app
// determine whether it is webclient or app based on refer
ref := c.GetHeader("referer")
if ref != "" {
f.DeviceInfo.Type = model.LoginLogClientWeb
@@ -92,9 +92,9 @@ func (l *Login) Login(c *gin.Context) {
}
// LoginOptions
// @Tags 登录
// @Summary 登录选项
// @Description 登录选项
// @Tags login
// @Summary login options
// @Description login options
// @Accept json
// @Produce json
// @Success 200 {object} []string
@@ -123,9 +123,9 @@ func (l *Login) LoginOptions(c *gin.Context) {
}
// Logout
// @Tags 登录
// @Summary 登出
// @Description 登出
// @Tags login
// @Summary logout
// @Description logout
// @Accept json
// @Produce json
// @Success 200 {string} string
+18 -18
View File
@@ -65,37 +65,37 @@ func (o *Oauth) OidcAuthQueryPre(c *gin.Context) (*model.User, *model.UserToken)
var ut *model.UserToken
q := &api.OidcAuthQuery{}
// 解析查询参数并处理错误
// parse query parameters and handle errors
if err := c.ShouldBindQuery(q); err != nil {
response.Error(c, response.TranslateMsg(c, "ParamsError")+": "+err.Error())
return nil, nil
}
// 获取 OAuth 缓存
// get OAuth cache
v := service.AllService.OauthService.GetOauthCache(q.Code)
if v == nil {
response.Error(c, response.TranslateMsg(c, "OauthExpired"))
return nil, nil
}
// 如果 UserId 为 0,说明还在授权中
// if UserId is 0, authorization is still in progress
if v.UserId == 0 {
//fix: 1.4.2 webclient oidc
c.JSON(http.StatusOK, gin.H{"message": "Authorization in progress, please login and bind", "error": "No authed oidc is found"})
return nil, nil
}
// 获取用户信息
// get user info
u = service.AllService.UserService.InfoById(v.UserId)
if u == nil {
response.Error(c, response.TranslateMsg(c, "UserNotFound"))
return nil, nil
}
// 删除 OAuth 缓存
// delete OAuth cache
service.AllService.OauthService.DeleteOauthCache(q.Code)
// 创建登录日志并生成用户令牌
// create a login log and generate a user token
ut = service.AllService.UserService.Login(u, &model.LoginLog{
UserId: u.Id,
Client: v.DeviceType,
@@ -111,7 +111,7 @@ func (o *Oauth) OidcAuthQueryPre(c *gin.Context) (*model.User, *model.UserToken)
return nil, nil
}
// 返回用户令牌
// return user token
return u, ut
}
@@ -136,7 +136,7 @@ func (o *Oauth) OidcAuthQuery(c *gin.Context) {
})
}
// OauthCallback 回调
// OauthCallback callback
// @Tags Oauth
// @Summary OauthCallback
// @Description OauthCallback
@@ -156,7 +156,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
}
cacheKey := state
oauthService := service.AllService.OauthService
//从缓存中获取
//get from cache
oauthCache := oauthService.GetOauthCache(cacheKey)
if oauthCache == nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -169,7 +169,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
action := oauthCache.Action
verifier := oauthCache.Verifier
var user *model.User
// 获取用户信息
// get user info
code := c.Query("code")
err, oauthUser := oauthService.Callback(code, verifier, op, nonce)
if err != nil {
@@ -184,7 +184,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
if action == service.OauthActionTypeBind {
//fmt.Println("bind", ty, userData)
// 检查此openid是否已经绑定过
// check whether this openid has already been bound
utr := oauthService.UserThirdInfo(op, openid)
if utr.UserId > 0 {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -192,7 +192,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
})
return
}
//绑定
//bind
user = service.AllService.UserService.InfoById(userId)
if user == nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -200,7 +200,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
})
return
}
//绑定
//bind
err := oauthService.BindOauthUser(userId, oauthUser, op)
if err != nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -214,7 +214,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
return
} else if action == service.OauthActionTypeLogin {
//登录
//login
if userId != 0 {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
"message": "OauthHasBeenSuccess",
@@ -225,13 +225,13 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
if user == nil {
oauthConfig := oauthService.InfoByOp(op)
if !*oauthConfig.AutoRegister {
//c.String(http.StatusInternalServerError, "还未绑定用户,请先绑定")
//c.String(http.StatusInternalServerError, "not yet bound to a user, please bind first")
oauthCache.UpdateFromOauthUser(oauthUser)
c.Redirect(http.StatusFound, "/_admin/#/oauth/bind/"+cacheKey)
return
}
//自动注册
//auto register
err, user = service.AllService.UserService.RegisterByOauth(oauthUser, op)
if err != nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -242,7 +242,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
}
oauthCache.UserId = user.Id
oauthService.SetOauthCache(cacheKey, oauthCache, 0)
// 如果是webadmin,登录成功后跳转到webadmin
// if it is webadmin, after successful login redirect to webadmin
if oauthCache.DeviceType == model.LoginLogClientWebAdmin {
/*service.AllService.UserService.Login(u, &model.LoginLog{
UserId: u.Id,
@@ -299,7 +299,7 @@ func (o *Oauth) Message(c *gin.Context) {
}
}
//返回js内容
//returnjscontent
c.Header("Content-Type", "application/javascript")
c.String(http.StatusOK, res)
}
+10 -10
View File
@@ -15,11 +15,11 @@ type Peer struct {
// SysInfo
// @Tags System
// @Summary 提交系统信息
// @Description 提交系统信息
// @Summary submit system info
// @Description submit system info
// @Accept json
// @Produce json
// @Param body body requstform.PeerForm true "系统信息表单"
// @Param body body requstform.PeerForm true "system info form"
// @Success 200 {string} string "SYSINFO_UPDATED,ID_NOT_FOUND"
// @Failure 500 {object} response.ErrorResponse
// @Router /sysinfo [post]
@@ -52,25 +52,25 @@ func (p *Peer) SysInfo(c *gin.Context) {
return
}
}
//SYSINFO_UPDATED 上传成功
//ID_NOT_FOUND 下次心跳会上传
//直接响应文本
//SYSINFO_UPDATED upload successful
//ID_NOT_FOUND will be uploaded on the next heartbeat
//respond with text directly
c.String(http.StatusOK, "SYSINFO_UPDATED")
}
// SysInfoVer
// @Tags System
// @Summary 获取系统版本信息
// @Description 获取系统版本信息
// @Summary get system version info
// @Description get system version info
// @Accept json
// @Produce json
// @Success 200 {string} string ""
// @Failure 500 {object} response.ErrorResponse
// @Router /sysinfo_ver [post]
func (p *Peer) SysInfoVer(c *gin.Context) {
//读取resources/version文件
// read the resources/version file
v := service.AllService.AppService.GetAppVersion()
// 加上启动时间,方便client上传信息
// add the start time so the client can conveniently upload info
v = fmt.Sprintf("%s\n%s", v, service.AllService.AppService.GetStartTime())
c.String(http.StatusOK, v)
}
+8 -8
View File
@@ -10,10 +10,10 @@ import (
type User struct {
}
// currentUser 当前用户
// @Tags 用户
// @Summary 用户信息
// @Description 用户信息
// currentUser current user
// @Tags user
// @Summary user info
// @Description user info
// @Accept json
// @Produce json
// @Success 200 {object} apiResp.UserPayload
@@ -26,10 +26,10 @@ type User struct {
// c.JSON(http.StatusOK, up)
//}
// Info 用户信息
// @Tags 用户
// @Summary 用户信息
// @Description 用户信息
// Info user info
// @Tags user
// @Summary user info
// @Description user info
// @Accept json
// @Produce json
// @Success 200 {object} apiResp.UserPayload
+10 -10
View File
@@ -12,10 +12,10 @@ import (
type WebClient struct {
}
// ServerConfig 服务配置
// ServerConfig service config
// @Tags WEBCLIENT
// @Summary 服务配置
// @Description 服务配置,给webclient提供api-server
// @Summary service config
// @Description service config, provides an api-server for the webclient
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -42,10 +42,10 @@ func (i *WebClient) ServerConfig(c *gin.Context) {
)
}
// SharedPeer 分享的peer
// SharedPeer shared peer
// @Tags WEBCLIENT
// @Summary 分享的peer
// @Description 分享的peer
// @Summary shared peer
// @Description shared peer
// @Accept json
// @Produce json
// @Success 200 {object} response.Response
@@ -65,7 +65,7 @@ func (i *WebClient) SharedPeer(c *gin.Context) {
return
}
if sr.Expire != 0 {
//判断是否过期,created_at + expire > now
//check whether expired,created_at + expire > now
ca := time.Time(sr.CreatedAt)
if ca.Add(time.Second * time.Duration(sr.Expire)).Before(time.Now()) {
response.Fail(c, 101, "share expired")
@@ -89,10 +89,10 @@ func (i *WebClient) SharedPeer(c *gin.Context) {
})
}
// ServerConfigV2 服务配置
// ServerConfigV2 service config
// @Tags WEBCLIENT_V2
// @Summary 服务配置
// @Description 服务配置,给webclient提供api-server
// @Summary service config
// @Description service config, provides an api-server for the webclient
// @Accept json
// @Produce json
// @Success 200 {object} response.Response