示例#1
0
def getalldealdiaryforqunid(request):
    returnData={}
    if request.method == "POST":
        pageNo = request.POST.get("page", None)  # 读取post数据,None为默认值
        qunid = request.POST.get("qunid", None)  # 读取post数据,None为默认值
    if request.method == "GET":
        pageNo = request.GET.get("page", None)  # 读取get数据,None为默认值
        qunid = request.GET.get("qunid", None)  # 读取get数据,None为默认值

    print("查询指定群日志处理接口参数:群ID" + qunid+"pageNo:"+pageNo)

    qun = QunDAO.getqunInfoqunid(qunid)

    page = PageForId()
    page.pageNo(pageNo)
    page.qunid(qunid)
    page.pageSize(10)
    page.start(10*(pageNo-1))
    try:
        alluserdeal_back = []
        alluserdeal = UserDealDAO.selectuserdealforqunid(page)
        print("查询到数目"+len(alluserdeal))
        for i in range(len(alluserdeal)):
            userDeal_back = fun.userdeal2back(alluserdeal[i])
            userelse = fun.user2else_back(UserDAO.getUserInfoId(alluserdeal[i].userid))
            userDeal_back.user=userelse
            userDeal_back.qun=qun

            alldealdiary_back =[]
            alldealdiary = DiaryDealDAO.selectdealdiaryfordealid(userDeal_back.id)
            for t in range(len(alldealdiary)):

                dealDiary_Back = fun.dealdiary2back(alldealdiary[t])
                diary=DiaryDAO.selectDiary(alldealdiary[t].id)
                diaryback=fun.diary2back(diary)
                dealDiary_Back.diary(diaryback)
                alldealdiary_back.add(dealDiary_Back)

            userDeal_back.alldealdiary(alldealdiary_back)
            alluserdeal_back.add(userDeal_back)

        returnData["respcode"]=ResultCode.SUCCESS
        returnData["message"]="查询所有日志处理成功!"
        returnData["data"]=alluserdeal_back
        returnData["errorcode"]=ResultCode.SUCCESS
        print("查询成功数目"+len(alluserdeal_back))

    except Exception as e:
        returnData["respcode"]=ResultCode.FAIL
        returnData["message"]="查询所有日志处理失败!"
        returnData["errorcode"]=ResultCode.FAIL
        returnData["data"]=""
        print("查询失败")

    return returnData
示例#2
0
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)
示例#3
0
def getalluser(request):
    if request.method == "POST":
        pageNo = request.POST.get("page", None)  # 读取get数据,None为默认值

    if request.method == "GET":
        pageNo = request.GET.get("page", None)  # 读取get数据,None为默认值

    print("分页查询所有用户page:", pageNo)

    result = {}
    alluserback = []

    page = PageForId()
    page.pageno = pageNo
    page.pagesize = 100  # 一次查询100个

    page.start = 100 * (pageNo - 1)  # 数据库本来就是从后向前查询的   在数据库中第0条记录就是最默认的记录

    alluser = UserDAO.queryalluser(page)

    if (alluser and len(alluser) != 0):
        for i in range(len(alluser)):
            user_back = fun.user2else_back(alluser[i])
            alluserback.append(user_back)

    result["respcode"] = ResultCode.SUCCESS
    result["message"] = "查询用户成功!"
    result["data"] = alluserback
    result["errorcode"] = ResultCode.SUCCESS
    print("查询用户成功!")
    return JsonResponse(result)
示例#4
0
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 result

    page = PageForId()
    page.pageNo=pageNo
    page.userId=userid
    page.pageSize=100  #一次查询100个
    page.deal=showtype
    totalPage = 0
    try:
        totalPage = MoreDAO.selectmorelistnumInfopage(page)
    except Exception as e1:
        print(e1)

    page.totalPage=totalPage
    page.pageSize=10
    page.start=10*(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.add(user_back)


    print("查询各种各样用户,数目为" ,len(alluser))
    result["respcode"]= ResultCode.SUCCESS
    result["message"]= "查询用户成功!"
    result["data"]= alluser
    result["errorcode"]= ResultCode.SUCCESS
    return result
示例#5
0
def queryAllsixin(request):
    #第一层的结果集
    result = {}
    allmessage_back = []

    if request.method == "POST":
        receive_id = int(request.POST.get("receive_id",
                                          None))  # 读取post数据,None为默认值
        pageNo = int(request.POST.get("page", None))  # 读取post数据,None为默认值
    if request.method == "GET":
        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)

    #获取聊天数目
    page = PageForId()
    page.pageno = pageNo
    page.receive_id = receive_id

    page.pagesize = 10
    page.start = 10 * (pageNo - 1)  #数据库本来就是从后向前查询的   在数据库中第0条记录就是最默认的记录
    try:
        allMessage = Chat_MessageDAO.queryAllsixin(page.receive_id, page.start,
                                                   page.pagesize)  #通过abid查询
        if (allMessage and len(allMessage) > 0):
            receiveuser = fun.user2else_back(UserDAO.getUserInfoId(receive_id))
            for message in allMessage:
                senduser = fun.user2else_back(
                    UserDAO.getUserInfoId(message.getSend_id()))
                message_back = fun.chatmessage2back(message)
                message_back['send_user'] = senduser
                message_back['receive_user'] = receiveuser

                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)
示例#6
0
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)
示例#7
0
def querytongzhifortype(request):
    #第一层的结果集*/
    result = {}
    allTongzhiback = []
    if request.method == "POST":
        pageNo = int(request.POST.get("page", None))  # 读取post数据,None为默认值
        messagetype = int(request.POST.get("messagetype",
                                           None))  # 读取post数据,None为默认值
    if request.method == "GET":
        pageNo = int(request.GET.get("page", None))  # 读取post数据,None为默认值
        messagetype = int(request.GET.get("messagetype",
                                          None))  # 读取post数据,None为默认值
    tongzhi_back = Tongzhi_back()

    print("查询指定类型的所有通知接口参数")
    page = PageForId()
    page.pageNo = pageNo
    page.pagesize = 20
    page.messagetype = messagetype
    page.start = 20 * (pageNo - 1)  #数据库本来就是从后向前查询的   在数据库中第0条记录就是最默认的记录
    try:
        allMessage = TongzhiDAO.querytongzhifortype(page)
        if (len(allMessage) > 0):
            for i in range(len(allMessage)):
                tongzhi = allMessage[i]
                tongzhi_back = fun.tongzhi2back(tongzhi)
                allTongzhiback.add(tongzhi_back)
        result["message"] = "查询成功"
        result["data"] = allTongzhiback
        result["errorcode"] = ""
        result["respcode"] = ResultCode.SUCCESS
        print("查询到通知数目", len(allTongzhiback))
    except Exception as e:
        print(e)
        result["message"] = "查询失败"
        result["data"] = ""
        result["errorcode"] = ResultCode.FAIL
        result["respcode"] = ResultCode.FAIL
    return result
示例#8
0
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)
示例#9
0
def queryAllsixinwithhe(request):
    #第一层的结果集
    result = {}
    allmessage_back = []
    if request.method == "POST":
        send_id = int(request.POST.get("send_id", 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":
        send_id = int(request.POST.get("send_id", 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, "发送者id", send_id, "page", pageNo)

    #首先查询是否存在聊天关系
    chatuser1 = Chatuser()
    chatuser1.send_id = send_id
    chatuser1.receive_id = receive_id
    chatuser1.usertype = ResultCode.CHATUSER_TYPE_RECEIVE
    chatuser1 = ChatuserDAO.querychatuserexist(chatuser1)
    if (chatuser1 == None):
        chatuser1 = Chatuser()
        chatuser1.send_id = send_id
        chatuser1.receive_id = receive_id
        chatuser1.usertype = ResultCode.CHATUSER_TYPE_SEND
        chatuser1 = ChatuserDAO.querychatuserexist(chatuser1)
        if (chatuser1 == None):
            result["message"] = "不存在聊天关系"
            result["data"] = allmessage_back
            result["errorcode"] = ""
            result["respcode"] = ResultCode.SUCCESS
            print("不存在聊天关系")
            return JsonResponse(result)

    #设置聊天关系为已读
#获取聊天数目
    page = PageForId()
    page.pageno = pageNo
    page.receive_id = receive_id
    page.send_id = send_id

    page.pagesize = 10
    page.start = 10 * (pageNo - 1)  #数据库本来就是从后向前查询的   在数据库中第0条记录就是最默认的记录

    try:
        allMessage = Chat_MessageDAO.queryAllsixinwithhe(
            page.abid, page.start, page.pagesize)  #通过abid查询
        if (allMessage and len(allMessage) > 0):
            page.state = ResultCode.CHATUSER_OLD
            ChatuserDAO.updatachatuserstateforuser(chatuser1)  #修改聊天用户的状态
            senduser = fun.user2else_back(UserDAO.getUserInfoId(send_id))
            receiveuser = fun.user2else_back(UserDAO.getUserInfoId(receive_id))
            for message in allMessage:
                print("查询聊天记录" + message.content)
                message_back = fun.chatmessage2back(message)
                if (message_back['send_id'] == send_id):
                    message_back['send_user'] = senduser
                    message_back['receive_user'] = receiveuser
                else:
                    message_back['send_user'] = receiveuser
                    message_back['receive_user'] = senduser

                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)