Merge remote-tracking branch 'origin/master'
This commit is contained in:
+13
-20
@@ -84,33 +84,26 @@ captcha:
|
||||
img-width: 240
|
||||
img-height: 80
|
||||
|
||||
# logger configuration
|
||||
log:
|
||||
prefix: '[GIN-VUE-ADMIN]'
|
||||
log-file: true
|
||||
stdout: 'DEBUG'
|
||||
file: 'DEBUG'
|
||||
|
||||
# zap logger configuration
|
||||
zap:
|
||||
# 可使用 "debug", "info", "warn", "error", "dpanic", "panic", "fatal",
|
||||
level: 'debug'
|
||||
level: 'info'
|
||||
# console: 控制台, json: json格式输出
|
||||
format: 'console'
|
||||
prefix: '[GIN-VUE-ADMIN]'
|
||||
director: 'log'
|
||||
link_name: 'latest_log'
|
||||
show_line: true
|
||||
link-name: 'latest_log'
|
||||
show-line: true
|
||||
# LowercaseLevelEncoder:小写, LowercaseColorLevelEncoder:小写带颜色,CapitalLevelEncoder: 大写, CapitalColorLevelEncoder: 大写带颜色,
|
||||
encode_level: 'LowercaseColorLevelEncoder'
|
||||
stacktrace_key: 'stacktrace'
|
||||
log_in_console: true
|
||||
encode-level: 'LowercaseColorLevelEncoder'
|
||||
stacktrace-key: 'stacktrace'
|
||||
log-in-console: true
|
||||
|
||||
email:
|
||||
email_from: 'xxx@163.com'
|
||||
email_nick_name: 'test'
|
||||
email_secret: 'xxx'
|
||||
email_to: 'xxx@qq.com'
|
||||
email_host: 'smtp.163.com'
|
||||
email_port: 465
|
||||
email_isSSL: true
|
||||
email-from: 'xxx@163.com'
|
||||
email-nickname: 'test'
|
||||
email-secret: 'xxx'
|
||||
email-to: 'xxx@qq.com'
|
||||
email-host: 'smtp.163.com'
|
||||
email-port: 465
|
||||
email-isSSL: true
|
||||
+14
-14
@@ -79,8 +79,8 @@ type Redis struct {
|
||||
}
|
||||
|
||||
type LocalUpload struct {
|
||||
Local bool `mapstructure:"local" json:"local" yaml:"local"`
|
||||
FilePath string `mapstructure:"file-path" json:"filePath" yaml:"file-path"`
|
||||
Local bool `mapstructure:"local" json:"local" yaml:"local"`
|
||||
FilePath string `mapstructure:"file-path" json:"filePath" yaml:"file-path"`
|
||||
}
|
||||
|
||||
type Qiniu struct {
|
||||
@@ -101,19 +101,19 @@ type Zap struct {
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type Email struct {
|
||||
EmailFrom string `mapstructure:"email_from" json:"emailFrom" yaml:"email_from"`
|
||||
EmailNickName string `mapstructure:"email_nick_name" json:"emailNickName" yaml:"email_nick_name"`
|
||||
EmailSecret string `mapstructure:"email_secret" json:"emailSecret" yaml:"email_secret"`
|
||||
EmailTo string `mapstructure:"email_to" json:"emailTo" yaml:"email_to"`
|
||||
EmailHost string `mapstructure:"email_host" json:"emailHost" yaml:"email_host"`
|
||||
EmailPort int `mapstructure:"email_port" json:"emailPort" yaml:"email_port"`
|
||||
EmailIsSSL bool `mapstructure:"email_isSSL" json:"emailIsSSL" yaml:"email_isSSL"`
|
||||
EmailFrom string `mapstructure:"email-from" json:"emailFrom" yaml:"email-from"`
|
||||
EmailNickname string `mapstructure:"email-nickname" json:"emailNickname" yaml:"email-nickname"`
|
||||
EmailSecret string `mapstructure:"email-secret" json:"emailSecret" yaml:"email-secret"`
|
||||
EmailTo string `mapstructure:"email-to" json:"emailTo" yaml:"email-to"`
|
||||
EmailHost string `mapstructure:"email-host" json:"emailHost" yaml:"email-host"`
|
||||
EmailPort int `mapstructure:"email-port" json:"emailPort" yaml:"email-port"`
|
||||
EmailIsSSL bool `mapstructure:"email-is-ssl" json:"emailIsSSL" yaml:"email-is-ssl"`
|
||||
}
|
||||
|
||||
+15
-1
@@ -6,13 +6,27 @@ import (
|
||||
_ "gin-vue-admin/packfile"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
const defaultConfigFile = "config.yaml"
|
||||
|
||||
func init() {
|
||||
pflag.StringP("configFile","c", "", "choose config file.")
|
||||
pflag.Parse()
|
||||
|
||||
// 优先级: 命令行 > 环境变量 > 默认值
|
||||
v := viper.New()
|
||||
v.SetConfigFile(defaultConfigFile)
|
||||
v.BindPFlags(pflag.CommandLine)
|
||||
v.SetEnvPrefix("gva")
|
||||
v.BindEnv("configFile") // GVA_CONFIGFILE
|
||||
|
||||
configFile := v.GetString("configFile")
|
||||
if configFile == ""{
|
||||
configFile = defaultConfigFile
|
||||
}
|
||||
|
||||
v.SetConfigFile(configFile)
|
||||
err := v.ReadInConfig()
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Fatal error config file: %s \n", err))
|
||||
|
||||
@@ -25,7 +25,7 @@ func RunWindowsServer() {
|
||||
// 保证文本顺序输出
|
||||
// In order to ensure that the text order output can be deleted
|
||||
time.Sleep(10 * time.Microsecond)
|
||||
global.GVA_LOG.Debug("server run success on ", zap.String("address", address))
|
||||
global.GVA_LOG.Info("server run success on ", zap.String("address", address))
|
||||
|
||||
fmt.Printf(`欢迎使用 Gin-Vue-Admin
|
||||
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
|
||||
|
||||
+5
-15
@@ -82,30 +82,20 @@ func getEncoderConfig() (config zapcore.EncoderConfig) {
|
||||
CallerKey: "caller",
|
||||
StacktraceKey: global.GVA_CONFIG.Zap.StacktraceKey,
|
||||
LineEnding: zapcore.DefaultLineEnding,
|
||||
EncodeLevel: zapcore.CapitalLevelEncoder,
|
||||
EncodeLevel: zapcore.LowercaseLevelEncoder,
|
||||
EncodeTime: CustomTimeEncoder,
|
||||
EncodeDuration: zapcore.SecondsDurationEncoder,
|
||||
EncodeCaller: zapcore.FullCallerEncoder,
|
||||
}
|
||||
switch {
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseLevelEncoder" && global.GVA_CONFIG.Zap.Format == "console" : // console小写编码器
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseLevelEncoder": // 小写编码器(默认)
|
||||
config.EncodeLevel = zapcore.LowercaseLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseLevelEncoder" && global.GVA_CONFIG.Zap.Format == "json" : // json小写编码器
|
||||
config.EncodeLevel = zapcore.LowercaseLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseColorLevelEncoder" && global.GVA_CONFIG.Zap.Format == "console": // console小写编码器带颜色
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseColorLevelEncoder": // 小写编码器带颜色
|
||||
config.EncodeLevel = zapcore.LowercaseColorLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseColorLevelEncoder" && global.GVA_CONFIG.Zap.Format == "json": // json小写编码器带颜色
|
||||
config.EncodeLevel = zapcore.LowercaseColorLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalLevelEncoder" && global.GVA_CONFIG.Zap.Format == "console": // console大写编码器
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalLevelEncoder": // 大写编码器
|
||||
config.EncodeLevel = zapcore.CapitalLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalLevelEncoder" && global.GVA_CONFIG.Zap.Format == "json": // json大写编码器
|
||||
config.EncodeLevel = zapcore.CapitalLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalColorLevelEncoder" && global.GVA_CONFIG.Zap.Format == "console": // console 大写编码器带颜色
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalColorLevelEncoder": // 大写编码器带颜色
|
||||
config.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
case global.GVA_CONFIG.Zap.EncodeLevel == "CapitalColorLevelEncoder" && global.GVA_CONFIG.Zap.Format == "json": // json 大写编码器带颜色
|
||||
config.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
default:
|
||||
config.EncodeLevel = zapcore.LowercaseLevelEncoder
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ require (
|
||||
github.com/spf13/afero v1.2.2 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.6.2
|
||||
github.com/swaggo/gin-swagger v1.2.0
|
||||
github.com/swaggo/swag v1.6.7
|
||||
|
||||
@@ -481,5 +481,5 @@ func InitData() {
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("initialize data failed", zap.Any("err", err))
|
||||
}
|
||||
global.GVA_LOG.Debug("initialize data success")
|
||||
global.GVA_LOG.Info("initialize data success")
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func GormDBTables(db *gorm.DB) {
|
||||
global.GVA_LOG.Error("register table failed", zap.Any("err", err))
|
||||
os.Exit(0)
|
||||
}
|
||||
global.GVA_LOG.Debug("register table success")
|
||||
global.GVA_LOG.Info("register table success")
|
||||
}
|
||||
|
||||
// GormMysql 初始化Mysql数据库
|
||||
|
||||
@@ -18,12 +18,12 @@ func Routers() *gin.Engine {
|
||||
// 为用户头像和文件提供静态地址
|
||||
Router.StaticFS(global.GVA_CONFIG.LocalUpload.FilePath, http.Dir(global.GVA_CONFIG.LocalUpload.FilePath))
|
||||
// Router.Use(middleware.LoadTls()) // 打开就能玩https了
|
||||
global.GVA_LOG.Debug("use middleware logger")
|
||||
global.GVA_LOG.Info("use middleware logger")
|
||||
// 跨域
|
||||
Router.Use(middleware.Cors())
|
||||
global.GVA_LOG.Debug("use middleware cors")
|
||||
global.GVA_LOG.Info("use middleware cors")
|
||||
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
global.GVA_LOG.Debug("register swagger handler")
|
||||
global.GVA_LOG.Info("register swagger handler")
|
||||
// 方便统一添加路由组前缀 多服务器上线使用
|
||||
ApiGroup := Router.Group("")
|
||||
router.InitUserRouter(ApiGroup) // 注册用户路由
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
func Cors() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
method := c.Request.Method
|
||||
c.Header("Access-Control-Allow-Origin", "*")
|
||||
origin := c.Request.Header.Get("Origin")
|
||||
c.Header("Access-Control-Allow-Origin", origin)
|
||||
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id\"")
|
||||
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT")
|
||||
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
type ExaCustomer struct {
|
||||
gorm.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"`
|
||||
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:管理角色ID"`
|
||||
SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:管理详情"`
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
type ExaFileUploadAndDownload struct {
|
||||
gorm.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:编号"`
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package model
|
||||
|
||||
type ExaSimpleUploader struct {
|
||||
ChunkNumber string `json:"chunkNumber" gorm:"comment:'当前切片标记'"`
|
||||
CurrentChunkSize string `json:"currentChunkSize" gorm:"comment:'当前切片容量'"`
|
||||
CurrentChunkPath string `json:"currentChunkPath" gorm:"comment:'切片本地路径'"`
|
||||
TotalSize string `json:"totalSize" gorm:"comment:'总容量'"`
|
||||
Identifier string `json:"identifier" gorm:"comment:'文件标识(md5)'"`
|
||||
Filename string `json:"filename" gorm:"comment:'文件名'"`
|
||||
TotalChunks string `json:"totalChunks" gorm:"comment:'切片总数'"`
|
||||
IsDone bool `json:"isDone" gorm:"comment:'是否上传完成'"`
|
||||
FilePath string `json:"filePath" gorm:"comment:'文件本地路径'"`
|
||||
ChunkNumber string `json:"chunkNumber" gorm:"comment:当前切片标记"`
|
||||
CurrentChunkSize string `json:"currentChunkSize" gorm:"comment:当前切片容量"`
|
||||
CurrentChunkPath string `json:"currentChunkPath" gorm:"comment:切片本地路径"`
|
||||
TotalSize string `json:"totalSize" gorm:"comment:总容量"`
|
||||
Identifier string `json:"identifier" gorm:"comment:文件标识(md5)"`
|
||||
Filename string `json:"filename" gorm:"comment:文件名"`
|
||||
TotalChunks string `json:"totalChunks" gorm:"comment:切片总数"`
|
||||
IsDone bool `json:"isDone" gorm:"comment:是否上传完成"`
|
||||
FilePath string `json:"filePath" gorm:"comment:文件本地路径"`
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
type SysApi struct {
|
||||
gorm.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路径"`
|
||||
Description string `json:"description" gorm:"comment:api中文描述"`
|
||||
ApiGroup string `json:"apiGroup" gorm:"comment:api组"`
|
||||
Method string `json:"method" gorm:"default:POST" gorm:"comment:方法"`
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ type SysAuthority struct {
|
||||
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"`
|
||||
AuthorityName string `json:"authorityName" gorm:"comment:角色名"`
|
||||
ParentId string `json:"parentId" gorm:"comment:父角色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;"`
|
||||
|
||||
@@ -2,8 +2,8 @@ package model
|
||||
|
||||
type SysMenu struct {
|
||||
SysBaseMenu
|
||||
MenuId string `json:"menuId" gorm:"comment:'菜单ID'"`
|
||||
AuthorityId string `json:"-" gorm:"comment:'角色ID'"`
|
||||
MenuId string `json:"menuId" gorm:"comment:菜单ID"`
|
||||
AuthorityId string `json:"-" gorm:"comment:角色ID"`
|
||||
Children []SysMenu `json:"children" gorm:"-"`
|
||||
Parameters []SysBaseMenuParameter `json:"parameters" gorm:"foreignKey:SysBaseMenuID;references:MenuId"`
|
||||
}
|
||||
|
||||
@@ -7,23 +7,23 @@ import (
|
||||
type SysBaseMenu struct {
|
||||
gorm.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:'附加属性'"`
|
||||
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:附加属性"`
|
||||
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:'菜单图标'"`
|
||||
KeepAlive bool `json:"keepAlive" gorm:"comment:是否缓存"`
|
||||
DefaultMenu bool `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"`
|
||||
Title string `json:"title" gorm:"comment:菜单名"`
|
||||
Icon string `json:"icon" gorm:"comment:菜单图标"`
|
||||
}
|
||||
|
||||
type SysBaseMenuParameter struct {
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type SysDictionary struct {
|
||||
gorm.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"`
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type SysDictionaryDetail struct {
|
||||
gorm.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:关联标记"`
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ import (
|
||||
|
||||
type JwtBlacklist struct {
|
||||
gorm.Model
|
||||
Jwt string `gorm:"type:text;comment:'jwt'"`
|
||||
Jwt string `gorm:"type:text;comment:jwt"`
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ import (
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type SysOperationRecord struct {
|
||||
gorm.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:"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:''"`
|
||||
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:"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"`
|
||||
User SysUser `json:"user"`
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
|
||||
type SysUser struct {
|
||||
gorm.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:'用户头像'"`
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:'用户角色'"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888;comment:'用户角色ID'"`
|
||||
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:用户头像"`
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"`
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@ import (
|
||||
// 工作流属性表
|
||||
type SysWorkflow struct {
|
||||
gorm.Model
|
||||
WorkflowNickName string `json:"workflowNickName" gorm:"comment:'工作流中文名称'"` // 工作流名称
|
||||
WorkflowName string `json:"workflowName" gorm:"comment:'工作流英文名称'"` // 工作流英文id
|
||||
WorkflowDescription string `json:"workflowDescription" gorm:"comment:'工作流描述'"` // 工作流描述
|
||||
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep" gorm:"comment:'工作流步骤'"` // 工作流步骤
|
||||
WorkflowNickName string `json:"workflowNickName" gorm:"comment:工作流中文名称"` // 工作流名称
|
||||
WorkflowName string `json:"workflowName" gorm:"comment:工作流英文名称"` // 工作流英文id
|
||||
WorkflowDescription string `json:"workflowDescription" gorm:"comment:工作流描述"` // 工作流描述
|
||||
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep" gorm:"comment:工作流步骤"` // 工作流步骤
|
||||
}
|
||||
|
||||
// 工作流状态表
|
||||
type SysWorkflowStepInfo struct {
|
||||
gorm.Model
|
||||
SysWorkflowID uint `json:"workflowID" gorm:"comment:'所属工作流ID'"` // 所属工作流ID
|
||||
IsStrat bool `json:"isStrat" gorm:"comment:'是否是开始流节点'"` // 是否是开始流节点
|
||||
StepName string `json:"stepName" gorm:"comment:'工作流节点名称'"` // 工作流名称
|
||||
StepNo float64 `json:"stepNo" gorm:"comment:'步骤id (第几步)'"` // 步骤id (第几步)
|
||||
StepAuthorityID string `json:"stepAuthorityID" gorm:"comment:'操作者级别id'"` // 操作者级别id
|
||||
IsEnd bool `json:"isEnd" gorm:"comment:'是否是完结流节点'"` // 是否是完结流节点
|
||||
SysWorkflowID uint `json:"workflowID" gorm:"comment:所属工作流ID"` // 所属工作流ID
|
||||
IsStart bool `json:"isStart" gorm:"comment:是否是开始流节点"` // 是否是开始流节点
|
||||
StepName string `json:"stepName" gorm:"comment:工作流节点名称"` // 工作流名称
|
||||
StepNo float64 `json:"stepNo" gorm:"comment:步骤id (第几步)"` // 步骤id (第几步)
|
||||
StepAuthorityID string `json:"stepAuthorityID" gorm:"comment:操作者级别id"` // 操作者级别id
|
||||
IsEnd bool `json:"isEnd" gorm:"comment:是否是完结流节点"` // 是否是完结流节点
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import "gorm.io/gorm"
|
||||
// 工作流流转表
|
||||
type SysWorkFlowProcess struct {
|
||||
gorm.Model
|
||||
ApplicationID uint `json:"applicationID" gorm:"comment:'当前工作流所属申请的ID'"` // 当前工作流所属申请的ID
|
||||
CurrentNode string `json:"currentNode" gorm:"comment:'当前进度节点'"` // 当前进度节点
|
||||
HistoricalNode string `json:"historicalNode" gorm:"comment:'上一个进度节点'"` // 上一个进度节点
|
||||
CurrentUser string `json:"currentUser" gorm:"comment:'当前进度操作人'"` // 当前进度操作人
|
||||
HistoricalUser string `json:"historicalUser" gorm:"comment:'上一个进度的操作人'"` // 上一个进度的操作人
|
||||
State bool `json:"state" gorm:"comment:'状态 是否是正在进行的状态'"` // 状态 是否是正在进行的状态
|
||||
ApplicationID uint `json:"applicationID" gorm:"comment:当前工作流所属申请的ID"` // 当前工作流所属申请的ID
|
||||
CurrentNode string `json:"currentNode" gorm:"comment:当前进度节点"` // 当前进度节点
|
||||
HistoricalNode string `json:"historicalNode" gorm:"comment:上一个进度节点"` // 上一个进度节点
|
||||
CurrentUser string `json:"currentUser" gorm:"comment:当前进度操作人"` // 当前进度操作人
|
||||
HistoricalUser string `json:"historicalUser" gorm:"comment:上一个进度的操作人"` // 上一个进度的操作人
|
||||
State bool `json:"state" gorm:"comment:是否是正在进行的状态"` // 状态 是否是正在进行的状态
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
type {{.StructName}} struct {
|
||||
gorm.Model {{- range .Fields}}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
|
||||
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
|
||||
{{- else }}
|
||||
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
|
||||
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
|
||||
{{- end }} {{- end }}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
|
||||
ClearCasbin(0, authorityId)
|
||||
rules := [][]string{}
|
||||
for _, v := range casbinInfos {
|
||||
cm := model.CasbinModel{
|
||||
Ptype: "p",
|
||||
@@ -28,26 +29,16 @@ func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
|
||||
Path: v.Path,
|
||||
Method: v.Method,
|
||||
}
|
||||
addflag := AddCasbin(cm)
|
||||
if addflag == false {
|
||||
return errors.New("存在相同api,添加失败,请联系管理员")
|
||||
}
|
||||
rules = append(rules, []string{cm.AuthorityId, cm.Path, cm.Method})
|
||||
}
|
||||
e := Casbin()
|
||||
success, _ := e.AddPolicies(rules)
|
||||
if success == false {
|
||||
return errors.New("存在相同api,添加失败,请联系管理员")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// @title AddCasbin
|
||||
// @description add casbin authority, 添加权限
|
||||
// @auth (2020/04/05 20:22)
|
||||
// @param cm model.CasbinModel
|
||||
// @return bool
|
||||
|
||||
func AddCasbin(cm model.CasbinModel) bool {
|
||||
e := Casbin()
|
||||
success, _ := e.AddPolicy(cm.AuthorityId, cm.Path, cm.Method)
|
||||
return success
|
||||
}
|
||||
|
||||
// @title UpdateCasbinApi
|
||||
// @description update casbin apis, API更新随动
|
||||
// @auth (2020/04/05 20:22)
|
||||
|
||||
@@ -23,7 +23,7 @@ func EmailTest(subject string, body string) error {
|
||||
|
||||
func send(to []string, subject string, body string) error {
|
||||
from := global.GVA_CONFIG.Email.EmailFrom
|
||||
nickName := global.GVA_CONFIG.Email.EmailNickName
|
||||
nickname := global.GVA_CONFIG.Email.EmailNickname
|
||||
secret := global.GVA_CONFIG.Email.EmailSecret
|
||||
host := global.GVA_CONFIG.Email.EmailHost
|
||||
port := global.GVA_CONFIG.Email.EmailPort
|
||||
@@ -31,8 +31,8 @@ func send(to []string, subject string, body string) error {
|
||||
|
||||
auth := smtp.PlainAuth("", from, secret, host)
|
||||
e := email.NewEmail()
|
||||
if nickName != "" {
|
||||
e.From = fmt.Sprintf("%s <%s>", nickName, from)
|
||||
if nickname != "" {
|
||||
e.From = fmt.Sprintf("%s <%s>", nickname, from)
|
||||
} else {
|
||||
e.From = from
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user