def post(self,request):  #post many data format is [bookscancode,bookscancode.....]
     #do not need authorized
     #if not request.user.is_authenticated():
     #    statusMessage={'status':'refuse'}
     #    return Response(statusMessage,status=status.HTTP_400_BAD_REQUEST)
     bookRfidCodeListTmp= request.data.get('bookScanCode') #list contain unicode string
     bookRfidCodeList=[item.encode('utf-8') for item in bookRfidCodeListTmp] #convert to stand string
     bookDb=Dblibrary()
     locationDb=DbLocation()  #this is class for query book location
     bookNameList=[bookDb.getBookNameByRfidCode(item) for item in bookRfidCodeList]  #get book name
     #print bookNameList
     bookOnShelfList=[locationDb.getBookOnShelf(item) for item in bookRfidCodeList] #get book on shelf
     #print bookOnShelfList
     bookLocationList=[locationDb.getBookLocation(item) for item in bookRfidCodeList] #get book location
     #print bookLocationList
     bookInformationList=[]
     for code,name,shelf,location in zip(bookRfidCodeList,bookNameList,bookOnShelfList,bookLocationList):
         oneBook={}
         oneBook['bookRfidCode']=code.decode('utf-8')
         oneBook['bookName']=name.decode('utf-8')
         oneBook['bookOnShelf']=shelf.decode('utf-8')
         oneBook['bookLocation']=location.decode('utf-8')
         bookInformationList.append(oneBook)
     bookInformation={}
     bookInformation['book']=bookInformationList
     jsonString=json.dumps(bookInformation)        
     #print jsonString        
     statusMessage={'status':'success'}
     return Response(jsonString,status=status.HTTP_200_OK)
 def post(self,request):
     # do authentication,if not login ,the information will not be save
     #if not request.user.is_authenticated():
     #    statusMessage={'status':'refuse'}
     #    return Response(statusMessage,status=status.HTTP_400_BAD_REQUEST)
     try:
         bookLocationListTmp=request.data.get('location')
         bookRfidList=[item.get('bookRfidCode').encode('utf-8') for item in bookLocationListTmp]
         shelfRfidList=[item.get('shelfRfidCode').encode('utf-8') for item in bookLocationListTmp]
         #print bookRfidList
         #print shelfRfidList
         locationQuery=DbLocation()
         locationQuery.saveBookListRelationWithShelfList(bookRfidList, shelfRfidList)
         statusMessage={'status':'good'}
     except LocationQueryException:
         print 'exception'
         statusMessage={'status':'refuse'}
     return Response(statusMessage,status=status.HTTP_200_OK)