def getallqunuser(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 = {} page = PageForId() page.pageno = pageNo page.userid = userid page.pagesize = 20 # 一次查询100个 page.start = 20 * (int(pageNo) - 1) # 数据库本来就是从后向前查询的 在数据库中第0条记录就是最默认的记录 allUsers = UserDAO.queryallqunuser(page) alluserback = [] for i in range(len(allUsers)): alluserback.append(fun.user2else_back(allUsers[i])) result["respcode"] = ResultCode.SUCCESS result["message"] = "查询用户成功!" result["data"] = alluserback result["errorcode"] = ResultCode.SUCCESS print("查询到用户,数目为", len(alluserback)) return JsonResponse(result)
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 getdifuser(request): if request.method == "POST": pageNo = request.POST.get("page", None) # 读取get数据,None为默认值 userid = request.POST.get("userid", None) # 读取get数据,None为默认值 showtype = request.POST.get("showtype", None) # 读取get数据,None为默认值 if request.method == "GET": pageNo = request.GET.get("page", None) # 读取get数据,None为默认值 userid = request.GET.get("userid", None) # 读取get数据,None为默认值 showtype = request.GET.get("showtype", None) # 读取get数据,None为默认值 print("查询各种类型的用户:用户ID:", userid, "类型", showtype) result = {} alluser = [] me = UserDAO.getUserInfoId(userid) if (not me): result["respcode"] = ResultCode.FAIL result["message"] = "用户不存在!请先注册登陆" result["data"] = "" result["errorcode"] = ResultCode.FAIL print("用户不存在") return JsonResponse(result) page = PageForId() page.pageno = pageNo page.userid = userid page.pagesize = 100 # 一次查询100个 page.deal = showtype page.start = 100 * (pageNo - 1) # 数据库本来就是从后向前查询的 在数据库中第0条记录就是最默认的记录 allmore = MoreDAO.selectmorelistInfopage(page) if (allmore and len(allmore) != 0): for i in range(len(allmore)): user1 = UserDAO.getUserInfoId(allmore[i].userid_destination) user_back = fun.user2else_back(user1) more = getuserdeal(userid, user1.id, ResultCode.USER_ZAN) if (more): user_back['ideal'] = ResultCode.USER_ZAN alluser.append(user_back) result["respcode"] = ResultCode.SUCCESS result["message"] = "查询用户成功!" result["data"] = alluser result["errorcode"] = ResultCode.SUCCESS print("查询各种类型用户,数目为", len(alluser)) return JsonResponse(result)