Ejemplo n.º 1
0
  @RequestMapping("/queryView")
  public String toQueryView(HttpServletRequest request, HttpServletResponse response, Model model)
      throws IOException {

    DataBaseQuery query = new DataBaseQuery();
    Result<List<DataBaseDO>> ret = dataBaseService.find(query);
    if (ret != null && ret.isSuccess() && ret.getValue() != null) {
      model.addAttribute("ret", ret.getValue());
    }
    return "/websql/queryView";
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "/query", method = RequestMethod.POST)
  @ResponseBody
  public DynamicColumnResult toExeSqlForQuery(
      @RequestParam("id") long id, @RequestParam("sql") String sql) throws IOException {

    try {

      Profiler.enter("start exe query");

      DynamicColumnResult result = null;

      if (id <= 0) {
        result = DynamicColumnResult.getErrorResult(Errors.ERROR_NOT_EXIST.toString());
        return result;
      }

      Result<DataBaseDO> dataBaseRet = dataBaseService.get(id);
      if (dataBaseRet != null && dataBaseRet.isSuccess() && dataBaseRet.getValue() != null) {
        if (isSingleSql(sql)) {
          result =
              webSqlService.executeQuery(
                  sql,
                  dataBaseRet.getValue(),
                  UserContextHolder.getUserId(),
                  UserContextHolder.getName());
        } else {
          result = DynamicColumnResult.getErrorResult(Errors.ERROR_SQL_COUNT.toString());
        }
      } else {
        result = DynamicColumnResult.getErrorResult(Errors.ERROR_NOT_EXIST.toString());
      }
      return result;
    } finally {
      Profiler.release();
    }
  }