Example #1
0
def api_category():
    """
    GET:

        action:<str>, 可以为get_category, get_category_type, 默认get_category
        1.获取当前用户指定的type的所有category
            action:<str>, 为get_category
            type:<str>, 你设置的那几个类别中的类别,在config.py文件中category, 可在网站管理端设置的

        2. 获取所有的type: config.py文件中category的所有CATEGORY TYPE
            action:<str>, 为get_category_type
        解释:
            在分类中(category)又分为几种类型(type)
            如: type为post有几个category

    POST:
        添加文集
        name:<str>
        type:<str>, 只能是你设置的那几个类别,在config.py文件中category, 或者网站管理设置
    PUT:
        修改文集
        id:<str>, post category id
        name:<str>
    DELETE:
        删除文集名称
        ids:<array>, post category ids
    """
    if request.c_method == "GET":
        if not request.argget.all("action") == "get_category_type":
            data = categorys()
        else:
            data = get_category_type()

    elif request.c_method == "POST":
        data = category_add()
    elif request.c_method == "PUT":
        data = category_edit()
    elif request.c_method == "DELETE":
        data = category_delete()
    else:
        data = {"msg_type": "w", "msg": METHOD_WARNING, "custom_status": 405}
    return response_format(data)
Example #2
0
def api_adm_category():
    '''
    Admin管理端category管理
    GET:
        1.获取指定的type的所有分类
        type:<str>, 你设置的那几个类别中的类别,在config.py文件中category, 或者网站管理设置

        2.获取所有的type
        get_type:<int>, get_type为1
    POST:
        添加文集
        name:<str>
        type:<str>, 只能是你设置的那几个类别,在config.py文件中category, 或者网站管理设置
    PUT:
        修改文集
        id:<str>, post category id
        name:<str>
    DELETE:
        删除文集名称
        ids:<array>, post category ids
    '''

    if request.c_method == "GET":
        if not request.argget.all("get_type"):
            data = categorys(0)
        else:
            data = get_category_type()

    elif request.c_method == "POST":
        data = category_add(0)
    elif request.c_method == "PUT":
        data = category_edit(0)
    elif request.c_method == "DELETE":
        data = category_delete(0)
    else:
        data = {"msg_type": "w", "msg": METHOD_WARNING, "http_status": 405}
    return response_format(data)