Merge pull request #477 from flipped-aurora/gva_gormv2_dev

Gva gormv2 dev
This commit is contained in:
奇淼(piexlmax
2021-05-18 16:47:39 +08:00
committed by GitHub
70 changed files with 1403 additions and 632 deletions
+4 -4
View File
@@ -166,7 +166,7 @@ npm run serve
### 2.2 server端
使用 goland等编辑工具,打开server目录,不可以打开 gin-vue-admin目录
使用 goland等编辑工具,打开server目录,不可以打开 gin-vue-admin目录
```bash
# 使用 go.mod
@@ -223,12 +223,12 @@ zap:
#### 2.3.1 安装 swagger
##### 1)可以翻墙
##### 1)可以科学上网
````
go get -u github.com/swaggo/swag/cmd/swag
````
##### 2)无法翻墙
##### 2)无法科学上网
由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.io](https://goproxy.io/zh/)
@@ -249,7 +249,7 @@ go get -u github.com/swaggo/swag/cmd/swag
cd server
swag init
````
执行上面的命令后,server目录下会出现docs文件夹,登录http://localhost:8888/swagger/index.html,即可查看swagger文档
执行上面的命令后,server目录下会出现docs文件夹,登录 http://localhost:8888/swagger/index.html ,即可查看swagger文档
## 3. 技术选型
+2 -11
View File
@@ -5,10 +5,7 @@ import (
"gin-vue-admin/model"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"os"
"os/exec"
"runtime"
"strconv"
"gin-vue-admin/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
@@ -54,13 +51,7 @@ func SetSystemConfig(c *gin.Context) {
// @Success 200 {string} string "{"code":0,"data":{},"msg":"重启系统成功"}"
// @Router /system/reloadSystem [post]
func ReloadSystem(c *gin.Context) {
if runtime.GOOS == "windows" {
response.FailWithMessage("系统不支持", c)
return
}
pid := os.Getpid()
cmd := exec.Command("kill", "-1", strconv.Itoa(pid))
err := cmd.Run()
err := utils.Reload()
if err != nil {
global.GVA_LOG.Error("重启系统失败!", zap.Any("err", err))
response.FailWithMessage("重启系统失败", c)
+21 -7
View File
@@ -70,6 +70,7 @@ local:
# autocode configuration
autocode:
transfer-restart: true
root: ""
server: /server
server-api: /api/v1
@@ -84,14 +85,14 @@ autocode:
web-form: /view
web-table: /view
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket ?域名地址)
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 域名地址)
qiniu:
zone: 'ZoneHuadong'
bucket: 'qm-plus-img'
img-path: 'http://qmplusimg.henrongyi.top'
zone: 'ZoneHuaDong'
bucket: ''
img-path: ''
use-https: false
access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ'
secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY'
access-key: ''
secret-key: ''
use-cdn-domains: false
@@ -114,4 +115,17 @@ tencent-cos:
# excel configuration
excel:
dir: './resource/excel/'
dir: './resource/excel/'
# timer task db clear table
Timer:
spec: "@daily" # 定时任务详细配置参考 https://pkg.go.dev/github.com/robfig/cron?utm_source=godoc
detail: [
# tableName: 需要清理的表名
# compareField: 需要比较时间的字段
# interval: 时间间隔, 具体配置详看 time.ParseDuration() 中字符串表示 且不能为负数
# 2160h = 24 * 30 * 3 -> 三个月
{ tableName: "sys_operation_records" , compareField: "created_at", interval: "2160h" },
#{ tableName: "log2" , compareField: "created_at", interval: "2160h" }
]
+14 -13
View File
@@ -1,17 +1,18 @@
package config
type Autocode struct {
Root string `mapstructure:"root" json:"root" yaml:"root"`
Server string `mapstructure:"server" json:"server" yaml:"server"`
SApi string `mapstructure:"server-api" json:"serverApi" yaml:"server-api"`
SInitialize string `mapstructure:"server-initialize" json:"serverInitialize" yaml:"server-initialize"`
SModel string `mapstructure:"server-model" json:"serverModel" yaml:"server-model"`
SRequest string `mapstructure:"server-request" json:"serverRequest" yaml:"server-request"`
SRouter string `mapstructure:"server-router" json:"serverRouter" yaml:"server-router"`
SService string `mapstructure:"server-service" json:"serverService" yaml:"server-service"`
Web string `mapstructure:"web" json:"web" yaml:"web"`
WApi string `mapstructure:"web-api" json:"webApi" yaml:"web-api"`
WForm string `mapstructure:"web-form" json:"webForm" yaml:"web-form"`
WTable string `mapstructure:"web-table" json:"webTable" yaml:"web-table"`
WFlow string `mapstructure:"web-flow" json:"webFlow" yaml:"web-flow"`
TransferRestart bool `mapstructure:"transfer-restart" json:"transferRestart" yaml:"transfer-restart"`
Root string `mapstructure:"root" json:"root" yaml:"root"`
Server string `mapstructure:"server" json:"server" yaml:"server"`
SApi string `mapstructure:"server-api" json:"serverApi" yaml:"server-api"`
SInitialize string `mapstructure:"server-initialize" json:"serverInitialize" yaml:"server-initialize"`
SModel string `mapstructure:"server-model" json:"serverModel" yaml:"server-model"`
SRequest string `mapstructure:"server-request" json:"serverRequest" yaml:"server-request"`
SRouter string `mapstructure:"server-router" json:"serverRouter" yaml:"server-router"`
SService string `mapstructure:"server-service" json:"serverService" yaml:"server-service"`
Web string `mapstructure:"web" json:"web" yaml:"web"`
WApi string `mapstructure:"web-api" json:"webApi" yaml:"web-api"`
WForm string `mapstructure:"web-form" json:"webForm" yaml:"web-form"`
WTable string `mapstructure:"web-table" json:"webTable" yaml:"web-table"`
WFlow string `mapstructure:"web-flow" json:"webFlow" yaml:"web-flow"`
}
+3 -3
View File
@@ -1,7 +1,7 @@
package config
type Captcha struct {
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"`
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"` // 验证码高度
}
+1 -1
View File
@@ -1,5 +1,5 @@
package config
type Casbin struct {
ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"`
ModelPath string `mapstructure:"model-path" json:"modelPath" yaml:"model-path"` // 存放casbin模型的相对路径
}
+1
View File
@@ -18,4 +18,5 @@ type Server struct {
AliyunOSS AliyunOSS `mapstructure:"aliyun-oss" json:"aliyunOSS" yaml:"aliyun-oss"`
TencentCOS TencentCOS `mapstructure:"tencent-cos" json:"tencentCOS" yaml:"tencent-cos"`
Excel Excel `mapstructure:"excel" json:"excel" yaml:"excel"`
Timer Timer `mapstructure:"timer" json:"timer" yaml:"timer"`
}
+7 -7
View File
@@ -1,11 +1,11 @@
package config
type Email struct {
To string `mapstructure:"to" json:"to" yaml:"to"`
Port int `mapstructure:"port" json:"port" yaml:"port"`
From string `mapstructure:"from" json:"from" yaml:"from"`
Host string `mapstructure:"host" json:"host" yaml:"host"`
IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"`
Secret string `mapstructure:"secret" json:"secret" yaml:"secret"`
Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"`
To string `mapstructure:"to" json:"to" yaml:"to"` // 收件人:多个以英文逗号分隔
Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口
From string `mapstructure:"from" json:"from" yaml:"from"` // 收件人
Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址
IsSSL bool `mapstructure:"is-ssl" json:"isSSL" yaml:"is-ssl"` // 是否SSL
Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // 密钥
Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname"` // 昵称
}
+8 -8
View File
@@ -1,14 +1,14 @@
package config
type Mysql struct {
Path string `mapstructure:"path" json:"path" yaml:"path"`
Config string `mapstructure:"config" json:"config" yaml:"config"`
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
Username string `mapstructure:"username" json:"username" yaml:"username"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
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"`
Path string `mapstructure:"path" json:"path" yaml:"path"` // 服务器地址:端口
Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` // 数据库名
Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名
Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码
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"` // 是否开启Gorm全局日志
LogZap string `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"`
}
+3 -3
View File
@@ -1,7 +1,7 @@
package config
type JWT struct {
SigningKey string `mapstructure:"signing-key" json:"signingKey" yaml:"signing-key"`
ExpiresTime int64 `mapstructure:"expires-time" json:"expiresTime" yaml:"expires-time"`
BufferTime int64 `mapstructure:"buffer-time" json:"bufferTime" yaml:"buffer-time"`
SigningKey string `mapstructure:"signing-key" json:"signingKey" yaml:"signing-key"` // jwt签名
ExpiresTime int64 `mapstructure:"expires-time" json:"expiresTime" yaml:"expires-time"` // 过期时间
BufferTime int64 `mapstructure:"buffer-time" json:"bufferTime" yaml:"buffer-time"` // 缓冲时间
}
+8 -8
View File
@@ -1,17 +1,17 @@
package config
type Local struct {
Path string `mapstructure:"path" json:"path" yaml:"path" `
Path string `mapstructure:"path" json:"path" yaml:"path"` // 本地文件路径
}
type Qiniu struct {
Zone string `mapstructure:"zone" json:"zone" yaml:"zone"`
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
ImgPath string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"`
UseHTTPS bool `mapstructure:"use-https" json:"useHttps" yaml:"use-https"`
AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"`
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"`
Zone string `mapstructure:"zone" json:"zone" yaml:"zone"` // 存储区域
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` // 空间名称
ImgPath string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"` // CDN加速域名
UseHTTPS bool `mapstructure:"use-https" json:"useHttps" yaml:"use-https"` // 是否使用https
AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"` // 秘钥AK
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` // 秘钥SK
UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"` // 上传是否使用CDN上传加速
}
type AliyunOSS struct {
+3 -3
View File
@@ -1,7 +1,7 @@
package config
type Redis struct {
DB int `mapstructure:"db" json:"db" yaml:"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"` // redis的哪个数据库
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口
Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码
}
+5 -5
View File
@@ -1,9 +1,9 @@
package config
type System struct {
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"`
OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"`
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"` // 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql
OssType string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"` // Oss类型
UseMultipoint bool `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"` // 多点登录拦截
}
+13
View File
@@ -0,0 +1,13 @@
package config
type Timer struct {
Start bool `mapstructure:"start" json:"start" yaml:"start"` // 是否启用
Spec string `mapstructure:"spec" json:"spec" yaml:"spec"` // CRON表达式
Detail []Detail `mapstructure:"detail" json:"detail" yaml:"detail"`
}
type Detail struct {
TableName string `mapstructure:"tableName" json:"tableName" yaml:"tableName"` // 需要清理的表名
CompareField string `mapstructure:"compareField" json:"compareField" yaml:"compareField"` // 需要比较时间的字段
Interval string `mapstructure:"interval" json:"interval" yaml:"interval"` // 时间间隔
}
+9 -9
View File
@@ -1,13 +1,13 @@
package config
type Zap struct {
Level string `mapstructure:"level" json:"level" yaml:"level"`
Format string `mapstructure:"format" json:"format" yaml:"format"`
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
Director string `mapstructure:"director" json:"director" yaml:"director"`
LinkName string `mapstructure:"link-name" json:"linkName" yaml:"link-name"`
ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"`
EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"`
StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"`
LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"`
Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别
Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀
Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹
LinkName string `mapstructure:"link-name" json:"linkName" yaml:"link-name"` // 软链接名称
ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine"` // 显示行
EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"` // 编码级
StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"` // 栈名
LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"` // 输出控制台
}
+1
View File
@@ -36,6 +36,7 @@ func Viper(path ...string) *viper.Viper {
v := viper.New()
v.SetConfigFile(config)
v.SetConfigType("yaml")
err := v.ReadInConfig()
if err != nil {
panic(fmt.Errorf("Fatal error config file: %s \n", err))
+263 -81
View File
File diff suppressed because it is too large Load Diff
+262 -80
View File
File diff suppressed because it is too large Load Diff
+248 -80
View File
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -1,9 +1,12 @@
package global
import (
"gin-vue-admin/utils/timer"
"go.uber.org/zap"
"gin-vue-admin/config"
"github.com/go-redis/redis"
"github.com/spf13/viper"
"gorm.io/gorm"
@@ -15,5 +18,6 @@ var (
GVA_CONFIG config.Server
GVA_VP *viper.Viper
//GVA_LOG *oplogging.Logger
GVA_LOG *zap.Logger
GVA_LOG *zap.Logger
GVA_Timer timer.Timer = timer.NewTimerTask()
)
+4 -4
View File
@@ -6,8 +6,8 @@ import (
)
type GVA_MODEL struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
ID uint `gorm:"primarykey"` // 主键ID
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
}
+3 -2
View File
@@ -8,8 +8,8 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/casbin/casbin/v2 v2.25.6
github.com/casbin/gorm-adapter/v3 v3.2.6
github.com/casbin/casbin/v2 v2.11.0
github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
github.com/fsnotify/fsnotify v1.4.9
@@ -36,6 +36,7 @@ require (
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/qiniu/api.v7/v7 v7.4.1
github.com/robfig/cron/v3 v3.0.1
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil v3.21.1+incompatible
github.com/spf13/afero v1.2.2 // indirect
+24
View File
@@ -0,0 +1,24 @@
package initialize
import (
"fmt"
"gin-vue-admin/config"
"gin-vue-admin/global"
"gin-vue-admin/utils"
)
func Timer() {
if global.GVA_CONFIG.Timer.Start {
for _, detail := range global.GVA_CONFIG.Timer.Detail {
fmt.Println(detail)
go func(detail config.Detail) {
global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() {
err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval)
if err != nil {
fmt.Println("timer error:", err)
}
})
}(detail)
}
}
}
+1
View File
@@ -17,6 +17,7 @@ func main() {
global.GVA_VP = core.Viper() // 初始化Viper
global.GVA_LOG = core.Zap() // 初始化zap日志库
global.GVA_DB = initialize.Gorm() // gorm连接数据库
initialize.Timer()
if global.GVA_DB != nil {
initialize.MysqlTables(global.GVA_DB) // 初始化表
// 程序结束前关闭数据库链接
+5 -5
View File
@@ -6,9 +6,9 @@ import (
type ExaCustomer struct {
global.GVA_MODEL
CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"`
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"`
SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"`
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"`
SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"`
CustomerName string `json:"customerName" form:"customerName" gorm:"comment:客户名"` // 客户名
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:客户手机号"` // 客户手机号
SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:管理ID"` // 管理ID
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"` // 管理角色ID
SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"` // 管理详情
}
+1 -1
View File
@@ -1,6 +1,6 @@
package model
type ExcelInfo struct {
FileName string `json:"fileName"`
FileName string `json:"fileName"` // 文件名
InfoList []SysBaseMenu `json:"infoList"`
}
+4 -4
View File
@@ -6,8 +6,8 @@ import (
type ExaFileUploadAndDownload struct {
global.GVA_MODEL
Name string `json:"name" gorm:"comment:文件名"`
Url string `json:"url" gorm:"comment:文件地址"`
Tag string `json:"tag" gorm:"comment:文件标签"`
Key string `json:"key" gorm:"comment:编号"`
Name string `json:"name" gorm:"comment:文件名"` // 文件名
Url string `json:"url" gorm:"comment:文件地址"` // 文件地址
Tag string `json:"tag" gorm:"comment:文件标签"` // 文件标签
Key string `json:"key" gorm:"comment:编号"` // 编号
}
+4 -4
View File
@@ -2,13 +2,13 @@ package request
// Paging common input parameter structure
type PageInfo struct {
Page int `json:"page" form:"page"`
PageSize int `json:"pageSize" form:"pageSize"`
Page int `json:"page" form:"page"` // 页码
PageSize int `json:"pageSize" form:"pageSize"` // 每页大小
}
// Find by id structure
type GetById struct {
ID float64 `json:"id" form:"id"`
ID float64 `json:"id" form:"id"` // 主键ID
}
type IdsReq struct {
@@ -17,7 +17,7 @@ type IdsReq struct {
// Get role by id structure
type GetAuthorityId struct {
AuthorityId string
AuthorityId string // 角色ID
}
type Empty struct{}
+2 -2
View File
@@ -6,6 +6,6 @@ import "gin-vue-admin/model"
type SearchApiParams struct {
model.SysApi
PageInfo
OrderKey string `json:"orderKey"`
Desc bool `json:"desc"`
OrderKey string `json:"orderKey"` // 排序
Desc bool `json:"desc"` // 排序方式:升序false(默认)|降序true
}
+3 -3
View File
@@ -2,12 +2,12 @@ package request
// Casbin info structure
type CasbinInfo struct {
Path string `json:"path"`
Method string `json:"method"`
Path string `json:"path"` // 路径
Method string `json:"method"` // 方法
}
// Casbin structure for input parameters
type CasbinInReceive struct {
AuthorityId string `json:"authorityId"`
AuthorityId string `json:"authorityId"` // 权限id
CasbinInfos []CasbinInfo `json:"casbinInfos"`
}
+5 -5
View File
@@ -1,9 +1,9 @@
package request
type InitDB struct {
Host string `json:"host"`
Port string `json:"port"`
UserName string `json:"userName" binding:"required"`
Password string `json:"password"`
DBName string `json:"dbName" binding:"required"`
Host string `json:"host"` // 服务器地址
Port string `json:"port"` // 数据库连接端口
UserName string `json:"userName" binding:"required"` // 数据库用户名
Password string `json:"password"` // 数据库密码
DBName string `json:"dbName" binding:"required"` // 数据库名
}
+1 -1
View File
@@ -5,5 +5,5 @@ import "gin-vue-admin/model"
// Add menu authority info structure
type AddMenuAuthorityInfo struct {
Menus []model.SysBaseMenu
AuthorityId string
AuthorityId string // 角色ID
}
+9 -9
View File
@@ -13,21 +13,21 @@ type Register struct {
// User login structure
type Login struct {
Username string `json:"username"`
Password string `json:"password"`
Captcha string `json:"captcha"`
CaptchaId string `json:"captchaId"`
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
Captcha string `json:"captcha"` // 验证码
CaptchaId string `json:"captchaId"` // 验证码ID
}
// Modify password structure
type ChangePasswordStruct struct {
Username string `json:"username"`
Password string `json:"password"`
NewPassword string `json:"newPassword"`
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
NewPassword string `json:"newPassword"` // 新密码
}
// Modify user's auth structure
type SetUserAuth struct {
UUID uuid.UUID `json:"uuid"`
AuthorityId string `json:"authorityId"`
UUID uuid.UUID `json:"uuid"` // 用户UUID
AuthorityId string `json:"authorityId"` // 角色ID
}
+1 -1
View File
@@ -8,5 +8,5 @@ type SysAuthorityResponse struct {
type SysAuthorityCopyResponse struct {
Authority model.SysAuthority `json:"authority"`
OldAuthorityId string `json:"oldAuthorityId"`
OldAuthorityId string `json:"oldAuthorityId"` // 旧角色ID
}
+4 -4
View File
@@ -6,8 +6,8 @@ import (
type SysApi struct {
global.GVA_MODEL
Path string `json:"path" gorm:"comment:api路径"`
Description string `json:"description" gorm:"comment:api中文描述"`
ApiGroup string `json:"apiGroup" gorm:"comment:api组"`
Method string `json:"method" gorm:"default:POST" gorm:"comment:方法"`
Path string `json:"path" gorm:"comment:api路径"` // api路径
Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述
ApiGroup string `json:"apiGroup" gorm:"comment:api组"` // api组
Method string `json:"method" gorm:"default:POST" gorm:"comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE
}
+6 -6
View File
@@ -5,14 +5,14 @@ import (
)
type SysAuthority struct {
CreatedAt time.Time
UpdatedAt time.Time
CreatedAt time.Time // 创建时间
UpdatedAt time.Time // 更新时间
DeletedAt *time.Time `sql:"index"`
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"`
AuthorityName string `json:"authorityName" gorm:"comment:角色名"`
ParentId string `json:"parentId" gorm:"comment:父角色ID"`
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID
AuthorityName string `json:"authorityName" gorm:"comment:角色名"` // 角色名
ParentId string `json:"parentId" gorm:"comment:父角色ID"` // 父角色ID
DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"`
Children []SysAuthority `json:"children" gorm:"-"`
SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"`
DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"`
DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard)
}
+17 -17
View File
@@ -4,27 +4,27 @@ import "errors"
// 初始版本自动化代码工具
type AutoCodeStruct struct {
StructName string `json:"structName"`
TableName string `json:"tableName"`
PackageName string `json:"packageName"`
Abbreviation string `json:"abbreviation"`
Description string `json:"description"`
AutoCreateApiToSql bool `json:"autoCreateApiToSql"`
AutoMoveFile bool `json:"autoMoveFile"`
StructName string `json:"structName"` // Struct名称
TableName string `json:"tableName"` // 表名
PackageName string `json:"packageName"` // 文件名称
Abbreviation string `json:"abbreviation"` // Struct简称
Description string `json:"description"` // Struct中文名称
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
Fields []*Field `json:"fields"`
}
type Field struct {
FieldName string `json:"fieldName"`
FieldDesc string `json:"fieldDesc"`
FieldType string `json:"fieldType"`
FieldJson string `json:"fieldJson"`
DataType string `json:"dataType"`
DataTypeLong string `json:"dataTypeLong"`
Comment string `json:"comment"`
ColumnName string `json:"columnName"`
FieldSearchType string `json:"fieldSearchType"`
DictType string `json:"dictType"`
FieldName string `json:"fieldName"` // Field名
FieldDesc string `json:"fieldDesc"` // 中文名
FieldType string `json:"fieldType"` // Field数据类型
FieldJson string `json:"fieldJson"` // FieldJson
DataType string `json:"dataType"` // 数据库字段类型
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
Comment string `json:"comment"` // 数据库字段描述
ColumnName string `json:"columnName"` // 数据库字段
FieldSearchType string `json:"fieldSearchType"` // 搜索条件
DictType string `json:"dictType"` // 字典
}
var AutoMoveErr error = errors.New("创建代码成功并移动文件成功")
+16 -16
View File
@@ -6,31 +6,31 @@ import (
type SysBaseMenu struct {
global.GVA_MODEL
MenuLevel uint `json:"-"`
ParentId string `json:"parentId" gorm:"comment:父菜单ID"`
Path string `json:"path" gorm:"comment:路由path"`
Name string `json:"name" gorm:"comment:路由name"`
Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"`
Component string `json:"component" gorm:"comment:对应前端文件路径"`
Sort int `json:"sort" gorm:"comment:排序标记"`
Meta `json:"meta" gorm:"comment:附加属性"`
MenuLevel uint `json:"-"`
ParentId string `json:"parentId" gorm:"comment:父菜单ID"` // 父菜单ID
Path string `json:"path" gorm:"comment:路由path"` // 路由path
Name string `json:"name" gorm:"comment:路由name"` // 路由name
Hidden bool `json:"hidden" gorm:"comment:是否在列表隐藏"` // 是否在列表隐藏
Component string `json:"component" gorm:"comment:对应前端文件路径"` // 对应前端文件路径
Sort int `json:"sort" gorm:"comment:排序标记"` // 排序标记
Meta `json:"meta" gorm:"comment:附加属性"` // 附加属性
SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"`
Children []SysBaseMenu `json:"children" gorm:"-"`
Parameters []SysBaseMenuParameter `json:"parameters"`
}
type Meta struct {
KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"`
DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"`
Title string `json:"title" gorm:"comment:菜单名"`
Icon string `json:"icon" gorm:"comment:菜单图标"`
CloseTab bool `json:"closeTab" gorm:"comment:自动关闭tab"`
KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"` // 是否缓存
DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"` // 是否是基础路由(开发中)
Title string `json:"title" gorm:"comment:菜单名"` // 菜单名
Icon string `json:"icon" gorm:"comment:菜单图标"` // 菜单图标
CloseTab bool `json:"closeTab" gorm:"comment:自动关闭tab"` // 自动关闭tab
}
type SysBaseMenuParameter struct {
global.GVA_MODEL
SysBaseMenuID uint
Type string `json:"type" gorm:"comment:地址栏携带参数为params还是query"`
Key string `json:"key" gorm:"comment:地址栏携带参数的key"`
Value string `json:"value" gorm:"comment:地址栏携带参数的值"`
Type string `json:"type" gorm:"comment:地址栏携带参数为params还是query"` // 地址栏携带参数为params还是query
Key string `json:"key" gorm:"comment:地址栏携带参数的key"` // 地址栏携带参数的key
Value string `json:"value" gorm:"comment:地址栏携带参数的值"` // 地址栏携带参数的值
}
+4 -4
View File
@@ -8,9 +8,9 @@ import (
// 如果含有time.Time 请自行import time包
type SysDictionary struct {
global.GVA_MODEL
Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"`
Type string `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"`
Status *bool `json:"status" form:"status" gorm:"column:status;comment:状态"`
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:描述"`
Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"` // 字典名(中)
Type string `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"` // 字典名(英)
Status *bool `json:"status" form:"status" gorm:"column:status;comment:状态"` // 状态
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:描述"` // 描述
SysDictionaryDetails []SysDictionaryDetail `json:"sysDictionaryDetails" form:"sysDictionaryDetails"`
}
+5 -5
View File
@@ -8,9 +8,9 @@ import (
// 如果含有time.Time 请自行import time包
type SysDictionaryDetail struct {
global.GVA_MODEL
Label string `json:"label" form:"label" gorm:"column:label;comment:展示值"`
Value int `json:"value" form:"value" gorm:"column:value;comment:字典值"`
Status *bool `json:"status" form:"status" gorm:"column:status;comment:启用状态"`
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序标记"`
SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:关联标记"`
Label string `json:"label" form:"label" gorm:"column:label;comment:展示值"` // 展示值
Value int `json:"value" form:"value" gorm:"column:value;comment:字典值"` // 字典值
Status *bool `json:"status" form:"status" gorm:"column:status;comment:启用状态"` // 启用状态
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序标记"` // 排序标记
SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:关联标记"` // 关联标记
}
+10 -10
View File
@@ -9,15 +9,15 @@ import (
// 如果含有time.Time 请自行import time包
type SysOperationRecord struct {
global.GVA_MODEL
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"`
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"`
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"`
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"`
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟"`
Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"`
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"`
Body string `json:"body" form:"body" gorm:"type:longtext;column:body;comment:请求Body"`
Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"`
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"`
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"` // 代理
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"` // 错误信息
Body string `json:"body" form:"body" gorm:"type:longtext;column:body;comment:请求Body"` // 请求Body
Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"` // 响应Body
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id
User SysUser `json:"user"`
}
+6 -6
View File
@@ -7,11 +7,11 @@ import (
type SysUser struct {
global.GVA_MODEL
UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"`
Username string `json:"userName" gorm:"comment:用户登录名"`
Password string `json:"-" gorm:"comment:用户登录密码"`
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称" `
HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"`
UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID
Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"`
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
}
+2 -2
View File
@@ -228,7 +228,7 @@ export default {
type: 'success',
message: '删除成功'
})
if (this.tableData.length == ids.length) {
if (this.tableData.length == ids.length && this.page > 1) {
this.page--;
}
this.deleteVisible = false
@@ -272,7 +272,7 @@ export default {
type: "success",
message: "删除成功"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
+5
View File
@@ -146,6 +146,11 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
if err != nil {
return err
}
if global.GVA_CONFIG.AutoCode.TransferRestart {
go func() {
_ = utils.Reload()
}()
}
return errors.New("创建代码成功并移动文件成功")
} else { // 打包
if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil {
+1 -2
View File
@@ -97,8 +97,7 @@ var (
func Casbin() *casbin.Enforcer {
once.Do(func() {
admin := global.GVA_CONFIG.Mysql
a, _ := gormadapter.NewAdapter(global.GVA_CONFIG.System.DbType, admin.Username+":"+admin.Password+"@("+admin.Path+")/"+admin.Dbname, true)
a, _ := gormadapter.NewAdapterByDB(global.GVA_DB)
e, _ = casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a)
e.AddFunction("ParamsMatch", ParamsMatchFunc)
})
+8 -2
View File
@@ -41,7 +41,12 @@ func createTable(dsn string, driver string, createSql string) error {
if err != nil {
return err
}
defer db.Close()
defer func(db *sql.DB) {
err := db.Close()
if err != nil {
}
}(db)
if err = db.Ping(); err != nil {
return err
}
@@ -82,7 +87,6 @@ func InitDB(conf request.InitDB) error {
conf.Port = "3306"
}
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/", conf.UserName, conf.Password, conf.Host, conf.Port)
fmt.Println(dsn)
createSql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;", conf.DBName)
if err := createTable(dsn, "mysql", createSql); err != nil {
return err
@@ -117,6 +121,7 @@ func InitDB(conf request.InitDB) error {
//global.GVA_LOG.Error("MySQL启动异常", zap.Any("err", err))
//os.Exit(0)
//return nil
_ = writeConfig(global.GVA_VP, BaseMysql)
return nil
} else {
sqlDB, _ := db.DB()
@@ -142,6 +147,7 @@ func InitDB(conf request.InitDB) error {
model.SysOperationRecord{},
)
if err != nil {
_ = writeConfig(global.GVA_VP, BaseMysql)
return err
}
err = initDB(
+148 -148
View File
@@ -13,154 +13,154 @@ var Casbin = new(casbin)
type casbin struct{}
var carbines = []gormadapter.CasbinRule{
{Ptype: "p", V0: "888", V1: "/base/login", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/user/register", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/api/createApi", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/api/getApiList", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/api/getApiById", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/api/deleteApi", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/api/updateApi", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/api/getAllApis", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/authority/createAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/authority/deleteAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/authority/getAuthorityList", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/authority/setDataAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/authority/updateAuthority", V2: "PUT"},
{Ptype: "p", V0: "888", V1: "/authority/copyAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/getMenu", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/getMenuList", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/addBaseMenu", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/getBaseMenuTree", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/addMenuAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/getMenuAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/deleteBaseMenu", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/updateBaseMenu", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/menu/getBaseMenuById", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/user/changePassword", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/user/getUserList", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/user/deleteUser", V2: "DELETE"},
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/casbin/updateCasbin", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/casbin/casbinTest/:pathParam", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/jwt/jsonInBlacklist", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/system/getSystemConfig", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/system/setSystemConfig", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/system/getServerInfo", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "PUT"},
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "DELETE"},
{Ptype: "p", V0: "888", V1: "/customer/customer", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/customer/customerList", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"},
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"},
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/findSysDictionaryDetail", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysDictionaryDetail/getSysDictionaryDetailList", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysDictionary/createSysDictionary", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/sysDictionary/deleteSysDictionary", V2: "DELETE"},
{Ptype: "p", V0: "888", V1: "/sysDictionary/updateSysDictionary", V2: "PUT"},
{Ptype: "p", V0: "888", V1: "/sysDictionary/findSysDictionary", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysDictionary/getSysDictionaryList", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/createSysOperationRecord", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecord", V2: "DELETE"},
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/updateSysOperationRecord", V2: "PUT"},
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/findSysOperationRecord", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/getSysOperationRecordList", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecordByIds", V2: "DELETE"},
{Ptype: "p", V0: "888", V1: "/user/setUserInfo", V2: "PUT"},
{Ptype: "p", V0: "888", V1: "/email/emailTest", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/excel/importExcel", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/excel/loadExcel", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/excel/exportExcel", V2: "POST"},
{Ptype: "p", V0: "888", V1: "/excel/downloadTemplate", V2: "GET"},
{Ptype: "p", V0: "888", V1: "/api/deleteApisByIds", V2: "DELETE"},
{Ptype: "p", V0: "8881", V1: "/base/login", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/user/register", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "POST"},
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"},
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"},
{Ptype: "p", V0: "8881", V1: "/customer/customer", V2: "GET"},
{Ptype: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/base/login", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/user/register", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/api/createApi", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "POST"},
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"},
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"},
{Ptype: "p", V0: "9528", V1: "/customer/customer", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"},
{Ptype: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
{PType: "p", V0: "888", V1: "/base/login", V2: "POST"},
{PType: "p", V0: "888", V1: "/user/register", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/createApi", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/getApiList", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/getApiById", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/deleteApi", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/updateApi", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/getAllApis", V2: "POST"},
{PType: "p", V0: "888", V1: "/authority/createAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/authority/deleteAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/authority/getAuthorityList", V2: "POST"},
{PType: "p", V0: "888", V1: "/authority/setDataAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/authority/updateAuthority", V2: "PUT"},
{PType: "p", V0: "888", V1: "/authority/copyAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/getMenu", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/getMenuList", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/addBaseMenu", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/getBaseMenuTree", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/addMenuAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/getMenuAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/deleteBaseMenu", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/updateBaseMenu", V2: "POST"},
{PType: "p", V0: "888", V1: "/menu/getBaseMenuById", V2: "POST"},
{PType: "p", V0: "888", V1: "/user/changePassword", V2: "POST"},
{PType: "p", V0: "888", V1: "/user/getUserList", V2: "POST"},
{PType: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"},
{PType: "p", V0: "888", V1: "/user/deleteUser", V2: "DELETE"},
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"},
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
{PType: "p", V0: "888", V1: "/casbin/updateCasbin", V2: "POST"},
{PType: "p", V0: "888", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
{PType: "p", V0: "888", V1: "/casbin/casbinTest/:pathParam", V2: "GET"},
{PType: "p", V0: "888", V1: "/jwt/jsonInBlacklist", V2: "POST"},
{PType: "p", V0: "888", V1: "/system/getSystemConfig", V2: "POST"},
{PType: "p", V0: "888", V1: "/system/setSystemConfig", V2: "POST"},
{PType: "p", V0: "888", V1: "/system/getServerInfo", V2: "POST"},
{PType: "p", V0: "888", V1: "/customer/customer", V2: "POST"},
{PType: "p", V0: "888", V1: "/customer/customer", V2: "PUT"},
{PType: "p", V0: "888", V1: "/customer/customer", V2: "DELETE"},
{PType: "p", V0: "888", V1: "/customer/customer", V2: "GET"},
{PType: "p", V0: "888", V1: "/customer/customerList", V2: "GET"},
{PType: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
{PType: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"},
{PType: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
{PType: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
{PType: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"},
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"},
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"},
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/findSysDictionaryDetail", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/getSysDictionaryDetailList", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysDictionary/createSysDictionary", V2: "POST"},
{PType: "p", V0: "888", V1: "/sysDictionary/deleteSysDictionary", V2: "DELETE"},
{PType: "p", V0: "888", V1: "/sysDictionary/updateSysDictionary", V2: "PUT"},
{PType: "p", V0: "888", V1: "/sysDictionary/findSysDictionary", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysDictionary/getSysDictionaryList", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysOperationRecord/createSysOperationRecord", V2: "POST"},
{PType: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecord", V2: "DELETE"},
{PType: "p", V0: "888", V1: "/sysOperationRecord/updateSysOperationRecord", V2: "PUT"},
{PType: "p", V0: "888", V1: "/sysOperationRecord/findSysOperationRecord", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysOperationRecord/getSysOperationRecordList", V2: "GET"},
{PType: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecordByIds", V2: "DELETE"},
{PType: "p", V0: "888", V1: "/user/setUserInfo", V2: "PUT"},
{PType: "p", V0: "888", V1: "/email/emailTest", V2: "POST"},
{PType: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
{PType: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
{PType: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
{PType: "p", V0: "888", V1: "/excel/importExcel", V2: "POST"},
{PType: "p", V0: "888", V1: "/excel/loadExcel", V2: "GET"},
{PType: "p", V0: "888", V1: "/excel/exportExcel", V2: "POST"},
{PType: "p", V0: "888", V1: "/excel/downloadTemplate", V2: "GET"},
{PType: "p", V0: "888", V1: "/api/deleteApisByIds", V2: "DELETE"},
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
{PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"},
{PType: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"},
{PType: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"},
{PType: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"},
{PType: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"},
{PType: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"},
{PType: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"},
{PType: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"},
{PType: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"},
{PType: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"},
{PType: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
{PType: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
{PType: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"},
{PType: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
{PType: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"},
{PType: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"},
{PType: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"},
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "POST"},
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"},
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"},
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "GET"},
{PType: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"},
{PType: "p", V0: "9528", V1: "/base/login", V2: "POST"},
{PType: "p", V0: "9528", V1: "/user/register", V2: "POST"},
{PType: "p", V0: "9528", V1: "/api/createApi", V2: "POST"},
{PType: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"},
{PType: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"},
{PType: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"},
{PType: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"},
{PType: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"},
{PType: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"},
{PType: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"},
{PType: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"},
{PType: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"},
{PType: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"},
{PType: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"},
{PType: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"},
{PType: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"},
{PType: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"},
{PType: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
{PType: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
{PType: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"},
{PType: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
{PType: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"},
{PType: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"},
{PType: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"},
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "POST"},
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"},
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"},
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "GET"},
{PType: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"},
{PType: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
}
//@author: [SliverHorn](https://github.com/SliverHorn)
+29
View File
@@ -0,0 +1,29 @@
package utils
import (
"errors"
"fmt"
"time"
"gorm.io/gorm"
)
//@author: [songzhibin97](https://github.com/songzhibin97)
//@function: ClearTable
//@description: 清理数据库表数据
//@param: target db(数据库对象) *gorm.DB,tableName(表名) string,compareField(比较字段) string , interval string 间隔
//@return: err
func ClearTable(db *gorm.DB, tableName string, compareField string, interval string) error {
if db == nil {
return errors.New("db Cannot be empty")
}
duration, err := time.ParseDuration(interval)
if err != nil {
return err
}
if duration < 0 {
return errors.New("parse duration < 0")
}
return db.Debug().Exec(fmt.Sprintf("DELETE FROM %s WHERE %s < ?", tableName, compareField), time.Now().Add(-duration)).Error
}
+5 -1
View File
@@ -18,7 +18,11 @@ func StructToMap(obj interface{}) map[string]interface{} {
var data = make(map[string]interface{})
for i := 0; i < obj1.NumField(); i++ {
data[obj1.Field(i).Name] = obj2.Field(i).Interface()
if obj1.Field(i).Tag.Get("mapstructure") != "" {
data[obj1.Field(i).Tag.Get("mapstructure")] = obj2.Field(i).Interface()
} else {
data[obj1.Field(i).Name] = obj2.Field(i).Interface()
}
}
return data
}
+18
View File
@@ -0,0 +1,18 @@
package utils
import (
"errors"
"os"
"os/exec"
"runtime"
"strconv"
)
func Reload() error {
if runtime.GOOS == "windows" {
return errors.New("系统不支持")
}
pid := os.Getpid()
cmd := exec.Command("kill", "-1", strconv.Itoa(pid))
return cmd.Run()
}
+109
View File
@@ -0,0 +1,109 @@
package timer
import (
"sync"
"github.com/robfig/cron/v3"
)
type Timer interface {
AddTaskByFunc(taskName string, spec string, task func()) (cron.EntryID, error)
AddTaskByJob(taskName string, spec string, job interface{ Run() }) (cron.EntryID, error)
FindCron(taskName string) (*cron.Cron, bool)
StartTask(taskName string)
StopTask(taskName string)
Remove(taskName string, id int)
Clear(taskName string)
Close()
}
// timer 定时任务管理
type timer struct {
taskList map[string]*cron.Cron
sync.Mutex
}
// AddTaskByFunc 通过函数的方法添加任务
func (t *timer) AddTaskByFunc(taskName string, spec string, task func()) (cron.EntryID, error) {
t.Lock()
defer t.Unlock()
if _, ok := t.taskList[taskName]; !ok {
t.taskList[taskName] = cron.New()
}
id, err := t.taskList[taskName].AddFunc(spec, task)
t.taskList[taskName].Start()
return id, err
}
// AddTaskByJob 通过接口的方法添加任务
func (t *timer) AddTaskByJob(taskName string, spec string, job interface{ Run() }) (cron.EntryID, error) {
t.Lock()
defer t.Unlock()
if _, ok := t.taskList[taskName]; !ok {
t.taskList[taskName] = cron.New()
}
id, err := t.taskList[taskName].AddJob(spec, job)
t.taskList[taskName].Start()
return id, err
}
// FindCron 获取对应taskName的cron 可能会为空
func (t *timer) FindCron(taskName string) (*cron.Cron, bool) {
t.Lock()
defer t.Unlock()
v, ok := t.taskList[taskName]
return v, ok
}
// StartTask 开始任务
func (t *timer) StartTask(taskName string) {
t.Lock()
defer t.Unlock()
if v, ok := t.taskList[taskName]; ok {
v.Start()
}
return
}
// StopTask 停止任务
func (t *timer) StopTask(taskName string) {
t.Lock()
defer t.Unlock()
if v, ok := t.taskList[taskName]; ok {
v.Stop()
}
return
}
// Remove 从taskName 删除指定任务
func (t *timer) Remove(taskName string, id int) {
t.Lock()
defer t.Unlock()
if v, ok := t.taskList[taskName]; ok {
v.Remove(cron.EntryID(id))
}
return
}
// Clear 清除任务
func (t *timer) Clear(taskName string) {
t.Lock()
defer t.Unlock()
if v, ok := t.taskList[taskName]; ok {
v.Stop()
delete(t.taskList, taskName)
}
}
// Close 释放资源
func (t *timer) Close() {
t.Lock()
defer t.Unlock()
for _, v := range t.taskList {
v.Stop()
}
}
func NewTimerTask() Timer {
return &timer{taskList: make(map[string]*cron.Cron)}
}
+5 -1
View File
@@ -1,2 +1,6 @@
ENV = 'development'
VUE_APP_BASE_API = '/api'
VUE_APP_CLI_PORT = '8080'
VUE_APP_SERVER_PORT = '8888'
VUE_APP_BASE_API = '/api'
VUE_APP_BASE_PATH = 'http://127.0.0.1'
+6 -1
View File
@@ -1,2 +1,7 @@
ENV = 'production'
VUE_APP_BASE_API = '/api'
VUE_APP_CLI_PORT = '8080'
VUE_APP_SERVER_PORT = '8888'
VUE_APP_BASE_API = '/api'
#下方修改为你的线上ip
VUE_APP_BASE_PATH = 'http://8.141.61.63'
+16 -9
View File
@@ -1,6 +1,6 @@
<template>
<el-drawer title="媒体库" :visible.sync="drawer">
<div style="display:flex;justify-content:space-around;flex-wrap:wrap;padding-top:40px">
<div class="media">
<el-image
class="header-img-box-list"
:src="(item.url && item.url.slice(0, 4) !== 'http')?path+item.url:item.url"
@@ -49,13 +49,20 @@ export default {
</script>
<style lang="scss">
.header-img-box-list {
width: 180px;
height: 180px;
border: 1px dashed #ccc;
border-radius: 20px;
text-align: center;
line-height: 180px;
cursor: pointer;
.media{
display:flex;
flex-wrap:wrap;
.header-img-box-list {
margin-top: 20px;
width: 120px;
margin-left: 20px;
height: 120px;
border: 1px dashed #ccc;
border-radius: 20px;
text-align: center;
line-height: 180px;
cursor: pointer;
}
}
</style>
+2 -2
View File
@@ -33,7 +33,7 @@ export default {
},
data(){
return{
path: path,
path: path + '/',
}
},
computed:{
@@ -72,4 +72,4 @@ export default {
height: 80px;
position: relative;
}
</style>
</style>
+3 -2
View File
@@ -146,11 +146,12 @@ export default new Vue({
store
}).$mount('#app')
console.log(`
欢迎使用 Gin-Vue-Admin
当前版本:V2.4.1
加群方式:微信:shouzi_1994 QQ群:622360840
默认自动化文档地址:http://127.0.0.1:` + buildConfig.goServerPort + `/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:`+ buildConfig.vueClientPort + `
默认自动化文档地址:http://127.0.0.1:${process.env.VUE_APP_SERVER_PORT}/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:${process.env.VUE_APP_CLI_PORT}
如果项目让您获得了收益,希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/docs/coffee
`)
+10 -6
View File
@@ -4,11 +4,11 @@ import getPageTitle from '@/utils/page'
let asyncRouterFlag = 0
const whiteList = ['login','init']
router.beforeEach(async(to, from, next) => {
const whiteList = ['login', 'init']
router.beforeEach(async (to, from, next) => {
const token = store.getters['user/token']
// 在白名单中的判断情况
//修改网页标签名称
// 在白名单中的判断情况
//修改网页标签名称
document.title = getPageTitle(to.meta.title)
if (whiteList.indexOf(to.name) > -1) {
if (token) {
@@ -25,9 +25,13 @@ router.beforeEach(async(to, from, next) => {
await store.dispatch('router/SetAsyncRouter')
const asyncRouters = store.getters['router/asyncRouters']
router.addRoutes(asyncRouters)
next({...to, replace: true })
next({ ...to, replace: true })
} else {
next()
if (to.matched.length) {
next()
} else {
next({ path: "/layout/404" })
}
}
}
// 不在白名单中并且未登陆的时候
+1 -1
View File
@@ -125,7 +125,7 @@ export default {
type: "success",
message: ""
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
+1 -1
View File
@@ -116,7 +116,7 @@ export default {
type: "success",
message: "删除成功!"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
+2 -3
View File
@@ -7,7 +7,6 @@
</div>
<div class="header">
<a href="/">
<!-- <img src="~@/assets/logo.png" class="logo" alt="logo" /> -->
<span class="title">Gin-Vue-Admin</span>
</a>
</div>
@@ -91,14 +90,14 @@ export default {
name: "Login",
data() {
const checkUsername = (rule, value, callback) => {
if (value.length < 5 || value.length > 12) {
if (value.length < 5) {
return callback(new Error("请输入正确的用户名"));
} else {
callback();
}
};
const checkPassword = (rule, value, callback) => {
if (value.length < 6 || value.length > 12) {
if (value.length < 6) {
return callback(new Error("请输入正确的密码"));
} else {
callback();
+4 -4
View File
@@ -199,7 +199,7 @@ export default {
type:"success",
message:res.msg
})
if (this.tableData.length == ids.length) {
if (this.tableData.length == ids.length && this.page > 1) {
this.page--;
}
this.deleteVisible = false
@@ -236,10 +236,10 @@ export default {
openDialog(type) {
switch (type) {
case "addApi":
this.dialogTitlethis = "新增Api";
this.dialogTitle = "新增Api";
break;
case "edit":
this.dialogTitlethis = "编辑Api";
this.dialogTitle = "编辑Api";
break;
default:
break;
@@ -265,7 +265,7 @@ export default {
type: "success",
message: "删除成功!"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
@@ -191,7 +191,7 @@ export default {
type: "success",
message: "删除成功!"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
@@ -220,7 +220,7 @@ export default {
type: "success",
message: "删除成功"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
@@ -209,7 +209,7 @@ export default {
type: "success",
message: "删除成功"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
+1 -1
View File
@@ -324,7 +324,7 @@ export default {
type: "success",
message: "删除成功!"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
@@ -177,7 +177,7 @@ export default {
type: "success",
message: "删除成功"
});
if (this.tableData.length == ids.length) {
if (this.tableData.length == ids.length && this.page > 1) {
this.page--;
}
this.deleteVisible = false;
@@ -192,7 +192,7 @@ export default {
type: "success",
message: "删除成功"
});
if (this.tableData.length == 1) {
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
}
this.getTableData();
+1 -1
View File
@@ -121,7 +121,7 @@ export default {
rules: {
username: [
{ required: true, message: "请输入用户名", trigger: "blur" },
{ min: 6, message: "最低6位字符", trigger: "blur" }
{ min: 5, message: "最低5位字符", trigger: "blur" }
],
password: [
{ required: true, message: "请输入用户密码", trigger: "blur" },
@@ -1,17 +1,15 @@
<template>
<div style="height:80vh">
<iframe width="100%" height="100%" :src="url" frameborder="0"></iframe>
<iframe width="100%" height="100%" :src="basePath+':8888/form-generator/#/'" frameborder="0"></iframe>
</div>
</template>
<script>
import buildConf from '@/../build.config.js'
var path = process.env.VUE_APP_BASE_API
var path = process.env.VUE_APP_BASE_PATH
export default {
name:"FormGenerator",
data(){
return{
url:'http://127.0.0.1:' + buildConf.goServerPort + '/form-generator/#/',
basePath:path
}
},
+1 -1
View File
@@ -247,7 +247,7 @@
<el-input v-model="config.qiniu.imgPath"></el-input>
</el-form-item>
<el-form-item label="是否使用https">
<el-checkbox v-model="config.qiniu.imgPath">开启</el-checkbox>
<el-checkbox v-model="config.qiniu.useHttps">开启</el-checkbox>
</el-form-item>
<el-form-item label="accessKey">
<el-input v-model="config.qiniu.accessKey"></el-input>
+2 -2
View File
@@ -15,7 +15,7 @@ module.exports = {
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
devServer: {
port: buildConf.vueClientPort,
port: process.env.VUE_APP_CLI_PORT,
open: true,
overlay: {
warnings: false,
@@ -25,7 +25,7 @@ module.exports = {
// 把key的路径代理到target位置
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { //需要代理的路径 例如 '/api'
target: `http://127.0.0.1:` + buildConf.goServerPort + `/`, //代理到 目标路径
target: `${process.env.VUE_APP_BASE_PATH}:${process.env.VUE_APP_SERVER_PORT}/`, //代理到 目标路径
changeOrigin: true,
pathRewrite: { // 修改路径数据
['^' + process.env.VUE_APP_BASE_API]: '' // 举例 '^/api:""' 把路径中的/api字符串删除