This commit is contained in:
konrad 2017-11-07 16:35:10 +01:00 committed by kolaente
parent 110361361b
commit b4b0b737a3
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
39 changed files with 158 additions and 163 deletions

View File

@ -1,8 +1,8 @@
package main
import (
"git.mowie.cc/konrad/Library/routes"
"git.mowie.cc/konrad/Library/models"
"git.mowie.cc/konrad/Library/routes"
"fmt"
)

View File

@ -1,6 +1,5 @@
package models
func ListAuthors(searchterm string) (authors []Author, err error) {
if searchterm == "" {

View File

@ -23,7 +23,6 @@ func ListBooks(searchterm string) (books []*Book, err error) {
}
}
// Get all authors and publishers
for i, book := range books {

View File

@ -1,10 +1,10 @@
package models
import (
"github.com/go-xorm/core"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
)
var x *xorm.Engine
@ -15,7 +15,6 @@ func getEngine() (*xorm.Engine, error){
return xorm.NewEngine("mysql", connStr)
}
// SetEngine sets the xorm.Engine
func SetEngine() (err error) {
x, err = getEngine()

View File

@ -14,6 +14,5 @@ func DeletePublisherByID(id int64) error {
//_, err = x.Where("publisher = ?", id).Update(book)
_, err = x.Table("books").Where("publisher = ?", id).Update(map[string]interface{}{"publisher": 0})
return err
}

View File

@ -1,8 +1,8 @@
package models
import (
"golang.org/x/crypto/bcrypt"
"fmt"
"golang.org/x/crypto/bcrypt"
)
type User struct {

View File

@ -1,10 +1,10 @@
package v1
import (
"github.com/labstack/echo"
"strconv"
"net/http"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"strconv"
)
func AuthorDelete(c echo.Context) error {

View File

@ -1,9 +1,9 @@
package v1
import (
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"strconv"
)

View File

@ -1,10 +1,10 @@
package v1
import (
"encoding/json"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"encoding/json"
"strings"
)

View File

@ -1,9 +1,9 @@
package v1
import (
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
)
func AuthorsList(c echo.Context) error {

View File

@ -1,12 +1,12 @@
package v1
import (
"encoding/json"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"encoding/json"
"strings"
"strconv"
"strings"
)
func AuthorUpdate(c echo.Context) error {

View File

@ -1,10 +1,10 @@
package v1
import (
"github.com/labstack/echo"
"strconv"
"net/http"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"strconv"
)
func BookDelete(c echo.Context) error {

View File

@ -1,9 +1,9 @@
package v1
import (
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"strconv"
)

View File

@ -1,10 +1,10 @@
package v1
import (
"encoding/json"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"encoding/json"
"strings"
)

View File

@ -1,9 +1,9 @@
package v1
import (
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"strconv"
)

View File

@ -1,10 +1,10 @@
package v1
import (
"encoding/json"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"encoding/json"
"strings"
)

View File

@ -1,10 +1,10 @@
package v1
import (
"github.com/labstack/echo"
"strconv"
"net/http"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"strconv"
)
func PublisherDelete(c echo.Context) error {

View File

@ -1,9 +1,9 @@
package v1
import (
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
)
func PublishersList(c echo.Context) error {

View File

@ -1,12 +1,12 @@
package v1
import (
"encoding/json"
"git.mowie.cc/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
"git.mowie.cc/konrad/Library/models"
"encoding/json"
"strings"
"strconv"
"strings"
)
func PublisherUpdate(c echo.Context) error {

View File

@ -1,9 +1,9 @@
package v1
import (
"github.com/labstack/echo"
"github.com/dgrijalva/jwt-go"
"fmt"
"github.com/dgrijalva/jwt-go"
"github.com/labstack/echo"
)
func CheckToken(c echo.Context) error {

View File

@ -1,11 +1,11 @@
package routes
import (
"github.com/labstack/echo"
"github.com/dgrijalva/jwt-go"
"time"
"net/http"
"git.mowie.cc/konrad/Library/models"
"github.com/dgrijalva/jwt-go"
"github.com/labstack/echo"
"net/http"
"time"
)
func Login(c echo.Context) error {

View File

@ -1,9 +1,9 @@
package routes
import (
apiv1 "git.mowie.cc/konrad/Library/routes/api/v1"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
apiv1 "git.mowie.cc/konrad/Library/routes/api/v1"
"git.mowie.cc/konrad/Library/models"
)
@ -44,7 +44,6 @@ func RegisterRoutes(e *echo.Echo) {
// Login Route
e.POST("/login", Login)
// ===== Routes with Authetification =====
// Authetification
a.Use(middleware.JWT(models.Config.JWTLoginSecret))