Esempio n. 1
0
def getList():
    myRes = MyResponse()
    try:
        query_data = db_session.query(UserInfo).all()
        myRes.data = MySqlalchemy.convertToList(query_data)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 2
0
def getList():
    myRes = MyResponse()
    try:
        query_data = db_session.query(RoleInfo).order_by(
            RoleInfo.TIME_MODIFY.desc())
        myRes.data = MySqlalchemy.convertToList(query_data)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 3
0
def getList():
    myRes = MyResponse()
    try:
        query_menuButton = db_session.query(OperInfo).order_by(
            OperInfo.OPER_SOFT.asc()).all()
        myRes.data = MySqlalchemy.convertToList(query_menuButton)
        print(myRes.data)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 4
0
def getList():
    myRes = MyResponse()
    try:
        query_menu = db_session.query(
            MenuInfo.MENU_KEY, MenuInfo.MENU_PKEY, MenuInfo.MENU_NAME,
            MenuInfo.MENU_URL, MenuInfo.MENU_ICON,
            MenuInfo.MENU_SOFT).order_by(MenuInfo.MENU_SOFT.asc()).all()
        myRes.data = MySqlalchemy.convertToList(query_menu)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 5
0
def getRoleListByUserKey():
    myRes = MyResponse()
    USER_KEY = MyRequest.get("USER_KEY", type=int)
    try:
        clomns = [UserRole.USER_KEY, RoleInfo.ROLE_NAME, UserRole.ROLE_KEY]
        query_data = db_session.query(*clomns).outerjoin(
            RoleInfo, RoleInfo.ROLE_KEY == UserRole.ROLE_KEY).filter(
                UserRole.USER_KEY == USER_KEY)
        myRes.data = MySqlalchemy.convertToList(query_data)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 6
0
def getRoleMenuAndOperList():
    myRes = MyResponse()
    ROLE_KEY = MyRequest.get("ROLE_KEY", type=int)
    try:
        query_data = db_session.query(RolePermission.ROLE_KEY,
                                      RolePermission.RESOURCE_KEY,
                                      RolePermission.RESOURCE_TYPE).filter(
                                          RolePermission.ROLE_KEY == ROLE_KEY)
        myRes.data = MySqlalchemy.convertToList(query_data)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 7
0
def getPageList():
    myRes = MyResponse()
    currentPage = MyRequest.get("currentPage", type=int)
    pageSize = MyRequest.get("pageSize", type=int)
    searchDptKey = MyRequest.get("searchDptKey", type=str)
    searchName = MyRequest.get("searchName", type=str).strip()
    columns = [
        UserInfo.USER_KEY, UserInfo.USER_NAME, UserInfo.LOGIN_NAME,
        UserInfo.USER_SEX, UserInfo.USER_POSITION, UserInfo.DPT_KEY,
        DptInfo.DPT_NAME, UserInfo.TIME_MODIFY, UserInfo.PHONE
    ]
    filters = []
    outerjoins = [(DptInfo, DptInfo.DPT_KEY == UserInfo.DPT_KEY)]
    try:
        USER_KEY = g.USER_KEY
        if USER_KEY != 1:
            filters.append(UserInfo.USER_KEY != 1)
        if searchDptKey != 0:
            filters.append(UserInfo.DPT_KEY.like(searchDptKey + "%"))
        if searchName is not None:
            filters.append(UserInfo.USER_NAME.like("%" + searchName + "%"))
        user_page_info = MySqlalchemy.get_page_list(
            currentPage,
            pageSize,
            UserInfo.USER_KEY,
            columns,
            outerjoins=outerjoins,
            filters=filters,
            orders=[UserInfo.TIME_MODIFY.desc()])
        ###拼接用户角色
        query_data_role = db_session.query(
            UserRole.USER_KEY, RoleInfo.ROLE_NAME,
            UserRole.ROLE_KEY).outerjoin(
                RoleInfo, RoleInfo.ROLE_KEY == UserRole.ROLE_KEY)
        list_role = MySqlalchemy.convertToList(query_data_role)
        for xuser in user_page_info["data"]:
            list_roleName = []
            for xrole in list_role:
                if xuser["USER_KEY"] == xrole["USER_KEY"]:
                    list_roleName.append(xrole["ROLE_NAME"])
            xuser["ROLE_NAMES"] = ",".join(list_roleName)
        myRes.data = user_page_info
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Esempio n. 8
0
def getDptAndUserList():
    myRes = MyResponse()
    try:
        query_data_dpt = db_session.query(DptInfo.DPT_KEY, DptInfo.DPT_PKEY,
                                          DptInfo.DPT_NAME)
        query_data_user = db_session.query(
            UserInfo.USER_KEY, UserInfo.DPT_KEY,
            UserInfo.USER_NAME).filter(UserInfo.USER_KEY != 1)
        query_data = query_data_dpt.union_all(query_data_user)
        myRes.data = MySqlalchemy.convertToList(query_data)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()