wms-be/modules/client/dto/client_dto.go

55 lines
2.0 KiB
Go

package dto
import (
"errors"
)
const (
MESSAGE_FAILED_CREATE_CLIENT = "failed create client"
MESSAGE_SUCCESS_CREATE_CLIENT = "success create client"
MESSAGE_FAILED_GET_CLIENT = "failed get client"
MESSAGE_SUCCESS_GET_CLIENT = "success get client"
MESSAGE_FAILED_UPDATE_CLIENT = "failed update client"
MESSAGE_SUCCESS_UPDATE_CLIENT = "success update client"
MESSAGE_FAILED_DELETE_CLIENT = "failed delete client"
MESSAGE_SUCCESS_DELETE_CLIENT = "success delete client"
MESSAGE_FAILED_GET_DATA_FROM_BODY = "failed get data from body"
)
var (
ErrCreateClient = errors.New("failed to create client")
ErrGetClientById = errors.New("failed to get client by id")
ErrUpdateClient = errors.New("failed to update client")
ErrDeleteClient = errors.New("failed to delete client")
)
type (
ClientCreateRequest struct {
Name string `json:"name" form:"name" binding:"required,min=2,max=100"`
PIC string `json:"pic" form:"pic" binding:"omitempty,min=2,max=100"`
Phone string `json:"phone" form:"phone" binding:"omitempty,min=6,max=20"`
Email string `json:"email" form:"email" binding:"omitempty,email,max=100"`
Address string `json:"address" form:"address" binding:"omitempty"`
Logo string `form:"-"` // diisi manual dari file, tidak di-bind otomatis
}
ClientResponse struct {
ID string `json:"id"`
Name string `json:"name"`
PIC string `json:"pic"`
Phone string `json:"phone"`
Email string `json:"email"`
Address string `json:"address"`
Logo string `json:"logo"`
}
ClientUpdateRequest struct {
Name *string `json:"name" form:"name" binding:"omitempty,min=2,max=100"`
PIC *string `json:"pic" form:"pic" binding:"omitempty,min=2,max=100"`
Phone *string `json:"phone" form:"phone" binding:"omitempty,min=6,max=20"`
Email *string `json:"email" form:"email" binding:"omitempty,email,max=100"`
Address *string `json:"address" form:"address" binding:"omitempty"`
Logo *string `form:"-"` // jika update logo, isi manual dari file
}
)