Add backups, currencies and dashboard APIs, and scope access by guard_name.
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user