Repository for the Bootcamp 23.1 challenge
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

68 lines
2.0 KiB

// DEBUG... COMENTAR DEPOIS
//_log.info("service called...");
const astroUid = _req.getString("uid");
if (astroUid && astroUid != "") {
const dbAstro = _db.queryFirst(`
SELECT
astro.uid,
--astro.id,
astro.name,
astro_type.name AS "astro_type",
astro_type.id AS "astro_type_code",
astro.equatorial_radius,
astro.rotation_velocity,
--astro.around_astro_id,
around.uid as "around_astro_uid",
around.name as "around_astro_name",
astro.periapsis,
astro.apoapsis
--,astro.image
FROM astro
INNER JOIN astro_type
ON astro.type_id = astro_type.id
LEFT JOIN ( SELECT id,uid,name FROM astro ) AS around
ON astro.around_astro_id = around.id
WHERE
astro.active = TRUE
AND astro_type.active = TRUE
AND astro.uid = CAST(? AS UUID)
`, astroUid);
if (dbAstro == null) {
_header.status(404);
_exec.stop();
}
const astro =
_val.map()
.set("uid", dbAstro.getString("uid"))
.set("name", dbAstro.getString("name"))
.set(
"type",
_val.map()
.set("name", dbAstro.getString("astro_type") )
.set("code", dbAstro.getString("astro_type_code")))
.set("equatorialRadius", dbAstro.getDouble("equatorial_radius"))
.set("rotationVelocity", dbAstro.getDouble("rotation_velocity"))
.set(
"aroundAstro",
_val.map()
.set("uid", dbAstro.getString("around_astro_uid"))
.set("name", dbAstro.getString("around_astro_name")))
.set("periapsis", dbAstro.getDouble("periapsis"))
.set("apoapsis", dbAstro.getDouble("apoapsis"))
;
// DEBUG...COMENTAR DEPOIS!
//_log.info('Server return...', astro);
_out.json(astro);
// DEBUG...COMENTAR DEPOIS!
//_log.info('service ended!');
}
else {
_header.status(400);
_exec.stop();
}