47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package users
|
|
|
|
import (
|
|
"clickandjoin.app/managementsystem/modules/scylladb"
|
|
"clickandjoin.app/managementsystem/modules/structs"
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func GetAllUsers(c *fiber.Ctx) error {
|
|
// swagger:operation GET /users users usersGetAllUsers
|
|
// ---
|
|
// summary: List of users
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// responses:
|
|
// '200':
|
|
// description: List of users
|
|
// schema:
|
|
// "$ref": "#/definitions/FoundAccountNamesResponse"
|
|
// '400':
|
|
// description: Invalid account name format
|
|
// '500':
|
|
// description: Internal server error
|
|
|
|
var users []structs.User
|
|
|
|
q := scylladb.Session.Query(scylladb.Users.SelectAll())
|
|
|
|
if err := q.SelectRelease(&users); err != nil {
|
|
logrus.Errorln("Failed to get users, err:", err)
|
|
}
|
|
|
|
var nUsers []structs.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})
|
|
}
|