Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eb8e3ce
chore(user.vue): Update user.vue, alter userInfo username to userName.
sliboy Aug 15, 2024
56ca3ae
feat: redis-list support
3vilive Aug 28, 2024
da56588
媒体库增加批量导入URL;
Aug 29, 2024
c1d5e95
fix 描述错误
Aug 29, 2024
ed10177
Merge branch 'flipped-aurora:main' into main
tesun Aug 31, 2024
d1b7c2d
feature: 自动化代码方法支持增加方法描述
pixelmaxQm Sep 3, 2024
2b3ebb0
Merge branch 'flipped-aurora:main' into main
tesun Sep 3, 2024
75500cf
update: 更新依赖,升级为最新版本
pixelmaxQm Sep 4, 2024
8818c25
feature: 自动化代码预览部分支持黑夜模式
pixelmaxQm Sep 4, 2024
9b90f27
fixed: 修复keepalive上线后失效的bug
pixelmaxQm Sep 5, 2024
65d99c0
Merge branch 'flipped-aurora:main' into main
tesun Sep 5, 2024
8ed441d
feature: 增加自动化基础模板功能
pixelmaxQm Sep 5, 2024
eb6267c
feature: 增加自动化基础模板功能
pixelmaxQm Sep 5, 2024
eec637a
Merge remote-tracking branch 'origin/dev274' into dev274
pixelmaxQm Sep 5, 2024
4d82669
Merge branch 'refs/heads/main' into dev274
pixelmaxQm Sep 5, 2024
6239b24
Update api.vue
ailiheizi Sep 6, 2024
f6dbdd1
将用户配置保存到数据库,刷新或者异地登录配置不丢失
Sep 6, 2024
abd331f
Merge pull request #1874 from ailiheizi/patch-2
pixelmaxQm Sep 9, 2024
f386489
Merge pull request #1870 from tesun/main
pixelmaxQm Sep 9, 2024
c73fb10
Merge pull request #1869 from 3vilive/feat-redis-list
pixelmaxQm Sep 9, 2024
8d00db1
update: 清除无用的userinfo配置信息
pixelmaxQm Sep 9, 2024
95cd59f
fixed: 清理开发阶段页面无端进入404的bug
pixelmaxQm Sep 9, 2024
d1cab06
feature: 前端主题配置跟随用户,不再单独设置json编译生效。
pixelmaxQm Sep 9, 2024
011a139
feature: 增加个人中心配置兼容性
pixelmaxQm Sep 9, 2024
dff5d4d
Merge branch 'flipped-aurora:main' into main
sliboy Sep 10, 2024
8443a6f
fix(package): 包名设置为中文会导致无法自动生成代码,禁止包名设置为中文
Sep 11, 2024
8d8c2d8
feature: 格式化代码
pixelmaxQm Sep 11, 2024
bf928ba
Merge pull request #1878 from sliboy/main
pixelmaxQm Sep 12, 2024
702e0e9
feature: 对严格模式新建根角色进行调整。
pixelmaxQm Sep 12, 2024
485acef
feature: 版本变更为2.7.4
pixelmaxQm Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions server/api/v1/example/exa_file_upload_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,26 @@ func (b *FileUploadAndDownloadApi) GetFileList(c *gin.Context) {
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}

// ImportURL
// @Tags ExaFileUploadAndDownload
// @Summary 导入URL
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body example.ExaFileUploadAndDownload true "对象"
// @Success 200 {object} response.Response{msg=string} "导入URL"
// @Router /fileUploadAndDownload/importURL [post]
func (b *FileUploadAndDownloadApi) ImportURL(c *gin.Context) {
var file []example.ExaFileUploadAndDownload
err := c.ShouldBindJSON(&file)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err := fileUploadAndDownloadService.ImportURL(&file); err != nil {
global.GVA_LOG.Error("导入URL失败!", zap.Error(err))
response.FailWithMessage("导入URL失败", c)
return
}
response.OkWithMessage("导入URL成功", c)
}
4 changes: 4 additions & 0 deletions server/api/v1/system/sys_authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (a *AuthorityApi) CreateAuthority(c *gin.Context) {
return
}

if *authority.ParentId == 0 && global.GVA_CONFIG.System.UseStrictAuth {
authority.ParentId = utils.Pointer(utils.GetUserAuthorityId(c))
}

if authBack, err = authorityService.CreateAuthority(authority); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败"+err.Error(), c)
Expand Down
29 changes: 27 additions & 2 deletions server/api/v1/system/sys_user.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package system

import (
"gorm.io/datatypes"
"strconv"
"time"

Expand Down Expand Up @@ -368,7 +369,6 @@ func (b *BaseApi) SetUserInfo(c *gin.Context) {
HeaderImg: user.HeaderImg,
Phone: user.Phone,
Email: user.Email,
SideMode: user.SideMode,
Enable: user.Enable,
})
if err != nil {
Expand Down Expand Up @@ -404,7 +404,6 @@ func (b *BaseApi) SetSelfInfo(c *gin.Context) {
HeaderImg: user.HeaderImg,
Phone: user.Phone,
Email: user.Email,
SideMode: user.SideMode,
Enable: user.Enable,
})
if err != nil {
Expand All @@ -415,6 +414,32 @@ func (b *BaseApi) SetSelfInfo(c *gin.Context) {
response.OkWithMessage("设置成功", c)
}

// SetSelfSetting
// @Tags SysUser
// @Summary 设置用户配置
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body datatypes.JSON
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "设置用户配置"
// @Router /user/SetSelfSetting [put]
func (b *BaseApi) SetSelfSetting(c *gin.Context) {
var req datatypes.JSON
err := c.ShouldBindJSON(&req)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}

err = userService.SetSelfSetting(&req, utils.GetUserID(c))
if err != nil {
global.GVA_LOG.Error("设置失败!", zap.Error(err))
response.FailWithMessage("设置失败", c)
return
}
response.OkWithMessage("设置成功", c)
}

// GetUserInfo
// @Tags SysUser
// @Summary 获取用户信息
Expand Down
11 changes: 11 additions & 0 deletions server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ redis:
- "172.21.0.4:7001"
- "172.21.0.2:7002"

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

# mongo configuration
mongo:
Expand Down
15 changes: 8 additions & 7 deletions server/config/config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package config

type Server struct {
JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
Mongo Mongo `mapstructure:"mongo" json:"mongo" yaml:"mongo"`
Email Email `mapstructure:"email" json:"email" yaml:"email"`
System System `mapstructure:"system" json:"system" yaml:"system"`
Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
JWT JWT `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
Zap Zap `mapstructure:"zap" json:"zap" yaml:"zap"`
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
RedisList []Redis `mapstructure:"redis-list" json:"redis-list" yaml:"redis-list"`
Mongo Mongo `mapstructure:"mongo" json:"mongo" yaml:"mongo"`
Email Email `mapstructure:"email" json:"email" yaml:"email"`
System System `mapstructure:"system" json:"system" yaml:"system"`
Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
// auto
AutoCode Autocode `mapstructure:"autocode" json:"autocode" yaml:"autocode"`
// gorm
Expand Down
1 change: 1 addition & 0 deletions server/config/redis.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

type Redis struct {
Name string `mapstructure:"name" json:"name" yaml:"name"` // 代表当前实例的名字
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的哪个数据库
Expand Down
5 changes: 4 additions & 1 deletion server/core/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func RunWindowsServer() {
// 初始化redis服务
initialize.Redis()
}

initialize.RedisList()

if global.GVA_CONFIG.System.UseMongo {
err := initialize.Mongo.Initialization()
if err != nil {
Expand All @@ -38,7 +41,7 @@ func RunWindowsServer() {

fmt.Printf(`
欢迎使用 gin-vue-admin
当前版本:v2.7.3
当前版本:v2.7.4
加群方式:微信号:shouzi_1994 QQ群:470239250
项目地址:https://github.com/flipped-aurora/gin-vue-admin
插件市场:https://plugin.gin-vue-admin.com
Expand Down
2 changes: 1 addition & 1 deletion server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8087,7 +8087,7 @@ const docTemplate = `{

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "v2.7.3",
Version: "v2.7.4",
Host: "",
BasePath: "",
Schemes: []string{},
Expand Down
2 changes: 1 addition & 1 deletion server/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "使用gin+vue进行极速开发的全栈开发基础平台",
"title": "Gin-Vue-Admin Swagger API接口文档",
"contact": {},
"version": "v2.7.3"
"version": "v2.7.4"
},
"paths": {
"/api/createApi": {
Expand Down
2 changes: 1 addition & 1 deletion server/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ info:
contact: {}
description: 使用gin+vue进行极速开发的全栈开发基础平台
title: Gin-Vue-Admin Swagger API接口文档
version: v2.7.3
version: v2.7.4
paths:
/api/createApi:
post:
Expand Down
25 changes: 18 additions & 7 deletions server/global/global.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package global

import (
"fmt"
"sync"

"github.com/gin-gonic/gin"
"github.com/qiniu/qmgo"
"sync"

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

var (
GVA_DB *gorm.DB
GVA_DBList map[string]*gorm.DB
GVA_REDIS redis.UniversalClient
GVA_MONGO *qmgo.QmgoClient
GVA_CONFIG config.Server
GVA_VP *viper.Viper
GVA_DB *gorm.DB
GVA_DBList map[string]*gorm.DB
GVA_REDIS redis.UniversalClient
GVA_REDISList map[string]redis.UniversalClient
GVA_MONGO *qmgo.QmgoClient
GVA_CONFIG config.Server
GVA_VP *viper.Viper
// GVA_LOG *oplogging.Logger
GVA_LOG *zap.Logger
GVA_Timer timer.Timer = timer.NewTimerTask()
Expand Down Expand Up @@ -53,3 +56,11 @@ func MustGetGlobalDBByDBName(dbname string) *gorm.DB {
}
return db
}

func GetRedis(name string) redis.UniversalClient {
redis, ok := GVA_REDISList[name]
if !ok || redis == nil {
panic(fmt.Sprintf("redis `%s` no init", name))
}
return redis
}
34 changes: 28 additions & 6 deletions server/initialize/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package initialize
import (
"context"

"github.com/flipped-aurora/gin-vue-admin/server/config"
"github.com/flipped-aurora/gin-vue-admin/server/global"

"github.com/redis/go-redis/v9"
"go.uber.org/zap"
)

func Redis() {
redisCfg := global.GVA_CONFIG.Redis
func initRedisClient(redisCfg config.Redis) (redis.UniversalClient, error) {
var client redis.UniversalClient
// 使用集群模式
if redisCfg.UseCluster {
Expand All @@ -28,10 +28,32 @@ func Redis() {
}
pong, err := client.Ping(context.Background()).Result()
if err != nil {
global.GVA_LOG.Error("redis connect ping failed, err:", zap.Error(err))
global.GVA_LOG.Error("redis connect ping failed, err:", zap.String("name", redisCfg.Name), zap.Error(err))
return nil, err
}

global.GVA_LOG.Info("redis connect ping response:", zap.String("name", redisCfg.Name), zap.String("pong", pong))
return client, nil
}

func Redis() {
redisClient, err := initRedisClient(global.GVA_CONFIG.Redis)
if err != nil {
panic(err)
} else {
global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong))
global.GVA_REDIS = client
}
global.GVA_REDIS = redisClient
}

func RedisList() {
redisMap := make(map[string]redis.UniversalClient)

for _, redisCfg := range global.GVA_CONFIG.RedisList {
client, err := initRedisClient(redisCfg)
if err != nil {
panic(err)
}
redisMap[redisCfg.Name] = client
}

global.GVA_REDISList = redisMap
}
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
//go:generate go mod download

// @title Gin-Vue-Admin Swagger API接口文档
// @version v2.7.3
// @version v2.7.4
// @description 使用gin+vue进行极速开发的全栈开发基础平台
// @securityDefinitions.apikey ApiKeyAuth
// @in header
Expand Down
2 changes: 2 additions & 0 deletions server/model/system/request/sys_auto_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type AutoCode struct {
AutoCreateApiToSql bool `json:"autoCreateApiToSql" example:"false"` // 是否自动创建api
AutoCreateMenuToSql bool `json:"autoCreateMenuToSql" example:"false"` // 是否自动创建menu
AutoCreateBtnAuth bool `json:"autoCreateBtnAuth" example:"false"` // 是否自动创建按钮权限
OnlyTemplate bool `json:"onlyTemplate" example:"false"` // 是否只生成模板
Fields []*AutoCodeField `json:"fields"`
DictTypes []string `json:"-"`
PrimaryField *AutoCodeField `json:"primaryField"`
Expand Down Expand Up @@ -236,6 +237,7 @@ type AutoFunc struct {
Package string `json:"package"`
FuncName string `json:"funcName"` // 方法名称
Router string `json:"router"` // 路由名称
FuncDesc string `json:"funcDesc"` // 方法介绍
BusinessDB string `json:"businessDB"` // 业务库
StructName string `json:"structName"` // Struct名称
PackageName string `json:"packageName"` // 文件名称
Expand Down
26 changes: 13 additions & 13 deletions server/model/system/sys_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package system
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/gofrs/uuid/v5"
"gorm.io/datatypes"
)

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

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

func (SysUser) TableName() string {
Expand Down
8 changes: 4 additions & 4 deletions server/resource/function/api.go.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{if .IsPlugin}}
// {{.FuncName}} 等待开发的的{{.Description}}接口
// {{.FuncName}} {{.FuncDesc}}
// @Tags {{.StructName}}
// @Summary 等待开发的的{{.Description}}接口
// @Summary {{.FuncDesc}}
// @accept application/json
// @Produce application/json
// @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表"
Expand All @@ -20,9 +20,9 @@ func (a *{{.Abbreviation}}) {{.FuncName}}(c *gin.Context) {

{{- else -}}

// {{.FuncName}} 等待开发的的{{.Description}}接口
// {{.FuncName}} {{.FuncDesc}}
// @Tags {{.StructName}}
// @Summary 等待开发的的{{.Description}}接口
// @Summary {{.FuncDesc}}
// @accept application/json
// @Produce application/json
// @Param data query {{.Package}}Req.{{.StructName}}Search true "成功"
Expand Down
8 changes: 4 additions & 4 deletions server/resource/function/api.js.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{if .IsPlugin}}
// {{.FuncName}} 等待开发的的{{.Description}}接口
// {{.FuncName}} {{.FuncDesc}}
// @Tags {{.StructName}}
// @Summary 等待开发的的{{.Description}}接口
// @Summary {{.FuncDesc}}
// @accept application/json
// @Produce application/json
// @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表"
Expand All @@ -16,9 +16,9 @@ export const {{.Router}} = () => {

{{- else -}}

// {{.FuncName}} 等待开发的的{{.Description}}接口
// {{.FuncName}} {{.FuncDesc}}
// @Tags {{.StructName}}
// @Summary 等待开发的的{{.Description}}接口
// @Summary {{.FuncDesc}}
// @accept application/json
// @Produce application/json
// @Param data query {{.Package}}Req.{{.StructName}}Search true "成功"
Expand Down
Loading
Loading