refactor: migrate from raw pgx to GORM, unify ErrNoRows, cleanup auth
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -76,16 +77,21 @@ func (h *Handler) GetByID(c *gin.Context) {
|
||||
}
|
||||
|
||||
// @Summary List organizations
|
||||
// @Description Get all organizations
|
||||
// @Description Get all organizations with pagination
|
||||
// @Tags organizations
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Page size (default 20)"
|
||||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} OrgListResponse
|
||||
// @Failure 500 {object} ErrorResponse
|
||||
// @Router /api/organizations [get]
|
||||
func (h *Handler) List(c *gin.Context) {
|
||||
resp, err := h.service.List(c.Request.Context())
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "20"))
|
||||
offset, _ := strconv.Atoi(c.DefaultQuery("offset", "0"))
|
||||
|
||||
resp, err := h.service.List(c.Request.Context(), limit, offset)
|
||||
if err != nil {
|
||||
log.Printf("list orgs error: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, ErrorResponse{Error: "internal server error"})
|
||||
|
||||
Reference in New Issue
Block a user