Compare commits
3 Commits
master
...
model_post
Author | SHA1 | Date |
---|---|---|
Etzelia | c410001f8d | |
Etzelia | 7ad5a3a5d6 | |
Etzelia | 017a921a4b |
|
@ -8,9 +8,9 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.canopymc.net/Etzelia/go-mcm"
|
"go.etztech.xyz/go-mcm"
|
||||||
"git.canopymc.net/Etzelia/go-mcm/model"
|
"go.etztech.xyz/go-mcm/model"
|
||||||
"git.canopymc.net/Etzelia/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
||||||
module git.jojodev.com/Minecraft/go-mcm
|
module go.etztech.xyz/go-mcm
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
5
mcm.go
5
mcm.go
|
@ -2,10 +2,9 @@ package mcm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go.etztech.xyz/go-mcm/model"
|
||||||
|
"go.etztech.xyz/go-mcm/web"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model"
|
|
||||||
"git.jojodev.com/Minecraft/go-mcm/web"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MCM struct {
|
type MCM struct {
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Alert struct {
|
type Alert struct {
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Application struct {
|
type Application struct {
|
||||||
|
@ -16,7 +15,7 @@ type Application struct {
|
||||||
EverBannedExplanation string `json:"ever_banned_explanation"`
|
EverBannedExplanation string `json:"ever_banned_explanation"`
|
||||||
Reference string `json:"reference"`
|
Reference string `json:"reference"`
|
||||||
ReadRules string `json:"read_rules"`
|
ReadRules string `json:"read_rules"`
|
||||||
Accepted *bool `json:"accepted"`
|
Accepted bool `json:"accepted"`
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
|
|
||||||
|
|
|
@ -17,40 +17,30 @@ type Builder struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBuilder(token string) *Builder {
|
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 {
|
func (db *Builder) QueryString() string {
|
||||||
return "?" + strings.Join(db.Params, "&")
|
return "?" + strings.Join(db.Params, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Eq(field Field, value interface{}) *Builder {
|
func (db *Builder) Exact(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__eq=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Ne(field Field, value interface{}) *Builder {
|
func (db *Builder) IExact(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__ne=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Exact(field Field, value interface{}) *Builder {
|
func (db *Builder) Contains(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__contains=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IExact(field Field, value interface{}) *Builder {
|
func (db *Builder) IContains(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__icontains=%s", 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))
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,43 +49,43 @@ func (db *Builder) In(field string, values ...string) *Builder {
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Gt(field Field, value interface{}) *Builder {
|
func (db *Builder) Gt(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Gte(field Field, value interface{}) *Builder {
|
func (db *Builder) Gte(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Lt(field Field, value interface{}) *Builder {
|
func (db *Builder) Lt(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Lte(field Field, value interface{}) *Builder {
|
func (db *Builder) Lte(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Startswith(field Field, value interface{}) *Builder {
|
func (db *Builder) Startswith(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IStartswith(field Field, value interface{}) *Builder {
|
func (db *Builder) IStartswith(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Endswith(field Field, value interface{}) *Builder {
|
func (db *Builder) Endswith(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IEndswith(field Field, value interface{}) *Builder {
|
func (db *Builder) IEndswith(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,72 +94,72 @@ func (db *Builder) Range(field Field, from, to string) *Builder {
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Date(field Field, value interface{}) *Builder {
|
func (db *Builder) Date(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__date=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__date=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Year(field Field, value interface{}) *Builder {
|
func (db *Builder) Year(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__year=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__year=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Month(field Field, value interface{}) *Builder {
|
func (db *Builder) Month(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__month=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__month=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Day(field Field, value interface{}) *Builder {
|
func (db *Builder) Day(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__day=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__day=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Week(field Field, value interface{}) *Builder {
|
func (db *Builder) Week(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__week=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__week=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) WeekDay(field Field, value interface{}) *Builder {
|
func (db *Builder) WeekDay(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Quarter(field Field, value interface{}) *Builder {
|
func (db *Builder) Quarter(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Time(field Field, value interface{}) *Builder {
|
func (db *Builder) Time(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__time=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__time=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Hour(field Field, value interface{}) *Builder {
|
func (db *Builder) Hour(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Minute(field Field, value interface{}) *Builder {
|
func (db *Builder) Minute(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Second(field Field, value interface{}) *Builder {
|
func (db *Builder) Second(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__second=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__second=%s", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IsNull(field Field, value interface{}) *Builder {
|
func (db *Builder) IsNull(field Field, value string) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%v", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%s", field, value))
|
||||||
return db
|
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))
|
db.Params = append(db.Params, fmt.Sprintf("%s__regex=r'%s'", field, value))
|
||||||
return db
|
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))
|
db.Params = append(db.Params, fmt.Sprintf("%s__iregex=r'%s'", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,5 @@ const (
|
||||||
PlayerApplicationID Field = "application_id"
|
PlayerApplicationID Field = "application_id"
|
||||||
PlayerFirstSeen Field = "first_seen"
|
PlayerFirstSeen Field = "first_seen"
|
||||||
PlayerLastSeen Field = "last_seen"
|
PlayerLastSeen Field = "last_seen"
|
||||||
PlayerDiscordID Field = "discord_id"
|
|
||||||
PlayerLink = Link
|
PlayerLink = Link
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IP struct {
|
type IP struct {
|
||||||
|
|
|
@ -2,11 +2,10 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Model struct {
|
type Model struct {
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Importance string
|
type Importance string
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Player struct {
|
type Player struct {
|
||||||
|
@ -15,7 +14,6 @@ type Player struct {
|
||||||
ApplicationID int64 `json:"application_id"`
|
ApplicationID int64 `json:"application_id"`
|
||||||
FirstSeen string `json:"first_seen"`
|
FirstSeen string `json:"first_seen"`
|
||||||
LastSeen string `json:"last_seen"`
|
LastSeen string `json:"last_seen"`
|
||||||
DiscordID string `json:"discord_id"`
|
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
|
|
||||||
model *Model `json:"-"`
|
model *Model `json:"-"`
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Priority string
|
type Priority string
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TicketNote struct {
|
type TicketNote struct {
|
||||||
|
|
|
@ -2,9 +2,8 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/model/django"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Results int64
|
type Results int64
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (web *Web) Alert(message string, ping bool) (*internal.Status, error) {
|
func (web *Web) Alert(message string, ping bool) (*internal.Status, error) {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (web *Web) Discord(message string, ping bool) (*internal.Status, error) {
|
func (web *Web) Discord(message string, ping bool) (*internal.Status, error) {
|
||||||
|
|
|
@ -3,8 +3,7 @@ package web
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
|
|
|
@ -3,8 +3,7 @@ package web
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"git.jojodev.com/Minecraft/go-mcm/internal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Online struct {
|
type Online struct {
|
||||||
|
|
Loading…
Reference in New Issue