def updatecaidanword(request): result = {} diary = Diary() if request.method == "POST": content = request.POST.get("content", None) # 读取post数据,None为默认值 qunid = request.POST.get("qunid", None) # 读取post数据,None为默认值 qundiarytype = request.POST.get("qundiarytype", None) # 读取post数据,None为默认值 state = request.POST.get("state", None) # 读取post数据,None为默认值 money = request.POST.get("money", None) # 读取post数据,None为默认值 urltitle = request.POST.get("urltitle", None) # 读取post数据,None为默认值 urlcontent = request.POST.get("urlcontent", None) # 读取post数据,None为默认值 userid = request.POST.get("userid", None) # 读取post数据,None为默认值 diaryid = request.POST.get("diaryid", None) # 读取post数据,None为默认值 if request.method == "GET": content = request.GET.get("content", None) # 读取get数据,None为默认值 qunid = request.GET.get("qunid", None) # 读取get数据,None为默认值 qundiarytype = request.POST.get("qundiarytype", None) # 读取get数据,None为默认值 state = request.POST.get("state", None) # 读取get数据,None为默认值 money = request.POST.get("money", None) # 读取get数据,None为默认值 urltitle = request.POST.get("urltitle", None) # 读取get数据,None为默认值 urlcontent = request.POST.get("urlcontent", None) # 读取get数据,None为默认值 userid = request.POST.get("userid", None) # 读取get数据,None为默认值 diaryid = request.POST.get("diaryid", None) # 读取get数据,None为默认值 print("修改菜单(图片)接口参数:用户id:", userid, "内容:", content, "可见群组", qunid) try: diary = DiaryDAO.selectDiary(diaryid) diary.diarytype(ResultCode.CONTENT_TYPEIMG) diary.state = state diary.userid = userid diary.content = content diary.qunid = qunid diary.type = qundiarytype diary.urltitle = urltitle diary.urlcontent = urlcontent diary.money = money diary.time = TimeUtil.getCurrentTime() diary.date = TimeUtil.getCurrentDate() DiaryDAO.updatediary(diary) result["data"] = "0" result["respcode"] = ResultCode.SUCCESS result["errorcode"] = "" result["message"] = "修改日志成功" except Exception as e: print(e) result["data"] = "0" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "修改日志失败" return JsonResponse(result)
def setstate(request): result = {} if request.method == "POST": diaryid = request.POST.get("diaryid", None) # 读取post数据,None为默认值 tip = request.POST.get("tip", None) # 读取post数据,None为默认值 type = request.POST.get("type", None) # 读取post数据,None为默认值 if request.method == "GET": diaryid = request.GET.get("diaryid", None) # 读取get数据,None为默认值 tip = request.GET.get("tip", None) # 读取get数据,None为默认值 type = request.GET.get("type", None) # 读取get数据,None为默认值 print("修改状态:日志ID", diaryid, "状态:", type) try: diary = DiaryDAO.selectDiary(diaryid) if (diary): if (type == "2" and not diary.type == "2"): #如果新类型为出售中,并且之前不是出售中,则增加用户的积分 user = UserDAO.getUserInfoId(diary.userid) #查询用户 user.zannum = user.zannum + diary.money #设置用户赞积分 UserDAO.updateUserInfo(user) if (type == "3" and not diary.type == "3"): #如果新类型为已汇款,并且之前不是已汇款,则增加用户的汇款金额 user = UserDAO.getUserInfoId(diary.userid) #查询用户 user.gold(user.gold + diary.money) #设置用户已回款金额 #如果之前是出售中,则删除出售中金额 if (diary.type == "2"): user.zannum(user.zannum - diary.money) #设置用户赞积分 UserDAO.updateUserInfo(user) diary.urlcontent = tip diary.type = type diary.date = TimeUtil.getCurrentDate() diary.time = TimeUtil.getCurrentTime() DiaryDAO.updatediary(diary) result["data"] = "0" result["respcode"] = ResultCode.SUCCESS result["errorcode"] = "" result["message"] = "修改日志成功" print('修改日志成功') return JsonResponse(result) except Exception as e: print(e) result["data"] = "0" result["respcode"] = ResultCode.FAIL result["errorcode"] = ResultCode.FAIL result["message"] = "修改日志失败" print('修改日志失败') return JsonResponse(result)
def addComment(request): result = {} comment = Comment() if request.method == "POST": diaryid = request.POST.get("diaryid", None) # 读取post数据,None为默认值 comment_user_id = request.POST.get("userid", None) # 读取post数据,None为默认值 comment_detail = request.POST.get("content", None) # 读取post数据,None为默认值 if request.method == "GET": diaryid = request.GET.get("diaryid", None) # 读取get数据,None为默认值 comment_user_id = request.GET.get("userid", None) # 读取get数据,None为默认值 comment_detail = request.POST.get("content", None) # 读取get数据,None为默认值 print("增加评论接口参数:日志ID", diaryid, "评论用户ID", comment_user_id, "评论内容", comment_detail) try: comment.comment_detail = comment_detail comment.comment_user_id = comment_user_id comment.diaryid = diaryid comment.comment_time = TimeUtil.getCurrentTimeAndDate() CommentDAO.addComment(comment) diary = DiaryDAO.selectDiary(diaryid) diary.commentnum = diary.commentnum() + 1 DiaryDAO.updatediary(diary) result["data"] = "0" result["errorcode"] = "" result["message"] = "评论成功" result["respcode"] = ResultCode.SUCCESS print('评论成功') except Exception as e: print(e) result["data"] = "" result['errorcode'] = ResultCode.FAIL result["message"] = "评论失败" 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 getuserallimg(request): if request.method == "POST": pageNo = request.POST.get("page", None) # 读取get数据,None为默认值 userid = request.POST.get("userid", None) # 读取get数据,None为默认值 if request.method == "GET": pageNo = request.GET.get("page", None) # 读取get数据,None为默认值 userid = request.GET.get("userid", None) # 读取get数据,None为默认值 print("查询用户图片:用户ID:", userid) result = {} allpic = [] page = PageForId() page.pageno = pageNo page.userid = userid page.pagesize = 10 # 一次查询100个 page.start = 10 * (pageNo - 1) # 数据库本来就是从后向前查询的 在数据库中第0条记录就是最默认的记录 alldiary = DiaryDAO.selectimgDiarysforuser(page) if (alldiary and len(alldiary) != 0): for i in range(len(alldiary)): if (alldiary[i].imgone): allpic.append(alldiary[i].imgone) if (alldiary[i].imgtwo): allpic.append(alldiary[i].imgtwo) if (alldiary[i].imgthree): allpic.append(alldiary[i].imgthree) if (alldiary[i].imgfour): allpic.append(alldiary[i].imgfour) if (alldiary[i].imgfive): allpic.append(alldiary[i].imgfive) if (alldiary[i].imgsix): allpic.append(alldiary[i].imgsix) if (alldiary[i].imgseven): allpic.append(alldiary[i].imgseven) if (alldiary[i].imgeight): allpic.append(alldiary[i].imgeight) if (alldiary[i].imgnine): allpic.append(alldiary[i].imgnine) result["respcode"] = ResultCode.SUCCESS result["message"] = "查询群组图片成功!" result["data"] = allpic result["errorcode"] = ResultCode.SUCCESS print("查询群组图片成功!") return JsonResponse(result)
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 getinfo(ocrtext,qun,user,filepath): ocrtext=ocrtext.replace(" ", "") respContent="" if (len(allname)==0): # 主要配置表中有,就都能识别 jsonobj=json.loads(qun.gonggao.replace('\'','\"')) # 获取配置的价格表 for keystr in jsonobj: money = jsonobj[keystr] onerow = keystr.split("|") if (len(onerow)==3): allname.append(keystr) allqiye.append(onerow[0]) allchanpin.append(onerow[1]) allbank.append(onerow[2]) alljiage.append(money) # 分为大杯和中杯饮品,和多少元代金券 bank="" qiye="" chanpin = "" quanma="" money=0 canshibie=False # 先用企业和商品类型识别一遍,这个为必须包含项 for i in range(len(allqiye)): if (allqiye[i] in ocrtext and allchanpin[i] in ocrtext): qiye = allqiye[i] chanpin=allchanpin[i] bank = allbank[i] money= float(alljiage[i]) canshibie=True break # 如果不能识别,就返回不能识别说明 if (not canshibie): respContent = '无法识别此类商品或此类商品已不再收录,您可以回复jg查看收录商品,或通过其他方式上传。\n\n'\ + '<a href="'+urlpath+'piaoquan/mydiary?qunid=999&typeindex=1&userid='+str(user.id)+'">券码管理</a>\n\n'\ + '<a href="'+urlpath+'piaoquan/setting?userid='+str(user.id)+'">个人账户中心</a>\n\n'\ + '回复“jg”查询商品价格!' # print(respContent) return respContent # 再用企业、商品类型、银行识别一遍,作为次选。因为银行并不是必选项 for i in range(len(allqiye)): if (allqiye[i] in ocrtext and allchanpin[i] in ocrtext and allbank[i] in ocrtext): qiye = allqiye[i] chanpin=allchanpin[i] bank = allbank[i] money= float(alljiage[i]) break # print(qiye, chanpin, bank, money) # 如果有图片就使用图片识别券码 if (filepath): try: code = QRcode.ocr_qrcode_zxing(filepath) # 识别图中的二维码 print("第一种方式二维码识别结果:",code) # if(code==None or code=="null" or code==""): # code = QRcode.ocr_qrcode_zxing(filepath) # 识别图中的二维码 # else: # # 判断编码是不是只有字母数字和= # regexstr="^[a-zA-Z=0-9]+$" # pattern = re.compile(regexstr) # result = re.match(pattern,code) # if (not result): # return '无法识别二维码' # print("二维码识别结果:"+code) if (code.find("=")>-1): quanma = code[0:code.find("=")] else: quanma = code except Exception as e: print("二维码识别出错:",e) # 没有图片或者图片匹配不到就正则表达式识别 if (quanma==""): # 识别券码 regexstr="[0-9A-Za-z]{10,30}" # 查找指定的字符串 pattern=re.compile(regexstr) matcher = re.match(pattern, ocrtext) i = 0 while(matcher.groups(i)): # 如果在匹配到的数字前出现的“订单编号”,则放弃 if (matcher.start(i)-8>0): if ('订单编号' in ocrtext[matcher.start(i)-8,matcher.start(i)]): i += 1 continue quanma= matcher.group(i) break # 如果券码为"" if (quanma==""): # 如果没有图片,则放弃 if (filepath==None): respContent = "无法识别券码,请通过其他方式上传,或者联系客服\n\n"\ + "<a href=\""+urlpath+"piaoquan/mydiary.jsp?qunid=999&typeindex=1&userid="+str(user.getId())+"\">券码管理</a>\n\n"\ + "<a href=\""+urlpath+"piaoquan/setting.jsp?userid="+str(user.getId())+"\">个人账户中心</a>\n\n"\ + "回复“jg”查询商品价格!" return respContent else: # 如果有图片,则券号自定义为no+时间+index global index index+=1 quanma="no"+TimeUtil.getCurrentDate1()+TimeUtil.getCurrentTime1()+str(index) # 修改图片名称为券号的名称 picname ="" if(filepath): mulu = filepath[0:filepath.rfind('/') + 1] # 目录(带最后的/) # picname = filepath[filepath.rfind('/') + 1:] # 文件名 geshi =filepath[filepath.index('.')+1:] picname = quanma+"."+geshi newfilepath = mulu+picname if (os.path.exists(newfilepath)): os.remove(newfilepath) os.rename(filepath,newfilepath) print('将图片重命名为新图片名称:',newfilepath) content = qiye + "|" + chanpin + "|" + bank #要存储返回的内容 tip="该票券不是第一次上传了\n" diary = DiaryDAO.selectDiaryforSerial(quanma) if (not diary): diary = Diary() diary.userid= user.id diary.qunid= 999 if (not filepath): diary.diarytype=ResultCode.CONTENT_TYPEWORD # 设置日志只有短信 else: diary.diarytype=ResultCode.CONTENT_TYPEIMG # 设置日志包含图片 diary.type="1" diary.serial=quanma diary.state=0 diary.content=content diary.time=TimeUtil.getCurrentTime() diary.date=TimeUtil.getCurrentDate() diary.money=10*int(money) # 怎么设置价格 if(filepath): datenow = TimeUtil.getCurrentMonth() diary.imgone= STATIC_URL1+ "upload/img/"+datenow+"/"+picname DiaryDAO.addDiary(diary) tip="" # 修改用户的以上传金额 user.tuijiannum = user.tuijiannum+diary.money # 设置用户以上传金额 UserDAO.updateUserInfo(user) respContent = "您的券码已经收到录入,等待橙子权益的汇款即可。\n\n商品:"+content+"\n券码:"+quanma+"\n价格:¥"+str(money) \ + "\n\n<a href=\""+urlpath+"piaoquan/setting.jsp?userid="+str(user.id)+"\">个人账户中心</a>\n\n"\ + "<a href=\""+urlpath+"piaoquan/mydiary.jsp?qunid=999&typeindex=1&userid="+str(user.id)+"\">券码管理</a>\n\n"+tip\ + "回复“jg”查询商品价格!" return respContent
def wordfun(msg,qun,user): Content = msg.content # 如果在设置价格 if "control:" in Content: Content=Content.replace("control:", "") try: jsonobj= json.loads(qun.gonggao.replace('\'','\"')) except Exception as e: print('json转化出错',e) jsonobj = {} key_value=Content.split(":") #使用冒号进行分割,key_value[0]为商品,key_value[1]为价格 if(key_value[1]=="0" and key_value[0] in jsonobj): #如果价格为0,就删除 jsonobj.pop(key_value[0]) else: jsonobj[key_value[0]]= float(key_value[1]) #添加修改值 qun.gonggao= str(jsonobj) QunDAO.updatequnInfoqun(qun) #清除从公告中加载的数据 allname.clear() allqiye.clear() allchanpin.clear() allbank.clear() alljiage.clear() respContent="配置修改成功" return respContent #设置已上传 elif "ysc" in Content: Content=Content.replace("ysc", "") #后面的认为是券码 diary = DiaryDAO.selectDiaryforSerial(Content) #根据券码查询日志 diary.type = "1" #1为已上传 DiaryDAO.updatediary(diary) respContent="设置已上传成功:"+diary.content return respContent #设置出售中 elif "csz" in Content: Content=Content.replace("csz", "") #后面的认为是券码 diary = DiaryDAO.selectDiaryforSerial(Content) #根据券码查询日志 diary.type = "2" #2为出售中 DiaryDAO.updatediary(diary) respContent="设置出售中成功:"+diary.content return respContent #设置已汇款 elif "yhk" in Content: Content=Content.replace("yhk", "") #后面的认为是券码 diary = DiaryDAO.selectDiaryforSerial(Content) #根据券码查询日志 diary.type = "3" #3为已汇款 DiaryDAO.updatediary(diary) respContent="设置已汇款成功:"+diary.content return respContent #设置纠纷 elif "jf" in Content: Content=Content.replace("jf", "") #后面的认为是券码 diary = DiaryDAO.selectDiaryforSerial(Content) #根据券码查询日志 diary.type = "4" #4为纠纷 DiaryDAO.updatediary(diary) respContent="设置纠纷成功:"+diary.content return respContent # 输入券码通知信息 else: try: respContent = getinfo(Content,qun,user,None) #根据文字生成响应文本 except Exception as e: print('根据短信获取票券出错', e) respContent = tosetting(user) #返回进入账户中心的信息 return respContent
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)
def addcaidan(request): diary = Diary() result = {} imagePath = [] realPath = STATICFILES_DIRS[0] + "/upload/userDiary/" # realPath = request.getSession().getServletContext().getRealPath("userDiary/") if request.method == "POST": content = request.POST.get("content", None) # 读取post数据,None为默认值 qunid = request.POST.get("qunid", None) # 读取post数据,None为默认值 qundiarytype = request.POST.get("qundiarytype", None) # 读取post数据,None为默认值 state = request.POST.get("state", None) # 读取post数据,None为默认值 money = request.POST.get("money", None) # 读取post数据,None为默认值 urltitle = request.POST.get("urltitle", None) # 读取post数据,None为默认值 urlcontent = request.POST.get("urlcontent", None) # 读取post数据,None为默认值 userid = request.POST.get("userid", None) # 读取post数据,None为默认值 if request.method == "GET": content = request.GET.get("content", None) # 读取get数据,None为默认值 qunid = request.GET.get("qunid", None) # 读取get数据,None为默认值 qundiarytype = request.POST.get("qundiarytype", None) # 读取get数据,None为默认值 state = request.POST.get("state", None) # 读取get数据,None为默认值 money = request.POST.get("money", None) # 读取get数据,None为默认值 urltitle = request.POST.get("urltitle", None) # 读取get数据,None为默认值 urlcontent = request.POST.get("urlcontent", None) # 读取get数据,None为默认值 userid = request.POST.get("userid", None) # 读取get数据,None为默认值 print("增加菜单(图片)接口参数:用户id:", userid, "内容:", content, "可见群组", qunid) print("上传图片的根目录为:" + realPath) files = request.FILES.getlist('files') for i in range(len(files)): multFile = files[i] filenameString = userid + "_" + str(int( time.time())) + "_" + str(i) + ".png" if (not multFile): print("文件未上传") else: # print("文件的长度为:" + multFile.getSize()) # print("文件的类型:" + multFile.getContentType()) # print("文件的属性域:" + multFile.getName()) # print("文件的原名:" + multFile.getOriginalFilename()) filepath = realPath + "/" + filenameString f_obj = open(filepath, 'wb+') for chunk in multFile.chunks(): f_obj.write(chunk) f_obj.close() fileName = STATIC_URL1 + "uploa/userDiary/" + filenameString imagePath.append(fileName) # 有图像 imgnum = len(imagePath) if imgnum > 0: diary.imgone = imagePath[0] if imgnum > 1: diary.imgtwo = imagePath[1] if imgnum > 2: diary.imgthree = imagePath[2] if imgnum > 3: diary.imgfour = imagePath[3] if imgnum > 4: diary.imgfive = imagePath[4] if imgnum > 5: diary.imgsix = imagePath[5] if imgnum > 6: diary.imgseven = imagePath[6] if imgnum > 7: diary.imgeight = imagePath[7] if imgnum > 8: diary.imgnine = imagePath[8] diary.diarytype = ResultCode.CONTENT_CAIDAN_IMG diary.state = state diary.userid = userid diary.content = content diary.qunid = qunid diary.type = qundiarytype diary.urltitle = urltitle diary.urlcontent = urlcontent diary.money = money diary.time = TimeUtil.getCurrentTime() diary.date = TimeUtil.getCurrentDate() DiaryDAO.addDiary(diary) result["data"] = "0" result["respcode"] = ResultCode.SUCCESS result["errorcode"] = "" result["message"] = "上传文件成功" return JsonResponse(result)