This commit is contained in:
Aditya Siregar
2025-10-10 00:05:50 +07:00
parent e7455f107a
commit 239f052a9a
4 changed files with 25 additions and 1 deletions
@@ -2,6 +2,7 @@ package handler
import (
"context"
"eslogad-be/internal/appcontext"
"net/http"
"strconv"
@@ -200,6 +201,28 @@ func (h *AdminApprovalFlowHandler) ListApprovalFlows(c *gin.Context) {
c.JSON(http.StatusOK, contract.BuildSuccessResponse(resp))
}
func (h *AdminApprovalFlowHandler) ListApprovalFlowsByDepartment(c *gin.Context) {
appCtx := appcontext.FromGinContext(c.Request.Context())
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "10"))
offset := (page - 1) * limit
req := &contract.ListApprovalFlowsRequest{
Limit: limit,
Offset: offset,
DepartmentID: &appCtx.DepartmentID,
}
resp, err := h.svc.ListApprovalFlows(c.Request.Context(), req)
if err != nil {
c.JSON(http.StatusInternalServerError, &contract.ErrorResponse{Error: err.Error(), Code: http.StatusInternalServerError})
return
}
c.JSON(http.StatusOK, contract.BuildSuccessResponse(resp))
}
func (h *AdminApprovalFlowHandler) ActivateApprovalFlow(c *gin.Context) {
id, err := uuid.Parse(c.Param("id"))
if err != nil {