def get_is_data(): userid = request.args.get('userID') eq_id = request.args.get('equipID') user_name = r.get(userid) wu = wx_user.query.filter(wx_user.name == user_name).first() #获取用户名 wxuser_id = wu.id #获取用户ID sql='select image_id from information where user_id=%s and equip_id=%s' %(wxuser_id,eq_id) cursor.execute(sql) image_id=cursor.fetchall() all_id=[] unread_id=[] for (i,) in image_id: unread_id.append(i) imgs_id = srch_hash_data('upload_img','equip_id',eq_id) for i in imgs_id: all_id.append(i) # 将所有的图片id减去未读图片的id获得已读图片的ID is_id=set(all_id)-set(unread_id) read_arr=[] for i in is_id: read_data = srch_hash_data('upload_img','id',str(i)) read_arr.append(read_data[0][0]) read_arr.append(read_data[0][1]) read_arr.append(read_data[0][2]) json_data=json.dumps(read_arr,cls=CJsonEncoder) return json_data
def delete(): types = request.form.getlist('types') types = ''.join(types) q = request.form.getlist('id') json_data = srch_hash_data(types,'delete',q) return json_data
def del_unread_data(): userid = request.args.get('userID') infor_id = request.args.get('inforID') read_flag = request.args.get('read_flag') if read_flag == 'unread_id': user_name = r.get(userid) wu = wx_user.query.filter(wx_user.name == user_name).first() #获取用户名 wxuser_id = wu.id #获取用户ID sql='delete from information where image_id=%s and user_id=%s' %(infor_id,wxuser_id) cursor.execute(sql) database.commit() data = srch_hash_data('imgs','id',infor_id) return data
def changedata(): userid = request.args.get('id') name = request.args.get('name') phone = request.args.get('phone') email = request.args.get('email') u_name = '\'%s\'' % name u_phone = '\'%s\'' % phone u_mail = '\'%s\'' % email if len(r.keys('wx_user*')) != 0: for k in r.scan_iter('wx_user*'): r_userid = r.hget(k, 'id') if userid == r_userid: print("更新缓存") user_infor = {'name': name, 'phone': phone, 'email': email} r.hmset(k, user_infor) sql = 'update wx_user set name=%s,phone=%s,email=%s where id=%s' % ( u_name, u_phone, u_mail, userid) cursor.execute(sql) database.commit() json_data = srch_hash_data('wx_user', 'init', 'None') return json_data
def get_equip_detail_data(): equip_unread_data = srch_hash_data('equipment','init','None') return equip_unread_data
def getimagedata(): imgsData = srch_hash_data('upload_img','init','') return imgsData
def imgdata(): searchname = request.args.get('name') types = request.args.get('types') json_data = srch_hash_data(types,'name',searchname) return json_data
def srch_time(): time = request.args.get('time') types = request.args.get('types') json_data = srch_hash_data(types,'date',time) return json_data
def getuserval(): userid = request.args.get('userID') userData = srch_hash_data('wx_user', 'name', r.get(userid)) return userData
def getuserdata(): json_data = srch_hash_data('wx_user', 'init', 'None') return json_data