diff options
author | Emile <hanemile@protonmail.com> | 2019-02-13 13:09:54 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-02-13 13:09:54 +0100 |
commit | bbed0542a975bdb1a67aadabea7a54b580fcbd08 (patch) | |
tree | 2b845c617d069726433d540f97ae82a72dcfa594 /http.go | |
parent | ee709e790d5866b3f5d5ef70b015729c522e63a6 (diff) |
moved the db_actions to an own package and adjusted the functions so that the database gets reached into the function for usage
Diffstat (limited to 'http.go')
-rw-r--r-- | http.go | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/http.go b/http.go index d19e1a0..7df8ed0 100644 --- a/http.go +++ b/http.go @@ -17,6 +17,8 @@ package main import ( + "database/sql" + "git.darknebu.la/GalaxySimulator/db-container/db_actions" "git.darknebu.la/GalaxySimulator/structs" ) @@ -48,48 +50,48 @@ API: } // newTree creates a new tree -func newTreeEndpoint(width float64) { - newTree(width) +func newTreeEndpoint(db *sql.DB, width float64) { + db_actions.NewTree(db, width) } // insertStarEndpoint inserts the star into the tree with the given index -func insertStarEndpoint(star structs.Star2D, index int64) { - insertStar(star, index) +func insertStarEndpoint(db *sql.DB, star structs.Star2D, index int64) { + db_actions.InsertStar(db, star, index) } // insertListEndpoint inserts the star into the tree with the given index -func insertListEndpoint(filename string) { - insertList(filename) +func insertListEndpoint(db *sql.DB, filename string) { + db_actions.InsertList(db, filename) } // deleteStarsEndpoint deletes all the rows from the stars table -func deleteStarsEndpoint() { - deleteAllStars() +func deleteStarsEndpoint(db *sql.DB) { + db_actions.DeleteAllStars(db) } // deleteNodesEndpoint deletes all the rows from the nodes table -func deleteNodesEndpoint() { - deleteAllNodes() +func deleteNodesEndpoint(db *sql.DB) { + db_actions.DeleteAllNodes(db) } -func listOfStarsGoEndpoint() []structs.Star2D { - listOfStars := getListOfStarsGo() +func listOfStarsGoEndpoint(db *sql.DB) []structs.Star2D { + listOfStars := db_actions.GetListOfStarsGo(db) return listOfStars } -func listOfStarsCsvEndpoint() []string { - listOfStars := getListOfStarsCsv() +func listOfStarsCsvEndpoint(db *sql.DB) []string { + listOfStars := db_actions.GetListOfStarsCsv(db) return listOfStars } -func updateTotalMassEndpoint(index int64) { - updateTotalMass(index) +func updateTotalMassEndpoint(db *sql.DB, index int64) { + db_actions.UpdateTotalMass(db, index) } -func updateCenterOfMassEndpoint(index int64) { - updateCenterOfMass(index) +func updateCenterOfMassEndpoint(db *sql.DB, index int64) { + db_actions.UpdateCenterOfMass(db, index) } -func genForestTreeEndpoint(index int64) string { - return genForestTree(index) +func genForestTreeEndpoint(db *sql.DB, index int64) string { + return db_actions.GenForestTree(db, index) } |