修改,兼容go-admin sdk方案

This commit is contained in:
linwenxiang committed 2021-03-09 19:12:49 +08:00
1 parent c541d09076
commit 25d8364bf4
151 files changed
+578 -3525

No files matched your search

+9 -9
View File
@@ -5,12 +5,12 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/tools"
"go-admin/tools/app"
"go-admin/tools/config"
"github.com/go-admin-team/go-admin-core/sdk/config"
"github.com/go-admin-team/go-admin-core/sdk/pkg"
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
"github.com/go-admin-team/go-admin-core/sdk/pkg/response"
"gorm.io/gorm"
)
type DataPermission struct {
@@ -22,15 +22,15 @@ type DataPermission struct {
func PermissionAction() gin.HandlerFunc {
return func(c *gin.Context) {
db, err := tools.GetOrm(c)
db, err := pkg.GetOrm(c)
if err != nil {
log.Error(err)
return
}
msgID := tools.GenerateMsgIDFromContext(c)
msgID := pkg.GenerateMsgIDFromContext(c)
var p = new(DataPermission)
if userId := tools.GetUserIdStr(c); userId != "" {
if userId := user.GetUserIdStr(c); userId != "" {
p, err = newDataPermission(db, userId)
if err != nil {
log.Errorf("MsgID[%s] PermissionAction error: %s", msgID, err)
@@ -71,7 +71,7 @@ func Permission(tableName string, p *DataPermission) func(db *gorm.DB) *gorm.DB
case "3":
return db.Where(tableName+".create_by in (SELECT user_id from sys_user where dept_id = ? )", p.DeptId)
case "4":
return db.Where(tableName+".create_by in (SELECT user_id from sys_user where sys_user.dept_id in(select dept_id from sys_dept where dept_path like ? ))", "%"+tools.IntToString(p.DeptId)+"%")
return db.Where(tableName+".create_by in (SELECT user_id from sys_user where sys_user.dept_id in(select dept_id from sys_dept where dept_path like ? ))", "%"+pkg.IntToString(p.DeptId)+"%")
case "5":
return db.Where(tableName+".create_by = ?", p.UserId)
default: