product_imp.go 758 B

123456789101112131415161718192021222324252627282930313233
  1. package imp
  2. import (
  3. "lot_interlligentControl/app/e"
  4. "lot_interlligentControl/global"
  5. "lot_interlligentControl/models"
  6. )
  7. type Product struct{}
  8. func (p Product) UpdateProduct(uid, id int, product models.ProductDto) e.Rescode {
  9. //TODO implement me
  10. tx := global.DBLink.Model(&models.Product{}).Where("id = ?", id).Updates(models.Product{
  11. ProductType: product.ProductType,
  12. CreateBy: uid,
  13. })
  14. if tx.RowsAffected > 0 {
  15. return e.SUCCESS
  16. }
  17. return e.ERROR
  18. }
  19. func (p Product) AddProduct(uid int, product models.ProductDto) e.Rescode {
  20. //TODO implement me
  21. var produ models.Product
  22. produ.ProductType = product.ProductType
  23. produ.CreateBy = uid
  24. tx := global.DBLink.Create(&produ)
  25. if tx.RowsAffected > 0 {
  26. return e.SUCCESS
  27. }
  28. return e.ERROR
  29. }