def taskAddData(request):
    taskData = json.loads(request.body)

    taskData = HTTP_taskService.taskDataToDict(request, taskData)
    taskData["addBy_id"] = request.session.get("loginName")
    taskData["addByName"] = request.session.get("userName")
    if VersionService.isCurrentVersion(request):
        # if "id" not in taskData.keys():
        createTask = HTTP_taskService.addTask(taskData)
        if createTask.id >= 1:
            return HttpResponse(ApiReturn(ApiReturn.CODE_OK).toJson())
        else:

            return HttpResponse(
                ApiReturn(ApiReturn.CODE_TASK_EXCEPITON, "任务保存失败").toJson())
    # else:
    #     taskData["modTime"] = datetime.datetime.now()
    #     editTaskData = HTTP_taskService.editTask(taskData)
    #     if editTaskData == 1:
    #         return HttpResponse(ApiReturn(ApiReturn.CODE_OK).toJson())
    #     else:
    #         return HttpResponse(ApiReturn(ApiReturn.CODE_TASK_EXCEPITON, "任务编辑保存失败").toJson())
    else:
        # if "id" not in taskData.keys():
        createTask = HTTP_taskService.addVersionTask(
            taskData, VersionService.getVersionName(request))
        if createTask.id >= 1:
            return HttpResponse(ApiReturn(ApiReturn.CODE_OK).toJson())
        else:

            return HttpResponse(
                ApiReturn(ApiReturn.CODE_TASK_EXCEPITON, "任务保存失败").toJson())
def taskDataSaveEdit(request):
    taskData = json.loads(request.body)

    taskData = HTTP_taskService.taskDataToDict(request, taskData)

    if VersionService.isCurrentVersion(request):
        taskData["modTime"] = datetime.datetime.now()
        editTaskData = HTTP_taskService.editTask(taskData)
        if editTaskData == 1:
            return HttpResponse(ApiReturn(ApiReturn.CODE_OK).toJson())
        else:
            return HttpResponse(
                ApiReturn(ApiReturn.CODE_TASK_EXCEPITON, "任务编辑保存失败").toJson())
    else:
        taskData["modTime"] = datetime.datetime.now()
        editTaskData = HTTP_taskService.editVersionTask(
            taskData, VersionService.getVersionName(request))
        if editTaskData == 1:
            return HttpResponse(ApiReturn(ApiReturn.CODE_OK).toJson())
        else:
            return HttpResponse(
                ApiReturn(ApiReturn.CODE_TASK_EXCEPITON, "任务编辑保存失败").toJson())