Browse Source

Merge branch 'gin-vue-admin_v2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gin-vue-admin_v2_dev

klausY 4 years ago
parent
commit
b4fb4d00b9

+ 1 - 0
README-zh_CN.md

@@ -183,6 +183,7 @@ go run main.go;
     │  ├─model          (结构体层)
     │  ├─resource       (资源)
     │  ├─router         (路由)
+    │  ├─service         (服务)
     │  └─utils	        (公共功能)
     └─web            (前端文件)
         ├─public        (发布模板)

+ 1 - 0
README.md

@@ -180,6 +180,7 @@ go run main.go;
     │  ├─model          (model and services)
     │  ├─resource       (resources, such as static pages, templates)
     │  ├─router         (routers)
+    │  ├─service         (services)
     │  └─utils	        (common utilities)
     └─web            (frontend)
         ├─public        (deploy templates)

+ 19 - 0
server/api/v1/sys_authority.go

@@ -29,6 +29,25 @@ func CreateAuthority(c *gin.Context) {
 	}
 }
 
+// @Tags authority
+// @Summary 拷贝角色
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body response.SysAuthorityCopyResponse true "拷贝角色"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"拷贝成功"}"
+// @Router /authority/copyAuthority [post]
+func CopyAuthority(c *gin.Context) {
+	var copyInfo resp.SysAuthorityCopyResponse
+	_ = c.ShouldBindJSON(&copyInfo)
+	err, authBack := service.CopyAuthority(copyInfo)
+	if err != nil {
+		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
+	} else {
+		response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
+	}
+}
+
 // @Tags authority
 // @Summary 删除角色
 // @Security ApiKeyAuth

+ 34 - 49
server/config.yaml

@@ -1,55 +1,40 @@
-# Gin-Vue-Admin Global Configuration
-
-# casbin configuration
+captcha:
+  key-long: 4
+  img-width: 120
+  img-height: 40
 casbin:
-    model-path: './resource/rbac_model.conf'
-
-# jwt configuration
+  model-path: ./resource/rbac_model.conf
 jwt:
-    signing-key: 'qmPlus'
-
-# mysql connect configuration
+  signing-key: qmPlus
+log:
+  prefix: '[GIN-VUE-ADMIN]'
+  log-file: true
+  stdout: DEBUG
+  file: DEBUG
 mysql:
-    username: root
-    password: 'Aa@6447985'
-    path: '127.0.0.1:3306'
-    db-name: 'qmplus'
-    config: 'charset=utf8&parseTime=True&loc=Local'
-    max-idle-conns: 10
-    max-open-conns: 10
-    log-mode: true
-#sqlite 配置
-sqlite:
-    path: db/db.db
-    log-mode: true
-    config: 'loc=Asia/Shanghai'
-# oss configuration
+  username: root
+  password: Aa@6447985
+  path: 127.0.0.1:3306
+  db-name: qmplus
+  config: charset=utf8&parseTime=True&loc=Local
+  max-idle-conns: 10
+  max-open-conns: 10
+  log-mode: true
 qiniu:
-    access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ'
-    secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY'
-
-# redis configuration
+  access-key: 25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ
+  secret-key: pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY
 redis:
-    addr: '127.0.0.1:6379'
-    passwprd: ''
-    db: 0
-
-# system configuration
+  addr: 127.0.0.1:6379
+  password: ""
+  db: 0
+sqlite:
+  username: ""
+  password: ""
+  path: db/db.db
+  config: loc=Asia/Shanghai
+  log-mode: true
 system:
-    use-multipoint: false
-    env: 'public'  # Change to "develop" to skip authentication for development mode
-    addr: 8888
-    db-type: "mysql"
-
-# captcha configuration
-captcha:
-    key-long: 4
-    img-width: 120
-    img-height: 40
-
-# logger configuration
-log:
-    prefix: '[GIN-VUE-ADMIN]'
-    log-file: true
-    stdout: 'DEBUG'
-    file: 'DEBUG'
+  use-multipoint: false
+  env: public
+  addr: 8888
+  db-type: mysql

+ 40 - 40
server/config/config.go

@@ -1,70 +1,70 @@
 package config
 
 type Server struct {
-	Mysql   Mysql   `mapstructure:"mysql" json:"mysql"`
-	Sqlite  Sqlite  `mapstructure:"sqlite" json:"sqlite"`
-	Qiniu   Qiniu   `mapstructure:"qiniu" json:"qiniu"`
-	Casbin  Casbin  `mapstructure:"casbin" json:"casbin"`
-	Redis   Redis   `mapstructure:"redis" json:"redis"`
-	System  System  `mapstructure:"system" json:"system"`
-	JWT     JWT     `mapstructure:"jwt" json:"jwt"`
-	Captcha Captcha `mapstructure:"captcha" json:"captcha"`
-	Log     Log     `mapstructure:"log" json:"log"`
+	Mysql   Mysql   `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
+	Sqlite  Sqlite  `mapstructure:"sqlite" json:"sqlite" yaml:"sqlite"`
+	Qiniu   Qiniu   `mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"`
+	Casbin  Casbin  `mapstructure:"casbin" json:"casbin" yaml:"casbin"`
+	Redis   Redis   `mapstructure:"redis" json:"redis" yaml:"redis"`
+	System  System  `mapstructure:"system" json:"system" yaml:"system"`
+	JWT     JWT     `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
+	Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
+	Log     Log     `mapstructure:"log" json:"log" yaml:"log"`
 }
 
 type System struct {
-	UseMultipoint bool   `mapstructure:"use-multipoint" json:"useMultipoint"`
-	Env           string `mapstructure:"env" json:"env"`
-	Addr          int    `mapstructure:"addr" json:"addr"`
-	DbType        string `mapstructure:"db-type" json:"dbType"`
+	UseMultipoint bool   `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"`
+	Env           string `mapstructure:"env" json:"env" yaml:"env"`
+	Addr          int    `mapstructure:"addr" json:"addr" yaml:"addr"`
+	DbType        string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
 }
 
 type JWT struct {
-	SigningKey string `mapstructure:"signing-key" json:"signingKey"`
+	SigningKey string `mapstructure:"signing-key" json:"signingKey" yaml:"signing-key"`
 }
 
 type Casbin struct {
-	ModelPath string `mapstructure:"model-path" json:"modelPath"`
+	ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"`
 }
 
 type Mysql struct {
-	Username     string `mapstructure:"username" json:"username"`
-	Password     string `mapstructure:"password" json:"password"`
-	Path         string `mapstructure:"path" json:"path"`
-	Dbname       string `mapstructure:"db-name" json:"dbname"`
-	Config       string `mapstructure:"config" json:"config"`
-	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns"`
-	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns"`
-	LogMode      bool   `mapstructure:"log-mode" json:"logMode"`
+	Username     string `mapstructure:"username" json:"username" yaml:"username"`
+	Password     string `mapstructure:"password" json:"password" yaml:"password"`
+	Path         string `mapstructure:"path" json:"path" yaml:"path"`
+	Dbname       string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
+	Config       string `mapstructure:"config" json:"config" yaml:"config"`
+	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
+	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
+	LogMode      bool   `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`
 }
 
 type Redis struct {
-	Addr     string `mapstructure:"addr" json:"addr"`
-	Password string `mapstructure:"password" json:"password"`
-	DB       int    `mapstructure:"db" json:"db"`
+	Addr     string `mapstructure:"addr" json:"addr" yaml:"addr"`
+	Password string `mapstructure:"password" json:"password" yaml:"password"`
+	DB       int    `mapstructure:"db" json:"db" yaml:"db"`
 }
 type Qiniu struct {
-	AccessKey string `mapstructure:"access-key" json:"accessKey"`
-	SecretKey string `mapstructure:"secret-key" json:"secretKey"`
+	AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"`
+	SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
 }
 
 type Captcha struct {
-	KeyLong   int `mapstructure:"key-long" json:"keyLong"`
-	ImgWidth  int `mapstructure:"img-width" json:"imgWidth"`
-	ImgHeight int `mapstructure:"img-height" json:"imgHeight"`
+	KeyLong   int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"`
+	ImgWidth  int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"`
+	ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"`
 }
 
 type Log struct {
-	Prefix  string `mapstructure:"prefix" json:"prefix"`
-	LogFile bool   `mapstructure:"log-file" json:"logFile"`
-	Stdout  string `mapstructure:"stdout" json:"stdout"`
-	File    string `mapstructure:"file" json:"file"`
+	Prefix  string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
+	LogFile bool   `mapstructure:"log-file" json:"logFile" yaml:"log-file"`
+	Stdout  string `mapstructure:"stdout" json:"stdout" yaml:"stdout"`
+	File    string `mapstructure:"file" json:"file" yaml:"file"`
 }
 
 type Sqlite struct {
-	Username string `mapstructure:"username" json:"username"`
-	Password string `mapstructure:"password" json:"password"`
-	Path     string `mapstructure:"path" json:"path"`
-	Config   string `mapstructure:"config" json:"config"`
-	LogMode  bool   `mapstructure:"log-mode" json:"logMode"`
+	Username string `mapstructure:"username" json:"username" yaml:"username"`
+	Password string `mapstructure:"password" json:"password" yaml:"password"`
+	Path     string `mapstructure:"path" json:"path" yaml:"path"`
+	Config   string `mapstructure:"config" json:"config" yaml:"config"`
+	LogMode  bool   `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`
 }

+ 147 - 5
server/docs/docs.go

@@ -1,6 +1,6 @@
 // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
 // This file was generated by swaggo/swag at
-// 2020-04-15 09:37:13.5084762 +0800 CST m=+0.126566601
+// 2020-04-20 14:50:58.4141704 +0800 CST m=+0.881639701
 
 package docs
 
@@ -248,6 +248,45 @@ var doc = `{
                 }
             }
         },
+        "/authority/copyAuthority": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "authority"
+                ],
+                "summary": "拷贝角色",
+                "parameters": [
+                    {
+                        "description": "拷贝角色",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "type": "object",
+                            "$ref": "#/definitions/response.SysAuthorityCopyResponse"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"拷贝成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/authority/createAuthority": {
             "post": {
                 "security": [
@@ -404,6 +443,45 @@ var doc = `{
                 }
             }
         },
+        "/authority/updateAuthority": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "authority"
+                ],
+                "summary": "设置角色资源权限",
+                "parameters": [
+                    {
+                        "description": "设置角色资源权限",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "type": "object",
+                            "$ref": "#/definitions/model.SysAuthority"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"设置成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/autoCode/createTemp": {
             "post": {
                 "security": [
@@ -1588,6 +1666,45 @@ var doc = `{
                 }
             }
         },
+        "/user/deleteUser": {
+            "delete": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SysUser"
+                ],
+                "summary": "删除用户",
+                "parameters": [
+                    {
+                        "description": "删除用户",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "type": "object",
+                            "$ref": "#/definitions/request.SetUserAuth"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/user/getUserList": {
             "post": {
                 "security": [
@@ -2072,12 +2189,18 @@ var doc = `{
                 "component": {
                     "type": "string"
                 },
+                "defaultMenu": {
+                    "type": "boolean"
+                },
                 "hidden": {
                     "type": "boolean"
                 },
                 "icon": {
                     "type": "string"
                 },
+                "keepAlive": {
+                    "type": "boolean"
+                },
                 "name": {
                     "type": "string"
                 },
@@ -2317,6 +2440,25 @@ var doc = `{
                     "type": "string"
                 }
             }
+        },
+        "response.SysAuthorityCopyResponse": {
+            "type": "object",
+            "properties": {
+                "authority": {
+                    "type": "object",
+                    "$ref": "#/definitions/model.SysAuthority"
+                },
+                "oldAuthorityId": {
+                    "type": "integer"
+                }
+            }
+        }
+    },
+    "securityDefinitions": {
+        "ApiKeyAuth": {
+            "type": "apiKey",
+            "name": "x-token",
+            "in": "header"
         }
     }
 }`
@@ -2332,12 +2474,12 @@ type swaggerInfo struct {
 
 // SwaggerInfo holds exported Swagger Info so clients can modify it
 var SwaggerInfo = swaggerInfo{
-	Version:     "",
+	Version:     "0.0.1",
 	Host:        "",
-	BasePath:    "",
+	BasePath:    "/",
 	Schemes:     []string{},
-	Title:       "",
-	Description: "",
+	Title:       "Swagger Example API",
+	Description: "This is a sample Server pets",
 }
 
 type s struct{}

+ 147 - 1
server/docs/swagger.json

@@ -1,9 +1,13 @@
 {
     "swagger": "2.0",
     "info": {
+        "description": "This is a sample Server pets",
+        "title": "Swagger Example API",
         "contact": {},
-        "license": {}
+        "license": {},
+        "version": "0.0.1"
     },
+    "basePath": "/",
     "paths": {
         "/api/createApi": {
             "post": {
@@ -227,6 +231,45 @@
                 }
             }
         },
+        "/authority/copyAuthority": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "authority"
+                ],
+                "summary": "拷贝角色",
+                "parameters": [
+                    {
+                        "description": "拷贝角色",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "type": "object",
+                            "$ref": "#/definitions/response.SysAuthorityCopyResponse"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"拷贝成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/authority/createAuthority": {
             "post": {
                 "security": [
@@ -383,6 +426,45 @@
                 }
             }
         },
+        "/authority/updateAuthority": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "authority"
+                ],
+                "summary": "设置角色资源权限",
+                "parameters": [
+                    {
+                        "description": "设置角色资源权限",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "type": "object",
+                            "$ref": "#/definitions/model.SysAuthority"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"设置成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/autoCode/createTemp": {
             "post": {
                 "security": [
@@ -1567,6 +1649,45 @@
                 }
             }
         },
+        "/user/deleteUser": {
+            "delete": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SysUser"
+                ],
+                "summary": "删除用户",
+                "parameters": [
+                    {
+                        "description": "删除用户",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "type": "object",
+                            "$ref": "#/definitions/request.SetUserAuth"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/user/getUserList": {
             "post": {
                 "security": [
@@ -2051,12 +2172,18 @@
                 "component": {
                     "type": "string"
                 },
+                "defaultMenu": {
+                    "type": "boolean"
+                },
                 "hidden": {
                     "type": "boolean"
                 },
                 "icon": {
                     "type": "string"
                 },
+                "keepAlive": {
+                    "type": "boolean"
+                },
                 "name": {
                     "type": "string"
                 },
@@ -2296,6 +2423,25 @@
                     "type": "string"
                 }
             }
+        },
+        "response.SysAuthorityCopyResponse": {
+            "type": "object",
+            "properties": {
+                "authority": {
+                    "type": "object",
+                    "$ref": "#/definitions/model.SysAuthority"
+                },
+                "oldAuthorityId": {
+                    "type": "integer"
+                }
+            }
+        }
+    },
+    "securityDefinitions": {
+        "ApiKeyAuth": {
+            "type": "apiKey",
+            "name": "x-token",
+            "in": "header"
         }
     }
 }

+ 93 - 0
server/docs/swagger.yaml

@@ -1,3 +1,4 @@
+basePath: /
 definitions:
   config.Captcha:
     properties:
@@ -217,10 +218,14 @@ definitions:
         type: array
       component:
         type: string
+      defaultMenu:
+        type: boolean
       hidden:
         type: boolean
       icon:
         type: string
+      keepAlive:
+        type: boolean
       name:
         type: string
       parentId:
@@ -380,9 +385,20 @@ definitions:
       uuid:
         type: string
     type: object
+  response.SysAuthorityCopyResponse:
+    properties:
+      authority:
+        $ref: '#/definitions/model.SysAuthority'
+        type: object
+      oldAuthorityId:
+        type: integer
+    type: object
 info:
   contact: {}
+  description: This is a sample Server pets
   license: {}
+  title: Swagger Example API
+  version: 0.0.1
 paths:
   /api/createApi:
     post:
@@ -520,6 +536,30 @@ paths:
       summary: 创建基础api
       tags:
       - SysApi
+  /authority/copyAuthority:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 拷贝角色
+        in: body
+        name: data
+        required: true
+        schema:
+          $ref: '#/definitions/response.SysAuthorityCopyResponse'
+          type: object
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: '{"success":true,"data":{},"msg":"拷贝成功"}'
+          schema:
+            type: string
+      security:
+      - ApiKeyAuth: []
+      summary: 拷贝角色
+      tags:
+      - authority
   /authority/createAuthority:
     post:
       consumes:
@@ -616,6 +656,30 @@ paths:
       summary: 设置角色资源权限
       tags:
       - authority
+  /authority/updateAuthority:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 设置角色资源权限
+        in: body
+        name: data
+        required: true
+        schema:
+          $ref: '#/definitions/model.SysAuthority'
+          type: object
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: '{"success":true,"data":{},"msg":"设置成功"}'
+          schema:
+            type: string
+      security:
+      - ApiKeyAuth: []
+      summary: 设置角色资源权限
+      tags:
+      - authority
   /autoCode/createTemp:
     post:
       consumes:
@@ -1343,6 +1407,30 @@ paths:
       summary: 用户修改密码
       tags:
       - SysUser
+  /user/deleteUser:
+    delete:
+      consumes:
+      - application/json
+      parameters:
+      - description: 删除用户
+        in: body
+        name: data
+        required: true
+        schema:
+          $ref: '#/definitions/request.SetUserAuth'
+          type: object
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: '{"success":true,"data":{},"msg":"修改成功"}'
+          schema:
+            type: string
+      security:
+      - ApiKeyAuth: []
+      summary: 删除用户
+      tags:
+      - SysUser
   /user/getUserList:
     post:
       consumes:
@@ -1438,4 +1526,9 @@ paths:
       summary: 注册工作流
       tags:
       - workflow
+securityDefinitions:
+  ApiKeyAuth:
+    in: header
+    name: x-token
+    type: apiKey
 swagger: "2.0"

+ 1 - 0
server/initialize/router.go

@@ -11,6 +11,7 @@ import (
 )
 
 //初始化总路由
+
 func Routers() *gin.Engine {
 	var Router = gin.Default()
 

+ 7 - 0
server/main.go

@@ -7,6 +7,13 @@ import (
 	//"runtime"
 )
 
+// @title Swagger Example API
+// @version 0.0.1
+// @description This is a sample Server pets
+// @securityDefinitions.apikey ApiKeyAuth
+// @in header
+// @name x-token
+// @BasePath /
 func main() {
 	switch global.GVA_CONFIG.System.DbType {
 	case "mysql":

+ 5 - 0
server/model/response/sys_authority.go

@@ -5,3 +5,8 @@ import "gin-vue-admin/model"
 type SysAuthorityResponse struct {
 	Authority model.SysAuthority `json:"authority"`
 }
+
+type SysAuthorityCopyResponse struct {
+	Authority      model.SysAuthority `json:"authority"`
+	OldAuthorityId string             `json:"oldAuthorityId"`
+}

+ 3 - 1
server/model/response/sys_casbin.go

@@ -1,5 +1,7 @@
 package response
 
+import "gin-vue-admin/model/request"
+
 type PolicyPathResponse struct {
-	Paths []map[string]string `json:"paths"`
+	Paths []request.CasbinInfo `json:"paths"`
 }

+ 1 - 0
server/router/sys_authority.go

@@ -12,6 +12,7 @@ func InitAuthorityRouter(Router *gin.RouterGroup) {
 		AuthorityRouter.POST("createAuthority", v1.CreateAuthority)   //创建角色
 		AuthorityRouter.POST("deleteAuthority", v1.DeleteAuthority)   //删除角色
 		AuthorityRouter.PUT("updateAuthority", v1.UpdateAuthority)    //更新角色
+		AuthorityRouter.POST("copyAuthority", v1.CopyAuthority)       //更新角色
 		AuthorityRouter.POST("getAuthorityList", v1.GetAuthorityList) //获取角色列表
 		AuthorityRouter.POST("setDataAuthority", v1.SetDataAuthority) //设置角色资源权限
 	}

+ 1 - 0
server/service/exa_file_upload_download.go

@@ -53,6 +53,7 @@ func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{},
 	offset := info.PageSize * (info.Page - 1)
 	db := global.GVA_DB
 	var fileLists []model.ExaFileUploadAndDownload
+	err = db.Find(&fileLists).Count(&total).Error
 	err = db.Limit(limit).Offset(offset).Order("updated_at desc").Find(&fileLists).Error
 	return err, fileLists, total
 }

+ 29 - 0
server/service/sys_authority.go

@@ -5,6 +5,8 @@ import (
 	"gin-vue-admin/global"
 	"gin-vue-admin/model"
 	"gin-vue-admin/model/request"
+	"gin-vue-admin/model/response"
+	"strconv"
 )
 
 // @title    CreateAuthority
@@ -19,6 +21,33 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut
 	return err, auth
 }
 
+// @title    CopyAuthority
+// @description   复制一个角色
+// @auth                     (2020/04/05  20:22)
+// @param     copyInfo        response.SysAuthorityCopyResponse
+// @return                    error
+// @return    authority       model.SysAuthority
+
+func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority model.SysAuthority) {
+	copyInfo.Authority.Children = []model.SysAuthority{}
+	err, menus := GetMenuAuthority(copyInfo.OldAuthorityId)
+	var baseMenu []model.SysBaseMenu
+	for _, v := range menus {
+		intNum, _ := strconv.Atoi(v.MenuId)
+		v.SysBaseMenu.ID = uint(intNum)
+		baseMenu = append(baseMenu, v.SysBaseMenu)
+	}
+	copyInfo.Authority.SysBaseMenus = baseMenu
+	err = global.GVA_DB.Create(&copyInfo.Authority).Error
+
+	paths := GetPolicyPathByAuthorityId(copyInfo.OldAuthorityId)
+	err = UpdateCasbin(copyInfo.Authority.AuthorityId, paths)
+	if err != nil {
+		_ = DeleteAuthority(&copyInfo.Authority)
+	}
+	return err, copyInfo.Authority
+}
+
 // @title    UpdateAuthority
 // @description   更改一个角色
 // @auth                     (2020/04/05  20:22)

+ 4 - 4
server/service/sys_casbin.go

@@ -71,13 +71,13 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod
 // @param     authorityId     string
 // @return                    []string
 
-func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []map[string]string) {
+func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinInfo) {
 	e := Casbin()
 	list := e.GetFilteredPolicy(0, authorityId)
 	for _, v := range list {
-		pathMaps = append(pathMaps, map[string]string{
-			"path":   v[1],
-			"method": v[2],
+		pathMaps = append(pathMaps, request.CasbinInfo{
+			Path:   v[1],
+			Method: v[2],
 		})
 	}
 	return pathMaps

+ 1 - 0
server/service/sys_user.go

@@ -79,6 +79,7 @@ func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total
 	offset := info.PageSize * (info.Page - 1)
 	db := global.GVA_DB
 	var userList []model.SysUser
+	err = db.Find(&userList).Count(&total).Error
 	err = db.Limit(limit).Offset(offset).Preload("Authority").Find(&userList).Error
 	return err, userList, total
 }

+ 1 - 1
web/src/view/example/breakpoint/breakpoint.vue

@@ -10,7 +10,7 @@
     <div class="el-upload__tip">请上传不超过5MB的文件</div>
     <div class="list">
       <transition-group name="list" tag="p">
-        <div class="list-item" v-for="(item,i) in uploadList" :key="i" >
+        <div class="list-item" v-for="item in uploadList" :key="item.name" >
           <i class="el-icon-document"></i>
           <span>{{ item.name }}</span>
           <span v-if="file" class="percentage" >{{percentage}}%</span>

+ 1 - 1
web/src/view/layout/aside/asideComponent/index.vue

@@ -14,7 +14,7 @@ export default {
   name: 'AsideComponent',
   computed: {
     menuComponent() {
-      if (this.routerInfo.children.length) {
+      if (this.routerInfo.children.filter(item=>!item.hidden).length) {
         return 'AsyncSubmenu'
       } else {
         return 'MenuItem'

+ 1 - 1
web/src/view/login/login.vue

@@ -25,7 +25,7 @@
             placeholder="请输入验证码"
             maxlength="10"
           />
-          <img :src="path + picPath" alt="请输入验证码" @click="loginVefify()" class="vPic">
+          <img v-if="picPath" :src="path + picPath" alt="请输入验证码" @click="loginVefify()" class="vPic">
         </el-form-item>
         <el-form-item>
           <el-button @click="submitForm" style="width:100%">登 录</el-button>

+ 0 - 10
web/src/view/systemTools/system/system.vue

@@ -78,11 +78,6 @@
       <el-form-item label="secretKey">
         <el-input v-model="config.qiniu.secretKey"></el-input>
       </el-form-item>
-      <el-form-item>
-        <el-button @click="update" type="primary">立即更新</el-button>
-        <el-button @click="reload" type="primary">重启服务(开发中)</el-button>
-      </el-form-item>
-
       <h2>验证码配置</h2>
       <el-form-item label="keyLong">
         <el-input v-model.number="config.captcha.keyLong"></el-input>
@@ -93,11 +88,6 @@
       <el-form-item label="imgHeight">
         <el-input v-model.number="config.captcha.imgHeight"></el-input>
       </el-form-item>
-      <el-form-item>
-        <el-button @click="update" type="primary">立即更新</el-button>
-        <el-button @click="reload" type="primary">重启服务(开发中)</el-button>
-      </el-form-item>
-
        <h2>日志配置</h2>
       <el-form-item label="prefix">
         <el-input v-model.number="config.log.prefix"></el-input>