diff --git a/app/start.go b/app/start.go index ec44dfc..d20881c 100644 --- a/app/start.go +++ b/app/start.go @@ -1,7 +1,6 @@ package app import ( - "database/sql" "fmt" "git.zxq.co/ripple/rippleapi/app/internals" @@ -11,15 +10,16 @@ import ( "github.com/getsentry/raven-go" "github.com/gin-gonic/contrib/gzip" "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" ) var ( - db *sql.DB + db *sqlx.DB cf common.Conf ) // Start begins taking HTTP connections. -func Start(conf common.Conf, dbO *sql.DB) *gin.Engine { +func Start(conf common.Conf, dbO *sqlx.DB) *gin.Engine { db = dbO cf = conf diff --git a/app/v1/token.go b/app/v1/token.go index 47d33e2..c46ae0b 100644 --- a/app/v1/token.go +++ b/app/v1/token.go @@ -5,6 +5,8 @@ import ( "database/sql" "fmt" + "github.com/jmoiron/sqlx" + "git.zxq.co/ripple/rippleapi/common" "git.zxq.co/ripple/schiavolib" "golang.org/x/crypto/bcrypt" @@ -204,7 +206,7 @@ func TokenFixPrivilegesGET(md common.MethodData) common.CodeMessager { return common.SimpleResponse(200, "Privilege fixing started!") } -func fixPrivileges(user int, db *sql.DB) { +func fixPrivileges(user int, db *sqlx.DB) { var wc string var params = make([]interface{}, 0, 1) if user != 0 { diff --git a/app/v1/user_scores.go b/app/v1/user_scores.go index 528e22e..251db52 100644 --- a/app/v1/user_scores.go +++ b/app/v1/user_scores.go @@ -8,26 +8,6 @@ import ( "git.zxq.co/ripple/rippleapi/common" ) -type score struct { - ID int `json:"id"` - BeatmapMD5 string `json:"beatmap_md5"` - Score int64 `json:"score"` - MaxCombo int `json:"max_combo"` - FullCombo bool `json:"full_combo"` - Mods int `json:"mods"` - Count300 int `json:"count_300"` - Count100 int `json:"count_100"` - Count50 int `json:"count_50"` - CountGeki int `json:"count_geki"` - CountKatu int `json:"count_katu"` - CountMiss int `json:"count_miss"` - Time time.Time `json:"time"` - PlayMode int `json:"play_mode"` - Accuracy float64 `json:"accuracy"` - PP float32 `json:"pp"` - Completed int `json:"completed"` -} - type userScore struct { score Beatmap beatmap `json:"beatmap"` diff --git a/common/method_data.go b/common/method_data.go index 7d4159f..d979985 100644 --- a/common/method_data.go +++ b/common/method_data.go @@ -1,16 +1,16 @@ package common import ( - "database/sql" "encoding/json" "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" ) // MethodData is a struct containing the data passed over to an API method. type MethodData struct { User Token - DB *sql.DB + DB *sqlx.DB RequestData RequestData C *gin.Context } diff --git a/main.go b/main.go index 49cd8c2..d665908 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "database/sql" "fmt" "log" "strings" @@ -12,6 +11,7 @@ import ( "git.zxq.co/ripple/schiavolib" // Golint pls dont break balls _ "github.com/go-sql-driver/mysql" + "github.com/jmoiron/sqlx" ) // Version is the git hash of the application. Do not edit. This is @@ -24,7 +24,7 @@ func init() { common.Version = Version } -var db *sql.DB +var db *sqlx.DB func main() { fmt.Print("Ripple API") @@ -49,7 +49,7 @@ func main() { } var err error - db, err = sql.Open(conf.DatabaseType, conf.DSN) + db, err = sqlx.Open(conf.DatabaseType, conf.DSN) if err != nil { schiavo.Bunker.Send(err.Error()) log.Fatalln(err)