131 lines
5.5 KiB
Go
131 lines
5.5 KiB
Go
package dto
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/Caknoooo/go-gin-clean-starter/database/entities"
|
|
"github.com/Caknoooo/go-gin-clean-starter/pkg/dto"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const (
|
|
// Failed
|
|
MESSAGE_FAILED_GET_DATA_FROM_BODY = "failed get data from body"
|
|
MESSAGE_FAILED_REGISTER_USER = "failed create user"
|
|
MESSAGE_FAILED_GET_LIST_USER = "failed get list user"
|
|
MESSAGE_FAILED_TOKEN_NOT_VALID = "token not valid"
|
|
MESSAGE_FAILED_TOKEN_NOT_FOUND = "token not found"
|
|
MESSAGE_FAILED_GET_USER = "failed get user"
|
|
MESSAGE_FAILED_LOGIN = "failed login"
|
|
MESSAGE_FAILED_UPDATE_USER = "failed update user"
|
|
MESSAGE_FAILED_DELETE_USER = "failed delete user"
|
|
MESSAGE_FAILED_PROSES_REQUEST = "failed proses request"
|
|
MESSAGE_FAILED_DENIED_ACCESS = "denied access"
|
|
MESSAGE_FAILED_VERIFY_EMAIL = "failed verify email"
|
|
|
|
// Success
|
|
MESSAGE_SUCCESS_REGISTER_USER = "success create user"
|
|
MESSAGE_SUCCESS_GET_LIST_USER = "success get list user"
|
|
MESSAGE_SUCCESS_GET_USER = "success get user"
|
|
MESSAGE_SUCCESS_LOGIN = "success login"
|
|
MESSAGE_SUCCESS_UPDATE_USER = "success update user"
|
|
MESSAGE_SUCCESS_DELETE_USER = "success delete user"
|
|
MESSAGE_SEND_VERIFICATION_EMAIL_SUCCESS = "success send verification email"
|
|
MESSAGE_SUCCESS_VERIFY_EMAIL = "success verify email"
|
|
)
|
|
|
|
var (
|
|
ErrCreateUser = errors.New("failed to create user")
|
|
ErrGetUserById = errors.New("failed to get user by id")
|
|
ErrGetUserByEmail = errors.New("failed to get user by email")
|
|
ErrEmailAlreadyExists = errors.New("email already exist")
|
|
ErrUpdateUser = errors.New("failed to update user")
|
|
ErrUserNotFound = errors.New("user not found")
|
|
ErrEmailNotFound = errors.New("email not found")
|
|
ErrDeleteUser = errors.New("failed to delete user")
|
|
ErrTokenInvalid = errors.New("token invalid")
|
|
ErrTokenExpired = errors.New("token expired")
|
|
ErrAccountAlreadyVerified = errors.New("account already verified")
|
|
)
|
|
|
|
type (
|
|
UserCreateRequest struct {
|
|
Name string `json:"name" form:"name" binding:"required,min=2,max=100"`
|
|
Username string `json:"username" form:"username" binding:"required,min=2,max=100"`
|
|
Password string `json:"password" form:"password" binding:"required,min=8"`
|
|
Gender string `json:"gender" form:"gender" binding:"omitempty,max=10"`
|
|
Address string `json:"address" form:"address" binding:"omitempty"`
|
|
Phone string `json:"phone" form:"phone" binding:"omitempty,min=8,max=20"`
|
|
Email string `json:"email" form:"email" binding:"required,email"`
|
|
PhotoUrl string `json:"photo_url" form:"photo_url" binding:"omitempty"`
|
|
ClientID uuid.UUID `json:"client_id" form:"client_id" binding:"required,uuid4"`
|
|
MaintenanceGroupUserID uuid.UUID `json:"maintenance_group_user_id" form:"maintenance_group_user_id" binding:"omitempty,uuid4"`
|
|
LocationID uuid.UUID `json:"location_id" form:"location_id" binding:"omitempty,uuid4"`
|
|
}
|
|
|
|
UserResponse struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password,omitempty"`
|
|
Gender string `json:"gender"`
|
|
Address string `json:"address"`
|
|
Phone string `json:"phone"`
|
|
Email string `json:"email"`
|
|
PhotoUrl string `json:"photo_url"`
|
|
}
|
|
|
|
UserPaginationResponse struct {
|
|
Data []UserResponse `json:"data"`
|
|
dto.PaginationResponse
|
|
}
|
|
|
|
GetAllUserRepositoryResponse struct {
|
|
Users []entities.User `json:"users"`
|
|
dto.PaginationResponse
|
|
}
|
|
|
|
UserUpdateRequest struct {
|
|
Name string `json:"name" form:"name" binding:"omitempty,min=2,max=100"`
|
|
Username string `json:"username" form:"username" binding:"omitempty,min=2,max=100"`
|
|
Password string `json:"password" form:"password" binding:"omitempty,min=8"`
|
|
Gender string `json:"gender" form:"gender" binding:"omitempty,max=10"`
|
|
Address string `json:"address" form:"address" binding:"omitempty"`
|
|
Phone string `json:"phone" form:"phone" binding:"omitempty,min=8,max=20"`
|
|
Email string `json:"email" form:"email" binding:"omitempty,email"`
|
|
PhotoUrl string `json:"photo_url" form:"photo_url" binding:"omitempty"`
|
|
ClientID uuid.UUID `json:"client_id" form:"client_id" binding:"omitempty,uuid4"`
|
|
MaintenanceGroupUserID uuid.UUID `json:"maintenance_group_user_id" form:"maintenance_group_user_id" binding:"omitempty,uuid4"`
|
|
LocationID uuid.UUID `json:"location_id" form:"location_id" binding:"omitempty,uuid4"`
|
|
}
|
|
|
|
UserUpdateResponse struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Username string `json:"username"`
|
|
Gender string `json:"gender"`
|
|
Address string `json:"address"`
|
|
Phone string `json:"phone"`
|
|
Email string `json:"email"`
|
|
PhotoUrl string `json:"photo_url"`
|
|
}
|
|
|
|
SendVerificationEmailRequest struct {
|
|
Email string `json:"email" form:"email" binding:"required"`
|
|
}
|
|
|
|
VerifyEmailRequest struct {
|
|
Token string `json:"token" form:"token" binding:"required"`
|
|
}
|
|
|
|
VerifyEmailResponse struct {
|
|
Email string `json:"email"`
|
|
IsVerified bool `json:"is_verified"`
|
|
}
|
|
|
|
UserLoginRequest struct {
|
|
Email string `json:"email" form:"email" binding:"required"`
|
|
Password string `json:"password" form:"password" binding:"required"`
|
|
}
|
|
)
|