class AppController {

    private static final String[] RISKY_STR_ARR = {"ScriptEngineManager", "URLClassLoader", "!!",
            "ClassLoader", "AnnotationConfigApplicationContext", "FileSystemXmlApplicationContext",
            "GenericXmlApplicationContext", "GenericGroovyApplicationContext", "GroovyScriptEngine",
            "GroovyClassLoader", "GroovyShell", "ScriptEngine", "ScriptEngineFactory", "XmlWebApplicationContext",
            "ClassPathXmlApplicationContext", "MarshalOutputStream", "InflaterOutputStream", "FileOutputStream"};

    @Autowired
    private AppService appService;

    @GetMapping(path = "/{app}/params")
    @Operation(summary = "The structure of the input parameters required to specify the monitoring type according to the app query", description = "根据app查询指定监控类型的需要输入参数的结构")
    public ResponseEntity<Message<List<ParamDefine>>> queryAppParamDefines(
            @Parameter(description = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
        List<ParamDefine> paramDefines = appService.getAppParamDefines(app.toLowerCase());
        return ResponseEntity.ok(Message.success(paramDefines));
    }

    @GetMapping(path = "/{monitorId}/pushdefine")
    @Operation(summary = "The definition structure of the specified monitoring type according to the push query", description = "根据monitorId查询push类型的定义结构")
    public ResponseEntity<Message<Job>> queryPushDefine(
            @Parameter(description = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("monitorId") final Long monitorId) {
        Job define = appService.getPushDefine(monitorId);
        return ResponseEntity.ok(Message.success(define));
    }

    @GetMapping(path = "/{monitorId}/define/dynamic")
    @Operation(summary = "The definition structure of the specified monitoring type according to the push query", description = "根据monitorId查询push类型的定义结构")
    public ResponseEntity<Message<Job>> queryAutoGenerateDynamicAppDefine(
            @Parameter(description = "Monitoring id | 监控任务ID", example = "5435345") @PathVariable("monitorId") final Long monitorId) {
        Job define = appService.getAutoGenerateDynamicDefine(monitorId);
        return ResponseEntity.ok(Message.success(define));
    }

    @GetMapping(path = "/{app}/define")
    @Operation(summary = "The definition structure of the specified monitoring type according to the app query", description = "根据app查询指定监控类型的定义结构")
    public ResponseEntity<Message<Job>> queryAppDefine(
            @Parameter(description = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
        Job define = appService.getAppDefine(app.toLowerCase());
        return ResponseEntity.ok(Message.success(define));
    }

    @GetMapping(path = "/{app}/define/yml")
    @Operation(summary = "The definition yml of the specified monitoring type according to the app query", description = "根据app查询指定监控类型的定义YML")
    public ResponseEntity<Message<String>> queryAppDefineYml(
            @Parameter(description = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
        String defineContent = appService.getMonitorDefineFileContent(app);
        return ResponseEntity.ok(Message.successWithData(defineContent));
    }

    @DeleteMapping(path = "/{app}/define/yml")
    @Operation(summary = "Delete monitor define yml", description = "根据app删除指定监控类型的定义YML")
    public ResponseEntity<Message<Void>> deleteAppDefineYml(
            @Parameter(description = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
        try {
            appService.deleteMonitorDefine(app);
        } catch (Exception e) {
            return ResponseEntity.ok(Message.fail(FAIL_CODE, e.getMessage()));
        }
        return ResponseEntity.ok(Message.success());
    }

    @PostMapping(path = "/define/yml")
    @Operation(summary = "Add new monitoring type define yml", description = "新增监控类型的定义YML")
    public ResponseEntity<Message<Void>> newAppDefineYml(@Valid @RequestBody MonitorDefineDto defineDto) {
        try {
            for (String riskyToken : RISKY_STR_ARR) {
                if (defineDto.getDefine().contains(riskyToken)) {
                    return ResponseEntity.ok(Message.fail(FAIL_CODE, "can not has malicious remote script"));
                }
            }
            appService.applyMonitorDefineYml(defineDto.getDefine(), false);
        } catch (Exception e) {
            return ResponseEntity.ok(Message.fail(FAIL_CODE, e.getMessage()));
        }
        return ResponseEntity.ok(Message.success());
    }

    @PutMapping(path = "/define/yml")
    @Operation(summary = "Update monitoring type define yml", description = "更新监控类型的定义YML")
    public ResponseEntity<Message<Void>> updateAppDefineYml(@Valid @RequestBody MonitorDefineDto defineDto) {
        try {
            for (String riskyToken : RISKY_STR_ARR) {
                if (defineDto.getDefine().contains(riskyToken)) {
                    return ResponseEntity.ok(Message.fail(FAIL_CODE, "can not has malicious remote script"));
                }
            }
            appService.applyMonitorDefineYml(defineDto.getDefine(), true);
        } catch (Exception e) {
            return ResponseEntity.ok(Message.fail(FAIL_CODE, e.getMessage()));
        }
        return ResponseEntity.ok(Message.success());
    }

    @GetMapping(path = "/hierarchy")
    @Operation(summary = "Query all monitor metrics level, output in a hierarchical structure", description = "查询所有监控的类型指标层级,以层级结构输出")
    public ResponseEntity<Message<List<Hierarchy>>> queryAppsHierarchy(
            @Parameter(description = "en: language type,zh: 语言类型",
                    example = "zh-CN")
            @RequestParam(name = "lang", required = false) String lang) {<FILL_FUNCTION_BODY>}
}

        if (lang == null || lang.isEmpty()) {
            lang = "zh-CN";
        }
        if (lang.contains(Locale.ENGLISH.getLanguage())) {
            lang = "en-US";
        } else if (lang.contains(Locale.CHINESE.getLanguage())) {
            lang = "zh-CN";
        } else {
            lang = "en-US";
        }
        List<Hierarchy> appHierarchies = appService.getAllAppHierarchy(lang);
        return ResponseEntity.ok(Message.success(appHierarchies));
    
<no_super_class>