diff --git a/README.md b/README.md
index a2ec2e5e..60b0a134 100644
--- a/README.md
+++ b/README.md
@@ -306,9 +306,11 @@ swag init
如果你觉得这个项目对你有帮助,你可以请作者喝饮料 :tropical_drink: [点我](https://www.gin-vue-admin.com/docs/coffee)
## 10. 友情链接
-
-[H5-Dooring | H5页面制作神器](https://github.com/MrXujiang/h5-Dooring)
-
+
+[H5-Dooring | H5页面制作神器](https://github.com/MrXujiang/h5-Dooring)
+
+[go-zero 微服务框架|缩短从需求到上线的距离](https://github.com/zeromicro/go-zero)
+
## 11. 商用注意事项
如果您将此项目用于商业用途,请遵守Apache2.0协议并保留作者技术支持声明。
diff --git a/server/api/v1/example/exa_excel.go b/server/api/v1/example/exa_excel.go
index 8646a8b6..d6578487 100644
--- a/server/api/v1/example/exa_excel.go
+++ b/server/api/v1/example/exa_excel.go
@@ -1,10 +1,11 @@
package example
import (
+ "os"
+
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
- "github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
@@ -89,12 +90,18 @@ func (e *ExcelApi) LoadExcel(c *gin.Context) {
func (e *ExcelApi) DownloadTemplate(c *gin.Context) {
fileName := c.Query("fileName")
filePath := global.GVA_CONFIG.Excel.Dir + fileName
- ok, err := utils.PathExists(filePath)
- if !ok || err != nil {
+
+ fi, err := os.Stat(filePath)
+ if err != nil {
global.GVA_LOG.Error("文件不存在!", zap.Error(err))
response.FailWithMessage("文件不存在", c)
return
}
+ if fi.IsDir() {
+ global.GVA_LOG.Error("不支持下载文件夹!", zap.Error(err))
+ response.FailWithMessage("不支持下载文件夹", c)
+ return
+ }
c.Writer.Header().Add("success", "true")
c.File(filePath)
}
diff --git a/server/api/v1/system/sys_user.go b/server/api/v1/system/sys_user.go
index d8d66e0a..55749fd0 100644
--- a/server/api/v1/system/sys_user.go
+++ b/server/api/v1/system/sys_user.go
@@ -105,7 +105,7 @@ func (b *BaseApi) tokenNext(c *gin.Context, user system.SysUser) {
// @Produce application/json
// @Param data body systemReq.Register true "用户名, 昵称, 密码, 角色ID"
// @Success 200 {object} response.Response{data=systemRes.SysUserResponse,msg=string} "用户注册账号,返回包括用户信息"
-// @Router /user/register [post]
+// @Router /user/admin_register [post]
func (b *BaseApi) Register(c *gin.Context) {
var r systemReq.Register
_ = c.ShouldBindJSON(&r)
diff --git a/server/model/system/request/sys_casbin.go b/server/model/system/request/sys_casbin.go
index d0031dcf..b07ac567 100644
--- a/server/model/system/request/sys_casbin.go
+++ b/server/model/system/request/sys_casbin.go
@@ -17,7 +17,7 @@ func DefaultCasbin() []CasbinInfo {
{Path: "/menu/getMenu", Method: "POST"},
{Path: "/jwt/jsonInBlacklist", Method: "POST"},
{Path: "/base/login", Method: "POST"},
- {Path: "/user/register", Method: "POST"},
+ {Path: "/user/admin_register", Method: "POST"},
{Path: "/user/changePassword", Method: "POST"},
{Path: "/user/setUserAuthority", Method: "POST"},
{Path: "/user/setUserInfo", Method: "PUT"},
diff --git a/server/resource/template/web/table.vue.tpl b/server/resource/template/web/table.vue.tpl
index cdad6847..367092a4 100644
--- a/server/resource/template/web/table.vue.tpl
+++ b/server/resource/template/web/table.vue.tpl
@@ -37,7 +37,7 @@
确定
- 删除
+ 删除
diff --git a/server/router/system/sys_user.go b/server/router/system/sys_user.go
index 49b48424..9a09176c 100644
--- a/server/router/system/sys_user.go
+++ b/server/router/system/sys_user.go
@@ -13,7 +13,7 @@ func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
userRouterWithoutRecord := Router.Group("user")
baseApi := v1.ApiGroupApp.SystemApiGroup.BaseApi
{
- userRouter.POST("register", baseApi.Register) // 用户注册账号
+ userRouter.POST("admin_register", baseApi.Register) // 管理员注册账号
userRouter.POST("changePassword", baseApi.ChangePassword) // 用户修改密码
userRouter.POST("setUserAuthority", baseApi.SetUserAuthority) // 设置用户权限
userRouter.DELETE("deleteUser", baseApi.DeleteUser) // 删除用户
diff --git a/server/service/system/sys_api.go b/server/service/system/sys_api.go
index 1be87fc3..0272ac63 100644
--- a/server/service/system/sys_api.go
+++ b/server/service/system/sys_api.go
@@ -2,6 +2,7 @@ package system
import (
"errors"
+ "fmt"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
@@ -89,6 +90,9 @@ func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.Pag
} else {
OrderStr = order
}
+ } else { // didn't matched any order key in `orderMap`
+ err = fmt.Errorf("非法的排序字段: %v", order)
+ return err, apiList, total
}
err = db.Order(OrderStr).Find(&apiList).Error
diff --git a/server/service/system/sys_initdb.go b/server/service/system/sys_initdb.go
index 002fee67..22c8161a 100644
--- a/server/service/system/sys_initdb.go
+++ b/server/service/system/sys_initdb.go
@@ -20,11 +20,11 @@ type InitDBService struct{}
func (initDBService *InitDBService) InitDB(conf request.InitDB) error {
switch conf.DBType {
case "mysql":
- return initDBService.initMsqlDB(conf)
+ return initDBService.initMysqlDB(conf)
case "pgsql":
return initDBService.initPgsqlDB(conf)
default:
- return initDBService.initMsqlDB(conf)
+ return initDBService.initMysqlDB(conf)
}
}
diff --git a/server/service/system/sys_initdb_mysql.go b/server/service/system/sys_initdb_mysql.go
index 5e653e8e..85b44298 100644
--- a/server/service/system/sys_initdb_mysql.go
+++ b/server/service/system/sys_initdb_mysql.go
@@ -29,11 +29,11 @@ func (initDBService *InitDBService) writeMysqlConfig(mysql config.Mysql) error {
return global.GVA_VP.WriteConfig()
}
-// initMsqlDB 创建数据库并初始化 mysql
+// initMysqlDB 创建数据库并初始化 mysql
// Author [piexlmax](https://github.com/piexlmax)
// Author [SliverHorn](https://github.com/SliverHorn)
// Author: [songzhibin97](https://github.com/songzhibin97)
-func (initDBService *InitDBService) initMsqlDB(conf request.InitDB) error {
+func (initDBService *InitDBService) initMysqlDB(conf request.InitDB) error {
dsn := conf.MysqlEmptyDsn()
createSql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS `%s` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;", conf.DBName)
if err := initDBService.createDatabase(dsn, "mysql", createSql); err != nil {
diff --git a/server/source/system/api.go b/server/source/system/api.go
index ad3e1a4a..63274e5f 100644
--- a/server/source/system/api.go
+++ b/server/source/system/api.go
@@ -22,7 +22,7 @@ func (a *api) Initialize() error {
{ApiGroup: "jwt", Method: "POST", Path: "/jwt/jsonInBlacklist", Description: "jwt加入黑名单(退出,必选)"},
{ApiGroup: "系统用户", Method: "DELETE", Path: "/user/deleteUser", Description: "删除用户"},
- {ApiGroup: "系统用户", Method: "POST", Path: "/user/register", Description: "用户注册"},
+ {ApiGroup: "系统用户", Method: "POST", Path: "/user/admin_register", Description: "用户注册"},
{ApiGroup: "系统用户", Method: "POST", Path: "/user/getUserList", Description: "获取用户列表"},
{ApiGroup: "系统用户", Method: "PUT", Path: "/user/setUserInfo", Description: "设置用户信息"},
{ApiGroup: "系统用户", Method: "PUT", Path: "/user/setSelfInfo", Description: "设置自身信息(必选)"},
diff --git a/server/source/system/casbin.go b/server/source/system/casbin.go
index 98135298..15cf431d 100644
--- a/server/source/system/casbin.go
+++ b/server/source/system/casbin.go
@@ -19,7 +19,7 @@ func (c *casbin) TableName() string {
func (c *casbin) Initialize() error {
entities := []adapter.CasbinRule{
{PType: "p", V0: "888", V1: "/base/login", V2: "POST"},
- {PType: "p", V0: "888", V1: "/user/register", V2: "POST"},
+ {PType: "p", V0: "888", V1: "/user/admin_register", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/createApi", V2: "POST"},
{PType: "p", V0: "888", V1: "/api/getApiList", V2: "POST"},
@@ -125,7 +125,7 @@ func (c *casbin) Initialize() error {
{PType: "p", V0: "888", V1: "/authorityBtn/canRemoveAuthorityBtn", V2: "POST"},
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
- {PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
+ {PType: "p", V0: "8881", V1: "/user/admin_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"},
@@ -164,7 +164,7 @@ func (c *casbin) Initialize() error {
{PType: "p", V0: "8881", V1: "/user/getUserInfo", 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: "/user/admin_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"},
diff --git a/web/src/api/user.js b/web/src/api/user.js
index ab9c634a..befd20ed 100644
--- a/web/src/api/user.js
+++ b/web/src/api/user.js
@@ -29,7 +29,7 @@ export const captcha = (data) => {
// @Router /base/resige [post]
export const register = (data) => {
return service({
- url: '/user/register',
+ url: '/user/admin_register',
method: 'post',
data: data
})
diff --git a/web/src/permission.js b/web/src/permission.js
index fdeb34c2..18788bdc 100644
--- a/web/src/permission.js
+++ b/web/src/permission.js
@@ -36,6 +36,7 @@ async function handleKeepAlive(to) {
router.beforeEach(async(to, from, next) => {
const userStore = useUserStore()
+ to.meta.matched = [...to.matched]
handleKeepAlive(to)
const token = userStore.token
// 在白名单中的判断情况
diff --git a/web/src/view/layout/index.vue b/web/src/view/layout/index.vue
index 309d918b..123d9286 100644
--- a/web/src/view/layout/index.vue
+++ b/web/src/view/layout/index.vue
@@ -31,6 +31,7 @@
+
{
}
})
-const matched = computed(() => route.matched)
+const matched = computed(() => route.meta.matched)
const changeUserAuth = async(id) => {
const res = await setUserAuthority({
diff --git a/web/src/view/superAdmin/api/api.vue b/web/src/view/superAdmin/api/api.vue
index ebf8aa93..55a27bcc 100644
--- a/web/src/view/superAdmin/api/api.vue
+++ b/web/src/view/superAdmin/api/api.vue
@@ -37,7 +37,7 @@
确定
- 删除
+ 删除
diff --git a/web/src/view/superAdmin/operation/sysOperationRecord.vue b/web/src/view/superAdmin/operation/sysOperationRecord.vue
index 2323bca4..fd34967d 100644
--- a/web/src/view/superAdmin/operation/sysOperationRecord.vue
+++ b/web/src/view/superAdmin/operation/sysOperationRecord.vue
@@ -27,7 +27,7 @@
确定
- 删除
+ 删除