package imp import ( "lot_interlligentControl/app/e" "lot_interlligentControl/global" "lot_interlligentControl/models" ) type ServiceNodes struct{} func (s ServiceNodes) GetNode(uid int) ([]models.ServiceNodes, e.Rescode) { //TODO implement me var node []models.ServiceNodes tx := global.DBLink.Where("id = ?", uid).Or("state=?", true).Find(&node) if tx.RowsAffected > 0 { return node, e.SUCCESS } return node, e.ERROR } func (s ServiceNodes) UpdateServiceNodes(uid, id int, nodes models.ServiceNodesDto) e.Rescode { //TODO implement me tx := global.DBLink.Where("id = ?", id).Updates(&models.ServiceNodes{ Address: nodes.Address, NodeName: nodes.NodeName, Tokey: nodes.Tokey, State: nodes.State, CreateBy: uid, }) if tx.RowsAffected > 0 { return e.SUCCESS } return e.ERROR } func (s ServiceNodes) AddServiceNodes(uid int, nodes models.ServiceNodesDto) e.Rescode { //TODO implement me var nodesModel models.ServiceNodes nodesModel.Address = nodes.Address nodesModel.NodeName = nodes.NodeName nodesModel.Tokey = nodes.Tokey nodesModel.State = true nodesModel.CreateBy = uid tx := global.DBLink.Create(&nodesModel) if tx.RowsAffected > 0 { return e.SUCCESS } return e.ERROR }