ch some
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

This commit is contained in:
2026-09-04 19:33:26 +05:00
parent 28509eb4ca
commit d1a6fcaadc
102 changed files with 2089 additions and 1957 deletions

View File

@@ -3,11 +3,11 @@ package userbranch
import (
"errors"
"net/http"
"strconv"
"online-back/internal/appresult"
"online-back/internal/handlers"
"online-back/internal/identity/rbac"
"online-back/internal/shared"
"online-back/pkg/logging"
"github.com/gin-gonic/gin"
@@ -50,6 +50,10 @@ func (h *handler) create(c *gin.Context) {
return
}
if !rbac.GuardNewBranchAssignment(c, dto.UserId) {
return
}
item, err := h.repository.Create(c.Request.Context(), dto)
if err != nil {
h.logger.Errorf("create branch user failed: %v", err)
@@ -73,7 +77,7 @@ func (h *handler) create(c *gin.Context) {
// @Failure 500 {object} appresult.AppError
// @Router /branch-users/{id} [delete]
func (h *handler) delete(c *gin.Context) {
id, ok := parseID(c.Param("id"))
id, ok := shared.ParseID(c.Param("id"))
if !ok {
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
return
@@ -105,11 +109,3 @@ func (h *handler) delete(c *gin.Context) {
c.JSON(http.StatusOK, appresult.SuccessWithData("branch user removed"))
}
func parseID(raw string) (int64, bool) {
id, err := strconv.ParseInt(raw, 10, 64)
if err != nil || id <= 0 {
return 0, false
}
return id, true
}