Add province-scoped branches for loan paid letters and harden loans.user_id.
Expose GET /loan-paid-off-letters/branches?province_id= for form pickers, require loans.user_id, and proxy the Vite frontend under /online/. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1987d4f596
commit
5f6ddc5217
14 files changed
+172
-343
No files matched your search
@@ -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("/branches", h.listBranchesByProvince)
|
||||
group.GET("/:id", h.getByID)
|
||||
group.POST("", h.create)
|
||||
group.PUT("/:id", h.update)
|
||||
@@ -41,6 +42,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param passport_id query string false "Filter by passport ID"
|
||||
// @Param name query string false "Filter by customer name"
|
||||
// @Param status query string false "Filter by status"
|
||||
// @Param branch_id query int false "Filter by branch ID"
|
||||
// @Param region query string false "Filter by region"
|
||||
@@ -67,6 +69,45 @@ func (h *handler) list(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||
}
|
||||
|
||||
// listBranchesByProvince godoc
|
||||
// @Summary List branches by province
|
||||
// @Description Returns branches for the selected province (etrap) id for loan paid-off letter forms
|
||||
// @Tags loan-paid-off-letters
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param province_id query int true "Province ID"
|
||||
// @Param active query bool false "Only active branches" default(true)
|
||||
// @Success 200 {object} appresult.AppSuccess
|
||||
// @Failure 400 {object} appresult.AppError
|
||||
// @Failure 500 {object} appresult.AppError
|
||||
// @Router /loan-paid-off-letters/branches [get]
|
||||
func (h *handler) listBranchesByProvince(c *gin.Context) {
|
||||
provinceID, ok := parseID(c.Query("province_id"))
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
|
||||
activeOnly := true
|
||||
if raw := c.Query("active"); raw != "" {
|
||||
active, err := strconv.ParseBool(raw)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||
return
|
||||
}
|
||||
activeOnly = active
|
||||
}
|
||||
|
||||
result, err := h.repository.ListBranchesByProvince(c.Request.Context(), provinceID, activeOnly)
|
||||
if err != nil {
|
||||
h.logger.Errorf("list branches by province failed: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||
}
|
||||
|
||||
// getByID godoc
|
||||
// @Summary Get loan paid off letter by ID
|
||||
// @Description Returns a single loan paid off letter
|
||||
@@ -241,6 +282,10 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
||||
filter.PassportId = raw
|
||||
}
|
||||
|
||||
if raw := strings.TrimSpace(c.Query("name")); raw != "" {
|
||||
filter.Name = raw
|
||||
}
|
||||
|
||||
if raw := strings.TrimSpace(c.Query("status")); raw != "" {
|
||||
filter.Status = &raw
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user