package access import "antrian-operasi/internal/shared" type AvailableMenuChildResponse struct { Title string `json:"title"` Icon string `json:"icon"` To string `json:"to"` Children []*AvailableMenuChildResponse `json:"children"` } type AvailableMenuResponse struct { ID string `json:"id"` Header string `json:"header"` Children []*AvailableMenuChildResponse `json:"children"` } func MapMenuModelToResponse(pages []RolePageModel) []AvailableMenuResponse { pageMap := make(map[string]*AvailableMenuChildResponse) var result []AvailableMenuResponse for _, p := range pages { pageMap[p.ID] = &AvailableMenuChildResponse{ Title: p.Name, Icon: p.Icon.String, To: p.Url.String, } if p.ParentId.String != "" { pageMap[p.ParentId.String].Children = append(pageMap[p.ParentId.String].Children, pageMap[p.ID]) } } for _, p := range pages { if p.ParentId.String == "" { result = append(result, AvailableMenuResponse{ ID: p.ID, Header: p.Name, Children: pageMap[p.ID].Children, }) } } return result } type UserRoleResponse struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` HakAkses []string `json:"hak_akses"` } type ListUserRolePaginateResponse struct { Data []UserRoleResponse Paging shared.PaginationInfo } type ListRolePermissionPaginateResponse struct { Data []RolePermissionModel Paging shared.PaginationInfo } type AccessPage struct { ID string `json:"id" binding:"required"` Page string `json:"page"` IsActive bool `json:"is_active" binding:"required"` Sort int `json:"sort"` ParentId *string `json:"parent_id" binding:"uuid"` } type DetailRolePageResponse struct { ID string `json:"id" db:"id" binding:"required,uuid"` Name string `json:"name" db:"name"` Status bool `json:"status" db:"is_active"` AccessPage []AccessPage `json:"access_page"` }