Beispiel #1
0
def resource_delete():
    """资源详情"""
    args = request.json
    key = http_util.check_params(args, 'res_id', 'res_type')
    if key:
        return http_util.return_param_not_found(key)

    login_user_id = http_util.get_login_user_id(request)

    if not login_user_id:
        return http_util.return_no_authorization()

    res_id = http_util.get_param(args, 'res_id')
    res_type = http_util.get_param_int(args, 'res_type')

    try:
        is_del = Resource.delete_resource(res_id, res_type)

        if not is_del:
            return http_util.return_internal_server_error("删除失败")

        # 记录用户行为
        Action.create_action(
            user_id=login_user_id,
            type=BaseConfig.TYPE_ACTION_DELETE,
            res_id=res_id,
            res_type=res_type
        )

        return http_util.return_model()
    except BaseException as e:
        app.logger.error(e)
        return http_util.return_internal_server_error()
Beispiel #2
0
def resource_delete_json():
    '''首页列表'''
    args = request.form

    res_id = http_util.get_param(args, 'res_id', None)
    res_type = http_util.get_param_int(args, 'res_type', 0)

    if not res_id or not res_type:
        return http_util.return_forbidden('res_id or res_type is error')

    check_use = Resource.check_resource_use_status(res_id, res_type)
    if check_use:
        return http_util.return_forbidden("{},不能删除".format(check_use))

    res = Resource.delete_resource(res_id, res_type)

    if res:
        return return_model()
    else:
        return http_util.return_internal_server_error()