Skip to content

Commit

Permalink
fix sql 1.7.1 login sub account []uint8 or int bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mojito-source committed Aug 24, 2023
1 parent 04235e1 commit e73d2dc
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions plugins/admin/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package models
import (
"database/sql"
"net/url"
"reflect"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -339,20 +340,31 @@ func (t UserModel) WithMenus() UserModel {
}

var menuIds []int64
var midInt int
var mid2Int int
var mInt int

for _, mid := range menuIdsModel {
if parentId, err := strconv.Atoi(string(mid["parent_id"].([]uint8))); err == nil && parentId != 0 {
if reflect.TypeOf(mid["parent_id"]).String() == "[]uint8" {
midInt, _ = strconv.Atoi(string(mid["parent_id"].([]uint8)))
mInt, _ = strconv.Atoi(string(mid["menu_id"].([]uint8)))
} else {
midInt = int(mid["parent_id"].(int64))
mInt = int(mid["menu_id"].(int64))
}
if midInt != 0 {
for _, mid2 := range menuIdsModel {
mid2Int, _ := strconv.Atoi(string(mid2["menu_id"].([]uint8)))
midInt, _ := strconv.Atoi(string(mid["parent_id"].([]uint8)))
if reflect.TypeOf(mid2["menu_id"]).String() == "[]uint8" {
mid2Int, _ = strconv.Atoi(string(mid2["menu_id"].([]uint8)))
} else {
mid2Int = int(mid2["menu_id"].(int64))
}
if mid2Int == midInt {
mInt, _ := strconv.Atoi(string(mid["menu_id"].([]uint8)))
menuIds = append(menuIds, int64(mInt))
break
}
}
} else {
mInt, _ := strconv.Atoi(string(mid["menu_id"].([]uint8)))
menuIds = append(menuIds, int64(mInt))
}
}
Expand Down

0 comments on commit e73d2dc

Please sign in to comment.