def delStation(inData): ''' :param: inData :return: {1:'success', 2:'failed', 3:'permission denied', 4:'param wrong'} ''' from user import User from sensor import Sensor if(('UserId' in inData) and ('StationId' in inData)): updateUserLevel = session.query( User.level).filter( User.id == inData['UserId'], User.valid == 1).first() if(updateUserLevel is None or int(updateUserLevel[0] != 0)): return 3 else: session.query(Station).filter(Station.id == inData['StationId'], Station.valid == 1).update( {'valid': 0, 'time': datetime.now()}) delSensorId = session.query( Sensor.id).filter( Sensor.stationId == inData['StationId'], Sensor.valid == 1).all() for sensorId in delSensorId: Sensor.delSensor( {'UserId': inData['UserId'], 'SensorId': int(sensorId[0])}) session.commit() return 1 else: return 4
def delStation(inData): ''' :param: inData :return: {1:'success', 2:'failed', 3:'permission denied', 4:'param wrong'} ''' from user import User from sensor import Sensor if(('UserId' in inData) and ('StationId' in inData)): updateUserLevel = session.query(User.level).filter(User.id == inData['UserId'], User.valid == 1).first() if(updateUserLevel == None or int(updateUserLevel[0] != 0)): return 3 else: session.query(Station).filter(Station.id == inData['StationId'], Station.valid == 1).update({'valid':0, 'time':datetime.now()}) delSensorId = session.query(Sensor.id).filter(Sensor.stationId == inData['StationId'], Sensor.valid == 1).all() for sensorId in delSensorId: Sensor.delSensor({'UserId':inData['UserId'], 'SensorId':int(sensorId[0])}) session.commit() return 1 else: return 4
from sensor import Sensor #ret=Sensor.check('sensor-name-test', 'sensor-number-test', 'sesnor-ip-test', 'sensor-mac-test', 1) #ret = Sensor.check('') #ret = Sensor.updateSensor({'UserId':2,'SensorId':2, 'Mac':'qe:rq:tq'}) ret = Sensor.delSensor({'UserId':2, 'SensorId':2}) print(ret) #tmp=Sensor.info({}) #print('111') #print(tmp)
from sensor import Sensor #ret=Sensor.check('sensor-name-test', 'sensor-number-test', 'sesnor-ip-test', 'sensor-mac-test', 1) #ret = Sensor.check('') #ret = Sensor.updateSensor({'UserId':2,'SensorId':2, 'Mac':'qe:rq:tq'}) ret = Sensor.delSensor({'UserId': 2, 'SensorId': 2}) print(ret) # tmp=Sensor.info({}) # print('111') # print(tmp)