add cmd
This commit is contained in:
@@ -14,6 +14,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @title 管理系统API
|
// @title 管理系统API
|
||||||
@@ -26,9 +29,79 @@ import (
|
|||||||
// @securitydefinitions.apikey BearerAuth
|
// @securitydefinitions.apikey BearerAuth
|
||||||
// @in header
|
// @in header
|
||||||
// @name Authorization
|
// @name Authorization
|
||||||
|
|
||||||
|
var rootCmd = &cobra.Command{
|
||||||
|
Use: "apimain",
|
||||||
|
Short: "RUSTDESK API SERVER",
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
InitGlobal()
|
||||||
|
},
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
//gin
|
||||||
|
http.ApiInit()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var resetPwdCmd = &cobra.Command{
|
||||||
|
Use: "reset-admin-pwd [pwd]",
|
||||||
|
Example: "reset-admin-pwd 123456",
|
||||||
|
Short: "Reset Admin Password",
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
pwd := args[0]
|
||||||
|
admin := service.AllService.UserService.InfoById(1)
|
||||||
|
err := service.AllService.UserService.UpdatePassword(admin, pwd)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("reset password fail! %v \n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Printf("reset password success! \n")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
var resetUserPwdCmd = &cobra.Command{
|
||||||
|
Use: "reset-pwd [userId] [pwd]",
|
||||||
|
Example: "reset-pwd 2 123456",
|
||||||
|
Short: "Reset User Password",
|
||||||
|
Args: cobra.ExactArgs(2),
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
userId := args[0]
|
||||||
|
pwd := args[1]
|
||||||
|
uid, err := strconv.Atoi(userId)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("userId must be int! \n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if uid <= 0 {
|
||||||
|
fmt.Printf("userId must be greater than 0! \n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
u := service.AllService.UserService.InfoById(uint(uid))
|
||||||
|
err = service.AllService.UserService.UpdatePassword(u, pwd)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("reset password fail! %v \n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Printf("reset password success! \n")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.PersistentFlags().StringVarP(&global.ConfigPath, "config", "c", "./conf/config.yaml", "choose config file")
|
||||||
|
rootCmd.AddCommand(resetPwdCmd, resetUserPwdCmd)
|
||||||
|
}
|
||||||
func main() {
|
func main() {
|
||||||
|
if err := rootCmd.Execute(); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitGlobal() {
|
||||||
//配置解析
|
//配置解析
|
||||||
global.Viper = config.Init(&global.Config)
|
global.Viper = config.Init(&global.Config, global.ConfigPath)
|
||||||
|
|
||||||
|
//从配置文件中加载密钥
|
||||||
|
config.LoadKeyFile(&global.Config.Rustdesk)
|
||||||
|
|
||||||
//日志
|
//日志
|
||||||
global.Logger = logger.New(&logger.Config{
|
global.Logger = logger.New(&logger.Config{
|
||||||
@@ -94,12 +167,7 @@ func main() {
|
|||||||
|
|
||||||
//locker
|
//locker
|
||||||
global.Lock = lock.NewLocal()
|
global.Lock = lock.NewLocal()
|
||||||
|
|
||||||
//gin
|
|
||||||
http.ApiInit()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DatabaseAutoUpdate() {
|
func DatabaseAutoUpdate() {
|
||||||
version := 246
|
version := 246
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -35,18 +34,15 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init 初始化配置
|
// Init 初始化配置
|
||||||
func Init(rowVal interface{}) *viper.Viper {
|
func Init(rowVal interface{}, path string) *viper.Viper {
|
||||||
var config string
|
if path == "" {
|
||||||
flag.StringVar(&config, "c", "", "choose config file.")
|
path = DefaultConfig
|
||||||
flag.Parse()
|
|
||||||
if config == "" { // 优先级: 命令行 > 默认值
|
|
||||||
config = DefaultConfig
|
|
||||||
}
|
}
|
||||||
v := viper.New()
|
v := viper.GetViper()
|
||||||
v.AutomaticEnv()
|
v.AutomaticEnv()
|
||||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
|
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
|
||||||
v.SetEnvPrefix("RUSTDESK_API")
|
v.SetEnvPrefix("RUSTDESK_API")
|
||||||
v.SetConfigFile(config)
|
v.SetConfigFile(path)
|
||||||
v.SetConfigType("yaml")
|
v.SetConfigType("yaml")
|
||||||
err := v.ReadInConfig()
|
err := v.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -63,7 +59,7 @@ func Init(rowVal interface{}) *viper.Viper {
|
|||||||
if err := v.Unmarshal(rowVal); err != nil {
|
if err := v.Unmarshal(rowVal); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
LoadKeyFile(&rowVal.(*Config).Rustdesk)
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3067,6 +3067,90 @@ const docTemplateadmin = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/admin/user/myPeer": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"token": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "设备列表",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"设备"
|
||||||
|
],
|
||||||
|
"summary": "设备列表",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "页码",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "页大小",
|
||||||
|
"name": "page_size",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "时间",
|
||||||
|
"name": "time_ago",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "主机名",
|
||||||
|
"name": "hostname",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "uuids 用逗号分隔",
|
||||||
|
"name": "uuids",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/model.PeerList"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/admin/user/update": {
|
"/admin/user/update": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -3407,6 +3491,12 @@ const docTemplateadmin = `{
|
|||||||
"admin.LoginPayload": {
|
"admin.LoginPayload": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"avatar": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"nickname": {
|
"nickname": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -3429,7 +3519,7 @@ const docTemplateadmin = `{
|
|||||||
"required": [
|
"required": [
|
||||||
"client_id",
|
"client_id",
|
||||||
"client_secret",
|
"client_secret",
|
||||||
"op",
|
"oauth_type",
|
||||||
"redirect_url"
|
"redirect_url"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -3448,6 +3538,9 @@ const docTemplateadmin = `{
|
|||||||
"issuer": {
|
"issuer": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"oauth_type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"op": {
|
"op": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -3567,6 +3660,10 @@ const docTemplateadmin = `{
|
|||||||
"avatar": {
|
"avatar": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"email": {
|
||||||
|
"description": "validate:\"required,email\" email不强制",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"group_id": {
|
"group_id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -3591,18 +3688,18 @@ const docTemplateadmin = `{
|
|||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 10,
|
||||||
"minLength": 4
|
"minLength": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin.UserOauthItem": {
|
"admin.UserOauthItem": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"op": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
|
||||||
"third_type": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3973,6 +4070,9 @@ const docTemplateadmin = `{
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"device_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -4042,6 +4142,9 @@ const docTemplateadmin = `{
|
|||||||
"issuer": {
|
"issuer": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"oauth_type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"op": {
|
"op": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -4220,6 +4323,9 @@ const docTemplateadmin = `{
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"group_id": {
|
"group_id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -4269,6 +4375,12 @@ const docTemplateadmin = `{
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"device_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"device_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"expired_at": {
|
"expired_at": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3060,6 +3060,90 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/admin/user/myPeer": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"token": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "设备列表",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"设备"
|
||||||
|
],
|
||||||
|
"summary": "设备列表",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "页码",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "页大小",
|
||||||
|
"name": "page_size",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "时间",
|
||||||
|
"name": "time_ago",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "主机名",
|
||||||
|
"name": "hostname",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "uuids 用逗号分隔",
|
||||||
|
"name": "uuids",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/model.PeerList"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/response.Response"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/admin/user/update": {
|
"/admin/user/update": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -3400,6 +3484,12 @@
|
|||||||
"admin.LoginPayload": {
|
"admin.LoginPayload": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"avatar": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"nickname": {
|
"nickname": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -3422,7 +3512,7 @@
|
|||||||
"required": [
|
"required": [
|
||||||
"client_id",
|
"client_id",
|
||||||
"client_secret",
|
"client_secret",
|
||||||
"op",
|
"oauth_type",
|
||||||
"redirect_url"
|
"redirect_url"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -3441,6 +3531,9 @@
|
|||||||
"issuer": {
|
"issuer": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"oauth_type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"op": {
|
"op": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -3560,6 +3653,10 @@
|
|||||||
"avatar": {
|
"avatar": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"email": {
|
||||||
|
"description": "validate:\"required,email\" email不强制",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"group_id": {
|
"group_id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -3584,18 +3681,18 @@
|
|||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 10,
|
||||||
"minLength": 4
|
"minLength": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin.UserOauthItem": {
|
"admin.UserOauthItem": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"op": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
|
||||||
"third_type": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3966,6 +4063,9 @@
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"device_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -4035,6 +4135,9 @@
|
|||||||
"issuer": {
|
"issuer": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"oauth_type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"op": {
|
"op": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -4213,6 +4316,9 @@
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"group_id": {
|
"group_id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -4262,6 +4368,12 @@
|
|||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"device_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"device_uuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"expired_at": {
|
"expired_at": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
admin.LoginPayload:
|
admin.LoginPayload:
|
||||||
properties:
|
properties:
|
||||||
|
avatar:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
nickname:
|
nickname:
|
||||||
type: string
|
type: string
|
||||||
route_names:
|
route_names:
|
||||||
@@ -107,6 +111,8 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
issuer:
|
issuer:
|
||||||
type: string
|
type: string
|
||||||
|
oauth_type:
|
||||||
|
type: string
|
||||||
op:
|
op:
|
||||||
type: string
|
type: string
|
||||||
redirect_url:
|
redirect_url:
|
||||||
@@ -116,7 +122,7 @@ definitions:
|
|||||||
required:
|
required:
|
||||||
- client_id
|
- client_id
|
||||||
- client_secret
|
- client_secret
|
||||||
- op
|
- oauth_type
|
||||||
- redirect_url
|
- redirect_url
|
||||||
type: object
|
type: object
|
||||||
admin.PeerBatchDeleteForm:
|
admin.PeerBatchDeleteForm:
|
||||||
@@ -188,6 +194,9 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
avatar:
|
avatar:
|
||||||
type: string
|
type: string
|
||||||
|
email:
|
||||||
|
description: validate:"required,email" email不强制
|
||||||
|
type: string
|
||||||
group_id:
|
group_id:
|
||||||
type: integer
|
type: integer
|
||||||
id:
|
id:
|
||||||
@@ -203,7 +212,7 @@ definitions:
|
|||||||
minimum: 0
|
minimum: 0
|
||||||
username:
|
username:
|
||||||
maxLength: 10
|
maxLength: 10
|
||||||
minLength: 4
|
minLength: 2
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- group_id
|
- group_id
|
||||||
@@ -212,10 +221,10 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
admin.UserOauthItem:
|
admin.UserOauthItem:
|
||||||
properties:
|
properties:
|
||||||
|
op:
|
||||||
|
type: string
|
||||||
status:
|
status:
|
||||||
type: integer
|
type: integer
|
||||||
third_type:
|
|
||||||
type: string
|
|
||||||
type: object
|
type: object
|
||||||
admin.UserPasswordForm:
|
admin.UserPasswordForm:
|
||||||
properties:
|
properties:
|
||||||
@@ -462,6 +471,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
created_at:
|
created_at:
|
||||||
type: string
|
type: string
|
||||||
|
device_id:
|
||||||
|
type: string
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
ip:
|
ip:
|
||||||
@@ -508,6 +519,8 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
issuer:
|
issuer:
|
||||||
type: string
|
type: string
|
||||||
|
oauth_type:
|
||||||
|
type: string
|
||||||
op:
|
op:
|
||||||
type: string
|
type: string
|
||||||
redirect_url:
|
redirect_url:
|
||||||
@@ -627,6 +640,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
created_at:
|
created_at:
|
||||||
type: string
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
group_id:
|
group_id:
|
||||||
type: integer
|
type: integer
|
||||||
id:
|
id:
|
||||||
@@ -659,6 +674,10 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
created_at:
|
created_at:
|
||||||
type: string
|
type: string
|
||||||
|
device_id:
|
||||||
|
type: string
|
||||||
|
device_uuid:
|
||||||
|
type: string
|
||||||
expired_at:
|
expired_at:
|
||||||
type: integer
|
type: integer
|
||||||
id:
|
id:
|
||||||
@@ -2519,6 +2538,57 @@ paths:
|
|||||||
summary: 我的授权
|
summary: 我的授权
|
||||||
tags:
|
tags:
|
||||||
- 用户
|
- 用户
|
||||||
|
/admin/user/myPeer:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 设备列表
|
||||||
|
parameters:
|
||||||
|
- description: 页码
|
||||||
|
in: query
|
||||||
|
name: page
|
||||||
|
type: integer
|
||||||
|
- description: 页大小
|
||||||
|
in: query
|
||||||
|
name: page_size
|
||||||
|
type: integer
|
||||||
|
- description: 时间
|
||||||
|
in: query
|
||||||
|
name: time_ago
|
||||||
|
type: integer
|
||||||
|
- description: ID
|
||||||
|
in: query
|
||||||
|
name: id
|
||||||
|
type: string
|
||||||
|
- description: 主机名
|
||||||
|
in: query
|
||||||
|
name: hostname
|
||||||
|
type: string
|
||||||
|
- description: uuids 用逗号分隔
|
||||||
|
in: query
|
||||||
|
name: uuids
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/response.Response'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/model.PeerList'
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/response.Response'
|
||||||
|
security:
|
||||||
|
- token: []
|
||||||
|
summary: 设备列表
|
||||||
|
tags:
|
||||||
|
- 设备
|
||||||
/admin/user/update:
|
/admin/user/update:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
|
|||||||
@@ -1365,7 +1365,7 @@ const docTemplateapi = `{
|
|||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 10,
|
||||||
"minLength": 4
|
"minLength": 2
|
||||||
},
|
},
|
||||||
"uuid": {
|
"uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@@ -1358,7 +1358,7 @@
|
|||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 10,
|
||||||
"minLength": 4
|
"minLength": 2
|
||||||
},
|
},
|
||||||
"uuid": {
|
"uuid": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
username:
|
username:
|
||||||
maxLength: 10
|
maxLength: 10
|
||||||
minLength: 4
|
minLength: 2
|
||||||
type: string
|
type: string
|
||||||
uuid:
|
uuid:
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
Logger *logrus.Logger
|
Logger *logrus.Logger
|
||||||
|
ConfigPath string = ""
|
||||||
Config config.Config
|
Config config.Config
|
||||||
Viper *viper.Viper
|
Viper *viper.Viper
|
||||||
Redis *redis.Client
|
Redis *redis.Client
|
||||||
|
|||||||
3
go.mod
3
go.mod
@@ -16,6 +16,7 @@ require (
|
|||||||
github.com/google/uuid v1.1.2
|
github.com/google/uuid v1.1.2
|
||||||
github.com/nicksnyder/go-i18n/v2 v2.4.0
|
github.com/nicksnyder/go-i18n/v2 v2.4.0
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/viper v1.9.0
|
github.com/spf13/viper v1.9.0
|
||||||
github.com/swaggo/files v1.0.1
|
github.com/swaggo/files v1.0.1
|
||||||
github.com/swaggo/gin-swagger v1.6.0
|
github.com/swaggo/gin-swagger v1.6.0
|
||||||
@@ -28,7 +29,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/compute/metadata v0.5.1 // indirect
|
|
||||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||||
@@ -44,6 +44,7 @@ require (
|
|||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.0 // indirect
|
github.com/goccy/go-json v0.10.0 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
|
|||||||
Reference in New Issue
Block a user