119 lines
6.0 KiB
Go
119 lines
6.0 KiB
Go
package dto
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/Caknoooo/go-gin-clean-starter/pkg/dto"
|
|
)
|
|
|
|
const (
|
|
// Failed
|
|
MESSAGE_FAILED_GET_DATA_FROM_BODY = "failed get data from body"
|
|
MESSAGE_FAILED_REGISTER_MG = "failed create maintenance group"
|
|
MESSAGE_FAILED_GET_LIST_MG = "failed get list maintenance group"
|
|
MESSAGE_FAILED_TOKEN_NOT_VALID = "token not valid"
|
|
MESSAGE_FAILED_TOKEN_NOT_FOUND = "token not found"
|
|
MESSAGE_FAILED_GET_MG = "failed get maintenance group"
|
|
MESSAGE_FAILED_LOGIN = "failed login"
|
|
MESSAGE_FAILED_UPDATE_MG = "failed update maintenance group"
|
|
MESSAGE_FAILED_DELETE_MG = "failed delete maintenance group"
|
|
MESSAGE_FAILED_PROSES_REQUEST = "failed proses request"
|
|
MESSAGE_FAILED_DENIED_ACCESS = "denied access"
|
|
MESSAGE_FAILED_VERIFY_EMAIL = "failed verify email"
|
|
MESSAGE_FAILED_CREATE_MG = "failed create maintenance group"
|
|
|
|
// Success
|
|
MESSAGE_SUCCESS_REGISTER_MG = "success create maintenance group"
|
|
MESSAGE_SUCCESS_GET_LIST_MG = "success get list maintenance group"
|
|
MESSAGE_SUCCESS_GET_MG = "success get maintenance group"
|
|
MESSAGE_SUCCESS_LOGIN = "success login"
|
|
MESSAGE_SUCCESS_UPDATE_MG = "success update maintenance group"
|
|
MESSAGE_SUCCESS_DELETE_MG = "success delete maintenance group"
|
|
MESSAGE_SEND_VERIFICATION_EMAIL_SUCCESS = "success send verification email"
|
|
MESSAGE_SUCCESS_VERIFY_EMAIL = "success verify email"
|
|
MESSAGE_SUCCESS_CREATE_MENU = "success create menu"
|
|
)
|
|
|
|
var (
|
|
ErrInteralServer = errors.New("internal server error")
|
|
ErrCreateMG = errors.New("failed to create maintenance group")
|
|
ErrGetMGById = errors.New("failed to get maintenance group by id")
|
|
ErrGetMGByEmail = errors.New("failed to get maintenance group by email")
|
|
ErrEmailAlreadyExists = errors.New("email already exist")
|
|
ErrUpdateMG = errors.New("failed to update maintenance group")
|
|
ErrMGNotFound = errors.New("maintenance group not found")
|
|
ErrEmailNotFound = errors.New("email not found")
|
|
ErrDeleteMG = errors.New("failed to delete maintenance group")
|
|
ErrTokenInvalid = errors.New("token invalid")
|
|
ErrTokenExpired = errors.New("token expired")
|
|
ErrAccountAlreadyVerified = errors.New("account already verified")
|
|
ErrCodeCodeExists = errors.New("code already exists")
|
|
ErrNameAlreadyExists = errors.New("name already exists")
|
|
)
|
|
|
|
type (
|
|
MaintGroupCreateRequest struct {
|
|
Code string `json:"code" form:"code" binding:"required,min=2,max=50"`
|
|
Name string `json:"name" form:"name" binding:"required,min=2,max=100"`
|
|
Description string `json:"description" form:"description" binding:"omitempty"`
|
|
ClientID string `json:"client_id" form:"client_id" binding:"required,uuid4"`
|
|
MaintenanceGroupRoles []MaintenanceGroupRole `json:"maintenance_group_roles" form:"maintenance_group_roles" binding:"required,dive,required"`
|
|
}
|
|
|
|
MaintenanceGroupRole struct {
|
|
RoleID string `json:"role_id" form:"role_id" binding:"required,uuid4"`
|
|
Level *int `json:"level" form:"level" binding:"required"`
|
|
MaintenanceGroupRoleUsers []MaintenanceGroupRoleUser `json:"maintenance_group_role_users" form:"maintenance_group_role_users" binding:"required,dive,required"`
|
|
}
|
|
|
|
MaintenanceGroupRoleUser struct {
|
|
UserID string `json:"user_id" form:"user_id" binding:"required,uuid4"`
|
|
}
|
|
|
|
MaintGroupResponse struct {
|
|
ID string `json:"id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Client dto.ClientResponse `json:"client"`
|
|
MaintenanceGroupRoles *[]MaintenanceGroupRoleResponse `json:"maintenance_group_roles"`
|
|
}
|
|
|
|
MaintenanceGroupRoleResponse struct {
|
|
ID string `json:"id"`
|
|
Role dto.RoleResponse `json:"role"`
|
|
Level *int `json:"level"`
|
|
MaintenanceGroupRoleUsers []MaintenanceGroupRoleUserResponse `json:"maintenance_group_role_users"`
|
|
}
|
|
|
|
MaintenanceGroupRoleUserResponse struct {
|
|
ID string `json:"id"`
|
|
User dto.UserResponse `json:"user"`
|
|
}
|
|
|
|
GetAllMaintenanceGroupResponse struct {
|
|
MaintenanceGroups []MaintGroupResponse `json:"maintenance_groups"`
|
|
dto.PaginationResponse
|
|
}
|
|
|
|
MaintGroupUpdateRequest struct {
|
|
Code *string `json:"code" form:"code" binding:"omitempty,min=2,max=50"`
|
|
Name *string `json:"name" form:"name" binding:"omitempty,min=2,max=100"`
|
|
Description *string `json:"description" form:"description" binding:"omitempty"`
|
|
ClientID *string `json:"client_id" form:"client_id" binding:"omitempty,uuid4"`
|
|
MaintenanceGroupRoles *[]MaintenanceGroupRoleUpdate `json:"maintenance_group_roles" form:"maintenance_group_roles" binding:"omitempty,dive"`
|
|
}
|
|
|
|
MaintenanceGroupRoleUpdate struct {
|
|
ID *string `json:"id" form:"id" binding:"omitempty,uuid4"`
|
|
RoleID *string `json:"role_id" form:"role_id" binding:"omitempty,uuid4"`
|
|
MaintenanceGroupRoleUsers *[]MaintenanceGroupRoleUser `json:"maintenance_group_role_users" form:"maintenance_group_role_users" binding:"omitempty,dive"`
|
|
Level *int `json:"level" form:"level" binding:"omitempty"`
|
|
}
|
|
|
|
MaintenanceGroupRoleUserUpdate struct {
|
|
ID *string `json:"id" form:"id" binding:"omitempty,uuid4"`
|
|
UserID *string `json:"user_id" form:"user_id" binding:"omitempty,uuid4"`
|
|
}
|
|
)
|