2022-11-16 09:05:26 +00:00
|
|
|
package operations
|
|
|
|
|
|
|
|
import (
|
2023-04-21 06:49:17 +00:00
|
|
|
. "github.com/reiver/greatape/components/api/protobuf"
|
|
|
|
. "github.com/reiver/greatape/components/api/services"
|
2023-06-26 07:50:54 +00:00
|
|
|
. "github.com/reiver/greatape/components/constants"
|
2023-04-21 06:49:17 +00:00
|
|
|
. "github.com/reiver/greatape/components/contracts"
|
2022-11-16 09:05:26 +00:00
|
|
|
. "github.com/xeronith/diamante/contracts/operation"
|
|
|
|
. "github.com/xeronith/diamante/contracts/service"
|
|
|
|
. "github.com/xeronith/diamante/contracts/system"
|
|
|
|
. "github.com/xeronith/diamante/operation"
|
|
|
|
)
|
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
type (
|
|
|
|
GetProfileByUserRunner func(IContext, *GetProfileByUserRequest) (*GetProfileByUserResult, error)
|
|
|
|
GetProfileByUserRunners []GetProfileByUserRunner
|
2022-11-16 09:05:26 +00:00
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
getProfileByUserOperation struct {
|
|
|
|
SecureOperation
|
|
|
|
|
|
|
|
runners GetProfileByUserRunners
|
|
|
|
}
|
|
|
|
)
|
2022-11-16 09:05:26 +00:00
|
|
|
|
|
|
|
func GetProfileByUserOperation() IOperation {
|
|
|
|
return &getProfileByUserOperation{
|
2023-06-26 07:50:54 +00:00
|
|
|
runners: GetProfileByUserRunners{
|
|
|
|
GetProfileByUserService,
|
|
|
|
},
|
2022-11-16 09:05:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
func (operation *getProfileByUserOperation) Tag() string {
|
|
|
|
return "GET_PROFILE_BY_USER"
|
|
|
|
}
|
|
|
|
|
2022-11-16 09:05:26 +00:00
|
|
|
func (operation *getProfileByUserOperation) Id() (ID, ID) {
|
|
|
|
return GET_PROFILE_BY_USER_REQUEST, GET_PROFILE_BY_USER_RESULT
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *getProfileByUserOperation) InputContainer() Pointer {
|
|
|
|
return new(GetProfileByUserRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *getProfileByUserOperation) OutputContainer() Pointer {
|
|
|
|
return new(GetProfileByUserResult)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *getProfileByUserOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
2023-06-26 07:50:54 +00:00
|
|
|
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
|
|
|
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
|
|
|
}
|
|
|
|
|
|
|
|
service := operation.runners[operation.ActiveRunner()]
|
|
|
|
if input, valid := payload.(*GetProfileByUserRequest); valid {
|
|
|
|
return service(context, input)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
2022-11-16 09:05:26 +00:00
|
|
|
}
|