Compare commits

..

3 Commits

Author SHA1 Message Date
Etzelia c410001f8d
Ignore ignored JSON tags
Signed-off-by: Etzelia <etzelia@hotmail.com>
2019-11-24 15:19:49 -06:00
Etzelia 7ad5a3a5d6
Update after testing
Signed-off-by: Etzelia <etzelia@hotmail.com>
2019-11-24 15:17:54 -06:00
Etzelia 017a921a4b
Add functions for model POST API
Signed-off-by: Etzelia <etzelia@hotmail.com>
2019-11-23 21:22:34 -06:00
18 changed files with 79 additions and 105 deletions

View File

@ -8,9 +8,9 @@ package main
import (
"fmt"
"git.canopymc.net/Etzelia/go-mcm"
"git.canopymc.net/Etzelia/go-mcm/model"
"git.canopymc.net/Etzelia/go-mcm/model/django"
"go.etztech.xyz/go-mcm"
"go.etztech.xyz/go-mcm/model"
"go.etztech.xyz/go-mcm/model/django"
)
func main() {

2
go.mod
View File

@ -1,3 +1,3 @@
module git.jojodev.com/Minecraft/go-mcm
module go.etztech.xyz/go-mcm
go 1.13

5
mcm.go
View File

@ -2,10 +2,9 @@ package mcm
import (
"fmt"
"go.etztech.xyz/go-mcm/model"
"go.etztech.xyz/go-mcm/web"
"strings"
"git.jojodev.com/Minecraft/go-mcm/model"
"git.jojodev.com/Minecraft/go-mcm/web"
)
type MCM struct {

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type Alert struct {

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type Application struct {
@ -16,7 +15,7 @@ type Application struct {
EverBannedExplanation string `json:"ever_banned_explanation"`
Reference string `json:"reference"`
ReadRules string `json:"read_rules"`
Accepted *bool `json:"accepted"`
Accepted bool `json:"accepted"`
Date string `json:"date"`
Link string `json:"link"`

View File

@ -17,40 +17,30 @@ type Builder struct {
}
func NewBuilder(token string) *Builder {
return &Builder{[]string{fmt.Sprintf("api=%v", token)}}
return &Builder{[]string{fmt.Sprintf("api=%s", token)}}
}
func (db *Builder) QueryString() string {
return "?" + strings.Join(db.Params, "&")
}
func (db *Builder) Eq(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__eq=%v", field, value))
func (db *Builder) Exact(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%s", field, value))
return db
}
func (db *Builder) Ne(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__ne=%v", field, value))
func (db *Builder) IExact(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%s", field, value))
return db
}
func (db *Builder) Exact(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%v", field, value))
func (db *Builder) Contains(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__contains=%s", field, value))
return db
}
func (db *Builder) IExact(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%v", field, value))
return db
}
func (db *Builder) Contains(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__contains=%v", field, value))
return db
}
func (db *Builder) IContains(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__icontains=%v", field, value))
func (db *Builder) IContains(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__icontains=%s", field, value))
return db
}
@ -59,43 +49,43 @@ func (db *Builder) In(field string, values ...string) *Builder {
return db
}
func (db *Builder) Gt(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%v", field, value))
func (db *Builder) Gt(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%s", field, value))
return db
}
func (db *Builder) Gte(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%v", field, value))
func (db *Builder) Gte(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%s", field, value))
return db
}
func (db *Builder) Lt(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%v", field, value))
func (db *Builder) Lt(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%s", field, value))
return db
}
func (db *Builder) Lte(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%v", field, value))
func (db *Builder) Lte(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%s", field, value))
return db
}
func (db *Builder) Startswith(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%v", field, value))
func (db *Builder) Startswith(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%s", field, value))
return db
}
func (db *Builder) IStartswith(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%v", field, value))
func (db *Builder) IStartswith(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%s", field, value))
return db
}
func (db *Builder) Endswith(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%v", field, value))
func (db *Builder) Endswith(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%s", field, value))
return db
}
func (db *Builder) IEndswith(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%v", field, value))
func (db *Builder) IEndswith(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%s", field, value))
return db
}
@ -104,72 +94,72 @@ func (db *Builder) Range(field Field, from, to string) *Builder {
return db
}
func (db *Builder) Date(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__date=%v", field, value))
func (db *Builder) Date(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__date=%s", field, value))
return db
}
func (db *Builder) Year(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__year=%v", field, value))
func (db *Builder) Year(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__year=%s", field, value))
return db
}
func (db *Builder) Month(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__month=%v", field, value))
func (db *Builder) Month(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__month=%s", field, value))
return db
}
func (db *Builder) Day(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__day=%v", field, value))
func (db *Builder) Day(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__day=%s", field, value))
return db
}
func (db *Builder) Week(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__week=%v", field, value))
func (db *Builder) Week(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__week=%s", field, value))
return db
}
func (db *Builder) WeekDay(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%v", field, value))
func (db *Builder) WeekDay(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%s", field, value))
return db
}
func (db *Builder) Quarter(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%v", field, value))
func (db *Builder) Quarter(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%s", field, value))
return db
}
func (db *Builder) Time(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__time=%v", field, value))
func (db *Builder) Time(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__time=%s", field, value))
return db
}
func (db *Builder) Hour(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%v", field, value))
func (db *Builder) Hour(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%s", field, value))
return db
}
func (db *Builder) Minute(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%v", field, value))
func (db *Builder) Minute(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%s", field, value))
return db
}
func (db *Builder) Second(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__second=%v", field, value))
func (db *Builder) Second(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__second=%s", field, value))
return db
}
func (db *Builder) IsNull(field Field, value interface{}) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%v", field, value))
func (db *Builder) IsNull(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%s", field, value))
return db
}
func (db *Builder) Regex(field Field, value interface{}) *Builder {
func (db *Builder) Regex(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__regex=r'%s'", field, value))
return db
}
func (db *Builder) IRegex(field Field, value interface{}) *Builder {
func (db *Builder) IRegex(field Field, value string) *Builder {
db.Params = append(db.Params, fmt.Sprintf("%s__iregex=r'%s'", field, value))
return db
}

View File

@ -8,6 +8,5 @@ const (
PlayerApplicationID Field = "application_id"
PlayerFirstSeen Field = "first_seen"
PlayerLastSeen Field = "last_seen"
PlayerDiscordID Field = "discord_id"
PlayerLink = Link
)

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type IP struct {

View File

@ -2,11 +2,10 @@ package model
import (
"fmt"
"go.etztech.xyz/go-mcm/model/django"
"net/url"
"reflect"
"strings"
"git.jojodev.com/Minecraft/go-mcm/model/django"
)
type Model struct {

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type Importance string

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type Player struct {
@ -15,7 +14,6 @@ type Player struct {
ApplicationID int64 `json:"application_id"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen"`
DiscordID string `json:"discord_id"`
Link string `json:"link"`
model *Model `json:"-"`

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type Priority string

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type TicketNote struct {

View File

@ -2,9 +2,8 @@ package model
import (
"encoding/json"
"git.jojodev.com/Minecraft/go-mcm/internal"
"git.jojodev.com/Minecraft/go-mcm/model/django"
"go.etztech.xyz/go-mcm/internal"
"go.etztech.xyz/go-mcm/model/django"
)
type Results int64

View File

@ -1,9 +1,8 @@
package web
import (
"go.etztech.xyz/go-mcm/internal"
"net/url"
"git.jojodev.com/Minecraft/go-mcm/internal"
)
func (web *Web) Alert(message string, ping bool) (*internal.Status, error) {

View File

@ -1,9 +1,8 @@
package web
import (
"go.etztech.xyz/go-mcm/internal"
"net/url"
"git.jojodev.com/Minecraft/go-mcm/internal"
)
func (web *Web) Discord(message string, ping bool) (*internal.Status, error) {

View File

@ -3,8 +3,7 @@ package web
import (
"encoding/json"
"fmt"
"git.jojodev.com/Minecraft/go-mcm/internal"
"go.etztech.xyz/go-mcm/internal"
)
type Log struct {

View File

@ -3,8 +3,7 @@ package web
import (
"encoding/json"
"fmt"
"git.jojodev.com/Minecraft/go-mcm/internal"
"go.etztech.xyz/go-mcm/internal"
)
type Online struct {