This commit is contained in:
苏尹岚
2021-01-21 17:01:21 +08:00
parent 1ed3146ed4
commit 091e46b74d

View File

@@ -1,8 +1,6 @@
package dao
import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
)
@@ -31,8 +29,6 @@ func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.M
sql += " AND a.level = ?"
sqlParams = append(sqlParams, level)
}
fmt.Println(sql)
fmt.Println(sqlParams)
err = GetRows(db, &menus, sql, sqlParams)
return menus, err
}
@@ -42,12 +38,12 @@ func GetMenuWithUser(db *DaoDB, name string, level int, userID string) (menus []
SELECT DISTINCT b.* FROM (
SELECT a.id,a.parent_id
FROM menu a
JOIN user_role b ON b.user_id = ?
JOIN role_menu c ON c.menu_id = a.id AND c.role_id = b.role_id
JOIN user_role b ON b.user_id = ? AND b.deleted_at = ?
JOIN role_menu c ON c.menu_id = a.id AND c.role_id = b.role_id AND c.deleted_at = ?
WHERE a.deleted_at = ?)a
JOIN menu b ON (b.id = a.id OR b.id = a.parent_id)
`
sqlParams := []interface{}{userID, utils.DefaultTimeValue}
sqlParams := []interface{}{userID, utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue}
err = GetRows(db, &menus, sql, sqlParams)
return menus, err
}