Skip to content

Commit c20ea7e

Browse files
pixelmaxQmsliboy3vilivetasktesun
authored
publish: 发布2.7.4版本Beta (#1880)
* 媒体库增加批量导入URL * fix 描述错误 * feature: 自动化代码方法支持增加方法描述 * update: 更新依赖,升级为最新版本 * feature: 自动化代码预览部分支持黑夜模式 * fixed: 修复keepalive上线后失效的bug * feature: 增加自动化基础模板功能 * feature: 增加自动化基础模板功能 * 将用户配置保存到数据库,刷新或者异地登录配置不丢失 * update: 清除无用的userinfo配置信息 * fixed: 清理开发阶段页面无端进入404的bug * feature: 前端主题配置跟随用户,不再单独设置json编译生效。 * feature: 增加个人中心配置兼容性 * fix(package): 包名设置为中文会导致无法自动生成代码,禁止包名设置为中文 * feature: 格式化代码 * feature: 对严格模式新建根角色进行调整。 * feature: 版本变更为2.7.4 --------- Co-authored-by: sliboy <[email protected]> Co-authored-by: ba0ch3ng <[email protected]> Co-authored-by: task <[email protected]> Co-authored-by: task <[email protected]> Co-authored-by: 爱丽-黑子 <[email protected]> Co-authored-by: sliboy <[email protected]>
1 parent df3fc0a commit c20ea7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+709
-403
lines changed

server/api/v1/example/exa_file_upload_download.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,26 @@ func (b *FileUploadAndDownloadApi) GetFileList(c *gin.Context) {
108108
PageSize: pageInfo.PageSize,
109109
}, "获取成功", c)
110110
}
111+
112+
// ImportURL
113+
// @Tags ExaFileUploadAndDownload
114+
// @Summary 导入URL
115+
// @Security ApiKeyAuth
116+
// @Produce application/json
117+
// @Param data body example.ExaFileUploadAndDownload true "对象"
118+
// @Success 200 {object} response.Response{msg=string} "导入URL"
119+
// @Router /fileUploadAndDownload/importURL [post]
120+
func (b *FileUploadAndDownloadApi) ImportURL(c *gin.Context) {
121+
var file []example.ExaFileUploadAndDownload
122+
err := c.ShouldBindJSON(&file)
123+
if err != nil {
124+
response.FailWithMessage(err.Error(), c)
125+
return
126+
}
127+
if err := fileUploadAndDownloadService.ImportURL(&file); err != nil {
128+
global.GVA_LOG.Error("导入URL失败!", zap.Error(err))
129+
response.FailWithMessage("导入URL失败", c)
130+
return
131+
}
132+
response.OkWithMessage("导入URL成功", c)
133+
}

server/api/v1/system/sys_authority.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func (a *AuthorityApi) CreateAuthority(c *gin.Context) {
3636
return
3737
}
3838

39+
if *authority.ParentId == 0 && global.GVA_CONFIG.System.UseStrictAuth {
40+
authority.ParentId = utils.Pointer(utils.GetUserAuthorityId(c))
41+
}
42+
3943
if authBack, err = authorityService.CreateAuthority(authority); err != nil {
4044
global.GVA_LOG.Error("创建失败!", zap.Error(err))
4145
response.FailWithMessage("创建失败"+err.Error(), c)

server/api/v1/system/sys_user.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package system
22

33
import (
4+
"gorm.io/datatypes"
45
"strconv"
56
"time"
67

@@ -368,7 +369,6 @@ func (b *BaseApi) SetUserInfo(c *gin.Context) {
368369
HeaderImg: user.HeaderImg,
369370
Phone: user.Phone,
370371
Email: user.Email,
371-
SideMode: user.SideMode,
372372
Enable: user.Enable,
373373
})
374374
if err != nil {
@@ -404,7 +404,6 @@ func (b *BaseApi) SetSelfInfo(c *gin.Context) {
404404
HeaderImg: user.HeaderImg,
405405
Phone: user.Phone,
406406
Email: user.Email,
407-
SideMode: user.SideMode,
408407
Enable: user.Enable,
409408
})
410409
if err != nil {
@@ -415,6 +414,32 @@ func (b *BaseApi) SetSelfInfo(c *gin.Context) {
415414
response.OkWithMessage("设置成功", c)
416415
}
417416

417+
// SetSelfSetting
418+
// @Tags SysUser
419+
// @Summary 设置用户配置
420+
// @Security ApiKeyAuth
421+
// @accept application/json
422+
// @Produce application/json
423+
// @Param data body datatypes.JSON
424+
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "设置用户配置"
425+
// @Router /user/SetSelfSetting [put]
426+
func (b *BaseApi) SetSelfSetting(c *gin.Context) {
427+
var req datatypes.JSON
428+
err := c.ShouldBindJSON(&req)
429+
if err != nil {
430+
response.FailWithMessage(err.Error(), c)
431+
return
432+
}
433+
434+
err = userService.SetSelfSetting(&req, utils.GetUserID(c))
435+
if err != nil {
436+
global.GVA_LOG.Error("设置失败!", zap.Error(err))
437+
response.FailWithMessage("设置失败", c)
438+
return
439+
}
440+
response.OkWithMessage("设置成功", c)
441+
}
442+
418443
// GetUserInfo
419444
// @Tags SysUser
420445
// @Summary 获取用户信息

server/config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ redis:
3131
- "172.21.0.4:7001"
3232
- "172.21.0.2:7002"
3333

34+
# redis-list configuration
35+
redis-list:
36+
- name: cache # 数据库的名称,注意: name 需要在 redis-list 中唯一
37+
useCluster: false # 是否使用redis集群模式
38+
addr: 127.0.0.1:6379 # 使用集群模式addr和db默认无效
39+
password: ""
40+
db: 0
41+
clusterAddrs:
42+
- "172.21.0.3:7000"
43+
- "172.21.0.4:7001"
44+
- "172.21.0.2:7002"
3445

3546
# mongo configuration
3647
mongo:

server/config/config.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package config
22

33
type Server struct {
4-
JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
5-
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
6-
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
7-
Mongo Mongo `mapstructure:"mongo" json:"mongo" yaml:"mongo"`
8-
Email Email `mapstructure:"email" json:"email" yaml:"email"`
9-
System System `mapstructure:"system" json:"system" yaml:"system"`
10-
Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
4+
JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
5+
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
6+
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
7+
RedisList []Redis `mapstructure:"redis-list" json:"redis-list" yaml:"redis-list"`
8+
Mongo Mongo `mapstructure:"mongo" json:"mongo" yaml:"mongo"`
9+
Email Email `mapstructure:"email" json:"email" yaml:"email"`
10+
System System `mapstructure:"system" json:"system" yaml:"system"`
11+
Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
1112
// auto
1213
AutoCode Autocode `mapstructure:"autocode" json:"autocode" yaml:"autocode"`
1314
// gorm

server/config/redis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package config
22

33
type Redis struct {
4+
Name string `mapstructure:"name" json:"name" yaml:"name"` // 代表当前实例的名字
45
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口
56
Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码
67
DB int `mapstructure:"db" json:"db" yaml:"db"` // 单实例模式下redis的哪个数据库

server/core/server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ func RunWindowsServer() {
1717
// 初始化redis服务
1818
initialize.Redis()
1919
}
20+
21+
initialize.RedisList()
22+
2023
if global.GVA_CONFIG.System.UseMongo {
2124
err := initialize.Mongo.Initialization()
2225
if err != nil {
@@ -38,7 +41,7 @@ func RunWindowsServer() {
3841

3942
fmt.Printf(`
4043
欢迎使用 gin-vue-admin
41-
当前版本:v2.7.3
44+
当前版本:v2.7.4
4245
加群方式:微信号:shouzi_1994 QQ群:470239250
4346
项目地址:https://github.com/flipped-aurora/gin-vue-admin
4447
插件市场:https://plugin.gin-vue-admin.com

server/docs/docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8087,7 +8087,7 @@ const docTemplate = `{
80878087

80888088
// SwaggerInfo holds exported Swagger Info so clients can modify it
80898089
var SwaggerInfo = &swag.Spec{
8090-
Version: "v2.7.3",
8090+
Version: "v2.7.4",
80918091
Host: "",
80928092
BasePath: "",
80938093
Schemes: []string{},

server/docs/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "使用gin+vue进行极速开发的全栈开发基础平台",
55
"title": "Gin-Vue-Admin Swagger API接口文档",
66
"contact": {},
7-
"version": "v2.7.3"
7+
"version": "v2.7.4"
88
},
99
"paths": {
1010
"/api/createApi": {

server/docs/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ info:
16341634
contact: {}
16351635
description: 使用gin+vue进行极速开发的全栈开发基础平台
16361636
title: Gin-Vue-Admin Swagger API接口文档
1637-
version: v2.7.3
1637+
version: v2.7.4
16381638
paths:
16391639
/api/createApi:
16401640
post:

server/global/global.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package global
22

33
import (
4+
"fmt"
5+
"sync"
6+
47
"github.com/gin-gonic/gin"
58
"github.com/qiniu/qmgo"
6-
"sync"
79

810
"github.com/flipped-aurora/gin-vue-admin/server/utils/timer"
911
"github.com/songzhibin97/gkit/cache/local_cache"
@@ -20,12 +22,13 @@ import (
2022
)
2123

2224
var (
23-
GVA_DB *gorm.DB
24-
GVA_DBList map[string]*gorm.DB
25-
GVA_REDIS redis.UniversalClient
26-
GVA_MONGO *qmgo.QmgoClient
27-
GVA_CONFIG config.Server
28-
GVA_VP *viper.Viper
25+
GVA_DB *gorm.DB
26+
GVA_DBList map[string]*gorm.DB
27+
GVA_REDIS redis.UniversalClient
28+
GVA_REDISList map[string]redis.UniversalClient
29+
GVA_MONGO *qmgo.QmgoClient
30+
GVA_CONFIG config.Server
31+
GVA_VP *viper.Viper
2932
// GVA_LOG *oplogging.Logger
3033
GVA_LOG *zap.Logger
3134
GVA_Timer timer.Timer = timer.NewTimerTask()
@@ -53,3 +56,11 @@ func MustGetGlobalDBByDBName(dbname string) *gorm.DB {
5356
}
5457
return db
5558
}
59+
60+
func GetRedis(name string) redis.UniversalClient {
61+
redis, ok := GVA_REDISList[name]
62+
if !ok || redis == nil {
63+
panic(fmt.Sprintf("redis `%s` no init", name))
64+
}
65+
return redis
66+
}

server/initialize/redis.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package initialize
33
import (
44
"context"
55

6+
"github.com/flipped-aurora/gin-vue-admin/server/config"
67
"github.com/flipped-aurora/gin-vue-admin/server/global"
78

89
"github.com/redis/go-redis/v9"
910
"go.uber.org/zap"
1011
)
1112

12-
func Redis() {
13-
redisCfg := global.GVA_CONFIG.Redis
13+
func initRedisClient(redisCfg config.Redis) (redis.UniversalClient, error) {
1414
var client redis.UniversalClient
1515
// 使用集群模式
1616
if redisCfg.UseCluster {
@@ -28,10 +28,32 @@ func Redis() {
2828
}
2929
pong, err := client.Ping(context.Background()).Result()
3030
if err != nil {
31-
global.GVA_LOG.Error("redis connect ping failed, err:", zap.Error(err))
31+
global.GVA_LOG.Error("redis connect ping failed, err:", zap.String("name", redisCfg.Name), zap.Error(err))
32+
return nil, err
33+
}
34+
35+
global.GVA_LOG.Info("redis connect ping response:", zap.String("name", redisCfg.Name), zap.String("pong", pong))
36+
return client, nil
37+
}
38+
39+
func Redis() {
40+
redisClient, err := initRedisClient(global.GVA_CONFIG.Redis)
41+
if err != nil {
3242
panic(err)
33-
} else {
34-
global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong))
35-
global.GVA_REDIS = client
3643
}
44+
global.GVA_REDIS = redisClient
45+
}
46+
47+
func RedisList() {
48+
redisMap := make(map[string]redis.UniversalClient)
49+
50+
for _, redisCfg := range global.GVA_CONFIG.RedisList {
51+
client, err := initRedisClient(redisCfg)
52+
if err != nil {
53+
panic(err)
54+
}
55+
redisMap[redisCfg.Name] = client
56+
}
57+
58+
global.GVA_REDISList = redisMap
3759
}

server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
//go:generate go mod download
1616

1717
// @title Gin-Vue-Admin Swagger API接口文档
18-
// @version v2.7.3
18+
// @version v2.7.4
1919
// @description 使用gin+vue进行极速开发的全栈开发基础平台
2020
// @securityDefinitions.apikey ApiKeyAuth
2121
// @in header

server/model/system/request/sys_auto_code.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type AutoCode struct {
2525
AutoCreateApiToSql bool `json:"autoCreateApiToSql" example:"false"` // 是否自动创建api
2626
AutoCreateMenuToSql bool `json:"autoCreateMenuToSql" example:"false"` // 是否自动创建menu
2727
AutoCreateBtnAuth bool `json:"autoCreateBtnAuth" example:"false"` // 是否自动创建按钮权限
28+
OnlyTemplate bool `json:"onlyTemplate" example:"false"` // 是否只生成模板
2829
Fields []*AutoCodeField `json:"fields"`
2930
DictTypes []string `json:"-"`
3031
PrimaryField *AutoCodeField `json:"primaryField"`
@@ -236,6 +237,7 @@ type AutoFunc struct {
236237
Package string `json:"package"`
237238
FuncName string `json:"funcName"` // 方法名称
238239
Router string `json:"router"` // 路由名称
240+
FuncDesc string `json:"funcDesc"` // 方法介绍
239241
BusinessDB string `json:"businessDB"` // 业务库
240242
StructName string `json:"structName"` // Struct名称
241243
PackageName string `json:"packageName"` // 文件名称

server/model/system/sys_user.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package system
33
import (
44
"github.com/flipped-aurora/gin-vue-admin/server/global"
55
"github.com/gofrs/uuid/v5"
6+
"gorm.io/datatypes"
67
)
78

89
type Login interface {
@@ -18,19 +19,18 @@ var _ Login = new(SysUser)
1819

1920
type SysUser struct {
2021
global.GVA_MODEL
21-
UUID uuid.UUID `json:"uuid" gorm:"index;comment:用户UUID"` // 用户UUID
22-
Username string `json:"userName" gorm:"index;comment:用户登录名"` // 用户登录名
23-
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
24-
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
25-
SideMode string `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"` // 用户侧边主题
26-
HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
27-
BaseColor string `json:"baseColor" gorm:"default:#fff;comment:基础颜色"` // 基础颜色
28-
AuthorityId uint `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
29-
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
30-
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"`
31-
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
32-
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
33-
Enable int `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
22+
UUID uuid.UUID `json:"uuid" gorm:"index;comment:用户UUID"` // 用户UUID
23+
Username string `json:"userName" gorm:"index;comment:用户登录名"` // 用户登录名
24+
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
25+
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
26+
HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
27+
AuthorityId uint `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
28+
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` // 用户角色
29+
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` // 多用户角色
30+
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
31+
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
32+
Enable int `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
33+
OriginSetting datatypes.JSON `json:"originSetting" form:"originSetting" gorm:"default:null;column:origin_setting;comment:配置;"` //配置
3434
}
3535

3636
func (SysUser) TableName() string {

server/resource/function/api.go.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{if .IsPlugin}}
2-
// {{.FuncName}} 等待开发的的{{.Description}}接口
2+
// {{.FuncName}} {{.FuncDesc}}
33
// @Tags {{.StructName}}
4-
// @Summary 等待开发的的{{.Description}}接口
4+
// @Summary {{.FuncDesc}}
55
// @accept application/json
66
// @Produce application/json
77
// @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表"
@@ -20,9 +20,9 @@ func (a *{{.Abbreviation}}) {{.FuncName}}(c *gin.Context) {
2020

2121
{{- else -}}
2222

23-
// {{.FuncName}} 等待开发的的{{.Description}}接口
23+
// {{.FuncName}} {{.FuncDesc}}
2424
// @Tags {{.StructName}}
25-
// @Summary 等待开发的的{{.Description}}接口
25+
// @Summary {{.FuncDesc}}
2626
// @accept application/json
2727
// @Produce application/json
2828
// @Param data query {{.Package}}Req.{{.StructName}}Search true "成功"

server/resource/function/api.js.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{if .IsPlugin}}
2-
// {{.FuncName}} 等待开发的的{{.Description}}接口
2+
// {{.FuncName}} {{.FuncDesc}}
33
// @Tags {{.StructName}}
4-
// @Summary 等待开发的的{{.Description}}接口
4+
// @Summary {{.FuncDesc}}
55
// @accept application/json
66
// @Produce application/json
77
// @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表"
@@ -16,9 +16,9 @@ export const {{.Router}} = () => {
1616

1717
{{- else -}}
1818

19-
// {{.FuncName}} 等待开发的的{{.Description}}接口
19+
// {{.FuncName}} {{.FuncDesc}}
2020
// @Tags {{.StructName}}
21-
// @Summary 等待开发的的{{.Description}}接口
21+
// @Summary {{.FuncDesc}}
2222
// @accept application/json
2323
// @Produce application/json
2424
// @Param data query {{.Package}}Req.{{.StructName}}Search true "成功"

0 commit comments

Comments
 (0)