package dto import ( "errors" "github.com/Caknoooo/go-gin-clean-starter/database/entities" pkgdto "github.com/Caknoooo/go-gin-clean-starter/pkg/dto" "github.com/google/uuid" ) const ( MESSAGE_FAILED_CREATE_AISLE = "failed create aisle" MESSAGE_SUCCESS_CREATE_AISLE = "success create aisle" MESSAGE_FAILED_GET_AISLE = "failed get aisle" MESSAGE_SUCCESS_GET_AISLE = "success get aisle" MESSAGE_FAILED_UPDATE_AISLE = "failed update aisle" MESSAGE_SUCCESS_UPDATE_AISLE = "success update aisle" MESSAGE_FAILED_DELETE_AISLE = "failed delete aisle" MESSAGE_SUCCESS_DELETE_AISLE = "success delete aisle" MESSAGE_FAILED_GET_DATA_FROM_BODY = "failed get data from body" ) var ( ErrCreateAisle = errors.New("failed to create aisle") ErrGetAisleById = errors.New("failed to get aisle by id") ErrUpdateAisle = errors.New("failed to update aisle") ErrDeleteAisle = errors.New("failed to delete aisle") ) type AisleCreateRequest struct { Code string `json:"code" binding:"required"` Name string `json:"name" binding:"required"` IsleX int `json:"isle_x"` BinY int `json:"bin_y"` LevelZ int `json:"level_z"` DimLength float64 `json:"dim_length"` DimWidth float64 `json:"dim_width"` DimHeight float64 `json:"dim_height"` Weight float64 `json:"weight"` QrCodeAisle string `json:"qr_code_aisle"` IsActive bool `json:"is_active"` ZoneID string `json:"zone_id" binding:"required"` DimUomID string `json:"dim_uom_id" binding:"required"` WeightUomID string `json:"weight_uom_id" binding:"required"` ClientID string `json:"client_id" binding:"required"` } type AisleUpdateRequest struct { Code string `json:"code"` Name string `json:"name"` IsleX int `json:"isle_x"` BinY int `json:"bin_y"` LevelZ int `json:"level_z"` DimLength float64 `json:"dim_length"` DimWidth float64 `json:"dim_width"` DimHeight float64 `json:"dim_height"` Weight float64 `json:"weight"` QrCodeAisle string `json:"qr_code_aisle"` IsActive bool `json:"is_active"` } type AisleResponse struct { ID string `json:"id"` Code string `json:"code"` Name string `json:"name"` IsleX int `json:"isle_x"` BinY int `json:"bin_y"` LevelZ int `json:"level_z"` DimLength float64 `json:"dim_length"` DimWidth float64 `json:"dim_width"` DimHeight float64 `json:"dim_height"` Weight float64 `json:"weight"` QrCodeAisle string `json:"qr_code_aisle"` IsActive bool `json:"is_active"` Zone pkgdto.IdNameResponse `json:"zone"` DimUom pkgdto.IdNameResponse `json:"dim_uom_id"` WeightUom pkgdto.IdNameResponse `json:"weight_uom_id"` Client pkgdto.IdNameResponse `json:"client_id"` } func ToAisleResponse(e entities.MAisleEntity) AisleResponse { zona := pkgdto.IdNameResponse{} if e.Zona.ID != uuid.Nil { zona.ID = e.Zona.ID.String() zona.Name = e.Zona.Name } dimUom := pkgdto.IdNameResponse{} if e.DimUom.ID != uuid.Nil { dimUom.ID = e.DimUom.ID.String() dimUom.Name = e.DimUom.Name } weightUom := pkgdto.IdNameResponse{} if e.WeightUom.ID != uuid.Nil { weightUom.ID = e.WeightUom.ID.String() weightUom.Name = e.WeightUom.Name } client := pkgdto.IdNameResponse{} if e.Client.ID != uuid.Nil { client.ID = e.Client.ID.String() client.Name = e.Client.Name } return AisleResponse{ ID: e.ID.String(), Code: e.Code, Name: e.Name, IsleX: e.IsleX, BinY: e.BinY, LevelZ: e.LevelZ, DimLength: e.DimLength, DimWidth: e.DimWidth, DimHeight: e.DimHeight, Weight: e.Weight, QrCodeAisle: e.QrCodeAisle, IsActive: e.IsActive, Zone: zona, DimUom: dimUom, WeightUom: weightUom, Client: client, } }