コード例 #1
0
ファイル: views.py プロジェクト: loulonglong/django
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)
コード例 #2
0
ファイル: views.py プロジェクト: loulonglong/django
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)