From 616778cac8ffe8039d8ebd931be81721f1282456 Mon Sep 17 00:00:00 2001 From: monastyr Date: Tue, 20 Nov 2018 00:32:55 +0100 Subject: [PATCH] struktura katalogow --- backend/golang-gin/cards_logger.py | 0 backend/golang-gin/config.go | 0 backend/golang-gin/connector_couchdb.go | 77 +++++++++++++++++++ backend/golang-gin/connector_mysql.go | 0 backend/golang-gin/decorators.go | 13 ++++ backend/golang-gin/main.go | 1 + backend/golang-gin/models.go | 56 ++++++++++++++ backend/golang-gin/views.go | 27 +++++++ frontend/app/config/index.js | 2 +- frontend/app/src/App.vue | 11 ++- frontend/app/src/components/AddNewCard.vue | 29 +++++++ .../app/src/components/GetAllCardsJson.vue | 29 +++++++ frontend/app/src/components/Login.vue | 0 frontend/app/src/components/Register.vue | 0 14 files changed, 238 insertions(+), 7 deletions(-) create mode 100644 backend/golang-gin/cards_logger.py create mode 100644 backend/golang-gin/config.go create mode 100644 backend/golang-gin/connector_couchdb.go create mode 100644 backend/golang-gin/connector_mysql.go create mode 100644 backend/golang-gin/decorators.go create mode 100644 backend/golang-gin/models.go create mode 100644 backend/golang-gin/views.go create mode 100644 frontend/app/src/components/AddNewCard.vue create mode 100644 frontend/app/src/components/GetAllCardsJson.vue create mode 100644 frontend/app/src/components/Login.vue create mode 100644 frontend/app/src/components/Register.vue diff --git a/backend/golang-gin/cards_logger.py b/backend/golang-gin/cards_logger.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/golang-gin/config.go b/backend/golang-gin/config.go new file mode 100644 index 0000000..e69de29 diff --git a/backend/golang-gin/connector_couchdb.go b/backend/golang-gin/connector_couchdb.go new file mode 100644 index 0000000..2aab8d1 --- /dev/null +++ b/backend/golang-gin/connector_couchdb.go @@ -0,0 +1,77 @@ +package main + +import ( + "fmt" + "net/url" + + "github.com/zemirco/couchdb" +) + +// create your own document +type dummyDocument struct { + couchdb.Document + Foo string `json:"foo"` + Beep string `json:"beep"` +} + +func connectCouchdb(url_couchdb string) { + if url_couchdb == "" { + url_couchdb = "http://127.0.0.1:5984/" + } + + u, err := url.Parse(url_couchdb) + if err != nil { + panic(err) + } + return u, err +} + +// start +func main() { + + u, err = connectCouchdb("") + // create a new client + client, err := couchdb.NewClient(u) + if err != nil { + panic(err) + } + + // get some information about your CouchDB + info, err := client.Info() + if err != nil { + panic(err) + } + fmt.Println(info) + + // // create a database + // if _, err = client.Create("dummy"); err != nil { + // panic(err) + // } + + // use your new "dummy" database and create a document + db := client.Use("dummy") + doc := &dummyDocument{ + Foo: "bar", + Beep: "bopp", + } + result, err := db.Post(doc) + if err != nil { + panic(err) + } + + // get id and current revision. + if err := db.Get(doc, result.ID); err != nil { + panic(err) + } + + // delete document + if _, err = db.Delete(doc); err != nil { + panic(err) + } + + // and finally delete the database + if _, err = client.Delete("dummy"); err != nil { + panic(err) + } + +} diff --git a/backend/golang-gin/connector_mysql.go b/backend/golang-gin/connector_mysql.go new file mode 100644 index 0000000..e69de29 diff --git a/backend/golang-gin/decorators.go b/backend/golang-gin/decorators.go new file mode 100644 index 0000000..230afd1 --- /dev/null +++ b/backend/golang-gin/decorators.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" +) + +func GenerateJWT() (string, error) { + fmt.Println("Generowanie JWT tokena dla klienta") +} + +func ValidateToken() (string, error) { + fmt.Println("Walidacja Tokena dla tresci dostepnych tylko dla zalogowanych użytkowników") +} diff --git a/backend/golang-gin/main.go b/backend/golang-gin/main.go index 29e3429..0043a00 100644 --- a/backend/golang-gin/main.go +++ b/backend/golang-gin/main.go @@ -55,6 +55,7 @@ func main() { // /jokes/like/:jokeID - which will capture likes sent to a particular joke api.GET("/jokes", JokeHandler) api.POST("/jokes/like/:jokeID", LikeJoke) + api.POST("/cards", getAllCards) // Start and run the server router.Run(":3000") diff --git a/backend/golang-gin/models.go b/backend/golang-gin/models.go new file mode 100644 index 0000000..30edad6 --- /dev/null +++ b/backend/golang-gin/models.go @@ -0,0 +1,56 @@ +package main + +// Structura karty + +type Card struct { + ID int `json:"id" binding:"required"` + Type int `json:"typ"` //0 karta pytanie, 1 karta odpowiedź + Blank int `json:"puste" binding:"required"` //ile kart odpowiedzi na pytanie + Text string `json:"tekst" binding:"required"` // podłoga to luka +} + +// Lista card +var cards = []Card{ + Card{0, 0, 0, "Adoptowanie dziecka tylko po, by porzucić je w galerii handlowej."}, + Card{1, 0, 0, "Sieroty, które wybuchają gdy ktoś je tylko pokocha."}, + Card{2, 0, 0, "Niekończąca się aktualizacja Windowsa"}, + Card{3, 0, 0, "Bug."}, + Card{4, 0, 0, "Wadliwe testy jednostkowe."}, + Card{5, 0, 0, "Użyszkodnik."}, + Card{6, 0, 0, "Aplikacja kalkulatora zajmująca 5GB."}, + Card{7, 1, 1, "Nie programuję w święta, bo _ się rodzi."}, + Card{8, 1, 1, "3 rzeczy lepsze od seksu. _ _ _"}, + Card{9, 0, 0, "Audyt bezpiezeństwa teleinformatycznego."}, + Card{10, 0, 0, "Testy na produkcji."}, + Card{11, 0, 0, "Pasywno-agresywna notatka o bałaganie w mieszkaniu."}, + Card{12, 0, 0, "Spanko."}, + Card{13, 0, 0, "Granko."}, + Card{14, 0, 0, "Niech żyje zbrodniczy reżim."}, + Card{15, 0, 0, "Kuce z Orła."}, + Card{16, 0, 0, "Wałówka od mamy."}, + Card{17, 0, 0, "10 dni do wypłaty."}, + Card{18, 0, 0, "Bo to zła kobieta była."}, + Card{19, 1, 2, "Rude to _ i _."}, + Card{20, 0, 0, "Tłusty drewnojad."}, + Card{21, 0, 0, "Zupa z paczki o smaku opakowania."}, + Card{22, 0, 0, "Przez twe oczy zielone, zielone _."}, + Card{23, 0, 0, "Naleśnikowa środa."}, + Card{24, 0, 0, "Kończenie dokumentacji o 5 nad ranem."}, + Card{25, 0, 0, "Powtarzanie roku."}, + Card{26, 0, 0, "Warunek."}, + Card{27, 0, 0, "Pralka."}, + Card{28, 0, 0, "Chodzenie po starym rynku w szpilkach."}, + Card{29, 0, 0, "Nieudana migracja bez logów."}, + Card{30, 0, 0, "Nocny dyżur."}, + Card{31, 1, 1, "Kac morderca jest wtedy gdy _."}, + Card{32, 0, 0, "Buka."}, + Card{33, 0, 0, "Nie mogę wyjść, mam _."}, + Card{34, 0, 0, "Cukier."}, + Card{35, 0, 0, "Co?"}, + Card{36, 0, 0, "Chodź, debata jest."}, + Card{37, 0, 0, "Ranga w pubg."}, + Card{38, 0, 0, "Dla Ciebie Pani Sarna."}, + Card{39, 1, 1, "Palenie papierosów powoduje _."}, + Card{40, 0, 0, "Syndrom Sztokholmski."}, + Card{41, 0, 0, "Domyśl się."}, +} diff --git a/backend/golang-gin/views.go b/backend/golang-gin/views.go new file mode 100644 index 0000000..a41bf39 --- /dev/null +++ b/backend/golang-gin/views.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "net/http" + + "github.com/gin-gonic/gin" +) + +func getAllCards(c *gin.Context) { + fmt.Println("Pobieranie wszystkich kart z bazy - pytań i odpowiedzi") + fmt.Println("Długość listy: ", len(cards)) + + c.JSON(http.StatusOK, &cards) +} + +func addNewCard() { + fmt.Println("Dodanie do couchDB nowej karty pytania lub odowiedzi") +} + +func addNewUser() { + fmt.Println("Rejestracja nowego użytkownika") +} + +func loginUser() { + fmt.Println("Logowanie użytkownika") +} diff --git a/frontend/app/config/index.js b/frontend/app/config/index.js index 52f75d6..a25a611 100644 --- a/frontend/app/config/index.js +++ b/frontend/app/config/index.js @@ -27,7 +27,7 @@ module.exports = { // Various Dev Server settings host: 'localhost', // can be overwritten by process.env.HOST - port: 3000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined + port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined autoOpenBrowser: false, errorOverlay: true, notifyOnErrors: true, diff --git a/frontend/app/src/App.vue b/frontend/app/src/App.vue index 5d74f4f..0764015 100644 --- a/frontend/app/src/App.vue +++ b/frontend/app/src/App.vue @@ -1,6 +1,7 @@ @@ -17,14 +18,12 @@ export default { methods: { downloadData: function () { console.log('Cokolwiek') - var formData = new FormData() - axios.post('/api/api/jokes/like/0', formData).then(response => { + axios.post('/api/jokes/like/0').then(response => { console.log("Server response: ",response.data) }) + console.log('Cokolwiek 2') + } - }, - created: function () { - this.downloadData() } } // https://codepen.io/anon/pen/BGzVpK diff --git a/frontend/app/src/components/AddNewCard.vue b/frontend/app/src/components/AddNewCard.vue new file mode 100644 index 0000000..7e08169 --- /dev/null +++ b/frontend/app/src/components/AddNewCard.vue @@ -0,0 +1,29 @@ + + + + diff --git a/frontend/app/src/components/GetAllCardsJson.vue b/frontend/app/src/components/GetAllCardsJson.vue new file mode 100644 index 0000000..4e61a3d --- /dev/null +++ b/frontend/app/src/components/GetAllCardsJson.vue @@ -0,0 +1,29 @@ + + + + diff --git a/frontend/app/src/components/Login.vue b/frontend/app/src/components/Login.vue new file mode 100644 index 0000000..e69de29 diff --git a/frontend/app/src/components/Register.vue b/frontend/app/src/components/Register.vue new file mode 100644 index 0000000..e69de29