Exemplo n.º 1
0
def getAllFromRoleInfoAndApiInfoByRoleId(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        apiId = requset.GET.get('roleId')
        if apiId:
            roleInfo = roleInfoDao.getAllFromRoleInfoByRoleId(apiId)
            if roleInfo.api_list == '*':
                apiInfoList = apiInfoDao.getAllFromApiInfo()
            elif roleInfo.api_list:
                apiIdList = json.loads(roleInfo.api_list)
                apiInfoList = apiInfoDao.getAllFromApiInfoByApiIdList(
                    apiIdList)
            else:
                apiInfoList = []
            code = 200
            data = {
                'roleInfo': OrmConversion(roleInfo),
                'apiInfoList': OrmConversion(list(apiInfoList))
            }
        else:
            raise Exception('参数报错: roleId 不能为空!')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 2
0
def getAllFromAmbient(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        ambientList = ambientDao.getAllFromAmbient()
        code, data = 200, {'ambientList': OrmConversion(list(ambientList))}
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 3
0
def getAllFromGitInfoByGitId(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        gitId = requset.GET.get('gitId')
        if gitId:
            gitInfo = gitInfoDao.getAllFromGitInfoByGitId(gitId)
            code, data = 200, {'gitInfo': OrmConversion(gitInfo)}
        else:
            raise Exception('参数报错: gitId 不能为空')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 4
0
def getAllFromUserGroupByGroupId(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        groupId = requset.GET.get('groupId')
        if groupId:
            userGroup = userGroupDao.getAllFromUserGroupByGroupId(groupId)
            code, data = 200, {'userGroup': OrmConversion(userGroup)}
        else:
            raise Exception('参数报错: groupId 不能为空!')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 5
0
def getAllFromValnById(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        id = requset.GET.get('id')
        if id and id.isdigit():
            vlanInfo = vlanDao.getAllFromValnById(id)
            code, data = 200, {'vlan': OrmConversion(vlanInfo)}
        else:
            raise Exception('参数报错: id不能为空!')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 6
0
def getAllFromApiInfoByRoleId(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        apiId = requset.GET.get('apiId')
        if apiId:
            apiInfo = apiInfoDao.getAllFromApiInfoByApiId(apiId)
            code, data = 200, {'apiInfo': OrmConversion(apiInfo)}
        else:
            raise Exception('参数报错: apiId 不能为空!')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 7
0
def getAllFromProjectSettingByProjectId(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        settingId = requset.GET.get('settingId')
        if settingId:
            projectSetting = projectSettingDao.getAllFromProjectSettingByProjectId(
                settingId)
            code, data = 200, {'projectSetting': OrmConversion(projectSetting)}
        else:
            raise Exception('参数报错: settingId 不能为空!')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 8
0
def getAllFromGitInfoByPage(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        page = requset.GET.get('page')
        gitName = requset.GET.get('gitName')
        if page:
            gitInfoList, numPages = gitInfoDao.getAllFromGitInfoByPage(page, gitName=gitName)
            code, data = 200, {
                'gitInfoList': OrmConversion(list(gitInfoList)),
                'numPages': numPages,
                'page': int(page)
            }
        else:
            raise Exception('参数报错: page 不能为空')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 9
0
def getListFromRoleInfoByPage(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        page = requset.GET.get('page')
        roleName = requset.GET.get('roleName')
        if page:
            roleInfoList, numPages = roleInfoDao.getListFromRoleInfoByPage(
                page=page, roleName=roleName)
            code = 200
            data = {
                'roleInfoList': OrmConversion(list(roleInfoList)),
                'numPages': numPages,
                'page': int(page)
            }
        else:
            raise Exception('参数报错: page  不能为空!')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())
Exemplo n.º 10
0
def getAllFromVlanByPage(requset):
    code, data, message = None, None, None
    try:
        checkUserSession(requset)
        page = requset.GET.get('page')
        vlanName = requset.GET.get('vlanName')
        if page:
            vlanList, numPages = vlanDao.getAllFromVlanByPage(
                page=page, vlanName=vlanName)
            code = 200
            data = {
                'vlanList': OrmConversion(list(vlanList)),
                'numPages': numPages,
                'page': int(page)
            }
        else:
            raise Exception('参数报错: page不能为空')
    except Exception as e:
        code, data, message = 300, None, str(e)
    finally:
        return HttpResponse(
            JsonResponse(code=code, message=message, data=data).getJson())