refactor: interface{} -> any

feat: 新增外链菜单
This commit is contained in:
meilin.huang
2023-06-01 12:31:32 +08:00
parent 9900b236ef
commit 17d96acceb
106 changed files with 316 additions and 312 deletions

View File

@@ -57,7 +57,7 @@ func (a *Account) Login(rc *req.Ctx) {
// 保存登录消息
go a.saveLogin(account, clientIp)
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"token": req.CreateToken(account.Id, account.Username),
"name": account.Name,
"username": account.Username,
@@ -84,7 +84,7 @@ func (a *Account) GetPermissions(rc *req.Ctx) {
}
// 保存该账号的权限codes
req.SavePermissionCodes(account.Id, permissions)
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"menus": menus.ToTrees(0),
"permissions": permissions,
}
@@ -268,20 +268,20 @@ func (a *Account) SaveRoles(rc *req.Ctx) {
// 将,拼接的字符串进行切割
idsStr := strings.Split(form.RoleIds, ",")
var newIds []interface{}
var newIds []any
for _, v := range idsStr {
id, _ := strconv.Atoi(v)
newIds = append(newIds, uint64(id))
}
// 将[]uint64转为[]interface{}
// 将[]uint64转为[]any
oIds := a.RoleApp.GetAccountRoleIds(uint64(form.Id))
var oldIds []interface{}
var oldIds []any
for _, v := range oIds {
oldIds = append(oldIds, v)
}
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 interface{}) bool {
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 any) bool {
return i1.(uint64) == i2.(uint64)
})

View File

@@ -7,5 +7,5 @@ import (
func GenerateCaptcha(rc *req.Ctx) {
id, image := captcha.Generate()
rc.ResData = map[string]interface{}{"base64Captcha": image, "cid": id}
rc.ResData = map[string]any{"base64Captcha": image, "cid": id}
}

View File

@@ -7,7 +7,7 @@ type ResourceForm struct {
Name string `binding:"required"`
Type int `binding:"required,oneof=1 2"`
Weight int
Meta map[string]interface{}
Meta map[string]any
}
type MenuResourceMeta struct {

View File

@@ -69,20 +69,20 @@ func (r *Role) SaveResource(rc *req.Ctx) {
// 将,拼接的字符串进行切割
idsStr := strings.Split(form.ResourceIds, ",")
var newIds []interface{}
var newIds []any
for _, v := range idsStr {
id, _ := strconv.Atoi(v)
newIds = append(newIds, uint64(id))
}
// 将[]uint64转为[]interface{}
// 将[]uint64转为[]any
oIds := r.RoleApp.GetRoleResourceIds(uint64(form.Id))
var oldIds []interface{}
var oldIds []any
for _, v := range oIds {
oldIds = append(oldIds, v)
}
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 interface{}) bool {
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 any) bool {
return i1.(uint64) == i2.(uint64)
})