Exemple #1
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
Exemple #2
0
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 != None 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.add(chatuser_back)
                        #如果是群聊
                    if (chatuser_back.usertype == ResultCode.CHATUSER_TYPE_QUN
                        ):
                        quntemp = QunDAO.getqunInfoqunid(chatuser_back.send_id)
                        chatuser_back['qun'] = quntemp
                        chatuser_back['receive_user'] = userreceive
                        allchatuser_back.add(chatuser_back)

        result["message"] = "查询成功"
        result["data"] = allchatuser_back
        result["errorcode"] = ""
        result["respcode"] = ResultCode.SUCCESS
        print("查询成功数目" + allchatuser_back.size())

    except Exception as e:
        print(e)
        result["message"] = "查询失败"
        result["data"] = ""
        result["errorcode"] = ResultCode.FAIL
        result["respcode"] = ResultCode.FAIL
        print("查询失败")

    return result
Exemple #3
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 != None 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.add(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 result
Exemple #4
0
def getUserInfo(request):
    result = {}
    if request.method == "POST":
        userid = request.POST.get("userid", None)  # 读取get数据,None为默认值

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

    print("查询用户资料接口参数:用户id:" + userid)

    user = UserDAO.getUserInfoId(userid)
    if (user):
        user_else= fun.user2else_back(user)
        result["message"]= "查询成功"
        result["respcode"]= ResultCode.SUCCESS
        result["data"]= user_else
        result["errorcode"]= ""
    else:
        # 没有查询到该用户
        result["message"]= "用户不存在"
        result["respcode"]=ResultCode.FAIL
        result["data"]=""
        result["errorcode"]=ResultCode.UNUSEREXIST
    

    return result
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
Exemple #6
0
def updateuserstate(request):
    result = {}
    user_receive = User()
    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"]= "修改失败not "
        return 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"]= "修改成功not "

    return result
Exemple #7
0
def uploadUserIcon(request):
    result = {}
    user=User()
    if request.method == "POST":
        id = request.POST.get("id", None)  # 读取get数据,None为默认值

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

    print("修改图像接口参数:用户id:"+id)
    realPath = request.getSession().getServletContext().getRealPath("userIcon/")

    if not os.path.exists(realPath):
        os.makedirs(realPath)
    try:
        files = request.FILES.getlist('files')
        multFile = files[0]
        filenameString = id + "_" + str(int(time.time())) + "_" + str(0) + ".png"

        filepath = realPath + "/" + filenameString

        f_obj = open(filepath, 'wb+')
        for chunk in multFile.chunks():
            f_obj.write(chunk)
        f_obj.close()

        fileName = "/userIcon/" + filenameString

        print("用户图像所在地址:" + realPath+"/"+fileName)
        user.image=fileName
        user.id=id
        UserDAO.updateUserIcon(user)

        users_back = UserDAO.getUserInfoId(user.id)
        loginResult = user2meBack(users_back)


        result["data"]= loginResult
        result["errorcode"]= ""
        result["message"]= "上传用户图像成功"
        result["respcode"]=ResultCode.SUCCESS
    except Exception as e:
        result["data"]= ""
        result["errorcode"]= ResultCode.VINT
        result["message"]= "文件不合法"
        result["respcode"]= ResultCode.FAIL


    return result
Exemple #8
0
def updateUserPwd(request):
    result = {}
    if request.method == "POST":
        id = request.POST.get("id", None)  # 读取get数据,None为默认值
        oldpassword = request.POST.get("oldpassword", None)  # 读取get数据,None为默认值
        newpassword = request.POST.get("newpassword", None)  # 读取get数据,None为默认值

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

    print("修改密码接口参数:源密码" + oldpassword + "新密码" + newpassword)

    user = UserDAO.getUserInfoId(id)
    if (user):
        if (oldpassword==user.password):
            user.password=newpassword
            UserDAO.updateUserPwd(user)
            result["message"]= "修改密码成功not "
            result["respcode"]= ResultCode.SUCCESS
            result["data"]= ResultCode.SUCCESS
            result["errorcode"]= ""
        else:
            result["message"]= "旧密码错误"
            result["respcode"]= ResultCode.FAIL
            result["data"]=""
            result["errorcode"]= ResultCode.OLDPWDFAIL

    else:
        result["message"]= "用户不存在"
        result["respcode"]= ResultCode.FAIL
        result["data"]= ""
        result["errorcode"]= ResultCode.UNUSEREXIST


    return result
Exemple #9
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 result

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

    totalPage = 0
    try:
        page.abid = chatuser1.abid
        totalPage = Chat_MessageDAO.querysixinnumwithhe(
            chatuser1.abid)  #查询Aid_Bid
    except Exception as e1:
        # TODO Auto-generated catch block
        print(e1)

    page.totalPage = totalPage
    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 = qun

                allmessage_back.add(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 result
Exemple #10
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 result

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

    totalPage = 0
    try:
        page.abid = chatuser1.abid
        totalPage = Chat_MessageDAO.querysixinnumwithhe(chatuser1.abid)
    #查询Aid_Bid
    except Exception as e:
        print(e)

        page.totalPage = totalPage
        page.pageSize = 10
        page.start = 10 * (pageNo - 1)  #数据库本来就是从后向前查询的   在数据库中第0条记录就是最默认的记录
        print("共有聊天记录" + totalPage + "abid:" + page.abid)
    try:
        allMessage = Chat_MessageDAO.queryAllsixinwithhe(
            page.abid, page.start, page.pageSize)  #通过abid查询
        if (allMessage != None 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.add(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 result
Exemple #11
0
def updateuserinf(request):
    result = {}
    user = User()
    if request.method == "POST":
        userid = request.POST.get("userid", None)  # 读取post数据,None为默认值
        phone = request.POST.get("phone", None)  # 读取post数据,None为默认值
        qunidstr = request.POST.get("qunid", None)  # 读取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为默认值
        id_number = request.POST.get("id_number", None)  # 读取get数据,None为默认值
        push_userId = request.POST.get("push_userId", None)  # 读取get数据,None为默认值
        push_channelId = request.POST.get("push_channelId", None)  # 读取get数据,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":
        userid = request.GET.get("userid", None)  # 读取get数据,None为默认值
        phone = request.GET.get("phone", None)  # 读取get数据,None为默认值
        qunidstr = request.GET.get("qunid", None)  # 读取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为默认值
        id_number = request.GET.get("id_number", None)  # 读取get数据,None为默认值
        push_userId = request.GET.get("push_userId", None)  # 读取get数据,None为默认值
        push_channelId = request.GET.get("push_channelId", 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("更新资料接口参数:" + "昵称:" + name + "手机号" + phone + "邮箱:" + email + "身份账号" + id_number + "地址:" + address)

    user = UserDAO.getUserInfoId(userid)
    if(not user):
        result["message"]= "修改用户资料失败"
        result["respcode"]= ResultCode.FAIL
        result["data"]="0"
        result["errorcode"]= ResultCode.FAIL
        return result

    user.id = userid
    if(name):  user.name=name
    if(qunidstr):  user.qunid=int(qunidstr)
    if(phone):  user.phone=phone
    if(email):  user.email=email
    if(id_number):  user.id_number=id_number
    if(address):  user.address=address
    if(school):  user.school=school
    if(wechat):  user.wechat=wechat
    if(alipay):  user.alipay=alipay
    if(usericon):  user.image=usericon
    if(push_userId):  user.push_userId=push_userId
    if(push_channelId):  user.push_channelId=push_channelId
    if(parameter1):  user.parameter1=parameter1
    if(parameter2):  user.parameter2=parameter2
    if(parameter3):  user.parameter3=parameter3
    if(parameter4):  user.parameter4=parameter4
    if(parameter5):  user.parameter5=parameter5
    if(parameter6):  user.parameter6=parameter6
    if(parameter7):  user.parameter7=parameter7
    if(parameter8):  user.parameter8=parameter8
    if(parameter9):  user.parameter9=parameter9
    if(parameter10):  user.parameter10=parameter10
    if(parameter11):  user.parameter11=parameter11
    if(parameter12):  user.parameter12=parameter12
    if(parameter13):  user.parameter13=parameter13
    if(parameter14):  user.parameter14=parameter14
    if(parameter15):  user.parameter15=parameter15
    if(parameter16):  user.parameter16=parameter16
    if(parameter17):  user.parameter17=parameter17
    if(parameter18):  user.parameter18=parameter18
    if(parameter19):  user.parameter19=parameter19
    if(parameter20):  user.parameter20=parameter20

    #升级为高级会员的条件,能创建群组
    if(id_number):
        pass
        #user.setState(ResultCode.USER_VIP)


    try:
        #先修该用户资料
        UserDAO.updateUserInfo(user)
        #根据用户id查询用户信息
        users_back = UserDAO.getUserInfoId(user.id)

        #将返回信息转变为本文信息类
        loginResult = user2meBack(users_back)

        result["data"]=  loginResult
        result["respcode"]=  ResultCode.SUCCESS
        result["errorcode"]=  ""
        result["message"]=  "修改用户资料成功"


    except Exception as e:
        print(e)
        result["message"]=  "修改用户资料失败"
        result["respcode"]=  ResultCode.FAIL
        result["data"]=  "0"
        result["errorcode"]=  ResultCode.FAIL

    return result
Exemple #12
0
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 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"] = more1
        result["respcode"] = ResultCode.SUCCESS
        result["errorcode"] = ResultCode.SUCCESS
        result["message"] = "添加处理成功"

    else:
        try:
            MoreDAO.adddeal(more)
            more = MoreDAO.selectmoreInfomore(more)
            result["data"] = 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 result
Exemple #13
0
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 result
Exemple #14
0
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 result