예제 #1
0
def doc_chapter():
    if request.method == 'GET':
        return post_json('error', '请使用post方法')
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys():
                if UserDal.check_uid(data) is not None:
                    result = doc_dal.DocDal().doc_chapter(data)
                    if result is not None:
                        doc_dict = result[0]
                        doc_chapter_list = result[1]
                        data = dict(
                            docid=doc_dict['docid'],
                            docname=doc_dict['docname'],
                            doctype=doc_dict['doctype'],
                            chapters=doc_chapter_list,
                        )
                        return post_json('success', data=data)
                    else:
                        return post_json('success', '提取目录出错')
                else:
                    return post_json('error', '用户校验出错')
            else:
                return post_json('error', '输入参数不完整或者不正确')
        else:
            return post_json('error', '输入参数不完整或者不正确')
    else:
        return render_template('404.html')
예제 #2
0
def doc_create():
    if request.method == 'GET':
        return '<h1>请使用post方法</h1>'
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys():
                if UserDal.check_uid(data) is not None:
                    doc_typeinfo = doc_dal.DocDal().get_doc_typeinfo()
                else:
                    return "用户校验出错"
            else:
                return '输入参数不完整或者不正确'
        else:
            return '输入参数不完整或者不正确'
        return post_json(0, 'success', dict(doctypeinfo=doc_typeinfo))
    else:
        return render_template('404.html')
예제 #3
0
def doc_delete():
    if request.method == 'GET':
        return '<h1>请使用post方法</h1>'
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys():
                if UserDal.check_uid(data) is not None:
                    rowcount = doc_dal.DocDal().delete_doc(data)
                else:
                    return "用户校验出错"
            else:
                return '输入参数不完整或者不正确'
        else:
            return '输入参数不完整或者不正确'
        if rowcount > 0:
            return post_json(0, 'success', data='删除文档成功')
        else:
            return post_json(data='删除文档出错')
    else:
        return render_template('404.html')
예제 #4
0
def doc_download():
    if request.method == 'GET':
        return post_json('error', '请使用post方法')
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys():
                if UserDal.check_uid(data) is None:
                    return post_json('error', '用户校验出错')
                if doc_dal.DocDal.get_doc_by_id(data) is None:
                    return post_json('error', '该文档不存在或已删除')
                doc_url = doc_dal.DocDal().get_doc_url(data, request)
                if doc_url is not None:
                    return post_json('success', data=doc_url)
                else:
                    return post_json('error', '文档下载出错')
            else:
                return post_json('error', '输入参数不完整或者不正确')
        else:
            return post_json('error', '输入参数不完整或者不正确')
    else:
        return render_template('404.html')
예제 #5
0
def doc_save_temp():
    if request.method == 'GET':
        return post_json('error', '请使用post方法')
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys() and 'cpcode' in data.keys() \
                    and 'cpcontent' in data.keys():
                if UserDal.check_uid(data) is not None:
                    doc_save_return = doc_dal.DocDal().doc_save_temp(data)
                    if doc_save_return is not None:
                        return post_json('success', '暂存数据成功')
                    else:
                        return post_json('error', '数据暂存出错')
                else:
                    return post_json('error', '用户校验出错')
            else:
                return post_json('error', '输入参数不完整或者不正确')
        else:
            return post_json('error', '输入参数不完整或者不正确')
    else:
        return render_template('404.html')
예제 #6
0
def doc_check_t():
    if request.method == 'GET':
        return post_json('error', '请使用post方法')
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys() and 'cpcode' in data.keys() \
                    and 'tmcode' in data.keys() and 'tminputcode' in data.keys():
                if UserDal.check_uid(data) is not None:
                    tcontentlist = doc_dal.DocDal().doc_check_t(data)
                    if doc_check_t is not None:
                        return post_json('success', data=tcontentlist)
                    else:
                        return post_json('error', '模板查询出错')
                else:
                    return post_json('error', '用户校验出错')
            else:
                return post_json('error', '输入参数不完整或者不正确')
        else:
            return post_json('error', '输入参数不完整或者不正确')
    else:
        return render_template('404.html')
예제 #7
0
def calc_nl_value():
    if request.method == 'GET':
        return post_json('error', '请使用post方法')
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys() and 'cpcode' in data.keys() \
                    and 'llist' in data.keys():
                if UserDal.check_uid(data) is not None:
                    calc_nl_value = doc_dal.DocDal().calc_nl_value(data)
                    if calc_nl_value is not None:
                        return post_json('success', data=calc_nl_value)
                    else:
                        return post_json('error', '标签提交出错')
                else:
                    return post_json('error', '用户校验出错')
            else:
                return post_json('error', '输入参数不完整或者不正确')
        else:
            return post_json('error', '输入参数不完整或者不正确')
    else:
        return render_template('404.html')
예제 #8
0
def get_doc_cl_check():
    if request.method == 'GET':
        return post_json('error', '请使用post方法')
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docid' in data.keys(
            ) and 'cpcode' in data.keys():
                if UserDal.check_uid(data) is not None:
                    doc_cl_check = doc_dal.DocDal().get_doc_cl_check(data)
                    if doc_cl_check is not None:
                        return post_json('success', data=doc_cl_check)
                    else:
                        return post_json('error', '章节模块查询出错')
                else:
                    return post_json('error', '用户校验出错')
            else:
                return post_json('error', '输入参数不完整或者不正确')
        else:
            return post_json('error', '输入参数不完整或者不正确')
    else:
        return render_template('404.html')
예제 #9
0
def doc_create1():
    if request.method == 'GET':
        return '<h1>请使用post方法</h1>'
    elif request.method == 'POST':
        if is_json(request.get_data()):
            data = json.loads(request.get_data())
            if 'uid' in data.keys() and 'docname' in data.keys(
            ) and 'doctype' in data.keys():
                if UserDal.check_uid(data) is not None:
                    new_doc = doc_dal.DocDal().insert_doc_and_get_doc(data)
                    if new_doc is not None:
                        doc_id = new_doc['doc_id']
                else:
                    return "用户校验出错"
            else:
                return '输入参数不完整或者不正确'
        else:
            return '输入参数不完整或者不正确'
        if new_doc is not None:
            return post_json(0, 'success', dict(docid=doc_id))
        else:
            return post_json(data='新建文档出错')
    else:
        return render_template('404.html')