Esempio n. 1
0
    def post(self, action):
        data = get_request_json()
        custom = read_custom()

        if action == 'queryCustomFunctions':
            functions = custom['functions']

            return make_response({"code": "000", "data": functions})

        elif action == 'queryCustomComparators':
            comparators = custom['comparators']

            return make_response({"code": "000", "data": comparators})

        elif action == 'queryCustomSetupHooks':
            setup_hooks = custom['setup-hooks']

            return make_response({"code": "000", "data": setup_hooks})

        elif action == 'queryCustomTeardownHooks':
            teardown_hooks = custom['teardown-hooks']

            return make_response({"code": "000", "data": teardown_hooks})

        else:
            return make_response({
                "code":
                "100",
                "desc":
                "url错误,不存在的接口动作<{action}>".format(action=action)
            })
Esempio n. 2
0
 def post(self, action):
     data = get_request_json()
     if action == 'queryAutotestDetails':
         try:
             system_id = data["system_id"]
             pageNo = data["pageNo"]
             pageSize = data["pageSize"]
         except KeyError:
             return make_response({"code": "100", "desc": "入参校验失败"})
         res_testreport = TestReportManager.query_testreport(
             system_id=system_id)
         #组装出参tableData
         list_testreport = list()
         for i in res_testreport:
             dict_testreport = dict()
             dict_testreport["start_at"] = i.start_at
             dict_testreport["duration"] = i.duration
             dict_testreport["status"] = i.status
             dict_testreport["url"] = i.url
             list_testreport.append(dict_testreport)
         #按测试开始时间倒叙展示
         list_testreport.sort(key=lambda x: x["start_at"])
         #分页起始行
         begin = (pageNo - 1) * pageSize
         #分页结束行
         end = pageNo * pageSize
         if (begin > len(res_testreport)):
             return make_response({"code": "200", "desc": "起始行数大于测试报告总条数"})
         if (end < len(res_testreport)):  #若分页结束行小于列表大小,截取到end
             list_testreport_ = list_testreport[begin:end]
         else:  #若分页结束行小于列表大小,截取到列表末尾
             list_testreport_ = list_testreport[begin:len(res_testreport)]
         return make_response({
             "code": "000",
             "totalNum": len(res_testreport),
             "tableData": list_testreport_
         })
     else:
         return make_response({
             "code":
             "100",
             "desc":
             "url错误,不存在的接口动作<{action}>".format(action=action)
         })
Esempio n. 3
0
    def post(self):
        data = get_request_json()

        try:
            testcase_id_list = data.pop("testcaseList", None)
            testsuite_id_list = data.pop("testsuiteList", None)
            module_id_list = data.pop("moduleList", None)
            system_id_list = data.pop("systemList", None)
            env_name = data["env"]
        except KeyError:
            return make_response({"code": "100", "desc": "入参校验失败"})

        kwargs = {
            "env_name": env_name,
        }
        if testcase_id_list:
            kwargs["testcase_id_list"] = testcase_id_list
        elif testsuite_id_list:
            kwargs["testsuite_id_list"] = testsuite_id_list
        elif module_id_list:
            kwargs["module_id_list"] = module_id_list
        elif system_id_list:
            kwargs["system_id_list"] = system_id_list

        try:
            report_path = run_test(**kwargs)
        except LoadCaseError:
            return make_response({"code": "200", "desc": "组装用例时出错"})
        except RunCaseError:
            return make_response({"code": "200", "desc": "执行用例时出错"})

        return make_response({
            "code":
            "000",
            "desc":
            "{report_path}".format(report_path=report_path)
        })
Esempio n. 4
0
    def post(self, action):
        data = get_request_json()

        if action == 'add':
            try:
                project_name = data.pop('projectName')
                simple_desc = data.pop('simpleDesc', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = ProjectInfoManager()

            # 判断项目名是否已存在,存在无法添加

            if pim.is_project_name_exist_for_update(project_name):
                return make_response({"code": "201", "desc": "项目名称已存在"})

            pim.insert_project(project_name=project_name, simple_desc=simple_desc)
            return make_response({"code": "000", "desc": "项目增加成功"})

        elif action == 'edit':
            try:
                id_ = data.pop('id')
                project_name = data.pop('projectName')
                simple_desc = data.pop('simpleDesc', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = ProjectInfoManager()

            # 校验项目ID是否存在,不存在无法修改

            if not pim.is_project_id_exist(id_):
                return make_response({"code": "201", "desc": "项目不存在,无法修改"})
            elif pim.is_project_name_exist_union(id_,project_name) and simple_desc != None:
                pim.update_project(id_, project_name=project_name, simple_desc=simple_desc)
                return make_response({"code": "000", "desc": "项目修改成功"})
            elif pim.is_project_id_exist(id_) and not pim.is_project_name_exist_for_update(project_name):
                pim.update_project(id_, project_name=project_name, simple_desc=simple_desc)
                return make_response({"code": "000", "desc": "项目修改成功"})
            else:
                return make_response({"code": "201", "desc": "项目名已存在,无法修改"})

        elif action == 'delete':
            try:
                id_ = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = ProjectInfoManager()
            pim.delete_project(id_)
            return make_response({"code": "000", "desc": "项目删除成功"})

        elif action == 'detail':
            try:
                pim = ProjectInfoManager()
                result1 = pim.project_info()
                i_ = 1

                desc_list = []
                projects = []

                # 循环查询project返回所有的Project数据,并将其加入list 方便遍历
                for i in result1:
                    projects.append([i.id, i.project_name])

                    # 遍历project_list 并将其添加到字典中,并对字段赋值
                for j in projects:
                    project_dict = {}
                    project_dict["id"] = i_
                    project_dict["projectId"] = j[0]
                    project_dict["label"] = j[1]
                    project_dict["children"] = []
                    desc_list.append(project_dict)
                    result2 = pim.system_info(j[0])
                    i_ = i_ + 1

                    # 遍历通过project_id查询system_info得到的结果,将其添加到systemlist当中,方便遍历最后组装到response
                    for k in result2:
                        print(k)
                        system_dict = {}
                        system_dict["id"] = i_
                        system_dict["systemId"] = k.id
                        system_dict["label"] = k.system_name
                        project_dict["children"].append(system_dict)
                        i_ = i_ + 1
                return make_response({"code": "000", "desc": desc_list})
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})


        elif action == 'list':
            try:
                # time.sleep(5)

                # 查询列表入参可以为空或者输入项目名称
                project_name = data.pop('projectName')
                pim = ProjectInfoManager()

                if project_name != "":
                    if not pim.is_project_name_exist(project_name):

                        return make_response({"code": "200", "desc": "项目名不存在,无法查询"})

                result1 = pim.project_info(project_name)
                print(project_name)
                print(result1)

                desc_list = []
                projects = []

                # 循环查询project返回所有的Project数据,并将其加入list 方便遍历
                for i in result1:
                    projects.append([i.id, i.project_name,i.simple_desc])

                    # 遍历project_list 并将其添加到字典中,并对字段赋值
                for j in projects:
                    project_dict = {}
                    project_dict["id"] = j[0]
                    project_dict["projectName"] = j[1]
                    project_dict["description"] = j[2]
                    desc_list.append(project_dict)
                # 将desc_list 根据项目名进行排序
                desc_list.sort(key = lambda desc_sort:(desc_sort.get("projectName",0)))
                return make_response({"code": "000", "desc": desc_list})
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

        elif action == 'subtree':
            try:
                project_id = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            sim = SystemInfoManager()
            system_list = sim.select_by_project_id(project_id)

            subtree = []
            index_id = 0
            for s in system_list:
                system_dict = dict()
                index_id += 1
                system_dict['id'] = index_id
                system_dict['label'] = s.system_name
                system_dict['systemId'] = s.id

                module_list = ModuleInfoManager.query_all_module(system_id=s.id)
                children_module = list()
                for m in module_list:
                    module_dict = dict()
                    index_id += 1
                    module_dict["id"] = index_id
                    module_dict["moduleId"] = m.id
                    module_dict["label"] = m.module_name

                    testsuite_list = TestsuiteInfoManager.query_all_testsuite(module_id=m.id)
                    children_testsuite = list()
                    for t in testsuite_list:
                        testsuite_dict = dict()
                        index_id += 1
                        testsuite_dict["id"] = index_id
                        testsuite_dict["testsuiteId"] = t.id
                        testsuite_dict["label"] = t.testsuite_name
                        children_testsuite.append(testsuite_dict)

                    module_dict["children"] = children_testsuite
                    children_module.append(module_dict)
                system_dict["children"] = children_module

                subtree.append(system_dict)

            # logger.debug(subtree)
            return make_response({"code": "000", "data": subtree})

        else:
            return make_response({"code": "100", "desc": "url错误,不存在的接口动作<{action}>".format(action=action)})
Esempio n. 5
0
    def post(self, action):
        data = get_request_json()

        if action == 'add':
            try:
                env_name = data.pop('envName')
                base_host = data.pop('baseHost')
                dubbo_zookeeper = data.pop('dubboZookeeper')
                mq_key = data.pop('mqKey')
                db_connect = data.pop('dbConnect')
                remote_host = data.pop('remoteHost')
                disconf_host = data.pop('disconfHost')
                redis_connect = data.pop('redisConnect')
                simple_desc = data.pop('simpleDesc', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = EnvInfoManager()

            # 判断env_name是否存在
            if pim.is_env_name_exist(env_name):
                return make_response({"code": "201", "desc": "环境配置已存在"})

                # 针对入参进行入库
            pim.insert_env(env_name=env_name,
                           base_host=base_host,
                           dubbo_zookeeper=dubbo_zookeeper,
                           mq_key=mq_key,
                           db_connect=db_connect,
                           remote_host=remote_host,
                           disconf_host=disconf_host,
                           redis_connect=redis_connect,
                           simple_desc=simple_desc)
            return make_response({"code": "000", "desc": "系统增加成功"})

        elif action == 'edit':
            try:
                id_ = data.pop('id')
                env_name = data.pop('envName')
                base_host = data.pop('baseHost')
                dubbo_zookeeper = data.pop('dubboZookeeper')
                mq_key = data.pop('mqKey')
                db_connect = data.pop('dbConnect')
                remote_host = data.pop('remoteHost')
                disconf_host = data.pop('disconfHost')
                redis_connect = data.pop('redisConnect')
                simple_desc = data.pop('simpleDesc')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = EnvInfoManager()

            # 判断修改数据是否存在

            if not pim.is_env_id_exist(id_):
                return make_response({"code": "200", "desc": "环境ID不存在,无法修改"})

# 根据入参进行数据修改

            pim.update_env(id_,
                           env_name=env_name,
                           base_host=base_host,
                           dubbo_zookeeper=dubbo_zookeeper,
                           mq_key=mq_key,
                           db_connect=db_connect,
                           remote_host=remote_host,
                           disconf_host=disconf_host,
                           redis_connect=redis_connect,
                           simple_desc=simple_desc)
            return make_response({"code": "000", "desc": "环境配置修改成功"})

        elif action == 'delete':
            try:
                id_ = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = EnvInfoManager()

            # 判断修改数据是否存在

            if not pim.is_env_id_exist(id_):
                return make_response({"code": "200", "desc": "环境不存在,无法删除"})

            # 根据入参进行数据修改

            pim.delete_env(id_)
            return make_response({"code": "000", "desc": "环境配置删除成功"})

        elif action == 'detail':
            pass

        elif action == 'list':
            # 查询列表入参可以为空或者输入项目名称
            try:
                env_name = data.pop('envName', None)
                pim = EnvInfoManager()

                # 判断入参有环境名时,是否可以查询
                if env_name:
                    if not pim.is_env_name_exist(env_name):
                        return make_response({"code": "000", "desc": []})

                result1 = pim.env_info(env_name)
                desc_list = []
                envs = []

                # 循环查询env返回所有的env数据,并将其加入list 方便遍历
                for i in result1:
                    envs.append([
                        i.id, i.env_name, i.base_host, i.dubbo_zookeeper,
                        i.mq_key, i.db_connect, i.remote_host, i.disconf_host,
                        i.redis_connect, i.simple_desc
                    ])

                print(envs)
                # 遍历project_list 并将其添加到字典中,并对字段赋值
                for j in envs:
                    env_dict = {}
                    env_dict["id"] = j[0]
                    env_dict["envName"] = j[1]
                    env_dict["baseHost"] = j[2]
                    env_dict["dubboZookeeper"] = j[3]
                    env_dict["mqKey"] = j[4]
                    env_dict["dbConnect"] = j[5]
                    env_dict["remoteHost"] = j[6]
                    env_dict["disconfHost"] = j[7]
                    env_dict["redisConnect"] = j[8]
                    env_dict["simpleDesc"] = j[9]
                    desc_list.append(env_dict)
                # 将desc_list 根据项目名进行排序
                desc_list.sort(
                    key=lambda desc_sort: (desc_sort.get("envName", 0)))
                return make_response({"code": "000", "desc": desc_list})
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

        else:
            return make_response({
                "code":
                "100",
                "desc":
                "url错误,不存在的接口动作<{action}>".format(action=action)
            })
Esempio n. 6
0
    def post(self, action):
        data = get_request_json()
        tim = TestcaseInfoManager()
        if action == 'add':
            handle_testcase(action, **data)

        elif action == 'edit':
            pass

        elif action == 'delete':
            """
                            api:/testcase/delete/:id
                        """
            try:
                id_ = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            if not tim.is_testcase_id_exist(id_):
                return make_response({"code": "200", "desc": "用例不存在,无法删除"})

            tim.delete_testcase(id_)
            return make_response({"code": "000", "desc": "测试用例删除成功"})

        elif action == 'detail':
            pass

        elif action == 'queryByTestsuiteId':
            """
                根据testsuite_id查找该套件下的所有测试用例
                url:/testcase/queryByTestsuiteId/:testsuite_id
            """
            try:
                testsuite_id = data.pop('testsuite_id')
                tsim = TestsuiteInfoManager()
                #判断testsuite_id是否存在
                if not tsim.query_testsuite_by_id(testsuite_id):
                    return make_response({
                        "code": "200",
                        "desc": "测试用例集不存在,无法查询"
                    })
                datas = tim.get_suite_testcase(testsuite_id)
                projects = []
                desc_list = []

                for i in datas:
                    projects.append([i.id, i.testcase_name])
                    '''[1,test1]'''
                for j in projects:
                    project_dict = {}
                    project_dict["id"] = j[0]
                    project_dict["testcase_name"] = j[1]
                    desc_list.append((project_dict))
                return make_response({"code": "000", "desc": desc_list})
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

        else:
            return make_response({
                "code":
                "100",
                "desc":
                "url错误,不存在的接口动作<{action}>".format(action=action)
            })
Esempio n. 7
0
    def post(self, action):
        data = get_request_json()
        mim = ModuleInfoManager()
        if action == 'add':
            try:
                system_id = data["systemId"]
                module_name = data["moduleName"]
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})
            module_name_list = mim.query_module(system_id, module_name)
            if len(module_name_list) != 0:
                return make_response({"code": "201", "desc": "这个名称的测试模块已经存在"})
            mim.insert_module(module_name=module_name, system_id=system_id)
            return make_response({
                "code": "000",
                "desc": "{}模块添加成功".format(module_name)
            })

        elif action == 'edit':
            try:
                id = data["id"]
                module_name = data["moduleName"]
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})
            res_module_name = mim.query_module_id(id=id)[0].module_name
            if res_module_name == module_name:
                return make_response({"code": "201", "desc": "您修改的模块名称已存在"})
            mim.update_module(id_=id, module_name=module_name)
            return make_response({"code": "000", "desc": "操作成功"})

        elif action == 'delete':
            try:
                id = data["id"]
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})
            mim.delete_module(id_=id)
            return make_response({"code": "000", "desc": "操作成功"})

        elif action == 'detail':
            pass

        elif action == 'list':
            try:
                system_id = data["systemId"]
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})
            module_list = mim.query_all_module(system_id=system_id)
            res = list()
            id = 0
            for i in module_list:
                module_dict = dict()
                if module_list:
                    id += 1
                    module_dict["id"] = id
                module_dict["moduleId"] = i.id
                module_dict["label"] = i.module_name
                testsuite_list = TestsuiteInfoManager.query_all_testsuite(
                    module_id=i.id)
                testsuite = list()
                for j in testsuite_list:
                    testsuite_dict = dict()
                    if testsuite_list:
                        id += 1
                        testsuite_dict["id"] = id
                    testsuite_dict["testsuiteId"] = j.id
                    testsuite_dict["label"] = j.testsuite_name
                    testsuite.append(testsuite_dict)
                module_dict["children"] = testsuite
                res.append(module_dict)
            return make_response({"code": "000", "desc": res})

        elif action == 'queryBySystemId':
            """ 根据SystemId查询系统下的所有模块
            url: /module/queryBySystemId
            input:
                {"systemId":"9"}
            output:
                {
                  "code": "000",
                  "data": [
                    {
                      "systemId": 4,
                      "systemName": "申请"
                    }
                  ]
                }
            """
            try:
                system_id = data.pop('systemId')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            obj = ModuleInfoManager.query_all_module(system_id)
            module_list = []
            for m in obj:
                module_info_dic = {
                    "systemName": m.module_name,
                    "systemId": m.id,
                }
                module_list.append(module_info_dic)

            return make_response({"code": "000", "data": module_list})
        else:
            return make_response({
                "code":
                "100",
                "desc":
                "url错误,不存在的接口动作<{action}>".format(action=action)
            })
Esempio n. 8
0
    def post(self, action):
        data = get_request_json()
        tim = TestsuiteInfoManager()

        if action == 'add':
            """
                url: /testsuite/add
                http类型入参: {"testsuiteName":"queryMock", "type":"HTTP", "info":{"apiUrl":"/mock/config/queryMock", "headers":"{\"Content-Type\":\"application/json\",\"oops\":\"oops\"}", "method":"POST"}, "moduleId":"5"}
                dubbo类型入参: {"testsuiteName":"queryMock_mq", "type":"MQ", "info":{"service":"service_for_dubbo", "method":"method_for_dubbo", "parameterTypes":"{\"cn.memedai.sse.facade.model.query.req\",\"cn.memedai.sse.facade.model.query.page\"}"}, "moduleId":"5"}
                mq类型入参:{"testsuiteName":"queryMock_mq", "type":"MQ", "info":{"topic":"topic_for_mq", "tag":"tag_for_mq"}, "moduleId":"5"}
            """
            try:
                testsuite_name = data.pop('testsuiteName')
                intf_type = data.pop('type')
                intf_info = data.pop('info')
                module_id = data.pop('moduleId')
                simple_desc = data.pop('simpleDesc', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            logger.debug(type(intf_info), intf_info)
            tim.insert_testsuite(testsuite_name=testsuite_name, simple_desc=simple_desc, intf_type=intf_type,
                                 intf_info=json_dumps(intf_info), module_id=module_id)
            return make_response({"code": "000", "desc": "{}测试集已添加".format(testsuite_name)})

        elif action == 'edit':
            """
                url: /testsuite/edit
                input: {"id":"3", "testsuiteName":"queryMock", "type":"HTTP", "info":{"apiUrl":"/mock/config/queryMock", "headers":"{\"Content-Type\":\"application/json\",\"oops\":\"oops\"}", "method":"POST"}, "moduleId":"5"}
            """
            try:
                id_ = data.pop('id')
                testsuite_name = data.pop('testsuiteName')
                intf_type = data.pop('type')
                intf_info = data.pop('info')
                module_id = data.pop('moduleId')
                simple_desc = data.pop('simpleDesc', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            tim.update_testsuite(id_, project_name=testsuite_name, simple_desc=simple_desc, intf_type=intf_type,
                                 intf_info=json_dumps(intf_info), module_id=module_id)
            return make_response({"code": "000", "desc": "{}测试集已修改".format(testsuite_name)})

        elif action == 'delete':
            """
                url: /testsuite/delete
                input: {"id":"3"}
            """
            try:
                id_ = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            tim.delete_testsuite(id_)
            return make_response({"code": "000", "desc": "测试集已删除"})

        elif action == 'detail':
            """
                url: /testsuite/detail
                input: {"id":"3"}
                output: {"code": "000", "data": {"testsuiteName":"queryMock", "type":"HTTP", "info":{"apiUrl":"/mock/config/queryMock", "headers":"{\"Content-Type\":\"application/json\",\"oops\":\"oops\"}", "method":"POST"}, "moduleId":"5"}}
            """
            try:
                id_ = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            obj = tim.query_testsuite_by_id(id_)
            data = {
                "testsuiteName": obj.testsuite_name,
                "simpleDesc": obj.simple_desc,
                "type": obj.intf_type,
                "info": json_loads(obj.intf_info),
                "moduleId": obj.module_id
            }
            return make_response({"code": "000", "data": data})

        elif action == 'list':
            pass

        else:
            return make_response({"code": "100", "desc": "url错误,不存在的接口动作<{action}>".format(action=action)})
Esempio n. 9
0
    def post(self, action):
        data = get_request_json()

        if action == 'add':
            try:
                system_name = data.pop('systemName')
                simple_desc = data.pop('simpleDesc', None)
                project_id = data.pop('projectId')
                test_user = data.pop('testUser', None)
                dev_user = data.pop('devUser', None)
                publish_app = data.pop('publishApp', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = SystemInfoManager()

            #判断project_id是否存在

            if not pim.is_project_id_exist(project_id):
                return make_response({"code": "200", "desc": "项目不存在"})

# 判断system_name是否存在
            elif pim.is_system_name_exist(system_name):
                return make_response({"code": "201", "desc": "系统名称已存在"})

#针对入参进行入库
            pim.insert_system(system_name=system_name,
                              simple_desc=simple_desc,
                              test_user=test_user,
                              dev_user=dev_user,
                              publish_app=publish_app,
                              project_id=project_id)
            return make_response({"code": "000", "desc": "系统增加成功"})

        elif action == 'edit':
            try:
                id_ = data.pop('id')
                system_name = data.pop('systemName')
                simple_desc = data.pop('simpleDesc')
                project_id = data.pop('projectId')
                test_user = data.pop('testUser', None)
                dev_user = data.pop('devUser', None)
                publish_app = data.pop('publishApp', None)
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = SystemInfoManager()

            # 判断修改数据是否存在

            if not pim.is_system_id_exist(id_):
                return make_response({"code": "200", "desc": "项目不存在,无法修改"})

            # 根据入参进行数据修改

            pim.update_system(id_,
                              system_name=system_name,
                              simple_desc=simple_desc,
                              test_user=test_user,
                              dev_user=dev_user,
                              publish_app=publish_app,
                              project_id=project_id)
            return make_response({"code": "000", "desc": "系统修改成功"})

        elif action == 'delete':
            try:
                id_ = data.pop('id')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = SystemInfoManager()

            # 判断修改数据是否存在

            if not pim.is_system_id_exist(id_):
                return make_response({"code": "200", "desc": "项目不存在,无法删除"})

            # 根据入参进行数据修改

            pim.delete_system(id_)
            return make_response({"code": "000", "desc": "系统删除成功"})

        elif action == 'detail':
            pass

        elif action == 'list':
            try:
                # 查询列表入参可以为空或者输入系统名称
                system_name = data.pop('systemName')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            pim = SystemInfoManager()

            if system_name != "":
                if not pim.is_system_name_exist(system_name):

                    return make_response({
                        "code": "200",
                        "desc": "系统名不存在,无法查询"
                    })

            result1 = pim.system_info(system_name)

            # print(system_name)
            # print(result1)

            desc_list = []
            systems = []

            # 循环查询system表返回所有的System数据,先通过project_id查询project_info表对应的name,再通过子循环往systems List添加信息,如果project_id存在,才插入

            for i in result1:
                result2 = pim.project_info(i.project_id)
                for k in result2:
                    systems.append(
                        [i.id, i.system_name, i.simple_desc, k.project_name])
                # systems.append([i.id, i.system_name, i.simple_desc, i.project_id])
            print(systems)

            # 遍历system_list 并将其添加到字典中,并对字段赋值
            for j in systems:
                system_dict = {}
                system_dict["id"] = j[0]
                system_dict["systemName"] = j[1]
                system_dict["description"] = j[2]
                system_dict["belongProject"] = j[3]
                desc_list.append(system_dict)
            # 将desc_list 根据项目名进行排序

            desc_list.sort(
                key=lambda desc_sort: (desc_sort.get("systemName", 0)))
            return make_response({"code": "000", "desc": desc_list})

        elif action == 'queryByProjectId':
            """ 根据projectId查询项目下的所有系统
            url: /system/queryByProjectId
            input:
                {"projectId":"14"}
            output:
                {
                  "code": "000",
                  "data": [
                    {
                      "systemId": 10,
                      "systemName": "mock"
                    }
                  ]
                }
            """
            try:
                project_id = data.pop('projectId')
            except KeyError:
                return make_response({"code": "100", "desc": "入参校验失败"})

            obj = SystemInfoManager.select_by_project_id(project_id)
            system_list = []
            for s in obj:
                system_info_dic = {
                    "systemName": s.system_name,
                    "systemId": s.id,
                }
                system_list.append(system_info_dic)

            return make_response({"code": "000", "data": system_list})

        else:
            return make_response({
                "code":
                "100",
                "desc":
                "url错误,不存在的接口动作<{action}>".format(action=action)
            })