serviceNode_imp.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package imp
  2. import (
  3. "lot_interlligentControl/app/e"
  4. "lot_interlligentControl/global"
  5. "lot_interlligentControl/models"
  6. )
  7. type ServiceNodes struct{}
  8. func (s ServiceNodes) GetNode(uid int) ([]models.ServiceNodes, e.Rescode) {
  9. //TODO implement me
  10. var node []models.ServiceNodes
  11. tx := global.DBLink.Where("id = ?", uid).Or("state=?", true).Find(&node)
  12. if tx.RowsAffected > 0 {
  13. return node, e.SUCCESS
  14. }
  15. return node, e.ERROR
  16. }
  17. func (s ServiceNodes) UpdateServiceNodes(uid, id int, nodes models.ServiceNodesDto) e.Rescode {
  18. //TODO implement me
  19. tx := global.DBLink.Where("id = ?", id).Updates(&models.ServiceNodes{
  20. Address: nodes.Address,
  21. NodeName: nodes.NodeName,
  22. Tokey: nodes.Tokey,
  23. State: nodes.State,
  24. CreateBy: uid,
  25. })
  26. if tx.RowsAffected > 0 {
  27. return e.SUCCESS
  28. }
  29. return e.ERROR
  30. }
  31. func (s ServiceNodes) AddServiceNodes(uid int, nodes models.ServiceNodesDto) e.Rescode {
  32. //TODO implement me
  33. var nodesModel models.ServiceNodes
  34. nodesModel.Address = nodes.Address
  35. nodesModel.NodeName = nodes.NodeName
  36. nodesModel.Tokey = nodes.Tokey
  37. nodesModel.State = true
  38. nodesModel.CreateBy = uid
  39. tx := global.DBLink.Create(&nodesModel)
  40. if tx.RowsAffected > 0 {
  41. return e.SUCCESS
  42. }
  43. return e.ERROR
  44. }