提交 bad43090 编写于 作者: 7 710leo

Add user dispname under the node

上级 c2867d96
......@@ -7,6 +7,7 @@ type NodeRole struct {
RoleId int64 `json:"role_id"`
NodePath string `xorm:"<- 'node_path'" json:"node_path"`
RoleTxt string `xorm:"-" json:"role_txt"`
Dispname string `xorm:"-" json:"dispname"`
}
func (nr *NodeRole) Save() error {
......
......@@ -22,8 +22,24 @@ func rolesUnderNodeGets(c *gin.Context) {
dangerous(err)
size := len(list)
var usernames []string
for i := 0; i < size; i++ {
usernames = append(usernames, list[i].Username)
}
users, err := models.UserGetByNames(usernames)
dangerous(err)
usersMap := make(map[string]models.User)
for i := 0; i < len(users); i++ {
usersMap[users[i].Username] = users[i]
}
for i := 0; i < size; i++ {
list[i].RoleTxt = m[list[i].RoleId]
if user, exists := usersMap[list[i].Username]; exists {
list[i].Dispname = user.Dispname
}
}
renderData(c, gin.H{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册