Пример #1
0
def getLoginUserPermissionList():
    myRes = MyResponse()
    try:
        USER_KEY = g.USER_KEY
        outerjoins_menu = []
        outerjoins_oper = []
        filters = []
        columns_menu = [
            MenuInfo.MENU_SOFT, MenuInfo.MENU_KEY, MenuInfo.MENU_ICON,
            MenuInfo.MENU_URL, MenuInfo.MENU_PKEY, MenuInfo.MENU_NAME
        ]
        columns_oper = [OperInfo.OPER_NAME, OperInfo.OPER_URL]
        if USER_KEY != 12:
            outerjoins_menu = [
                (RolePermission,
                 and_(MenuInfo.MENU_KEY == RolePermission.RESOURCE_KEY,
                      RolePermission.RESOURCE_TYPE == 0)),
                (UserRole, UserRole.ROLE_KEY == RolePermission.ROLE_KEY)
            ]
            outerjoins_oper = [
                (RolePermission,
                 and_(OperInfo.OPER_KEY == RolePermission.RESOURCE_KEY,
                      RolePermission.RESOURCE_TYPE == 1)),
                (UserRole, UserRole.ROLE_KEY == RolePermission.ROLE_KEY)
            ]
            filters = [(UserRole.USER_KEY == USER_KEY)]
        query_data_menu = MySqlalchemy.get_all(columns_menu,
                                               outerjoins=outerjoins_menu,
                                               filters=filters,
                                               orders=[
                                                   (MenuInfo.MENU_SOFT.asc())
                                               ])
        query_data_oper = MySqlalchemy.get_all(columns_oper,
                                               outerjoins=outerjoins_oper,
                                               filters=filters,
                                               orders=[
                                                   (OperInfo.OPER_SOFT.asc())
                                               ])
        myRes.data = {"menuList": query_data_menu, "operList": query_data_oper}
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Пример #2
0
def getList():
    myRes = MyResponse()
    try:
        myRes.data=MySqlalchemy.get_all(DptInfo,orders=DptInfo.DPT_SOFT.asc())
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = ResState.ERROR_DB
    return myRes.to_json()