Add GET /loan-orders/mobile to list loan orders created from the mobile app.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-22 18:37:31 +05:00
parent 8795ae2195
commit 427d5b4e07
6 changed files with 240 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler
func (h *handler) Register(router *gin.RouterGroup) {
group := router.Group(baseURL, appresult.JwtTokenCheck())
group.GET("", h.list)
group.GET("/mobile", h.listMobile)
group.GET("/:id", h.getByID)
group.POST("", h.create)
group.PUT("/:id", h.update)
@@ -56,7 +57,36 @@ func (h *handler) list(c *gin.Context) {
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
return
}
h.respondList(c, filter)
}
// listMobile godoc
// @Summary List mobile loan orders
// @Description Returns paginated loan orders created from the mobile app
// @Tags loan-orders
// @Produce json
// @Security BearerAuth
// @Param status query string false "Filter by status"
// @Param branch_id query int false "Filter by branch ID"
// @Param user_id query int false "Filter by user ID"
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
// @Router /loan-orders/mobile [get]
func (h *handler) listMobile(c *gin.Context) {
filter, ok := parseListFilter(c)
if !ok {
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
return
}
filter.Source = "mobile"
h.respondList(c, filter)
}
func (h *handler) respondList(c *gin.Context, filter ListFilter) {
result, err := h.repository.List(c.Request.Context(), filter)
if err != nil {
h.logger.Errorf("list loan orders failed: %v", err)