Merge branch 'master' of https://eng-git.canterbury.ac.nz/fwy13/territory_walker
This commit is contained in:
@@ -39,9 +39,30 @@ CREATE TABLE `polygonPoints` (
|
|||||||
FOREIGN KEY (polygonID) REFERENCES polygonArea(polygonID)
|
FOREIGN KEY (polygonID) REFERENCES polygonArea(polygonID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
DELIMITER //
|
||||||
|
CREATE PROCEDURE getPolygonPoints
|
||||||
|
(IN id VARCHAR(6))
|
||||||
|
BEGIN
|
||||||
|
SELECT * FROM `polygonPoints`
|
||||||
|
JOIN `polygonArea` ON
|
||||||
|
`polygonArea`.polygonID = polygonPoints.polygonID
|
||||||
|
JOIN (SELECT * FROM `userJoinedGames` WHERE gameID = id) AS userColour ON
|
||||||
|
`polygonArea`.userID = userColour.UserID
|
||||||
|
WHERE
|
||||||
|
polygonArea.gameID = id;
|
||||||
|
END //
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
INSERT INTO `gameInstances` (gameID) VALUES ("samdum");
|
INSERT INTO `gameInstances` (gameID) VALUES ("samdum");
|
||||||
INSERT INTO `users` (userID, nickname) VALUES ("samded", "Lesmaux");
|
INSERT INTO `users` (userID, nickname) VALUES ("samded", "Lesmaux");
|
||||||
INSERT INTO `users` (userID, nickname) VALUES ("fanded", "Umbra Sheep");
|
INSERT INTO `users` (userID, nickname) VALUES ("fanded", "Umbra Sheep");
|
||||||
|
INSERT INTO `polygonArea` (gameID, polygonID, userID, area) VALUES
|
||||||
|
("samdum", "someuniqueid", "samded", 100000.1);
|
||||||
|
INSERT INTO `polygonPoints` (polygonID, lat, lng) VALUES
|
||||||
|
("someuniqueid", -43.5623, 172.5655),
|
||||||
|
("someuniqueid", -43.5623, 172.5650),
|
||||||
|
("someuniqueid", -43.5628, 172.5650),
|
||||||
|
("someuniqueid", -43.5628, 172.5655);
|
||||||
-- TODO CREATE PROCEDURE FOR GENERATING GAME ID
|
-- TODO CREATE PROCEDURE FOR GENERATING GAME ID
|
||||||
-- concat(substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', rand()*36+1, 1),
|
-- concat(substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', rand()*36+1, 1),
|
||||||
-- substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', rand()*36+1, 1),
|
-- substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', rand()*36+1, 1),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ module.exports = function (server) {
|
|||||||
|
|
||||||
server.get("/polygons", function (req, res, next) {
|
server.get("/polygons", function (req, res, next) {
|
||||||
if (versioner.currentVersion === 1) {
|
if (versioner.currentVersion === 1) {
|
||||||
apiV1.getPolygons(res);
|
apiV1.getPolygons(req, res);
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
res.send(200);
|
res.send(200);
|
||||||
|
|||||||
+9
-3
@@ -1,11 +1,17 @@
|
|||||||
let db = require("../config/db.js");
|
let db = require("../config/db.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getPolygons : function (res) {
|
getPolygons : function (req, res) {
|
||||||
db.get().query("", function(err, rows){
|
if (req.query.gameID != null) {
|
||||||
|
let query = "CALL getPolygonPoints(\"samdum\");";
|
||||||
|
console.log("hi");
|
||||||
|
db.get().query(query, function(err, rows){
|
||||||
if (err) return res.send(400);
|
if (err) return res.send(400);
|
||||||
res.send(rows);
|
res.send(rows[0]);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
res.send(500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
-8926
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user