Beispiel #1
0
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)
Beispiel #2
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