def deleteOneDevice(self,deviceId,userId): rows,isEof = database.db_select_sensor(deviceId=deviceId) for item in rows: self.deleteOneSensor(deviceId,item[0]) authManager.deviceRemove(deviceId) #remove from accessKey database.db_delete_device(deviceId) database.db_delete_deviceauth(userId,deviceId) privilegeM.priv_del(masterId=userId,object='device',objectId=deviceId,master='user')
def respBuilder_get_onedevice(dbRecord): responseApi = copy.deepcopy(restDef.RESTFUL_API[restDef.HTTP_RES['deviceOne']]['@GET']['RESP']) responseApi['id']=dbRecord[0] responseApi['name']=dbRecord[1] responseApi['description']=dbRecord[2] responseApi['regTime']=dbRecord[3] responseApi['local']=dbRecord[4] responseApi['latitude']=dbRecord[5] responseApi['longitude']=dbRecord[6] responseApi['userDefArea']=dbRecord[7] responseApi['userIdList'] = database.db_select_userlist_by_deviceid(responseApi['id']) (rows,isEof) = database.db_select_sensor(deviceId=responseApi['id'],num=100) for item in rows: responseApi['sensorList'].append(item[0]) responseApi['key'] = dbRecord[8] return responseApi
def _getResponse(self, request, pathPara): (rows,isEof) = database.db_select_sensor(id=pathPara[1],deviceId=pathPara[0]) if len(rows)<=0: return {} return msgbuilder.respBuilder_get_onesensor(rows[0])
def _getResponse(self, request, pathPara): (rows,isEof) = database.db_select_sensor(request['sort'], request['maxNum'], request['skipNum'], deviceId=pathPara[0]) return msgbuilder.respBuilder_get_sensor(rows, isEof)