added user relationships
parent
539b9af78f
commit
5b81dea629
|
@ -69,4 +69,18 @@ var (
|
|||
},
|
||||
PartKey: []string{"user_first_id", "user_second_id"},
|
||||
})
|
||||
|
||||
UserRelationship = table.New(table.Metadata{
|
||||
Name: "user_relationship",
|
||||
Columns: []string{
|
||||
"user_first_id",
|
||||
"user_second_id",
|
||||
"user_first_following_state",
|
||||
"user_second_following_state",
|
||||
"blocked_state",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
},
|
||||
PartKey: []string{"user_first_id", "user_second_id"},
|
||||
})
|
||||
)
|
||||
|
|
|
@ -67,3 +67,18 @@ type UserSignUpProcess struct {
|
|||
type UserSignUpProcessesResponse struct {
|
||||
UserSignUpProcesses []UserSignUpProcess
|
||||
}
|
||||
|
||||
type UserRelationship struct {
|
||||
UserFirstId string
|
||||
UserSecondId string
|
||||
UserFirstFollowingState uint8
|
||||
UserSecondFollowingState uint8
|
||||
BlockedState uint8
|
||||
CreatedAt int64
|
||||
UpdatedAt int64
|
||||
}
|
||||
|
||||
// swagger:model UserRelationshipsResponse
|
||||
type UserRelationshipsResponse struct {
|
||||
Relationships []UserRelationship
|
||||
}
|
||||
|
|
|
@ -69,3 +69,30 @@ func GetAllUserSignUpProcesses(c *fiber.Ctx) error {
|
|||
|
||||
return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses})
|
||||
}
|
||||
|
||||
func GetAllUserRelationships(c *fiber.Ctx) error {
|
||||
// swagger:operation GET /users/relationships users usersGetAllUserRelationships
|
||||
// ---
|
||||
// summary: List of user relationships
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// responses:
|
||||
// '200':
|
||||
// description: List of user relationships
|
||||
// schema:
|
||||
// "$ref": "#/definitions/UsersResponse"
|
||||
// '500':
|
||||
// description: Internal server error
|
||||
|
||||
var userRelationships []structs.UserRelationship
|
||||
|
||||
q := scylladb.Session.Query(scylladb.UserRelationship.SelectAll())
|
||||
|
||||
if err := q.SelectRelease(&userRelationships); err != nil {
|
||||
logrus.Errorln("Failed to get user relationships, err:", err)
|
||||
}
|
||||
|
||||
return c.JSON(structs.UserRelationshipsResponse{Relationships: userRelationships})
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ func SetupRoutes(app *fiber.App) {
|
|||
us := v1.Group("/users")
|
||||
us.Get("/", ApiKeyValidation, users.GetAllUsers)
|
||||
us.Get("/signupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses)
|
||||
us.Get("/relationships", ApiKeyValidation, users.GetAllUserRelationships)
|
||||
|
||||
wss := v1.Group("/wssessions")
|
||||
wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)
|
||||
|
|
Loading…
Reference in New Issue