func (s *InventoryService) CreateInventory(m *model.Inventory) (*model.Inventory, error) {
	if m == nil {
		panic("Inventory can't be null!")
	}
	m.CreateTime = time.Now()
	// m.PrepareToSave() // prepare to save, create time...
	return inventorydao.Create(m)
}
Exemple #2
0
func Create(m *model.Inventory) (*model.Inventory, error) {
	res, err := em.Insert().Exec(
		m.GroupId, m.ProductId, m.Color, m.Size, m.Stock, m.ProviderId, m.OperatorId,
		m.Status, m.Type, m.Note, m.SendTime, m.ReceiveTime, m.CreateTime,
	)
	if err != nil {
		return nil, err
	}
	liid, err := res.LastInsertId()
	m.Id = liid
	return m, nil
}