def setjiage(request): result={} if request.method == "POST": key = request.POST.get("key", None) # 读取post数据,None为默认值 jiage = float(request.POST.get("jiage", None)) # 读取post数据,None为默认值 print("修改价格:", request.POST) if request.method == "GET": key = request.GET.get("key", None) # 读取get数据,None为默认值 jiage = float(request.GET.get("jiage", None)) # 读取get数据,None为默认值 print("修改价格:", request.GET) try: qun = QunDAO.getqunInfoqunid(999) try: jsonobj=json.loads(qun.gonggao.replace('\'','"')) # python中json转换不支持单引号,所以需要将所有单引号换成双引号 except Exception as e: print('公告转化为json出错:',e) jsonobj={} if(key in jsonobj): #如果价格为0,就删除 jsonobj.pop(key) if(jiage>0): jsonobj[key] = str(jiage) #添加修改值 qun.gonggao = str(jsonobj) QunDAO.updatequnInfoqun(qun) #清除从公告中加载的数据 allname.clear() allqiye.clear() allchanpin.clear() allbank.clear() alljiage.clear() result["data"]= "0" result["respcode"]= ResultCode.SUCCESS result["errorcode"]= "" result["message"]= "修改价格成功" print('修改价格成功') except Exception as e: print('设置价格出错',e) result["data"]="0" result["respcode"]=ResultCode.FAIL result["errorcode"]= ResultCode.FAIL result["message"]= "修改价格失败" print('修改价格失败') return JsonResponse(result)
def updateuserstate(request): result = {} if request.method == "POST": userid = request.POST.get("userid", None) # 读取get数据,None为默认值 qunid = request.POST.get("qunid", None) # 读取get数据,None为默认值 userstate = request.POST.get("userstate", None) # 读取get数据,None为默认值 if request.method == "GET": userid = request.GET.get("userid", None) # 读取get数据,None为默认值 qunid = request.GET.get("qunid", None) # 读取get数据,None为默认值 userstate = request.GET.get("userstate", None) # 读取get数据,None为默认值 print("修改用户在群组中的状态接口参数:用户id", userid, "用户状态", userstate) user_receive = UserDAO.getUserInfoId(userid) user_receive.state = userstate UserDAO.updateUserInfo(user_receive) qun = QunDAO.getqunInfoqunid(qunid) userqun = Userqun() userqun.userid = userid userqun.qunid = qunid userqun = UserqunDAO.getuserqunInfouserqun(userqun) if (not userqun or not qun): result["data"] = "" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "修改失败" print('修改失败') return JsonResponse(result) userqun.userstate = userstate UserqunDAO.updateuserqun(userqun) # 如果升级为群主 if (userstate == ResultCode.USERQUN_QUNZHU): # 查找原群主关系组 userqun.userid = qun.userid userqun.qunid = qunid userqun = UserqunDAO.getuserqunInfouserqun(userqun) userqun.userstate = ResultCode.USERQUN_FUZHU UserqunDAO.updateuserqun(userqun) # 修改群信息 qun.userid = userid QunDAO.updatequnInfoqun(qun) result["data"] = "" result["respcode"] = ResultCode.SUCCESS result["errorcode"] = "" result["message"] = "修改成功" print('修改成功') return JsonResponse(result)
def queryAllchatuser(request): #第一层的结果集 result = {} allchatuser_back = [] if request.method == "POST": receive_id = request.POST.get("receive_id", None) # 读取post数据,None为默认值 if request.method == "GET": receive_id = request.GET.get("receive_id", None) # 读取post数据,None为默认值 print("查询所有聊天用户接口参数:接收者ID", receive_id) try: allchatuser = ChatuserDAO.queryallchatuser(receive_id) if (allchatuser and len(allchatuser) > 0): userreceive = fun.user2else_back(UserDAO.getUserInfoId(receive_id)) for chatuser in allchatuser: print("查询到总数为", len(allchatuser)) if (chatuser.state != ResultCode.CHATUSER_HIDE): #如果不隐藏该关系的话 chatuser_back = fun.chatuser2back(chatuser) #如果是私信 if (chatuser_back['usertype'] == ResultCode.CHATUSER_TYPE_SEND or chatuser_back['usertype'] == ResultCode.CHATUSER_TYPE_RECEIVE): usertemp = UserDAO.getUserInfoId( chatuser_back['send_id']) chatuser_back['send_user'] = fun.user2else_back( usertemp) chatuser_back['receive_user'] = userreceive allchatuser_back.append(chatuser_back) #如果是群聊 if (chatuser_back['usertype'] == ResultCode.CHATUSER_TYPE_QUN): quntemp = QunDAO.getqunInfoqunid(chatuser_back.send_id) chatuser_back['qun'] = model_to_dict(quntemp) chatuser_back['receive_user'] = userreceive allchatuser_back.append(chatuser_back) result["message"] = "查询成功" result["data"] = allchatuser_back result["errorcode"] = "" result["respcode"] = ResultCode.SUCCESS print("查询成功数目", len(allchatuser_back)) except Exception as e: print(e) result["message"] = "查询失败" result["data"] = "" result["errorcode"] = ResultCode.FAIL result["respcode"] = ResultCode.FAIL print("查询失败") return JsonResponse(result)
def getdiaryurl(request): global urlpath if request.method == "POST": diaryid = request.POST.get("diaryid", None) # 读取post数据,None为默认值 if request.method == "GET": diaryid = request.GET.get("diaryid", None) # 读取post数据,None为默认值 print("web查看日志(链接)接口参数:日志id:", diaryid) diary = DiaryDAO.selectDiary(diaryid) if (diary): diary.tuijiannum = diary.tuijiannum + 1 DiaryDAO.updatediary(diary) qun = QunDAO.getqunInfoqunid(diary.qunid) if (diary.diarytype == ResultCode.CONTENT_TYPEURL): filepath = diary.urlcontent if (filepath and not filepath == ''): realPath = request.getSession().getServletContext( ).getRealPath("") htmlfile = open(realPath + filepath) contentstr = htmlfile.readlines() contentstr = contentstr.replace('src="/', 'src="' + urlpath + '/') dict = { 'contentstr': contentstr, 'title': diary.urltitle, 'paper_time': diary.date, 'paper_qun': qun.aname, 'tuijian_num': str(diary.tuijiannum), } return render_to_response("diaryurl_back.html", dict) # 返回文件响应,第二个参数必须为字典 else: pass
def user2meBack(user): user_me_back = {} user_me_back['id'] = user.id user_me_back['qunid'] = user.qunid user_me_back['usertype'] = user.usertype user_me_back['identity'] = user.identity user_me_back['state'] = user.state user_me_back['phone'] = user.phone user_me_back['userIcon'] = user.image user_me_back['name'] = user.name user_me_back['email'] = user.email user_me_back['id_number'] = user.id_number user_me_back['address'] = user.address user_me_back['school'] = user.school user_me_back['gold'] = user.gold user_me_back['zannum'] = user.zannum user_me_back['tuijiannum'] = user.tuijiannum user_me_back['commentnum'] = user.commentnum user_me_back['shoucangnum'] = user.shoucangnum user_me_back['wechat'] = user.wechat user_me_back['alipay'] = user.alipay user_me_back['parameter1'] = user.parameter1 user_me_back['parameter2'] = user.parameter2 user_me_back['parameter3'] = user.parameter3 user_me_back['parameter4'] = user.parameter4 user_me_back['parameter5'] = user.parameter5 user_me_back['parameter6'] = user.parameter6 user_me_back['parameter7'] = user.parameter7 user_me_back['parameter8'] = user.parameter8 user_me_back['parameter9'] = user.parameter9 user_me_back['parameter10'] = user.parameter10 user_me_back['parameter11'] = user.parameter11 user_me_back['parameter12'] = user.parameter12 user_me_back['parameter13'] = user.parameter13 user_me_back['parameter14'] = user.parameter14 user_me_back['parameter15'] = user.parameter15 user_me_back['parameter16'] = user.parameter16 user_me_back['parameter17'] = user.parameter17 user_me_back['parameter18'] = user.parameter18 user_me_back['parameter19'] = user.parameter19 user_me_back['parameter20'] = user.parameter20 try: allqun = [] # =====================获取自己加入的群组,在群组社交中使用==================== if (ResultCode.app_name == "群组社交"): allUserquns = UserqunDAO.getqunInfouserid(user.id) if (allUserquns): for i in range(len(allUserquns)): quntemp = QunDAO.getqunInfoqunid(allUserquns[i].qunid) if (not quntemp): # 说明群已经删了 UserqunDAO.deluserqunforid(allUserquns[i].id) diary = Diary() diary.userid = user.id diary.qunid = allUserquns[i].qunid diary.state = ResultCode.DIARY_JUST_ME diary.type = fun.daqun().type1 DiaryDAO.updatediaryforqunid(diary) else: quntemp.userstate = allUserquns[i].userstate allqun.append(quntemp) # ============================获取自己创建的群组 在爱吃系统中使用========================== if (ResultCode.app_name == "爱吃"): quntemp = QunDAO.getqunInfoqunid(user.qunid) if (quntemp): # 说明群已经删了 quntemp.userstate = ResultCode.USERQUN_QUNZHU allqun.append(quntemp) # print("用户不包含公共平台,共有群组数目"+allqun.size()) # 创建一个自由群 草稿 全网 # allqun.append(fun.daqun()) user_me_back['allQun'] = fun.allqun2back(allqun) except Exception as e: print(e) return user_me_back
def login(request): result = {} user = User() if request.method == "POST": phone = request.POST.get("phone", None) # 读取get数据,None为默认值 password = request.POST.get("password", None) # 读取get数据,None为默认值 identity = request.POST.get("identity", None) # 读取get数据,None为默认值 school = request.POST.get("school", None) # 读取get数据,None为默认值 qunid = request.POST.get("qunid", 0) # 读取get数据,None为默认值 if request.method == "GET": phone = request.GET.get("phone", None) # 读取get数据,None为默认值 password = request.GET.get("password", None) # 读取get数据,None为默认值 identity = request.GET.get("identity", None) # 读取get数据,None为默认值 school = request.GET.get("school", None) # 读取get数据,None为默认值 qunid = request.GET.get("qunid", 0) # 读取get数据,None为默认值 print("用户登录接口参数:电话", phone, "密码", password) user.phone = phone user.password = password user = UserDAO.login(user) if (user): if (identity): user.identity = identity if (school): user.school = school UserDAO.updateUserInfo(user) # 如果登陆时需要加入群组,这里加入群组 if (qunid): try: qun = QunDAO.getqunInfoqunid(qunid) userqun = Userqun() userqun.userid = user.id userqun.qunid = qunid userquntemp = UserqunDAO.getuserqunInfouserqun(userqun) if (not userquntemp): if (qun.quntype == ResultCode.QUN_USER or qun.quntype == ResultCode.QUN_USER_DIARY or qun.quntype == ResultCode.QUN_USER_DIARY_NOT_USER): userqun.userstate = ResultCode.USERQUN_NOT else: userqun.userstate = ResultCode.USERQUN_YUAN UserqunDAO.adduserqun(userqun) # 添加群聊关系 chatuser = Chatuser() chatuser.send_id = qunid chatuser.receive_id = user.id chatuser.usertype = ResultCode.CHATUSER_TYPE_QUN chatuser.state = ResultCode.CHATUSER_HIDE chatuser.abid = str(qunid) chatuser.content = "" chatuser.time = TimeUtil.getCurrentTime() chatuser.date = TimeUtil.getCurrentDate() ChatuserDAO.addchatuser(chatuser) except Exception as e: print(e) user_me_back = user2meBack(user) # appBean = AppVersionDAO.queryVersionById(1) # 这里要求数据库中首先在版本表中存在版本的相关信息 result["data"] = user_me_back result["respcode"] = ResultCode.SUCCESS result["errorcode"] = "" result["message"] = "登陆成功" print('登陆成功') else: result["data"] = "" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "账号或密码错误" print('账号密码错误') return JsonResponse(result)
def userRegist(request): user = User() result = {} if request.method == "POST": phone = request.POST.get("phone", None) # 读取post数据,None为默认值 qunid = request.POST.get("qunid", 0) # 读取get数据,None为默认值 password = request.POST.get("password", None) # 读取post数据,None为默认值 name = request.POST.get("name", None) # 读取post数据,None为默认值 identity = request.POST.get("identity", None) # 读取post数据,None为默认值 email = request.POST.get("email", None) # 读取post数据,None为默认值 address = request.POST.get("address", None) # 读取post数据,None为默认值 school = request.POST.get("school", None) # 读取post数据,None为默认值 usertype = request.POST.get("usertype", 0) # 读取post数据,None为默认值 usericon = request.POST.get("usericon", None) # 读取get数据,None为默认值 wechat = request.POST.get("wechat", None) # 读取get数据,None为默认值 alipay = request.POST.get("alipay", None) # 读取get数据,None为默认值 parameter1 = request.POST.get("parameter1", None) # 读取get数据,None为默认值 parameter2 = request.POST.get("parameter2", None) # 读取get数据,None为默认值 parameter3 = request.POST.get("parameter3", None) # 读取get数据,None为默认值 parameter4 = request.POST.get("parameter4", None) # 读取get数据,None为默认值 parameter5 = request.POST.get("parameter5", None) # 读取get数据,None为默认值 parameter6 = request.POST.get("parameter6", None) # 读取get数据,None为默认值 parameter7 = request.POST.get("parameter7", None) # 读取get数据,None为默认值 parameter8 = request.POST.get("parameter8", None) # 读取get数据,None为默认值 parameter9 = request.POST.get("parameter9", None) # 读取get数据,None为默认值 parameter10 = request.POST.get("parameter10", None) # 读取get数据,None为默认值 parameter11 = request.POST.get("parameter11", None) # 读取get数据,None为默认值 parameter12 = request.POST.get("parameter12", None) # 读取get数据,None为默认值 parameter13 = request.POST.get("parameter13", None) # 读取get数据,None为默认值 parameter14 = request.POST.get("parameter14", None) # 读取get数据,None为默认值 parameter15 = request.POST.get("parameter15", None) # 读取get数据,None为默认值 parameter16 = request.POST.get("parameter16", None) # 读取get数据,None为默认值 parameter17 = request.POST.get("parameter17", None) # 读取get数据,None为默认值 parameter18 = request.POST.get("parameter18", None) # 读取get数据,None为默认值 parameter19 = request.POST.get("parameter19", None) # 读取get数据,None为默认值 parameter20 = request.POST.get("parameter20", None) # 读取get数据,None为默认值 if request.method == "GET": phone = request.GET.get("phone", None) # 读取get数据,None为默认值 qunid = request.GET.get("qunid", 0) # 读取get数据,None为默认值 password = request.GET.get("password", None) # 读取get数据,None为默认值 name = request.GET.get("name", None) # 读取get数据,None为默认值 identity = request.GET.get("identity", None) # 读取get数据,None为默认值 email = request.GET.get("email", None) # 读取get数据,None为默认值 address = request.GET.get("address", None) # 读取get数据,None为默认值 school = request.GET.get("school", None) # 读取get数据,None为默认值 usertype = request.GET.get("usertype", 0) # 读取post数据,None为默认值 usericon = request.GET.get("usericon", None) # 读取get数据,None为默认值 wechat = request.GET.get("wechat", None) # 读取get数据,None为默认值 alipay = request.GET.get("alipay", None) # 读取get数据,None为默认值 parameter1 = request.GET.get("parameter1", None) # 读取get数据,None为默认值 parameter2 = request.GET.get("parameter2", None) # 读取get数据,None为默认值 parameter3 = request.GET.get("parameter3", None) # 读取get数据,None为默认值 parameter4 = request.GET.get("parameter4", None) # 读取get数据,None为默认值 parameter5 = request.GET.get("parameter5", None) # 读取get数据,None为默认值 parameter6 = request.GET.get("parameter6", None) # 读取get数据,None为默认值 parameter7 = request.GET.get("parameter7", None) # 读取get数据,None为默认值 parameter8 = request.GET.get("parameter8", None) # 读取get数据,None为默认值 parameter9 = request.GET.get("parameter9", None) # 读取get数据,None为默认值 parameter10 = request.GET.get("parameter10", None) # 读取get数据,None为默认值 parameter11 = request.GET.get("parameter11", None) # 读取get数据,None为默认值 parameter12 = request.GET.get("parameter12", None) # 读取get数据,None为默认值 parameter13 = request.GET.get("parameter13", None) # 读取get数据,None为默认值 parameter14 = request.GET.get("parameter14", None) # 读取get数据,None为默认值 parameter15 = request.GET.get("parameter15", None) # 读取get数据,None为默认值 parameter16 = request.GET.get("parameter16", None) # 读取get数据,None为默认值 parameter17 = request.GET.get("parameter17", None) # 读取get数据,None为默认值 parameter18 = request.GET.get("parameter18", None) # 读取get数据,None为默认值 parameter19 = request.GET.get("parameter19", None) # 读取get数据,None为默认值 parameter20 = request.GET.get("parameter20", None) # 读取get数据,None为默认值 print("注册用户接口参数:电话", phone, "密码", password, "名称:", name) if (not phone or not password): result["data"] = "" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "注册失败,电话密码不能为空" print("注册失败,电话密码不能为空") return JsonResponse(result) # 先查询手机号是否已经注册过了 u = UserDAO.queryuserforphone(phone) if u: result["data"] = ResultCode.FAIL result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.USEREXIST result["message"] = "注册失败,用户已经存在" print("注册失败用户存在") else: # u1 = UserDAO.queryUserForidentity(identity) # if u1: # result["data"] = ResultCode.FAIL # result["respcode"] = ResultCode.FAIL # result["errorcode"] = ResultCode.USEREXIST # result["message"] = "注册失败,该用户已经注册过一次" # else: user.usertype = usertype if (usertype == 0): user.state = ResultCode.USERQUN_NOT # 客户从手机端注册,,默认为未审核 if (usertype == 1): user.state = ResultCode.USERQUN_QUNZHU # 代理商从pc端注册,默认为审核 user.image = usericon user.email = email user.phone = phone user.password = password user.name = name user.address = address user.school = school user.identity = identity user.wechat = wechat user.alipay = alipay user.parameter1 = parameter1 user.parameter2 = parameter2 user.parameter3 = parameter3 user.parameter4 = parameter4 user.parameter5 = parameter5 user.parameter6 = parameter6 user.parameter7 = parameter7 user.parameter8 = parameter8 user.parameter9 = parameter9 user.parameter10 = parameter10 user.parameter11 = parameter11 user.parameter12 = parameter12 user.parameter13 = parameter13 user.parameter14 = parameter14 user.parameter15 = parameter15 user.parameter16 = parameter16 user.parameter17 = parameter17 user.parameter18 = parameter18 user.parameter19 = parameter19 user.parameter20 = parameter20 UserDAO.regist(user) # 注册函数 无返回值 users = UserDAO.login(user) # 同时登陆,返回数据,尤其是ID号 # 如果注册时需要加入群组,这里加入群组 if (qunid): try: # 添加用户群关系就是加入了群组 qun = QunDAO.getqunInfoqunid(qunid) userqun = Userqun() userqun.userid = users.id userqun.qunid = qunid userquntemp = UserqunDAO.getuserqunInfouserqun(userqun) if (not userquntemp): if (qun.quntype == ResultCode.QUN_USER or qun.quntype == ResultCode.QUN_USER_DIARY or qun.quntype == ResultCode.QUN_USER_DIARY_NOT_USER): userqun.userstate = ResultCode.USERQUN_NOT else: userqun.userstate = ResultCode.USERQUN_YUAN UserqunDAO.adduserqun(userqun) # 添加群聊关系 chatuser = Chatuser() chatuser.send_id = qunid chatuser.receive_id = users.id chatuser.usertype = ResultCode.CHATUSER_TYPE_QUN chatuser.state = ResultCode.CHATUSER_HIDE chatuser.abid = str(qunid) chatuser.content = "" chatuser.time = TimeUtil.getCurrentTime() chatuser.date = TimeUtil.getCurrentDate() ChatuserDAO.addchatuser(chatuser) except Exception as e: print(e) usermeback = user2meBack(users) result["data"] = usermeback result["respcode"] = ResultCode.SUCCESS result["errorcode"] = "" result["message"] = "注册成功" print("注册成功") return JsonResponse(result)
def queryqunchat(request): #第一层的结果集 result = {} allmessage_back = [] if request.method == "POST": qunid = int(request.POST.get("qunid", None)) # 读取post数据,None为默认值 receive_id = int(request.POST.get("receive_id", None)) # 读取post数据,None为默认值 pageNo = int(request.POST.get("page", None)) # 读取post数据,None为默认值 if request.method == "GET": qunid = int(request.GET.get("qunid", None)) # 读取post数据,None为默认值 receive_id = int(request.GET.get("receive_id", None)) # 读取post数据,None为默认值 pageNo = int(request.POST.get("page", None)) # 读取post数据,None为默认值 print("查询群聊接口参数:接收者ID", receive_id, "page", pageNo) #首先查询是否存在聊天关系 chatuser1 = Chatuser() chatuser1.send_id = qunid chatuser1.receive_id = receive_id chatuser1.usertype = ResultCode.CHATUSER_TYPE_QUN chatuser1 = ChatuserDAO.querychatqunexist(chatuser1) if (chatuser1 == None): result["message"] = "暂无聊天信息" result["data"] = "" result["errorcode"] = "" result["respcode"] = ResultCode.FAIL print("不存在聊天关系") return JsonResponse(result) #设置聊天关系为已读 #获取聊天数目 page = PageForId() page.pageno = pageNo page.receive_id = receive_id page.send_id = qunid page.abid = chatuser1.abid page.pagesize = 20 page.start = 20 * (pageNo - 1) #数据库本来就是从后向前查询的 在数据库中第0条记录就是最默认的记录 try: allMessage = Chat_MessageDAO.queryAllsixinwithhe( page.abid, page.start, page.pagesize) #通过abid查询 if (len(allMessage) > 0): #修改聊天用户的状态 在群聊中 page.state = ResultCode.CHATUSER_OLD ChatuserDAO.updatachatuserstateforuser(page) qun = QunDAO.getqunInfoqunid(qunid) for message in allMessage: message_back = fun.chatmessage2back(message) #获取消息发送者信息 senduser = fun.user2else_back( UserDAO.getUserInfoId(message_back['send_id'])) message_back['send_user'] = senduser message_back['qun'] = model_to_dict(qun) allmessage_back.append(message_back) result["message"] = "查询成功" result["data"] = allmessage_back result["errorcode"] = "" result["respcode"] = ResultCode.SUCCESS except Exception as e: print(e) result["message"] = "查询失败" result["data"] = "" result["errorcode"] = ResultCode.FAIL result["respcode"] = ResultCode.FAIL print("查询失败") return JsonResponse(result)
def wechat(request): # 微信接入验证是GET方法, if request.method == "GET": signature = request.GET.get("signature", None) timestamp = request.GET.get("timestamp", None) nonce = request.GET.get("nonce", None) # if not check_signature(token=WEIXIN_TOKEN, signature=signature, timestamp=timestamp, nonce=nonce): # print('验证失败') # return HttpResponseBadRequest('Verify Failed') return HttpResponse(request.GET.get('echostr', ''), content_type="text/plain") # 微信正常的收发消息是用POST方法。 else: xml = request.body msg = parse_message(xml) user = UserDAO.queryUserForidentity(msg.source) qun = QunDAO.getqunInfoqunid(999) if not qun: respContent = "系统尚未架构" reply = TextReply(content=respContent, message=msg) r_xml = reply.render() return HttpResponse(r_xml) #注册没注册用户都可以查看价格 if msg.type == 'text': content = msg.content if "jg" in content: # print('回复价格表') respContent=" 每日播报 \n\n价格高、回款快、信誉100%!\n\n" try: jsonobj =json.loads(qun.gonggao.replace('\'','\"')) # python字符串转化为字典必须为双引号 for key in jsonobj: respContent+= key+":¥"+jsonobj[key]+"\n" respContent+='\n\n<a href="'+urlpath+STATIC_URL1+'piaoquan/shangchuanzishi.html">更多上传姿势</a>' reply = TextReply(content=respContent, message=msg) r_xml = reply.render() return HttpResponse(r_xml) except Exception as e: print('返回价格表出错:',e) #如果用户没有注册,则必须先注册才能进行后面的操作 if not user: respContent = toregister(msg.source) reply = TextReply(content=respContent, message=msg) r_xml = reply.render() return HttpResponse(r_xml) # 如果是文本消息 if msg.type == 'text': backstr = wordfun(msg,qun,user) reply = TextReply(content=backstr, message=msg) r_xml = reply.render() return HttpResponse(r_xml) # 如果是图片消息 if msg.type == 'image': backstr = imagefun(msg, qun, user) reply = TextReply(content=backstr, message=msg) r_xml = reply.render() return HttpResponse(r_xml) # 如果是点击事件消息 elif msg.type == 'event': try: push = ScanCodeWaitMsgEvent(msg) # 获取二维码信息,字符串 content = msg.scan_result print(content) # 如何处理,自行处理,回复一段文本或者图文 reply = TextReply(content="something", message=msg) r_xml = reply.render() return HttpResponse(r_xml) except Exception as e: print('点击事件响应出错:',e)
def deldealinfomore(request): result = {} if request.method == "POST": deal = request.POST.get("deal", 0) # 读取post数据,None为默认值 userid_source = request.POST.get("userid_source", 0) # 读取post数据,None为默认值 diaryid_source = request.POST.get("diaryid_source", 0) # 读取post数据,None为默认值 qunid_source = request.POST.get("qunid_source", 0) # 读取post数据,None为默认值 userid_destination = request.POST.get("userid_destination", 0) # 读取post数据,None为默认值 diaryid_destination = request.POST.get("diaryid_destination", 0) # 读取post数据,None为默认值 qunid_destination = request.POST.get("qunid_destination", 0) # 读取post数据,None为默认值 if request.method == "GET": deal = request.GET.get("deal", 0) # 读取get数据,None为默认值 userid_source = request.GET.get("userid_source", 0) # 读取get数据,None为默认值 diaryid_source = request.GET.get("diaryid_source", 0) # 读取get数据,None为默认值 qunid_source = request.GET.get("qunid_source", 0) # 读取get数据,None为默认值 userid_destination = request.GET.get("userid_destination", 0) # 读取get数据,None为默认值 diaryid_destination = request.GET.get("diaryid_destination", 0) # 读取get数据,None为默认值 qunid_destination = request.GET.get("qunid_destination", 0) # 读取get数据,None为默认值 print("删除更多操作接口参数:deal", deal) more = More() more.deal = deal more.userid_source = userid_source more.userid_destination = userid_destination more.diaryid_source = diaryid_source more.diaryid_destination = diaryid_destination more.qunid_source = qunid_source more.qunid_destination = qunid_destination more = MoreDAO.selectmoreInfomore(more) if (more): MoreDAO.deldealInfoid(more.id) result["data"] = "" result["respcode"] = ResultCode.SUCCESS result["errorcode"] = ResultCode.SUCCESS result["message"] = "删除处理成功" #如果是日志点赞则添加到日志属性中去 if (more.diaryid_destination): diary = DiaryDAO.selectDiary(more.diaryid_destination) if (diary): if (more.deal == ResultCode.DIARY_ZAN): diary.zannum = diary.zannum - 1 DiaryDAO.updatediary(diary) elif (more.deal == ResultCode.DIARY_SHOUCANG): diary.shoucangnum = diary.shoucangnum - 1 DiaryDAO.updatediary(diary) elif (more.deal == ResultCode.DIARY_TUIJIAN): diary.tuijiannum = diary.tuijiannum - 1 DiaryDAO.updatediary(diary) #如果是群组点赞 则添加到群属性中 elif (more.qunid_destination()): qun = QunDAO.getqunInfoqunid(more.qunid_destination) if (qun): if (more.deal == ResultCode.QUN_ZAN): qun.zannum = qun.zannum - 1 QunDAO.updatequnInfoqun(qun) elif (more.deal == ResultCode.QUN_SHOUCANG): qun.shoucangnum = qun.shoucangnum - 1 QunDAO.updatequnInfoqun(qun) elif (more.deal == ResultCode.QUN_TUIJIAN): qun.tuijiannum = qun.tuijiannum - 1 QunDAO.updatequnInfoqun(qun) #如果是用户点赞 则添加到用户属性中 elif (more.userid_destination): user = UserDAO.getUserInfoId(more.userid_destination) if (user): if (more.deal == ResultCode.USER_ZAN): user.zannum = user.zannum - 1 UserDAO.updateUserInfo(user) if (more.deal == ResultCode.USER_SHOUCANG): user.shoucangnum = user.shoucangnum - 1 UserDAO.updateUserInfo(user) if (more.deal == ResultCode.USER_TUIJIAN): user.tuijiannum = user.tuijiannum - 1 UserDAO.updateUserInfo(user) return JsonResponse(result)
def deldeal(request): result = {} if request.method == "POST": id = request.POST.get("id", None) # 读取post数据,None为默认值 if request.method == "GET": id = request.GET.get("id", None) # 读取get数据,None为默认值 print("删除更多操作接口参数:操作id", id) more = MoreDAO.selectdealInfoid(id) try: MoreDAO.deldealInfoid(id) result["data"] = "" result["respcode"] = ResultCode.SUCCESS result["errorcode"] = ResultCode.SUCCESS result["message"] = "删除处理成功" #如果是日志点赞则添加到日志属性中去 if (more.diaryid_destination): diary = DiaryDAO.selectDiary(more.diaryid_destination) if (diary): if (more.deal == ResultCode.DIARY_ZAN): diary.zannum = diary.zannum - 1 DiaryDAO.updatediary(diary) elif (more.deal == ResultCode.DIARY_SHOUCANG): diary.shoucangnum = diary.shoucangnum - 1 DiaryDAO.updatediary(diary) elif (more.deal == ResultCode.DIARY_TUIJIAN): diary.tuijiannum = diary.tuijiannum - 1 DiaryDAO.updatediary(diary) #如果是群组点赞 则添加到群属性中 elif (more.qunid_destination): qun = QunDAO.getqunInfoqunid(more.qunid_destination) if (qun): if (more.deal == ResultCode.QUN_ZAN): qun.zannum = qun.zannum - 1 QunDAO.updatequnInfoqun(qun) elif (more.deal == ResultCode.QUN_SHOUCANG): qun.shoucangnum = qun.shoucangnum - 1 QunDAO.updatequnInfoqun(qun) elif (more.deal == ResultCode.QUN_TUIJIAN): qun.tuijiannum = qun.tuijiannum - 1 QunDAO.updatequnInfoqun(qun) #如果是用户点赞 则添加到用户属性中 elif (more.userid_destination): user = UserDAO.getUserInfoId(more.userid_destination) if (user): if (more.deal == ResultCode.USER_ZAN): user.zannum = user.zannum - 1 UserDAO.updateUserInfo(user) if (more.deal == ResultCode.USER_SHOUCANG): user.shoucangnum = user.shoucangnum - 1 UserDAO.updateUserInfo(user) if (more.deal == ResultCode.USER_TUIJIAN): user.tuijiannum = user.tuijiannum - 1 UserDAO.updateUserInfo(user) except Exception as e: result["data"] = "" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "删除处理成功" return JsonResponse(result)
def adddeal(request): result = {} if request.method == "POST": deal = request.POST.get("deal", None) # 读取post数据,None为默认值 userid_source = request.POST.get("userid_source", 0) # 读取post数据,None为默认值 diaryid_source = request.POST.get("diaryid_source", 0) # 读取post数据,None为默认值 qunid_source = request.POST.get("qunid_source", 0) # 读取post数据,None为默认值 userid_destination = request.POST.get("userid_destination", 0) # 读取post数据,None为默认值 diaryid_destination = request.POST.get("diaryid_destination", 0) # 读取post数据,None为默认值 qunid_destination = request.POST.get("qunid_destination", 0) # 读取post数据,None为默认值 if request.method == "GET": deal = request.GET.get("deal", None) # 读取get数据,None为默认值 userid_source = request.GET.get("userid_source", 0) # 读取get数据,None为默认值 diaryid_source = request.GET.get("diaryid_source", 0) # 读取get数据,None为默认值 qunid_source = request.GET.get("qunid_source", 0) # 读取get数据,None为默认值 userid_destination = request.GET.get("userid_destination", 0) # 读取get数据,None为默认值 diaryid_destination = request.GET.get("diaryid_destination", 0) # 读取get数据,None为默认值 qunid_destination = request.GET.get("qunid_destination", 0) # 读取get数据,None为默认值 print("添加更多操作接口参数:操作类型", deal, "源用户id", userid_source, "源日志id:", diaryid_source, "目的用户id:", userid_destination, "目的日志id:", diaryid_destination, "源群id:", qunid_source, "目的群id:", qunid_destination) if (userid_source == userid_destination): result["data"] = "" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "添加处理失败" return JsonResponse(result) more = More() more.deal = deal more.userid_source = userid_source more.userid_destination = userid_destination more.diaryid_source = diaryid_source more.diaryid_destination = diaryid_destination more.qunid_source = qunid_source more.qunid_destination = qunid_destination more1 = MoreDAO.selectmoreInfomore(more) if (more1): result["data"] = model_to_dict(more1) result["respcode"] = ResultCode.SUCCESS result["errorcode"] = ResultCode.SUCCESS result["message"] = "添加处理成功" else: try: MoreDAO.adddeal(more) more = MoreDAO.selectmoreInfomore(more) result["data"] = model_to_dict(more) result["respcode"] = ResultCode.SUCCESS result["errorcode"] = ResultCode.SUCCESS result["message"] = "添加处理成功" #如果是日志点赞则添加到日志属性中去 if (diaryid_destination != 0): diary = DiaryDAO.selectDiary(diaryid_destination) if (diary): if (deal == ResultCode.DIARY_ZAN): diary.zannum = diary.zannum + 1 DiaryDAO.updatediary(diary) elif (deal == ResultCode.DIARY_SHOUCANG): diary.shoucangnum = diary.shoucangnum + 1 DiaryDAO.updatediary(diary) elif (deal == ResultCode.DIARY_TUIJIAN): diary.tuijiannum = diary.tuijiannum + 1 DiaryDAO.updatediary(diary) #如果是群组点赞 则添加到群属性中 elif (qunid_destination != 0): qun = QunDAO.getqunInfoqunid(qunid_destination) if (qun): if (deal == ResultCode.QUN_ZAN): qun.zannum = qun.zannum + 1 QunDAO.updatequnInfoqun(qun) elif (deal == ResultCode.QUN_SHOUCANG): qun.shoucangnum = qun.shoucangnum + 1 QunDAO.updatequnInfoqun(qun) elif (deal == ResultCode.QUN_TUIJIAN): qun.tuijiannum = qun.tuijiannum + 1 QunDAO.updatequnInfoqun(qun) #如果是用户点赞 则添加到用户属性中 elif (userid_destination != 0): user = UserDAO.getUserInfoId(userid_destination) if (user): if (deal == ResultCode.USER_ZAN): user.zannum = user.zannum + 1 UserDAO.updateUserInfo(user) if (deal == ResultCode.USER_SHOUCANG): user.shoucangnum = user.shoucangnum + 1 UserDAO.updateUserInfo(user) if (deal == ResultCode.USER_TUIJIAN): user.tuijiannum = user.tuijiannum + 1 UserDAO.updateUserInfo(user) except Exception as e: result["data"] = "" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "添加处理失败" return JsonResponse(result)