示例#1
0
def apk_analysis_handler():
    """
    @api {post} /v1/tool/apk/analysis 分析 apk 包信息
    @apiName AnalysisApkInformation
    @apiGroup 拓展
    @apiDescription 分析 apk 包信息
    @apiParam {apk_download_url} apk 包的下载地址
    @apiParamExample {json} Request-Example:
    {
      "apk_download_url": "http://tcloud-static.ywopt.com/static/3787c7f2-5caa-434a-9a47-3e6122807ada.apk"
    }
    @apiSuccessExample {json} Success-Response:
    HTTP/1.1 200 OK
    {
        "code": 0,
        "data": {
            "default_activity": "com.earn.freemoney.cashapp.activity.SplashActivity",
            "icon": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAVr0lEQVR42u2debAdVZ3HP6f79N3ekuQlJOQlARICBCGs",
            "label": "Dosh Winner",
            "package_name": "com.earn.freemoney.cashapp",
            "size": "13.97",
            "version_code": "86",
            "version_name": "2.0.36"
        },
        "message": "ok"
    }
    """
    apk_download_url, type = parse_json_form('tool_apk_analysis_upload')
    if apk_download_url:
        data = ToolBusiness.apk_analysis(apk_download_url, type)
        return json_detail_render(0, data)
    else:
        return json_detail_render(101, 'apk_download_url is required!')
示例#2
0
def phone_move_handler(pid):
    """
    @api {post} /v1/asset/phone/move/{int:id} 流转 资产设备
    @apiName MovePhone
    @apiGroup 项目
    @apiDescription 流转 资产设备
    @apiParam {int} id
    @apiParam {int} borrow_id 流转人 ID
    @apiParamExample {json} Request-Example:
    {
        "borrow_id": 2
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
          "code": 0,
          "data": [],
          "message": "ok"
    }
    """
    if is_admin() or PhoneBusiness.can_move_status(pid):
        borrow_id = parse_json_form('phone_move')
        ret, msg = PhoneBusiness.move_to_user(pid, borrow_id)
        return json_detail_render(ret, [], msg)
    else:
        return json_detail_render(403)
示例#3
0
def login_handler():
    """
    @api {post} /v1/user/login 登录
    @apiName Login
    @apiGroup 用户
    @apiDescription 登录
    @apiParam {string} username 用户
    @apiParam {string} password 密码
    @apiParamExample {json} Request-Example:
    {
        "username":"******",
        "password":"******"
    }
    @apiSuccess {string} token 用户token
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": {
            "token": "tokenxxxx.xxxxx"
        },
        "message": "ok"
    }
    """
    username, passwd = parse_json_form('login')
    if passwd is '':
        return json_detail_render(301)
    code, data = AuthBusiness.login(username, passwd)

    return json_detail_render(code, data)
示例#4
0
def login_handler():
    """
    @api {post} /v1/user/login 登录
    @apiName Login
    @apiGroup 用户
    @apiDescription 登录
    @apiParam {string} username 用户
    @apiParam {string} password 密码
    @apiParamExample {json} Request-Example:
    {
        "username":"******",
        "password":"******"
    }
    @apiSuccess {string} token 用户token
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": {
            "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IndpZ2dlbnMiLCJ1c2VyaWQiOj"
        },
        "message": "ok"
    }
    """
    username, passwd = parse_json_form('login')
    if passwd is '':
        return json_detail_render(301)
    # code, data = AuthBusiness.login(username, passwd)
    code, data = AuthBusiness.ssoLogin(username, passwd)

    return json_detail_render(code, data)
示例#5
0
def requirement_query_pass_handler():
    id_or_title = request.args.get('id_or_title')
    if id_or_title:
        data = RequirementBusiness.get_requirement_by_id_or_title(id_or_title)
        return json_detail_render(0, data)
    else:
        code, data = RequirementBusiness.get_requirement()
        return json_detail_render(code, data)
示例#6
0
def update_tag():
    tag_id, project_id, description, tag_type = parse_json_form('updatetag')
    data = TagBusiness.judage_tag(project_id, tag_type)
    content_list = []

    for i in range(0, len(data)):
        content_list.append(data[i]['tag'])

    if tag_id in content_list:
        return json_detail_render(102, [], '增加的tag已经存在')
    ret = TagBusiness.create(tag_id, project_id, description, tag_type)
    return json_detail_render(ret)
示例#7
0
def track_create_history_device():
    project_id, user_id, device_typename, device_number = parse_json_form(
        "track_device_create")

    data = TrackUploadBusiness.check_device_exist(project_id, user_id,
                                                  device_number)

    if len(data) > 0:
        return json_detail_render(0, [], 'ok')

    code, message = TrackUploadBusiness.create(project_id, user_id, 0,
                                               device_typename, device_number)

    return json_detail_render(code, [], message)
示例#8
0
def project_unless_user():
    """
    @api {get} /v1/user/unless/user_list 获取 不是当前项目的用户列表
    @apiName GetUserListsByUnlessPorject
    @apiGroup 用户
    @apiDescription 获取不是当前项目的用户列表
    @apiParam {int} project_id 项目id
    @apiParam {int} [limit] limit
    @apiParam {int} [offset] offset
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": [
            {
                "project_id": 4
            }
        ],
        "message": "ok"
    }
    """
    user_list = []
    user_data = UserBusiness.query_user_list()
    # 项目列表的用户
    for i in range(0, len(user_data)):
        user_list.append(int(user_data[i]['user_id']))
    # 过滤admin用户
    # admin_list = UserBusiness.query_admin_list()

    user_list = list(set(user_list))

    data = UserBusiness.query_unless_user_list(user_list)

    return json_detail_render(0, data)
示例#9
0
def wx_user_bind_handler():
    """
    @api {post} /v1/user/wxbinduser 关联 企业微信到老账号
    @apiName WxBindUser
    @apiGroup 用户
    @apiDescription 企业微信关联老账号
    @apiParam {int} userid 老账号的ID
    @apiParam {int} wxuserid 企业微信用户的ID
    @apiParamExample {json} Request-Example:
    {
        "wxuserid": 58,
        "userid": 20
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
       "code": 0,
       "data": [],
       "message": ""
     }
    """
    userid, wxuserid = parse_json_form('wxbinduser')
    ret, msg = UserBusiness.wx_bind_user(userid, wxuserid)

    return json_detail_render(ret, msg)
示例#10
0
def user_bind_project_handler():
    """
    @api {post} /v1/user/bindproject 绑定 项目到用户
    @apiName BindProject
    @apiGroup 用户
    @apiDescription 给用户绑定项目,赋予访问权限等
    @apiParam {int} user_id 用户ID
    @apiParam {int[]} project_ids 项目
    @apiParamExample {json} Request-Example:
    {
        "user_id":1,
        "project_ids":[1]
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
       "code": 0,
       "data": [],
       "message": ""
     }
    """
    user_id, pids = parse_json_form('userbindprojects')
    ret, msg = UserBusiness.bind_projects(user_id, pids)

    return json_detail_render(ret, [], msg)
示例#11
0
def user_bind_role_handler():
    """
    @api {post} /v1/user/userbindroles 绑定 用户角色
    @apiName BindUserRole
    @apiGroup 用户
    @apiDescription 绑定用户角色
    @apiParam {int} userid 用户ID
    @apiParam {int[]} roleids role list可以为空,表示清空绑定关系
    @apiParamExample {json} Request-Example:
    {
        "userid":6,
        "roleids":[4]
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
       "code": 0,
       "data": [],
       "message": ""
     }
    """
    userid, roleids, project_id = parse_json_form('userbindroles')

    ret, msg = UserBusiness.user_bind_roles(userid, roleids, project_id)
    return json_detail_render(ret, [], msg)
示例#12
0
def get_usedetail_handler():
    """
    @api {get} /v1/tcdevices/usedetail 云真机设备使用详情
    @apiName DevicesDetail
    @apiGroup 云真机
    @apiDescription 云真机设备使用详情
    @apiParamExample {json} Request-Example:
    无
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
        "code":0,
        "data":[
            {
                "comment":"HUAWEI Che1-CL10",
                "id":1,
                "serial":"b43052ac3437",
                "times":169,
                "use_time":"863"
            }
        ],
        "message":"ok"
    }
    """
    data = TcDevicesBusiness.query_all_json()
    return json_detail_render(0, data)
示例#13
0
def user_reset_handler():
    """
    @api {post} /v1/user/resetpassword 重置 用户密码
    @apiName ResetPassword
    @apiGroup 用户
    @apiDescription 重置用户密码
    @apiParam {int} userid 用户ID
    @apiParam {string} newpassword 新密码
    @apiParamExample {json} Request-Example:
    {
        "userid":1,
        "newpassword":"******"
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": [],
        "message": "ok"
    }
    """
    project_id = request.args.get('project_id')
    userid, newpassword = parse_json_form('resetpassword')
    ret, msg = UserBusiness.reset_password(userid, newpassword, project_id)

    return json_detail_render(ret, message=msg)
示例#14
0
def run_project():
    """
    @api {post} /v1/cidata/run 触发job
    @apiName runJob
    @apiGroup CI
    @apiDescription 触发job
    @apiParam {list} run_list 触发的list
    @apiParam {int} project_id 项目id
    @apiParamExample {json} Request-Example:
    {
        "run_list": [1],
        "project_id":1
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
        "code": 0,
        "data": [
            {
                "id": 1,
                "isexcuting": false,
                "job": "test_email",
                "name": "test view"
            }
        ],
        "message": "ok"
    }
    """
    project_id, run_list = parse_json_form('cidatarunandreport')
    code, data, message = CiJobBusiness.run(project_id, run_list)
    return json_detail_render(code, data, message)
示例#15
0
def description_list(ci_id):
    """
    @api {get} /v1/description/:ci_id 获取job的描述
    @apiName GetJenkinsJobDescription
    @apiGroup CI
    @apiDescription 获取job的描述
    @apiParam {int} ci_id job id
    @apiParamExample {json} Request-Example:
    {
        "ci_id": 1,
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": [
            {
                "error_count": 1,
                "error_message": "['oom:\\n', '// OOM: com.tcloud(dump time: 2019-07-03 12:13:56)]",
                "error_type": "OOM",
                "id": 5,
                "monkey_id": 29
            }
        ],
        "message": "ok"
    }
    """
    data = CiDataBusiness.query_description_by_id(ci_id)
    return json_detail_render(0, data)
示例#16
0
def user_index_handler():
    """
    @api {post} /v1/user/add 新增 用户
    @apiName CreateUser
    @apiGroup 用户
    @apiDescription 新增用户
    @apiParam {string} username 用户名:字母[+数字]
    @apiParam {string} nickname 昵称
    @apiParam {string} password 密码
    @apiParam {int[]} roleids 角色,可传入空数组
    @apiParam {string} email 邮箱
    @apiParam {string} telephone 手机号
    @apiParamExample {json} Request-Example:
    {
        "username":"******",
        "nickname":"zhangdashan",
        "password":"******",
        "roleids":[],
        "email":"*****@*****.**",
        "telephone":"13131313131"
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": [],
        "message": "ok"
    }
    """
    username, nickname, password, email, telephone = parse_json_form('adduser')
    ret, msg = UserBusiness.create_new_user_and_bind_roles(
        username, nickname, password, email, telephone)

    return json_detail_render(ret, [], msg)
示例#17
0
def detach_user():
    """
    @api {post} /v1/user/detachuser 项目解绑用户
    @apiName DetachUserForProject
    @apiGroup 用户
    @apiDescription 项目解绑用户
    @apiParam {int} user_id 用户ID
    @apiParam {int} project_id 项目ID
    @apiParamExample {json} Request-Example:
    {
        "project_id": 75,
        "user_id":1
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
    "code":0,
    "data":[],
    "message":"ok"
    }
    """
    project_id, user_id = parse_json_form('projectdetachusers')
    ret, msg = UserBusiness.project_detach_user(project_id, user_id)

    return json_detail_render(ret, [], msg)
示例#18
0
def module_details_handler(mid):
    """
    @api {post} /v1/module/{id} 修改 模块
    @apiName ModifyModule
    @apiGroup 项目
    @apiDescription 修改模块,应该只是修改名称描述,感觉后续可能要修改parent_id
    @apiParam {string} name 名称
    @apiParam {int} project_id 项目od
    @apiParam {string} description 描述
    @apiParam {int} weight weight
    @apiParamExample {json} Request-Example:
    {
        "name":"用力模块",
        "project_id":"4",
        "description":"",
        "weight":1
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": "",
        "message": "ok"
    }
    """
    name, project_id, description, weight = parse_json_form('modulemodify')
    ret, msg = ModuleBusiness.module_modify(mid, name, project_id, description,
                                            weight)

    return json_detail_render(ret, [], msg)
示例#19
0
def module_indexs_handler():
    """
    @api {post} /v1/module/ 新增 模块
    @apiName CreateModule
    @apiGroup 项目
    @apiDescription 新增模块,分为父模块还是子模块
    @apiParam {string} name 名称
    @apiParam {int} project_id 项目od
    @apiParam {string} description 描述
    @apiParam {int} parent_id 父模块id
    @apiParamExample {json} Request-Example:
    {
        "name":"用力模块",
        "project_id":4,
        "description":"",
        "parent_id":110
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": "",
        "message": "ok"
    }
    """
    name, project_id, description, parent_id = parse_json_form('modulecreate')
    ret, msg = ModuleBusiness.module_create(name, project_id, description,
                                            parent_id)

    return json_detail_render(ret, [], msg)
示例#20
0
def module_detail_handler(mid):
    """
    @api {get} /v1/module/{id} 获取 项目的某个用例模块
    @apiName GetModuleByModuleid
    @apiGroup 项目
    @apiDescription 获取项目的某个用例模块(需要token)
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
         "code":0,
         "data":[
            {
                "description": "",
                "id": 342,
                "name": "看板管理",
                "projectid": 4,
                "status": 0,
                "weight": 1
            }
        ],
        "message":"ok",
     }
    """
    data = ModuleBusiness.query_json_by_id(mid)

    return json_detail_render(0, data)
示例#21
0
def get_dashboard_usedetail_handler():
    """
    @api {get} /v1/tcdevices/dashboard 云真机使用报表
    @apiName Dashboard
    @apiGroup 云真机
    @apiDescription 云真机使用报表
    @apiParam {string} start_time 开始时间
    @apiParam {string} end_time 结束时间
    @apiParamExample {json} Request-Example:
    ?start_time=2019-07-26&end_time=2019-07-26
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
    "code":0,
    "data":[
        {
            "devices_times":[
                {
                    "date":"2019-07-26",
                    "times":1
                }
            ],
            "devices_use_time":[
                {
                    "date":"2019-07-26",
                    "use_time":140
                }
            ]
        }
    ],
    "message":"ok"
    }
    """
    data = TcDevicesBusiness.query_dashboard()
    return json_detail_render(0, data)
示例#22
0
def get_user_usedetail_handler():
    """
    @api {get} /v1/tcdevices/usedetail/user 云真机个人使用详情
    @apiName UserDetail
    @apiGroup 云真机
    @apiDescription 云真机个人使用详情
    @apiParam {string} userid 用户ID
    @apiParamExample {json} Request-Example:
    ?userid=1
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
    "code":0,
    "data":[
        {
            "creation_time":"2019-07-26 11:15:57",
            "id":1148,
            "manufacturer":"HUAWEI",
            "model":"VKY-AL00",
            "platform":"Android",
            "resolution":"2560x1440",
            "serial":"Y2J5T17410004213",
            "use_time":"140",
            "user_id":17,
            "user_name":"秦捷",
            "version":"7.0"
        }
    ],
    "message":"ok"
    }
    """
    data = TcDevicesBusiness.query_user_all_json()
    return json_detail_render(0, data)
示例#23
0
def get_json_by_id():
    user_id = request.args.get('userid')
    project_id = request.args.get('project_id')
    if not project_id:
        project_id = request.headers.get('projectid')
    data = UserBusiness.query_json_by_id_and_project(user_id, project_id)
    return json_detail_render(0, data)
示例#24
0
def review_comment_requirement(review_id):
    comment, result = parse_json_form('review_comment')
    RequirementReviewBusiness.review_modify(review_id, comment, result)

    # 数据同步到需求列表中
    ret = RequirementBusiness.review_modify(result)
    return json_detail_render(ret)
示例#25
0
def ci_list():
    """
    @api {get} /v1/cidata/ 获取jenkins的job
    @apiName GetJenkinsJob
    @apiGroup CI
    @apiDescription 查询jenkins的job
    @apiSuccessExample {json} Success-Response:
    HTTP/1.1 200 OK
    {
        "code": 0,
        "data": [
            {
                "accuracy": "0",
                "case_count": 0,
                "description": "自动化例会通知",
                "id": 15,
                "name": "automation_meeting",
                "nextBuildNumber": 63,
                "status": 0
            }
        ],
        "message": "ok"
    }
    """
    data = CiDataBusiness.query_all_json()
    return json_detail_render(0, data)
示例#26
0
def update_branch():
    """
    @api {get} /v1/deploy/branch 获取分支信息
    @apiName deployBranch
    @apiGroup Deploy
    @apiDescription 获取分支信息
    @apiParam {int} server_id 服务id
    @apiParamExample {json} Request-Example:
    {
        "server_id": 45
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
        "code": 0,
        "data": [
            "20190604",
            "master",
            "develop",
            "release/inno",
            "dev/push",
            "release/cpc"
        ],
        "message": "成功"
    }
    """
    code, data, message = DeployBusiness.get_branch()

    return json_detail_render(code, data, message)
示例#27
0
def gain_report():
    """
    @api {post} /v1/cidata/report 获取报告
    @apiName gainJobReport
    @apiGroup CI
    @apiDescription job的报告
    @apiParam {list} run_list 触发的list
    @apiParam {int} project_id 项目id
    @apiParamExample {json} Request-Example:
    {
        "run_list": [1],
        "project_id":1
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
        "code": 0,
        "data": [
            {
                "id": 1,
                "isexcuting": false,
                "job": "tcloud_regression_test",
                "name": "Tcloud回归测试",
                "url": "http://host:port/report.html"
            }
        ],
        "message": "ok"
    }
    """
    project_id, run_list = parse_json_form('cidatarunandreport')
    code, data, message = CiJobBusiness.gain_report(project_id, run_list)
    return json_detail_render(code, data, message)
示例#28
0
def version_modify_handler(version_id):
    """
    @api {post} /v1/version/{version_id} 修改版本
    @apiName ModifyVersion
    @apiGroup 项目
    @apiDescription 修改版本
    @apiParam {string} title 标题
    @apiParam {int} project_id 项目ID
    @apiParam {string} start_time 版本开始时间
    @apiParam {string} end_time 版本结束时间
    @apiParam {int} publish_status 发布状态0:未发布1:已发布
    @apiParam {string} description 描述
    @apiParam {string} comment 备注
    @apiParamExample {json} Request-Example:
    {
        "title": "str",
        "project_id": 1,
        "start_time": "2018-11-11",
        "end_time": "2018-11-11",
        "publish_status": 1,
        "description": "str",
        "comment": "str"
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
    "code":0,
    "data":[],
    "message":"ok"
    }
    """
    title, start_time, end_time, description = parse_json_form('versionmodify')
    ret = VersionBusiness.version_modify(version_id, title, start_time, end_time, description)
    return json_detail_render(ret)
示例#29
0
def wxuser_index_handler():
    """
    @api {post} /v1/wxlogin/ 登录 微信
    @apiName WxLogin
    @apiGroup 用户
    @apiDescription 登录微信
    @apiParam {string} user_code 用户编码
    @apiParamExample {json} Request-Example:
    {
        "user_code":"j2qL3QjNXXwa_4A0WJFDNJyPEx88HTHytARgRbr176g"
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
       "code": 0,
       "data": {
            "token": "asdasdasd"
        },
       "message": ""
     }
    """
    user_code = parse_json_form('wx_user_code')

    ret, data, msg = WxLoginBusiness.get_user(user_code[0])

    return json_detail_render(ret, data, msg)
示例#30
0
def user_detail_modify_handler(user_id):
    """
    @api {post} /v1/user/{user_id} 修改 用户密码
    @apiName ModifyPassword
    @apiGroup 用户
    @apiDescription 修改用户密码
    @apiParam {string} oldpassword 旧密码
    @apiParam {string} newpassword 新密码
    @apiParamExample {json} Request-Example:
    {
        "oldpassword":"******",
        "newpassword":"******"
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
     {
        "code": 0,
        "data": [],
        "message": "ok"
    }
    @apiErrorExample {json} Error-Response:
     HTTP/1.1 200 OK
     {
        "code": 301,
        "data": [],
        "message": "password wrong"
    }
    """
    project_id = request.args.get('project_id')
    oldpassword, newpassword = parse_json_form('modifypassword')
    ret = UserBusiness.modify_password(user_id, oldpassword, newpassword,
                                       project_id)
    return json_detail_render(ret)