Ejemplo n.º 1
0
def ajax_update_user(request: HttpRequest):
    """更新用户"""
    resp = Resp()
    try:
        result = BdUserService().update_user(params=UserRequestParam(request))
        resp.success(result)
    except BaseError as e:
        logger.error('update user fail: %s', e)
        resp.fail_error(e)
    except Exception as e:
        logger.error('update user error: %s', e)
        resp.fail(CODE_99999)
    return JsonResponse(utils.obj_to_dict(resp), encoder=CustomerEncoder)
Ejemplo n.º 2
0
def ajax_obtain_page_users(request: HttpRequest):
    """获取用户分页列表数据"""
    resp = Resp()
    try:
        result = BdUserService().obtain_page_users(params=UsersRequestParam(request))
        resp.success(data=result)
    except BaseError as e:
        logger.error('obtain page users fail: %s', e)
        resp.fail_error(e)
    except Exception as e:
        logger.error('obtain page users error: %s', e)
        resp.fail(CODE_99999)
    return JsonResponse(utils.obj_to_dict(resp), encoder=CustomerEncoder)
Ejemplo n.º 3
0
def ajax_obtain_all_menus(request: HttpRequest):
    """获取所有菜单"""
    resp = Resp()
    try:
        result = BdMenuService().obtain_all_menus()
        resp.success(data=result)
    except BaseError as e:
        logger.error('obtain all menus fail: %s', e)
        resp.fail_error(e)
    except Exception as e:
        logger.error('obtain all menus error: %s', e)
        resp.fail(CODE_99999)
    return JsonResponse(utils.obj_to_dict(resp), encoder=CustomerEncoder)
Ejemplo n.º 4
0
def ajax_add_menu(request: HttpRequest):
    """添加菜单"""
    resp = Resp()
    try:
        result = BdMenuService().add_menu(params=MenusRequestParam(request))
        resp.success(data=result)
    except BaseError as e:
        logger.error('add menu fail: %s', e)
        resp.fail_error(e)
    except Exception as e:
        logger.error('add menu error: %s', e)
        resp.fail(CODE_99999)
    return JsonResponse(utils.obj_to_dict(resp), encoder=CustomerEncoder)
Ejemplo n.º 5
0
def ajax_obtain_role(request: HttpRequest):
    """获取单个角色"""
    resp = Resp()
    try:
        result = BdRoleService().obtain_role(params=RoleRequestParam(request))
        resp.success(data=result)
    except BaseError as e:
        logger.error('obtain role fail: %s', e)
        resp.fail_error(e)
    except Exception as e:
        logger.error('obtain role error: %s', e)
        resp.fail(CODE_99999)
    return JsonResponse(utils.obj_to_dict(resp), encoder=CustomerEncoder)