<%_ if (position === 'import') { _%>
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
<%_ } _%>
<%_ if (position === 'method') { _%>

     /**
     * {@code GET  /statistics-apis/count} : count all the statisticsApis.
     *
     * @param id the statisticsApis which the requested entities should match.
     * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body.
     */
    @GetMapping("/statistics-apis/result/{id}")
    public ResponseEntity<Object> runStatisticsApis(@PathVariable <%= databaseTypeSql ? 'Long' : 'String' %> id) throws JsonProcessingException {
        Optional<StatisticsApiDTO> one = statisticsApiService.findOne(id);
        <%_ if (databaseTypeSql) { _%>
        if (one.isPresent()) {
            List result = statisticsApiQueryService.runSql(one.get().getApiBody());
            ObjectMapper mapper = new ObjectMapper();
            one.get().setResult(mapper.writeValueAsString(result));
            statisticsApiService.save(one.get());
            return ResponseEntity.ok().body(result);
        }
        <%_ } else { _%>
        /** todo
        if (one.isPresent()) {
            List result = statisticsApiQueryService.runSql(one.get().getApiBody());
            one.get().setResult(mapper.writeValueAsString(result));
            statisticsApiService.save(one.get());
            return ResponseEntity.ok().body(result);
        } */
        <%_ } _%>
        return ResponseEntity.notFound().build();
    }
<%_ } _%>
