Skip to content

Commit 4724cec

Browse files
author
piexlmax
committed
casbin结构修改为三方包内部结构,避免升级冲突。
1 parent 887ddae commit 4724cec

File tree

4 files changed

+3
-19
lines changed

4 files changed

+3
-19
lines changed

server/core/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func RunWindowsServer() {
2626
}
2727

2828
Router := initialize.Routers()
29-
3029
Router.Static("/form-generator", "./resource/page")
3130

3231
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)

server/initialize/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Routers() *gin.Engine {
2727
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
2828

2929
Router.StaticFS(global.GVA_CONFIG.Local.Path, http.Dir(global.GVA_CONFIG.Local.Path)) // 为用户头像和文件提供静态地址
30-
// Router.Use(middleware.LoadTls()) // 打开就能玩https了
30+
// Router.Use(middleware.LoadTls()) // 如果需要使用https 请打开此中间件 然后前往 core/server.go 将启动模式 更变为 Router.RunTLS("端口","你的cre/pem文件","你的key文件")
3131
global.GVA_LOG.Info("use middleware logger")
3232
// 跨域,如需跨域可以打开下面的注释
3333
// Router.Use(middleware.Cors()) // 直接放行全部跨域请求

server/model/system/sys_casbin.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

server/service/system/sys_casbin.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/casbin/casbin/v2"
88
gormadapter "github.com/casbin/gorm-adapter/v3"
99
"github.com/flipped-aurora/gin-vue-admin/server/global"
10-
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
1110
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
1211
_ "github.com/go-sql-driver/mysql"
1312
)
@@ -26,13 +25,7 @@ func (casbinService *CasbinService) UpdateCasbin(authorityId string, casbinInfos
2625
casbinService.ClearCasbin(0, authorityId)
2726
rules := [][]string{}
2827
for _, v := range casbinInfos {
29-
cm := system.CasbinModel{
30-
Ptype: "p",
31-
AuthorityId: authorityId,
32-
Path: v.Path,
33-
Method: v.Method,
34-
}
35-
rules = append(rules, []string{cm.AuthorityId, cm.Path, cm.Method})
28+
rules = append(rules, []string{authorityId, v.Path, v.Method})
3629
}
3730
e := casbinService.Casbin()
3831
success, _ := e.AddPolicies(rules)
@@ -49,7 +42,7 @@ func (casbinService *CasbinService) UpdateCasbin(authorityId string, casbinInfos
4942
//@return: error
5043

5144
func (casbinService *CasbinService) UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error {
52-
err := global.GVA_DB.Table("casbin_rule").Model(&system.CasbinModel{}).Where("v1 = ? AND v2 = ?", oldPath, oldMethod).Updates(map[string]interface{}{
45+
err := global.GVA_DB.Model(&gormadapter.CasbinRule{}).Where("v1 = ? AND v2 = ?", oldPath, oldMethod).Updates(map[string]interface{}{
5346
"v1": newPath,
5447
"v2": newMethod,
5548
}).Error

0 commit comments

Comments
 (0)