mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
add api get list stock log by product warehouse id
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
|
||||
)
|
||||
|
||||
type StockLogListDTO struct {
|
||||
Id uint `json:"id"`
|
||||
ProductWarehouseId uint `json:"product_warehouse_id"`
|
||||
Increase float64 `json:"increase"`
|
||||
Decrease float64 `json:"decrease"`
|
||||
Stock float64 `json:"stock"`
|
||||
LoggableType string `json:"loggable_type"`
|
||||
LoggableId uint `json:"loggable_id"`
|
||||
Notes *string `json:"notes"`
|
||||
CreatedBy uint `json:"created_by"`
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func ToStockLogListDTO(e entity.StockLog) StockLogListDTO {
|
||||
var notes *string
|
||||
if e.Notes != "" {
|
||||
n := e.Notes
|
||||
notes = &n
|
||||
}
|
||||
|
||||
var createdUser *userDTO.UserRelationDTO
|
||||
if e.CreatedUser != nil && e.CreatedUser.Id != 0 {
|
||||
mapped := userDTO.ToUserRelationDTO(*e.CreatedUser)
|
||||
createdUser = &mapped
|
||||
}
|
||||
|
||||
return StockLogListDTO{
|
||||
Id: e.Id,
|
||||
ProductWarehouseId: e.ProductWarehouseId,
|
||||
Increase: e.Increase,
|
||||
Decrease: e.Decrease,
|
||||
Stock: e.Stock,
|
||||
LoggableType: e.LoggableType,
|
||||
LoggableId: e.LoggableId,
|
||||
Notes: notes,
|
||||
CreatedBy: e.CreatedBy,
|
||||
CreatedUser: createdUser,
|
||||
CreatedAt: e.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func ToStockLogListDTOs(e []entity.StockLog) []StockLogListDTO {
|
||||
if len(e) == 0 {
|
||||
return []StockLogListDTO{}
|
||||
}
|
||||
result := make([]StockLogListDTO, len(e))
|
||||
for i, log := range e {
|
||||
result[i] = ToStockLogListDTO(log)
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user