def flow_source_query_handler(): """ @api {post} /v1/flow/getsource 获取用户流程配置 @apiName GetSource @apiGroup 流程 @apiDescription 获取用户流程配置 @apiParam {int} project_id 项目ID @apiParam {int} user_id 用户ID @apiParamExample {json} Request-Example: { "project_id": 2, "user_id": 1 } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code":0, "data":[ { "creator":17, "id":12, "project_id":1, "user_ids":"[1,2,4,5,6]" } ], "message":"ok" } """ project_id, user_id = parse_json_form('getflowsource') data = FlowBusiness.flow_source_get(project_id, user_id) return json_detail_render(0, data=data)
def flow_day_query_all_handler(): """ @api {post} /v1/flow/dashboard 获取流程统计 @apiName GetFlowDashboard @apiGroup 流程 @apiDescription 获取流程统计 @apiParam {int} project_id 项目ID @apiParam {str} start_date 开始时间 @apiParam {str} end_date 结束时间 @apiParamExample {json} Request-Example: { "project_id":1, "start_date":"2019-07-26", "end_date":"2019-07-26" } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code":0, "data":[], "message":"ok" } """ project_id, start_date, end_date = parse_json_form('flowdashboard') data = FlowBusiness.flow_add_dashboard(project_id, start_date, end_date) return json_detail_render(0, data)
def flow_priority_switch_handler(flow_id): """ @api {post} /v1/flow/next/{flow_id} 执行流程 @apiName NextFlow @apiGroup 流程 @apiDescription 执行流程 @apiParam {int} id 步骤ID @apiParam {str} name 名称 @apiParam {str} result 结果 @apiParam {str} comment 备注 @apiParamExample {json} Request-Example: { "id":2, "name":"测试新版流程(+涉及端和上线依赖)2", "result":"6", "comment":"<p>pass</p>" } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code":0, "data":[], "message":"ok" } """ _id, name, result, comment = parse_json_form('flow_next') ret, msg = FlowBusiness.flow_next(flow_id, _id, name, result, comment) return json_detail_render(ret, [], msg)
def deploy_create_handler(): """ @api {post} /v1/deploy 创建数据 @apiName deployCreate @apiGroup Deploy @apiDescription 创建数据 @apiParam {int} project_id 项目id @apiParam {list} server_list 服务列表 @apiParam {list} node_list 节点列表 @apiParam {string} branch 分支 @apiParam {int} flow_id 流程id @apiParamExample {json} Request-Example: { "project_id": 1, "server_list": [], "node_list": [], "branch": "", "flow_id": 1 } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code": 101, "data": [ { deploy_id: None } ], "message": "can not find object" } """ project_id, server_list, node_list, branch, flow_id = parse_json_form( 'deploy_create') code, deploy_id = DeployBusiness.create(project_id, server_list, node_list, branch, flow_id) if code == 101: return json_detail_render(code, [{ 'deploy_id': deploy_id }], '此服务正在部署请稍后') return json_detail_render(code, [{'deploy_id': deploy_id}])
def update_deploy_result(): """ @api {get} /v1/deploy/update/result 更新部署结果 @apiName deployUpdateResult @apiGroup Deploy @apiDescription 更新部署结果 @apiParam {int} deploy_id 部署id @apiParam {list} result 部署结果 @apiParamExample {json} Request-Example: { "deploy_id": 1, result: [] } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code": 0, "data": [], "message": "ok" } """ deploy_id, result = parse_json_form('deploy_result') code = DeployRecordBusiness.modify_result(result, deploy_id) # DeployRecordBusiness.run_automan(deploy_id) # 写入部署日志,等结果部署完成之后再写入结果 single_data = DeployRecordBusiness.not_init_data(deploy_id) if len(single_data) == 0: delopy_data = DeployRecordBusiness.query_record_deploy(deploy_id) if len(delopy_data) > 0: DeployLogBusiness.deploy_data(delopy_data, deploy_id) # DeployRecordBusiness.run_automan(deploy_id) # 写入自动化日志 # DeployLogBusiness.automan_data(auto_man_data[1],deploy_id) return json_detail_render(code, [], 'ok')
def flow_source_handler(): """ @api {post} /v1/flow/source 新增用户流程配置 @apiName CreateSource @apiGroup 流程 @apiDescription 新增用户流程配置 @apiParam {int} project_id 项目ID @apiParam {str} user_ids 选择的用户list @apiParamExample {json} Request-Example: { "project_id":1, "user_ids":"[1,2,4,5,6]" } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code":0, "data":[], "message":"ok" } """ project_id, user_ids, = parse_json_form('flowsource') code = FlowBusiness.flow_source_add(project_id, user_ids) return json_detail_render(code)
def flow_modify_handler(flow_id): """ @api {post} /v1/flow/{flow_id} 修改流程 @apiName ModifyFlow @apiGroup 流程 @apiDescription 修改流程 @apiParam {int} [priority] 优先级 @apiParam {int} weight 权重 @apiParam {str} name 流程名称 @apiParam {str} dependence 上线依赖 @apiParam {str} comment 备注 @apiParam {list} platform 涉及端 @apiParam {list} user_owner 流程负责人 @apiParam {list} user_test 流程测试 @apiParam {list} user_prod 流程产品 @apiParam {list} user_dev 流程开发 @apiParamExample {json} Request-Example: { "name": "str", "priority": 1, "user_dev": [1], "user_prod": [1,3], "user_test": [1], "user_owner": [1,3], "action": "str", "platform": [1,3], "dependence": "dependence", "weight": 1, "comment": "str" } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code":0, "data":[], "message":"ok" } """ name, priority, user_dev, user_prod, user_test, user_owner, weight, comment, dependence = parse_json_form( 'flow_modify') ret, msg = FlowBusiness.flow_modify(flow_id, name, priority, user_dev, user_prod, user_test, user_owner, weight, comment, dependence) return json_detail_render(ret, [], msg)
def flow_add_handler(): """ @api {post} /v1/flow/ 新增 流程 @apiName CreateFlow @apiGroup 流程 @apiDescription 新增流程 @apiParam {int} flow_type 流程类型 @apiParam {int} flow_assemble_id 流程集合 @apiParam {int} [priority] 优先级 @apiParam {int} project_id 项目ID @apiParam {int} version_id 版本ID @apiParam {int} creator 创建用户ID @apiParam {int} weight 权重 @apiParam {str} name 流程名称 @apiParam {str} requirement_list 需求列表 @apiParam {str} action 步骤 @apiParam {str} dependence 上线依赖 @apiParam {str} comment 备注 @apiParam {list} platform 涉及端 @apiParam {list} user_owner 流程负责人 @apiParam {list} user_test 流程测试 @apiParam {list} user_prod 流程产品 @apiParam {list} user_dev 流程开发 @apiParamExample {json} Request-Example: { "name": "str", "flow_type": 1, "requirement_list": "str", "flow_assemble_id": 1, "priority": 1, "project_id": 1, "version_id": 1, "creator": 1, "user_dev": [1], "user_prod": [1,3], "user_test": [1], "user_owner": [1,3], "action": "str", "platform": [1,3], "dependence": "dependence", "weight": 1, "comment": "str" } @apiSuccessExample {json} Success-Response: HTTP/1.1 200 OK { "code":0, "data":[], "message":"ok" } """ (name, flow_type, requirement_list, flow_assemble_id, priority, project_id, version_id, creator, user_dev, user_prod, user_test, user_owner, action, weight, comment, platform, dependence) = parse_json_form('flow_create') ret, data = FlowBusiness.flow_create(name, flow_type, requirement_list, flow_assemble_id, priority, project_id, version_id, creator, user_dev, user_prod, user_test, user_owner, action, weight, comment, platform, dependence) return json_detail_render(ret, data)