Example #1
0
def api_user_message():
    '''
    GET:
        获取用户的消息
        type:<array>,消息类型, 比如["notice", "private_letter"]
        label:<array>, 消息label, 默认全部label, 比如['comment', 'audit_failure', 'sys_notice']
        pre:<int>,每页获取几条数据,默认10
        page:<int>,第几页,默认1
        status_update:<str>,获取后的消息状态更新. 可以为: "have_read"
    PUT:
        更新消息状态
        ids:<array>,消息id
        status_update:<str>,获取后的消息状态更新. 可以为: "have_read"
    DELETE:
        删除消息
        ids:<array>,消息id
    :return:
    '''

    if request.c_method == "GET":
        data = get_user_msgs()
    elif request.c_method == "PUT":
        data = update_user_msgs()
    elif request.c_method == "DELETE":
        data = delete_user_msgs()
    else:
        data = {"msg_type": "w", "msg": METHOD_WARNING, "http_status": 405}
    return response_format(data)
Example #2
0
def api_adm_message():
    """
    GET:
        获取用户消息
        is_sys_msg:<int>,获取系统消息? 1表示是, 0表示否
        pre:<int>,每页获取几条数据,默认10
        page:<int>,第几页,默认1
        type:<array>,消息类型, 比如["notice", "comment", "audit"]
    DELETE:
        删除消息(此接口只能删除由系统发出的消息user_id==0的)
        ids:<array>,消息id
    :return:
    """

    if request.c_method == "GET":
        data = get_user_msgs(is_admin=True)

    elif request.c_method == "DELETE":
        data = delete_user_msgs(is_admin=True)
    else:
        data = {"msg_type": "w", "msg": METHOD_WARNING, "http_status": 405}
    return response_format(data)