2018-11-20 00:32:55 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2019-01-09 02:29:12 +01:00
|
|
|
// func JokeHandler(c *gin.Context) {
|
|
|
|
// c.Header("Content-Type", "application/json")
|
|
|
|
// c.JSON(http.StatusOK, jokes)
|
|
|
|
// }
|
2018-11-20 00:32:55 +01:00
|
|
|
|
2019-01-09 02:29:12 +01:00
|
|
|
func getUsersView(c *gin.Context) {
|
|
|
|
// dodanie nowej karty do bzy
|
2018-11-20 00:32:55 +01:00
|
|
|
fmt.Println("Dodanie do couchDB nowej karty pytania lub odowiedzi")
|
2019-01-09 02:29:12 +01:00
|
|
|
|
|
|
|
var userList []map[string]interface{}
|
|
|
|
|
|
|
|
allUsers := getAllUsers()
|
|
|
|
for _, arg := range allUsers {
|
|
|
|
tmp := make(map[string]interface{})
|
|
|
|
tmp["login"] = arg.login
|
|
|
|
tmp["userDescription"] = arg.userDescription
|
|
|
|
tmp["points"] = arg.points
|
|
|
|
userList = append(userList, tmp)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Header("Content-Type", "application/json")
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
|
"code": http.StatusOK,
|
|
|
|
"allUsers": userList, // cast it to string before showing
|
|
|
|
})
|
2018-11-20 00:32:55 +01:00
|
|
|
}
|
|
|
|
|
2019-01-09 02:29:12 +01:00
|
|
|
func addNewUserView() {
|
|
|
|
// dodanie nowego użytkownika
|
2018-11-20 00:32:55 +01:00
|
|
|
fmt.Println("Rejestracja nowego użytkownika")
|
|
|
|
}
|
|
|
|
|
2019-01-09 02:29:12 +01:00
|
|
|
func loginUserView() {
|
|
|
|
//logowanie - czy jest w bazie
|
2018-11-20 00:32:55 +01:00
|
|
|
fmt.Println("Logowanie użytkownika")
|
|
|
|
}
|