Add backups, currencies and dashboard APIs, and scope access by guard_name.
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

Web users may only CRUD their own records, operators stay in assigned branches, and admin/manager/superadmin keep full access.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-31 18:14:47 +05:00
parent 0d000f9af6
commit 28509eb4ca
65 changed files with 9132 additions and 296 deletions

View File

@@ -38,7 +38,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
// list godoc
// @Summary List loan orders
// @Description Returns paginated loan orders with optional filters
// @Description Returns paginated loan orders created from the web with optional filters
// @Tags loan-orders
// @Produce json
// @Security BearerAuth
@@ -58,6 +58,7 @@ func (h *handler) list(c *gin.Context) {
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
return
}
filter.Source = "web"
h.respondList(c, filter)
}
@@ -127,7 +128,7 @@ func (h *handler) getByID(c *gin.Context) {
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
return
}
if !rbac.GuardBranch(c, item.BranchId) {
if !rbac.GuardOrder(c, item.UserId, item.BranchId) {
return
}
@@ -324,7 +325,7 @@ func queryValue(c *gin.Context, keys ...string) string {
}
func (h *handler) guardBranchByID(c *gin.Context, id int64) bool {
if !rbac.HasBranchScope(c) {
if rbac.SkipRecordGuard(c) {
return true
}
item, err := h.repository.GetByID(c.Request.Context(), id)
@@ -336,5 +337,5 @@ func (h *handler) guardBranchByID(c *gin.Context, id int64) bool {
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
return false
}
return rbac.GuardBranch(c, item.BranchId)
return rbac.GuardOrder(c, item.UserId, item.BranchId)
}