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:
77
docs/docs.go
77
docs/docs.go
@@ -1857,6 +1857,83 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/loan-orders/mobile": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns paginated loan orders created from the mobile app",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"loan-orders"
|
||||||
|
],
|
||||||
|
"summary": "List mobile loan orders",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by branch ID",
|
||||||
|
"name": "branch_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by user ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by region",
|
||||||
|
"name": "region",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 1,
|
||||||
|
"description": "Page number",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 10,
|
||||||
|
"description": "Items per page",
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppSuccess"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/loan-orders/{id}": {
|
"/loan-orders/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|||||||
@@ -1851,6 +1851,83 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/loan-orders/mobile": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns paginated loan orders created from the mobile app",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"loan-orders"
|
||||||
|
],
|
||||||
|
"summary": "List mobile loan orders",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by branch ID",
|
||||||
|
"name": "branch_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by user ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by region",
|
||||||
|
"name": "region",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 1,
|
||||||
|
"description": "Page number",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 10,
|
||||||
|
"description": "Items per page",
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppSuccess"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/loan-orders/{id}": {
|
"/loan-orders/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|||||||
@@ -2678,6 +2678,56 @@ paths:
|
|||||||
summary: Update loan order
|
summary: Update loan order
|
||||||
tags:
|
tags:
|
||||||
- loan-orders
|
- loan-orders
|
||||||
|
/loan-orders/mobile:
|
||||||
|
get:
|
||||||
|
description: Returns paginated loan orders created from the mobile app
|
||||||
|
parameters:
|
||||||
|
- description: Filter by status
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
type: string
|
||||||
|
- description: Filter by branch ID
|
||||||
|
in: query
|
||||||
|
name: branch_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by user ID
|
||||||
|
in: query
|
||||||
|
name: user_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by region
|
||||||
|
in: query
|
||||||
|
name: region
|
||||||
|
type: string
|
||||||
|
- default: 1
|
||||||
|
description: Page number
|
||||||
|
in: query
|
||||||
|
name: page
|
||||||
|
type: integer
|
||||||
|
- default: 10
|
||||||
|
description: Items per page
|
||||||
|
in: query
|
||||||
|
name: limit
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppSuccess'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: List mobile loan orders
|
||||||
|
tags:
|
||||||
|
- loan-orders
|
||||||
/loan-paid-off-letters:
|
/loan-paid-off-letters:
|
||||||
get:
|
get:
|
||||||
description: Returns paginated loan paid off letters with optional filters
|
description: Returns paginated loan paid off letters with optional filters
|
||||||
|
|||||||
@@ -176,6 +176,11 @@ func buildListQuery(filter loanorders.ListFilter) (whereClause string, args []in
|
|||||||
conditions = append(conditions, fmt.Sprintf("lo.region = $%d", len(args)))
|
conditions = append(conditions, fmt.Sprintf("lo.region = $%d", len(args)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if filter.Source != "" {
|
||||||
|
args = append(args, filter.Source)
|
||||||
|
conditions = append(conditions, fmt.Sprintf("lo.source = $%d", len(args)))
|
||||||
|
}
|
||||||
|
|
||||||
if len(conditions) == 0 {
|
if len(conditions) == 0 {
|
||||||
return "", args
|
return "", args
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ type ListFilter struct {
|
|||||||
Status *string
|
Status *string
|
||||||
BranchId *int64
|
BranchId *int64
|
||||||
UserId *int64
|
UserId *int64
|
||||||
|
Source string
|
||||||
Region string
|
Region string
|
||||||
Page int
|
Page int
|
||||||
Limit int
|
Limit int
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler
|
|||||||
func (h *handler) Register(router *gin.RouterGroup) {
|
func (h *handler) Register(router *gin.RouterGroup) {
|
||||||
group := router.Group(baseURL, appresult.JwtTokenCheck())
|
group := router.Group(baseURL, appresult.JwtTokenCheck())
|
||||||
group.GET("", h.list)
|
group.GET("", h.list)
|
||||||
|
group.GET("/mobile", h.listMobile)
|
||||||
group.GET("/:id", h.getByID)
|
group.GET("/:id", h.getByID)
|
||||||
group.POST("", h.create)
|
group.POST("", h.create)
|
||||||
group.PUT("/:id", h.update)
|
group.PUT("/:id", h.update)
|
||||||
@@ -56,7 +57,36 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
return
|
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)
|
result, err := h.repository.List(c.Request.Context(), filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Errorf("list loan orders failed: %v", err)
|
h.logger.Errorf("list loan orders failed: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user