package users import ( "clickandjoin.app/managementsystem/modules/scylladb" "clickandjoin.app/managementsystem/modules/structs" gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper" "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper/dbstructs" "github.com/gofiber/fiber/v2" ) func GetAllUsers(c *fiber.Ctx) error { // swagger:operation GET /users users usersGetAllUsers // --- // summary: List of all users // consumes: // - application/json // produces: // - application/json // responses: // '200': // schema: // "$ref": "#/definitions/UsersResponse" // '500': // description: Internal server error var users []dbstructs.User q := scylladb.Session.Query(gocnjhelper.DbMUsers.SelectAll()) if err := q.SelectRelease(&users); err != nil { gocnjhelper.LogErrorf("Failed to get all users, err: %s", err) } var nUsers []dbstructs.User if len(users) > 0 { // remove password value from result for _, user := range users { user.Password = "" nUsers = append(nUsers, user) } } return c.JSON(structs.UsersResponse{Users: nUsers}) } /* func GetUserProfile(c *fiber.Ctx) error { // swagger:operation GET /users/:userId users usersGetUserProfile // --- // summary: Get the profile from a user // consumes: // - application/json // produces: // - application/json // responses: // '200': // schema: // "$ref": "#/definitions/UserResponse" // '400': // description: Internal userId specified // '500': // description: Internal server error userId := c.Params("userId") if len(userId) != utils.LenUserId { return c.SendStatus(fiber.StatusBadRequest) } foundUser := structs.User{Id: userId} q := scylladb.Session.Query(scylladb.Users.Get()).BindStruct(foundUser) if err := q.GetRelease(&foundUser); err != nil { logrus.Println("Failed to get user, err:", err) return c.SendStatus(fiber.StatusUnprocessableEntity) } var resUser structs.UserResponse copier.Copy(&resUser, &foundUser) return c.JSON(resUser) }*/ func GetAllUserSignUpProcesses(c *fiber.Ctx) error { // swagger:operation GET /users/signupprocesses users usersGetAllUserSignUpProcesses // --- // summary: List of all user sign up processes // consumes: // - application/json // produces: // - application/json // responses: // '200': // schema: // "$ref": "#/definitions/UserSignUpProcessesResponse" // '500': // description: Internal server error var userSignUpProcesses []dbstructs.UserSignUpProcess q := scylladb.Session.Query(gocnjhelper.DbMUserSignUpProcess.SelectAll()) if err := q.SelectRelease(&userSignUpProcesses); err != nil { gocnjhelper.LogErrorf("Failed to get all user sign up processes, err: %s", err) } return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses}) } func GetAllUserRelationships(c *fiber.Ctx) error { // swagger:operation GET /users/relationships users usersGetAllUserRelationships // --- // summary: List of all user relationships // consumes: // - application/json // produces: // - application/json // responses: // '200': // schema: // "$ref": "#/definitions/UserRelationshipsResponse" // '500': // description: Internal server error var userRelationships []dbstructs.UserRelationship q := scylladb.Session.Query(gocnjhelper.DbMUserRelationship.SelectAll()) if err := q.SelectRelease(&userRelationships); err != nil { gocnjhelper.LogErrorf("Failed to get all user relationships, err: %s", err) } return c.JSON(structs.UserRelationshipsResponse{Relationships: userRelationships}) } func GetAllUserPrivacySettings(c *fiber.Ctx) error { // swagger:operation GET /users/privacysettings users usersGetAllUserPrivacySettings // --- // summary: List of all user privacy settings // consumes: // - application/json // produces: // - application/json // responses: // '200': // schema: // "$ref": "#/definitions/UserRelationshipsResponse" // '500': // description: Internal server error var userPrivacySettings []dbstructs.UserPrivacySettings q := scylladb.Session.Query(gocnjhelper.DbMUserPrivacySettings.SelectAll()) if err := q.SelectRelease(&userPrivacySettings); err != nil { gocnjhelper.LogErrorf("Failed to get all user privacy settings, err: %s", err) } return c.JSON(structs.UserPrivacySettingsResponse{PrivacySettings: userPrivacySettings}) }