2025-09-28 01:53:09 +00:00
package controller
import (
2025-09-30 13:34:56 +00:00
"netidhub-saas-be/app/database/entity"
"netidhub-saas-be/app/module/approval_workflows/request"
"netidhub-saas-be/app/module/approval_workflows/service"
"netidhub-saas-be/utils/paginator"
2025-09-28 01:53:09 +00:00
"strconv"
2025-09-30 13:34:56 +00:00
2025-10-01 03:10:18 +00:00
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog"
2025-09-30 13:34:56 +00:00
utilRes "netidhub-saas-be/utils/response"
utilVal "netidhub-saas-be/utils/validator"
2025-09-28 01:53:09 +00:00
)
type approvalWorkflowsController struct {
approvalWorkflowsService service . ApprovalWorkflowsService
Log zerolog . Logger
}
type ApprovalWorkflowsController interface {
All ( c * fiber . Ctx ) error
Show ( c * fiber . Ctx ) error
Save ( c * fiber . Ctx ) error
Update ( c * fiber . Ctx ) error
Delete ( c * fiber . Ctx ) error
GetDefault ( c * fiber . Ctx ) error
SetDefault ( c * fiber . Ctx ) error
Activate ( c * fiber . Ctx ) error
Deactivate ( c * fiber . Ctx ) error
GetWithSteps ( c * fiber . Ctx ) error
SaveWithSteps ( c * fiber . Ctx ) error
UpdateWithSteps ( c * fiber . Ctx ) error
2025-10-02 02:50:11 +00:00
SaveWithClientSettings ( c * fiber . Ctx ) error
2025-10-02 15:51:49 +00:00
UpdateWithClientSettings ( c * fiber . Ctx ) error
2025-10-02 05:28:10 +00:00
GetComprehensiveDetails ( c * fiber . Ctx ) error
2025-09-28 01:53:09 +00:00
}
func NewApprovalWorkflowsController ( approvalWorkflowsService service . ApprovalWorkflowsService , log zerolog . Logger ) ApprovalWorkflowsController {
return & approvalWorkflowsController {
approvalWorkflowsService : approvalWorkflowsService ,
Log : log ,
}
}
// All ApprovalWorkflows
// @Summary Get all ApprovalWorkflows
// @Description API for getting all ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param req query request.ApprovalWorkflowsQueryRequest false "query parameters"
// @Param req query paginator.Pagination false "pagination parameters"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows [get]
func ( _i * approvalWorkflowsController ) All ( c * fiber . Ctx ) error {
paginate , err := paginator . Paginate ( c )
if err != nil {
return err
}
reqContext := request . ApprovalWorkflowsQueryRequestContext {
Name : c . Query ( "name" ) ,
Description : c . Query ( "description" ) ,
IsActive : c . Query ( "isActive" ) ,
IsDefault : c . Query ( "isDefault" ) ,
}
req := reqContext . ToParamRequest ( )
req . Pagination = paginate
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
_i . Log . Info ( ) . Interface ( "authToken" , authToken ) . Msg ( "" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
approvalWorkflowsData , paging , err := _i . approvalWorkflowsService . GetAll ( authToken , req )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows list successfully retrieved" } ,
Data : approvalWorkflowsData ,
Meta : paging ,
} )
}
// Show ApprovalWorkflows
// @Summary Get one ApprovalWorkflows
// @Description API for getting one ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id} [get]
func ( _i * approvalWorkflowsController ) Show ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
approvalWorkflowsData , err := _i . approvalWorkflowsService . FindOne ( authToken , uint ( id ) )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully retrieved" } ,
Data : approvalWorkflowsData ,
} )
}
// Save ApprovalWorkflows
// @Summary Save ApprovalWorkflows
// @Description API for saving ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param payload body request.ApprovalWorkflowsCreateRequest true "Required payload"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows [post]
func ( _i * approvalWorkflowsController ) Save ( c * fiber . Ctx ) error {
req := new ( request . ApprovalWorkflowsCreateRequest )
if err := utilVal . ParseAndValidate ( c , req ) ; err != nil {
return err
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
// Convert request to entity
workflow := req . ToEntity ( )
steps := req . ToStepsEntity ( )
2025-10-01 03:10:18 +00:00
approvalWorkflowsData , err := _i . approvalWorkflowsService . Create ( authToken , workflow , steps )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully created" } ,
Data : approvalWorkflowsData ,
} )
}
// Update ApprovalWorkflows
// @Summary Update ApprovalWorkflows
// @Description API for updating ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Param payload body request.ApprovalWorkflowsUpdateRequest true "Required payload"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id} [put]
func ( _i * approvalWorkflowsController ) Update ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
req := new ( request . ApprovalWorkflowsUpdateRequest )
if err := utilVal . ParseAndValidate ( c , req ) ; err != nil {
return err
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
// Convert request to entity
workflow := req . ToEntity ( )
2025-10-01 03:10:18 +00:00
err = _i . approvalWorkflowsService . Update ( authToken , uint ( id ) , workflow )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully updated" } ,
} )
}
// Delete ApprovalWorkflows
// @Summary Delete ApprovalWorkflows
// @Description API for deleting ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id} [delete]
func ( _i * approvalWorkflowsController ) Delete ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
err = _i . approvalWorkflowsService . Delete ( authToken , uint ( id ) )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully deleted" } ,
} )
}
// GetDefault ApprovalWorkflows
// @Summary Get default ApprovalWorkflows
// @Description API for getting default ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/default [get]
func ( _i * approvalWorkflowsController ) GetDefault ( c * fiber . Ctx ) error {
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
approvalWorkflowsData , err := _i . approvalWorkflowsService . GetDefault ( authToken )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "Default ApprovalWorkflows successfully retrieved" } ,
Data : approvalWorkflowsData ,
} )
}
// SetDefault ApprovalWorkflows
// @Summary Set default ApprovalWorkflows
// @Description API for setting default ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id}/set-default [put]
func ( _i * approvalWorkflowsController ) SetDefault ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
err = _i . approvalWorkflowsService . SetDefault ( authToken , uint ( id ) )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully set as default" } ,
} )
}
// Activate ApprovalWorkflows
// @Summary Activate ApprovalWorkflows
// @Description API for activating ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id}/activate [put]
func ( _i * approvalWorkflowsController ) Activate ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
err = _i . approvalWorkflowsService . ActivateWorkflow ( authToken , uint ( id ) )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully activated" } ,
} )
}
// Deactivate ApprovalWorkflows
// @Summary Deactivate ApprovalWorkflows
// @Description API for deactivating ApprovalWorkflows
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id}/deactivate [put]
func ( _i * approvalWorkflowsController ) Deactivate ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
err = _i . approvalWorkflowsService . DeactivateWorkflow ( authToken , uint ( id ) )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows successfully deactivated" } ,
} )
}
// GetWithSteps ApprovalWorkflows
// @Summary Get ApprovalWorkflows with steps
// @Description API for getting ApprovalWorkflows with steps
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id}/with-steps [get]
func ( _i * approvalWorkflowsController ) GetWithSteps ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
2025-10-01 03:10:18 +00:00
workflowData , stepsData , err := _i . approvalWorkflowsService . GetWorkflowWithSteps ( authToken , uint ( id ) )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
// Combine workflow and steps data
responseData := map [ string ] interface { } {
"workflow" : workflowData ,
"steps" : stepsData ,
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows with steps successfully retrieved" } ,
Data : responseData ,
} )
}
// SaveWithSteps ApprovalWorkflows
// @Summary Create ApprovalWorkflows with steps
// @Description API for creating ApprovalWorkflows with steps
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param req body request.ApprovalWorkflowsWithStepsCreateRequest true "ApprovalWorkflows with steps data"
// @Success 201 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/with-steps [post]
func ( _i * approvalWorkflowsController ) SaveWithSteps ( c * fiber . Ctx ) error {
req := new ( request . ApprovalWorkflowsWithStepsCreateRequest )
if err := utilVal . ParseAndValidate ( c , req ) ; err != nil {
return err
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
// Convert request to entities
workflow := req . ToEntity ( )
steps := req . ToStepsEntity ( )
2025-10-01 03:10:18 +00:00
approvalWorkflowsData , err := _i . approvalWorkflowsService . CreateWorkflowWithSteps ( authToken , workflow , steps )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows with steps successfully created" } ,
Data : approvalWorkflowsData ,
} )
}
// UpdateWithSteps ApprovalWorkflows
// @Summary Update ApprovalWorkflows with steps
// @Description API for updating ApprovalWorkflows with steps
// @Tags ApprovalWorkflows
// @Security Bearer
2025-10-01 03:10:18 +00:00
// @Param Authorization header string true "Insert the Authorization"
2025-09-28 01:53:09 +00:00
// @Param id path int true "ApprovalWorkflows ID"
// @Param req body request.ApprovalWorkflowsWithStepsUpdateRequest true "ApprovalWorkflows with steps data"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/{id}/with-steps [put]
func ( _i * approvalWorkflowsController ) UpdateWithSteps ( c * fiber . Ctx ) error {
id , err := strconv . Atoi ( c . Params ( "id" ) )
if err != nil {
return utilRes . ErrorBadRequest ( c , "Invalid ID format" )
}
req := new ( request . ApprovalWorkflowsWithStepsUpdateRequest )
if err := utilVal . ParseAndValidate ( c , req ) ; err != nil {
return err
}
2025-10-01 03:10:18 +00:00
// Get authToken from context
authToken := c . Get ( "Authorization" )
2025-09-28 01:53:09 +00:00
// Convert request to entities
workflow := & entity . ApprovalWorkflows {
Name : req . Name ,
Description : & req . Description ,
IsActive : req . IsActive ,
IsDefault : req . IsDefault ,
}
steps := make ( [ ] * entity . ApprovalWorkflowSteps , len ( req . Steps ) )
for i , stepReq := range req . Steps {
steps [ i ] = stepReq . ToEntity ( uint ( id ) )
}
2025-10-01 03:10:18 +00:00
err = _i . approvalWorkflowsService . UpdateWorkflowWithSteps ( authToken , uint ( id ) , workflow , steps )
2025-09-28 01:53:09 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "ApprovalWorkflows with steps successfully updated" } ,
} )
2025-09-30 13:34:56 +00:00
}
2025-10-02 02:50:11 +00:00
// SaveWithClientSettings ApprovalWorkflows
// @Summary Create comprehensive ApprovalWorkflows with client settings
// @Description API for creating ApprovalWorkflows with workflow steps and client approval settings in a single call
// @Tags ApprovalWorkflows
// @Security Bearer
// @Param Authorization header string true "Insert the Authorization"
// @Param req body request.CreateApprovalWorkflowWithClientSettingsRequest true "Comprehensive approval workflow data"
// @Success 201 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/with-client-settings [post]
func ( _i * approvalWorkflowsController ) SaveWithClientSettings ( c * fiber . Ctx ) error {
req := new ( request . CreateApprovalWorkflowWithClientSettingsRequest )
if err := utilVal . ParseAndValidate ( c , req ) ; err != nil {
return err
}
// Get authToken from context
authToken := c . Get ( "Authorization" )
// Create comprehensive workflow with client settings
workflowData , clientSettingsData , err := _i . approvalWorkflowsService . CreateWorkflowWithClientSettings ( authToken , * req )
if err != nil {
return err
}
2025-10-02 15:51:49 +00:00
_i . Log . Info ( ) . Interface ( "workflowData" , workflowData ) . Interface ( "clientSettingsData" , clientSettingsData ) . Msg ( "Comprehensive workflow with client settings created successfully" )
2025-10-02 02:50:11 +00:00
// Combine workflow, steps, and client settings data
responseData := map [ string ] interface { } {
"workflow" : workflowData ,
"clientSettings" : clientSettingsData ,
"message" : "Comprehensive approval workflow with client settings created successfully" ,
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "Comprehensive approval workflow with client settings successfully created" } ,
Data : responseData ,
} )
}
2025-10-02 05:28:10 +00:00
// GetComprehensiveDetails ApprovalWorkflows
// @Summary Get comprehensive approval workflow details
// @Description API for getting comprehensive details of approval workflow including steps, client settings, and related data
// @Tags ApprovalWorkflows
// @Security Bearer
// @Param Authorization header string true "Insert the Authorization"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
2025-10-07 02:00:08 +00:00
// @Router /approval-workflows/comprehensive-details [get]
2025-10-02 05:28:10 +00:00
func ( _i * approvalWorkflowsController ) GetComprehensiveDetails ( c * fiber . Ctx ) error {
// Get authToken from context
authToken := c . Get ( "Authorization" )
// Get comprehensive workflow details
2025-10-07 02:00:08 +00:00
details , err := _i . approvalWorkflowsService . GetComprehensiveWorkflowDetails ( authToken )
2025-10-02 05:28:10 +00:00
if err != nil {
return err
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "Comprehensive workflow details retrieved successfully" } ,
Data : details ,
} )
}
2025-10-02 15:51:49 +00:00
// UpdateWithClientSettings ApprovalWorkflows
// @Summary Update comprehensive ApprovalWorkflows with client settings
// @Description API for updating ApprovalWorkflows with workflow steps and client approval settings in a single call
// @Tags ApprovalWorkflows
// @Security Bearer
// @Param Authorization header string true "Insert the Authorization"
// @Param req body request.UpdateApprovalWorkflowWithClientSettingsRequest true "Comprehensive approval workflow update data"
// @Success 200 {object} response.Response
// @Failure 400 {object} response.BadRequestError
// @Failure 401 {object} response.UnauthorizedError
// @Failure 500 {object} response.InternalServerError
// @Router /approval-workflows/with-client-settings [put]
func ( _i * approvalWorkflowsController ) UpdateWithClientSettings ( c * fiber . Ctx ) error {
req := new ( request . UpdateApprovalWorkflowWithClientSettingsRequest )
if err := utilVal . ParseAndValidate ( c , req ) ; err != nil {
return err
}
// Get authToken from context
authToken := c . Get ( "Authorization" )
// Update comprehensive workflow with client settings
workflowData , clientSettingsData , err := _i . approvalWorkflowsService . UpdateWorkflowWithClientSettings ( authToken , * req )
if err != nil {
return err
}
// Combine workflow, steps, and client settings data
responseData := map [ string ] interface { } {
"workflow" : workflowData ,
"clientSettings" : clientSettingsData ,
"message" : "Comprehensive approval workflow with client settings updated successfully" ,
}
return utilRes . Resp ( c , utilRes . Response {
Success : true ,
Messages : utilRes . Messages { "Comprehensive approval workflow with client settings successfully updated" } ,
Data : responseData ,
} )
}