Skip to content

Commit 9c41ed8

Browse files
author
piexlmax
committed
Merge remote-tracking branch 'origin/main'
2 parents 4724cec + 4078dda commit 9c41ed8

File tree

49 files changed

+533
-274
lines changed

Some content is hidden

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

49 files changed

+533
-274
lines changed

server/api/v1/system/sys_user.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ func (b *BaseApi) SetUserInfo(c *gin.Context) {
275275
var user system.SysUser
276276
_ = c.ShouldBindJSON(&user)
277277
user.Username = ""
278+
user.Password = ""
279+
user.AuthorityId = ""
278280
if err := utils.Verify(user, utils.IdVerify); err != nil {
279281
response.FailWithMessage(err.Error(), c)
280282
return
@@ -299,6 +301,8 @@ func (b *BaseApi) SetSelfInfo(c *gin.Context) {
299301
var user system.SysUser
300302
_ = c.ShouldBindJSON(&user)
301303
user.Username = ""
304+
user.Password = ""
305+
user.AuthorityId = ""
302306
user.ID = utils.GetUserID(c)
303307
if err, ReqUser := userService.SetUserInfo(user); err != nil {
304308
global.GVA_LOG.Error("设置失败!", zap.Error(err))

server/config/gorm_mysql.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ type Mysql struct {
1616
func (m *Mysql) Dsn() string {
1717
return m.Username + ":" + m.Password + "@tcp(" + m.Path + ":" + m.Port + ")/" + m.Dbname + "?" + m.Config
1818
}
19+
20+
func (m *Mysql) GetLogMode() string {
21+
return m.LogMode
22+
}

server/config/gorm_pgsql.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ func (p *Pgsql) Dsn() string {
2424
func (p *Pgsql) LinkDsn(dbname string) string {
2525
return "host=" + p.Path + " user=" + p.Username + " password=" + p.Password + " dbname=" + dbname + " port=" + p.Port + " " + p.Config
2626
}
27+
28+
func (m *Pgsql) GetLogMode() string {
29+
return m.LogMode
30+
}

server/core/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func RunWindowsServer() {
3737

3838
fmt.Printf(`
3939
欢迎使用 github.com/flipped-aurora/gin-vue-admin/server
40-
当前版本:V2.5.0 beta
40+
当前版本:V2.5.0 beta.2
4141
加群方式:微信号:shouzi_1994 QQ群:622360840
4242
GVA讨论社区:https://support.qq.com/products/371961
4343
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html

server/go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/go-sql-driver/mysql v1.5.0
1919
github.com/gookit/color v1.3.1
2020
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible
21+
github.com/jackc/pgx/v4 v4.15.0 // indirect
2122
github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
2223
github.com/mojocn/base64Captcha v1.3.1
2324
github.com/natefinch/lumberjack v2.0.0+incompatible
@@ -36,10 +37,11 @@ require (
3637
github.com/unrolled/secure v1.0.7
3738
github.com/xuri/excelize/v2 v2.4.1
3839
go.uber.org/zap v1.16.0
40+
golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506 // indirect
3941
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
4042
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
4143
gorm.io/driver/mysql v1.0.1
42-
gorm.io/driver/postgres v0.2.6
43-
gorm.io/gorm v1.20.11
44+
gorm.io/driver/postgres v1.2.3
45+
gorm.io/gorm v1.22.5
4446
nhooyr.io/websocket v1.8.6
4547
)

server/go.sum

Lines changed: 58 additions & 3 deletions
Large diffs are not rendered by default.

server/initialize/internal/gorm.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
"gorm.io/gorm/logger"
1111
)
1212

13+
type DBBASE interface {
14+
GetLogMode() string
15+
}
16+
1317
var Gorm = new(_gorm)
1418

1519
type _gorm struct{}
@@ -23,7 +27,19 @@ func (g *_gorm) Config() *gorm.Config {
2327
LogLevel: logger.Warn,
2428
Colorful: true,
2529
})
26-
switch global.GVA_CONFIG.Mysql.LogMode {
30+
var logMode DBBASE
31+
switch global.GVA_CONFIG.System.DbType {
32+
case "mysql":
33+
logMode = &global.GVA_CONFIG.Mysql
34+
break
35+
case "pgsql":
36+
logMode = &global.GVA_CONFIG.Pgsql
37+
break
38+
default:
39+
logMode = &global.GVA_CONFIG.Mysql
40+
}
41+
42+
switch logMode.GetLogMode() {
2743
case "silent", "Silent":
2844
config.Logger = _default.LogMode(logger.Silent)
2945
case "error", "Error":

server/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/flipped-aurora/gin-vue-admin/server/core"
55
"github.com/flipped-aurora/gin-vue-admin/server/global"
66
"github.com/flipped-aurora/gin-vue-admin/server/initialize"
7+
"go.uber.org/zap"
78
)
89

910
//go:generate go env -w GO111MODULE=on
@@ -19,8 +20,9 @@ import (
1920
// @name x-token
2021
// @BasePath /
2122
func main() {
22-
global.GVA_VP = core.Viper() // 初始化Viper
23-
global.GVA_LOG = core.Zap() // 初始化zap日志库
23+
global.GVA_VP = core.Viper() // 初始化Viper
24+
global.GVA_LOG = core.Zap() // 初始化zap日志库
25+
zap.ReplaceGlobals(global.GVA_LOG)
2426
global.GVA_DB = initialize.Gorm() // gorm连接数据库
2527
initialize.Timer()
2628
initialize.DBList()

server/model/system/request/sys_init.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,30 @@ func (i *InitDB) PgsqlEmptyDsn() string {
4343
// Author [SliverHorn](https://github.com/SliverHorn)
4444
func (i *InitDB) ToMysqlConfig() config.Mysql {
4545
return config.Mysql{
46-
Path: i.Host,
47-
Port: i.Port,
48-
Dbname: i.DBName,
49-
Username: i.UserName,
50-
Password: i.Password,
51-
Config: "charset=utf8mb4&parseTime=True&loc=Local",
46+
Path: i.Host,
47+
Port: i.Port,
48+
Dbname: i.DBName,
49+
Username: i.UserName,
50+
Password: i.Password,
51+
MaxIdleConns: 10,
52+
MaxOpenConns: 100,
53+
LogMode: "error",
54+
Config: "charset=utf8mb4&parseTime=True&loc=Local",
5255
}
5356
}
5457

5558
// ToPgsqlConfig 转换 config.Pgsql
5659
// Author [SliverHorn](https://github.com/SliverHorn)
5760
func (i *InitDB) ToPgsqlConfig() config.Pgsql {
5861
return config.Pgsql{
59-
Path: i.Host,
60-
Port: i.Port,
61-
Dbname: i.DBName,
62-
Username: i.UserName,
63-
Password: i.Password,
64-
Config: "sslmode=disable TimeZone=Asia/Shanghai",
62+
Path: i.Host,
63+
Port: i.Port,
64+
Dbname: i.DBName,
65+
Username: i.UserName,
66+
Password: i.Password,
67+
MaxIdleConns: 10,
68+
MaxOpenConns: 100,
69+
LogMode: "error",
70+
Config: "sslmode=disable TimeZone=Asia/Shanghai",
6571
}
6672
}

server/model/system/sys_user.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ type SysUser struct {
1818
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
1919
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
2020
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"`
21+
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户角色ID
22+
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
2123
}

0 commit comments

Comments
 (0)