用户添加全新啊
This commit is contained in:
@@ -11,8 +11,8 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
func GetMenu(ctx *jxcontext.Context) (menus []*model.Menu, err error) {
|
||||
return dao.GetMenu(dao.GetDB(), "", 0)
|
||||
func GetMenu(ctx *jxcontext.Context, userID string) (menus []*model.Menu, err error) {
|
||||
return dao.GetMenu(dao.GetDB(), "", 0, userID)
|
||||
}
|
||||
|
||||
func AddMenu(ctx *jxcontext.Context, menu *model.Menu) (err error) {
|
||||
|
||||
@@ -5,21 +5,26 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetMenu(db *DaoDB, name string, level int) (menus []*model.Menu, err error) {
|
||||
func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.Menu, err error) {
|
||||
sqlParams := []interface{}{}
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM menu
|
||||
WHERE deleted_at = ?
|
||||
SELECT DISTINCT a.*
|
||||
FROM menu a
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
if userID != "" {
|
||||
sql += ` 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
|
||||
`
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
sql += " WHERE a.deleted_at = ?"
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
if name != "" {
|
||||
sql += " AND name LIKE ?"
|
||||
sql += " AND a.name LIKE ?"
|
||||
sqlParams = append(sqlParams, "%"+name+"%")
|
||||
}
|
||||
if level != 0 {
|
||||
sql += " AND level = ?"
|
||||
sql += " AND a.level = ?"
|
||||
sqlParams = append(sqlParams, level)
|
||||
}
|
||||
err = GetRows(db, &menus, sql, sqlParams)
|
||||
|
||||
@@ -32,12 +32,13 @@ func (c *PowerController) AddMenu() {
|
||||
// @Title 查询功能(菜单)
|
||||
// @Description 查询功能(菜单)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param userID query string false "用户ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetMenu [get]
|
||||
func (c *PowerController) GetMenu() {
|
||||
c.callGetMenu(func(params *tPowerGetMenuParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetMenu(params.Ctx)
|
||||
retVal, err = cms.GetMenu(params.Ctx, params.UserID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user