aa
This commit is contained in:
@@ -1,108 +0,0 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.Menu, err error) {
|
||||
sqlParams := []interface{}{}
|
||||
sql := `
|
||||
SELECT DISTINCT a.*
|
||||
FROM menu a
|
||||
`
|
||||
if userID != "" {
|
||||
sql += `
|
||||
JOIN menu d ON d.parent_id = a.id
|
||||
JOIN user_role b ON b.user_id = ?
|
||||
JOIN role_menu c ON c.menu_id = d.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 a.name LIKE ?"
|
||||
sqlParams = append(sqlParams, "%"+name+"%")
|
||||
}
|
||||
if level != 0 {
|
||||
sql += " AND a.level = ?"
|
||||
sqlParams = append(sqlParams, level)
|
||||
}
|
||||
err = GetRows(db, &menus, sql, sqlParams)
|
||||
return menus, err
|
||||
}
|
||||
|
||||
func GetMenuWithUser(db *DaoDB, name string, level int, userID string) (menus []*model.Menu, err error) {
|
||||
sql := `
|
||||
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
|
||||
WHERE a.deleted_at = ?)a
|
||||
JOIN menu b ON (b.id = a.id OR b.id = a.parent_id)
|
||||
`
|
||||
sqlParams := []interface{}{userID, utils.DefaultTimeValue}
|
||||
err = GetRows(db, &menus, sql, sqlParams)
|
||||
return menus, err
|
||||
}
|
||||
|
||||
func GetRole(db *DaoDB, name string) (roles []*model.Role, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM role
|
||||
WHERE deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if name != "" {
|
||||
sql += " AND name LIKE ?"
|
||||
sqlParams = append(sqlParams, "%"+name+"%")
|
||||
}
|
||||
err = GetRows(db, &roles, sql, sqlParams)
|
||||
return roles, err
|
||||
}
|
||||
|
||||
func GetUserRole(db *DaoDB, userIDs []string, roleIDs []int) (userRoles []*model.UserRole, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM user_role
|
||||
WHERE deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if len(userIDs) > 0 {
|
||||
sql += " AND user_id IN (" + GenQuestionMarks(len(userIDs)) + ")"
|
||||
sqlParams = append(sqlParams, userIDs)
|
||||
}
|
||||
if len(roleIDs) > 0 {
|
||||
sql += " AND role_id IN (" + GenQuestionMarks(len(roleIDs)) + ")"
|
||||
sqlParams = append(sqlParams, roleIDs)
|
||||
}
|
||||
err = GetRows(db, &userRoles, sql, sqlParams)
|
||||
return userRoles, err
|
||||
}
|
||||
|
||||
func GetRoleMenu(db *DaoDB, roleIDs, menuIDs []int) (roleMenus []*model.RoleMenu, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM role_menu
|
||||
WHERE deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if len(roleIDs) > 0 {
|
||||
sql += " AND role_id IN (" + GenQuestionMarks(len(roleIDs)) + ")"
|
||||
sqlParams = append(sqlParams, roleIDs)
|
||||
}
|
||||
if len(menuIDs) > 0 {
|
||||
sql += " AND menu_id IN (" + GenQuestionMarks(len(menuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, menuIDs)
|
||||
}
|
||||
err = GetRows(db, &roleMenus, sql, sqlParams)
|
||||
return roleMenus, err
|
||||
}
|
||||
@@ -59,17 +59,16 @@ func (*MessageStatus) TableIndex() [][]string {
|
||||
type ImMessageRecord struct {
|
||||
ModelIDCULD
|
||||
|
||||
UserID string `orm:"size(48);column(user_id)" json:"userID"` //发消息的userID
|
||||
GroupID int `orm:"column(group_id)" json:"groupID"` //组ID
|
||||
Content string `orm:"type(text)" json:"content"` //消息内容
|
||||
MessageType int `json:"messageType"` //消息类型,1文字,2图片,3音频
|
||||
Seq int64 `json:"seq"`
|
||||
Weight int `json:"weight"`
|
||||
Height int `json:"height"`
|
||||
AudioLength string `json:"audioLength"`
|
||||
Key string `orm:"-" json:"key"`
|
||||
ToUserID string `orm:"size(48);column(to_user_id)" json:"toUserID"` //收消息的userID
|
||||
UserInfo *GetUserResult `orm:"-" json:"userInfo"`
|
||||
UserID string `orm:"size(48);column(user_id)" json:"userID"` //发消息的userID
|
||||
GroupID int `orm:"column(group_id)" json:"groupID"` //组ID
|
||||
Content string `orm:"type(text)" json:"content"` //消息内容
|
||||
MessageType int `json:"messageType"` //消息类型,1文字,2图片,3音频
|
||||
Seq int64 `json:"seq"`
|
||||
Weight int `json:"weight"`
|
||||
Height int `json:"height"`
|
||||
AudioLength string `json:"audioLength"`
|
||||
Key string `orm:"-" json:"key"`
|
||||
ToUserID string `orm:"size(48);column(to_user_id)" json:"toUserID"` //收消息的userID
|
||||
}
|
||||
|
||||
func (*ImMessageRecord) TableIndex() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user