Example usage for io.vertx.core.json JsonObject put

List of usage examples for io.vertx.core.json JsonObject put

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject put.

Prototype

public JsonObject put(String key, Object value) 

Source Link

Document

Put an Object into the JSON object with the specified key.

Usage

From source file:com.funmix.entity.CompanyConverter.java

License:Apache License

public static void toJson(Company obj, JsonObject json) {
    if (obj.getAddress() != null) {
        json.put("address", obj.getAddress());
    }/*from   w  ww.  j av a  2 s .  co  m*/
    if (obj.getCompanyname() != null) {
        json.put("companyname", obj.getCompanyname());
    }
    if (obj.getContact() != null) {
        json.put("contact", obj.getContact());
    }
    if (obj.getContact_phone() != null) {
        json.put("contact_phone", obj.getContact_phone());
    }
    if (obj.getCreated_time() != null) {
        json.put("created_time", obj.getCreated_time());
    }
    json.put("id", obj.getId());
    json.put("latitude", obj.getLatitude());
    json.put("longitude", obj.getLongitude());
    if (obj.getMemo() != null) {
        json.put("memo", obj.getMemo());
    }
    if (obj.getPhone() != null) {
        json.put("phone", obj.getPhone());
    }
    json.put("status", obj.getStatus());
}

From source file:com.funmix.entity.ContactConverter.java

License:Apache License

public static void toJson(Contact obj, JsonObject json) {
    if (obj.getCompany() != null) {
        json.put("company", obj.getCompany());
    }/*from   w  ww.  j  a v  a  2s .  c  om*/
    if (obj.getContact() != null) {
        json.put("contact", obj.getContact());
    }
    if (obj.getFhdz() != null) {
        json.put("fhdz", obj.getFhdz());
    }
    if (obj.getHtzq() != null) {
        json.put("htzq", obj.getHtzq());
    }
    json.put("id", obj.getId());
    if (obj.getMemo() != null) {
        json.put("memo", obj.getMemo());
    }
    if (obj.getPhone() != null) {
        json.put("phone", obj.getPhone());
    }
    json.put("rate", obj.getRate());
}

From source file:com.funmix.entity.DriverConverter.java

License:Apache License

public static void toJson(Driver obj, JsonObject json) {
    if (obj.getCreated_time() != null) {
        json.put("created_time", obj.getCreated_time());
    }//from  w  w w.j a  va2  s.  c om
    if (obj.getDriverlicense() != null) {
        json.put("driverlicense", obj.getDriverlicense());
    }
    if (obj.getEmail() != null) {
        json.put("email", obj.getEmail());
    }
    json.put("id", obj.getId());
    if (obj.getMemo() != null) {
        json.put("memo", obj.getMemo());
    }
    if (obj.getPhone() != null) {
        json.put("phone", obj.getPhone());
    }
    json.put("status", obj.getStatus());
    if (obj.getUsername() != null) {
        json.put("username", obj.getUsername());
    }
}

From source file:com.funmix.entity.LineConverter.java

License:Apache License

public static void toJson(Line obj, JsonObject json) {
    if (obj.getDrivername() != null) {
        json.put("drivername", obj.getDrivername());
    }/*  ww  w .j av  a  2s . co  m*/
    if (obj.getEndaddr() != null) {
        json.put("endaddr", obj.getEndaddr());
    }
    if (obj.getEndtime() != null) {
        json.put("endtime", obj.getEndtime());
    }
    json.put("id", obj.getId());
    if (obj.getLicenseplate() != null) {
        json.put("licenseplate", obj.getLicenseplate());
    }
    if (obj.getLinename() != null) {
        json.put("linename", obj.getLinename());
    }
    if (obj.getPath() != null) {
        json.put("path", obj.getPath());
    }
    json.put("process", obj.getProcess());
    if (obj.getStartaddr() != null) {
        json.put("startaddr", obj.getStartaddr());
    }
    if (obj.getStarttime() != null) {
        json.put("starttime", obj.getStarttime());
    }
    json.put("status", obj.getStatus());
}

From source file:com.funmix.entity.OrderConverter.java

License:Apache License

public static void toJson(Order obj, JsonObject json) {
    json.put("abnormal", obj.getAbnormal());
    if (obj.getAttachment() != null) {
        json.put("attachment", obj.getAttachment());
    }//from w  w w. j av  a2s .c  o  m
    json.put("companyid", obj.getCompanyid());
    if (obj.getCreatetime() != null) {
        json.put("createtime", obj.getCreatetime());
    }
    json.put("deliverymode", obj.getDeliverymode());
    if (obj.getDrivername() != null) {
        json.put("drivername", obj.getDrivername());
    }
    json.put("endway", obj.getEndway());
    if (obj.getFhaddress() != null) {
        json.put("fhaddress", obj.getFhaddress());
    }
    if (obj.getFhlatitude() != null) {
        json.put("fhlatitude", obj.getFhlatitude());
    }
    if (obj.getFhlongitude() != null) {
        json.put("fhlongitude", obj.getFhlongitude());
    }
    if (obj.getFhname() != null) {
        json.put("fhname", obj.getFhname());
    }
    if (obj.getFhphone() != null) {
        json.put("fhphone", obj.getFhphone());
    }
    if (obj.getFhtime() != null) {
        json.put("fhtime", obj.getFhtime());
    }
    if (obj.getFhunit() != null) {
        json.put("fhunit", obj.getFhunit());
    }
    if (obj.getFhunitphone() != null) {
        json.put("fhunitphone", obj.getFhunitphone());
    }
    json.put("id", obj.getId());
    if (obj.getLicenseplate() != null) {
        json.put("licenseplate", obj.getLicenseplate());
    }
    if (obj.getMemo() != null) {
        json.put("memo", obj.getMemo());
    }
    if (obj.getOrderno() != null) {
        json.put("orderno", obj.getOrderno());
    }
    json.put("packagecount", obj.getPackagecount());
    if (obj.getPacking() != null) {
        json.put("packing", obj.getPacking());
    }
    json.put("paperreceipt", obj.getPaperreceipt());
    json.put("paymentmode", obj.getPaymentmode());
    if (obj.getProductcode() != null) {
        json.put("productcode", obj.getProductcode());
    }
    if (obj.getProductname() != null) {
        json.put("productname", obj.getProductname());
    }
    if (obj.getSdtime() != null) {
        json.put("sdtime", obj.getSdtime());
    }
    if (obj.getShaddress() != null) {
        json.put("shaddress", obj.getShaddress());
    }
    if (obj.getShlatitude() != null) {
        json.put("shlatitude", obj.getShlatitude());
    }
    if (obj.getShlongitude() != null) {
        json.put("shlongitude", obj.getShlongitude());
    }
    if (obj.getShname() != null) {
        json.put("shname", obj.getShname());
    }
    if (obj.getShphone() != null) {
        json.put("shphone", obj.getShphone());
    }
    if (obj.getShtime() != null) {
        json.put("shtime", obj.getShtime());
    }
    if (obj.getShunit() != null) {
        json.put("shunit", obj.getShunit());
    }
    if (obj.getShunitphone() != null) {
        json.put("shunitphone", obj.getShunitphone());
    }
    json.put("status", obj.getStatus());
    json.put("totalfee", obj.getTotalfee());
    if (obj.getUpdatetime() != null) {
        json.put("updatetime", obj.getUpdatetime());
    }
    json.put("weight", obj.getWeight());
}

From source file:com.funmix.entity.SiteConverter.java

License:Apache License

public static void toJson(Site obj, JsonObject json) {
    if (obj.getAddress() != null) {
        json.put("address", obj.getAddress());
    }//ww  w  .j  av a  2  s . com
    if (obj.getContact() != null) {
        json.put("contact", obj.getContact());
    }
    if (obj.getContact_phone() != null) {
        json.put("contact_phone", obj.getContact_phone());
    }
    json.put("id", obj.getId());
    json.put("latitude", obj.getLatitude());
    json.put("longitude", obj.getLongitude());
    if (obj.getMemo() != null) {
        json.put("memo", obj.getMemo());
    }
    if (obj.getPhone() != null) {
        json.put("phone", obj.getPhone());
    }
    if (obj.getSitename() != null) {
        json.put("sitename", obj.getSitename());
    }
}

From source file:com.funmix.entity.TruckConverter.java

License:Apache License

public static void toJson(Truck obj, JsonObject json) {
    json.put("id", obj.getId());
    if (obj.getLastupdate() != null) {
        json.put("lastupdate", obj.getLastupdate());
    }//from  w ww  .j a  v a 2s.  c  o  m
    json.put("latitude", obj.getLatitude());
    if (obj.getLicenseplate() != null) {
        json.put("licenseplate", obj.getLicenseplate());
    }
    json.put("longitude", obj.getLongitude());
    json.put("tonnage", obj.getTonnage());
    if (obj.getTruck_type() != null) {
        json.put("truck_type", obj.getTruck_type());
    }
    json.put("volume_height", obj.getVolume_height());
    json.put("volume_length", obj.getVolume_length());
    json.put("volume_width", obj.getVolume_width());
}

From source file:com.funmix.entity.UserConverter.java

License:Apache License

public static void toJson(User obj, JsonObject json) {
    json.put("access_status", obj.getAccess_status());
    if (obj.getApi_routers() != null) {
        json.put("api_routers", obj.getApi_routers());
    }//from   w w w . j a va  2 s. co m
    json.put("companyid", obj.getCompanyid());
    if (obj.getCreated_time() != null) {
        json.put("created_time", obj.getCreated_time());
    }
    if (obj.getDefault_web_routers() != null) {
        json.put("default_web_routers", obj.getDefault_web_routers());
    }
    if (obj.getEmail() != null) {
        json.put("email", obj.getEmail());
    }
    json.put("id", obj.getId());
    if (obj.getPassword() != null) {
        json.put("password", obj.getPassword());
    }
    if (obj.getPhone() != null) {
        json.put("phone", obj.getPhone());
    }
    json.put("status", obj.getStatus());
    if (obj.getToken() != null) {
        json.put("token", obj.getToken());
    }
    if (obj.getUsername() != null) {
        json.put("username", obj.getUsername());
    }
    if (obj.getWeb_routers() != null) {
        json.put("web_routers", obj.getWeb_routers());
    }
}

From source file:com.funmix.service.DriverServiceImpl.java

@Override
public Future<JsonObject> getAll(JsonObject params) {
    Future<JsonObject> result = Future.future();
    StringBuffer sqlCount = new StringBuffer(SQL_QUERY_COUNT);
    StringBuffer sqlQuery = new StringBuffer(SQL_QUERY_ALL);
    StringBuffer order = new StringBuffer();
    StringBuffer where = new StringBuffer();
    JsonArray queryparams = new JsonArray();
    JsonArray countparams = new JsonArray();
    params.forEach(r -> {//from w  w w. j av a 2 s .c  om
        String key = r.getKey();
        if (key.equals("orderby")) {
            order.append(" order by ").append(r.getValue());
        } else if (key.equals("page")) {
        } else if (key.equals("page_size")) {
        } else {
            if (where.length() == 0)
                where.append(" where ");
            else
                where.append(" and ");
            where.append(key).append(" like ? ");
            queryparams.add("%" + r.getValue() + "%");
            countparams.add("%" + r.getValue() + "%");
        }
    });

    if (where.length() > 0) {
        sqlCount.append(where);
        sqlQuery.append(where);
    }
    JsonObject jrs = new JsonObject();
    client.getConnection(connHandler(result, connection -> {
        log.info(sqlCount);
        if (countparams.size() == 0)
            connection.query(sqlCount.toString(), r -> {
                if (r.failed()) {
                    result.fail(r.cause());
                } else {
                    int count = r.result().getRows().get(0).getInteger("count");
                    jrs.put("total", count);
                }
            });
        else
            connection.queryWithParams(sqlCount.toString(), countparams, r -> {
                if (r.failed()) {
                    result.fail(r.cause());
                } else {
                    int count = r.result().getRows().get(0).getInteger("count");
                    jrs.put("total", count);
                }
            });
        if (order.length() > 0) {
            sqlQuery.append(order);
            queryparams.add(params.getString("orderby"));
        }
        if (params.getValue("page") == null) {
            params.put("page", "0");
            params.put("page_size", "" + Integer.MAX_VALUE);
        }
        sqlQuery.append(" limit ?,? ");
        log.info(sqlQuery);
        int page = Integer.parseInt(params.getString("page"));
        int limit = Integer.parseInt(params.getString("page_size"));
        queryparams.add(Utils.calcPage(page, limit)).add(limit);
        connection.queryWithParams(sqlQuery.toString(), queryparams, r -> {
            if (r.failed()) {
                result.fail(r.cause());
            } else {
                jrs.put("data", r.result().getRows().stream().map(Driver::new).collect(Collectors.toList()));
                jrs.put("per_page", limit);
                jrs.put("current_page", page);
            }
            result.complete(new JsonObject().put("status", 200).put("data", new JsonObject().put("list", jrs)));
        });
        connection.close();

    }));
    return result;
}

From source file:com.funmix.service.LineServiceImpl.java

@Override
public Future<JsonObject> getAll(JsonObject params) {
    Future<JsonObject> result = Future.future();
    StringBuffer sqlCount = new StringBuffer(SQL_QUERY_COUNT);
    StringBuffer sqlQuery = new StringBuffer(SQL_QUERY_ALL);
    StringBuffer order = new StringBuffer();
    StringBuffer where = new StringBuffer();
    JsonArray queryparams = new JsonArray();
    JsonArray countparams = new JsonArray();
    params.forEach(r -> {/*from  ww w.j  a  va  2s . c  o  m*/
        String key = r.getKey();
        if (key.equals("orderby")) {
            order.append(" order by ").append(r.getValue());
        } else if (key.equals("page")) {
        } else if (key.equals("page_size")) {
        } else {
            if (where.length() == 0)
                where.append(" where ");
            else
                where.append(" and ");
            where.append(key).append(" like ? ");
            queryparams.add("%" + r.getValue() + "%");
            countparams.add("%" + r.getValue() + "%");
        }
    });

    if (where.length() > 0) {
        sqlCount.append(where);
        sqlQuery.append(where);
    }
    JsonObject jrs = new JsonObject();
    client.getConnection(connHandler(result, connection -> {
        log.info(sqlCount);
        if (countparams.size() == 0)
            connection.query(sqlCount.toString(), r -> {
                if (r.failed()) {
                    result.fail(r.cause());
                } else {
                    int count = r.result().getRows().get(0).getInteger("count");
                    jrs.put("total", count);
                }
            });
        else
            connection.queryWithParams(sqlCount.toString(), countparams, r -> {
                if (r.failed()) {
                    result.fail(r.cause());
                } else {
                    int count = r.result().getRows().get(0).getInteger("count");
                    jrs.put("total", count);
                }
            });
        if (order.length() > 0) {
            sqlQuery.append(order);
            queryparams.add(params.getString("orderby"));
        }
        if (params.getValue("page") == null) {
            params.put("page", "0");
            params.put("page_size", "" + Integer.MAX_VALUE);
        }
        sqlQuery.append(" limit ?,? ");
        log.info(sqlQuery);
        int page = Integer.parseInt(params.getString("page"));
        int limit = Integer.parseInt(params.getString("page_size"));
        queryparams.add(Utils.calcPage(page, limit)).add(limit);
        connection.queryWithParams(sqlQuery.toString(), queryparams, r -> {
            if (r.failed()) {
                result.fail(r.cause());
            } else {
                log.info(r.result().getRows().toString());
                jrs.put("data", r.result().getRows().stream().map(Line::new).collect(Collectors.toList()));
                jrs.put("per_page", limit);
                jrs.put("current_page", page);
            }
            result.complete(new JsonObject().put("status", 200).put("data", new JsonObject().put("list", jrs)));
        });
        connection.close();

    }));
    return result;
}