parent
0ae5f0c704
commit
f652bbd2bd
3
mcm.go
3
mcm.go
|
@ -2,9 +2,10 @@ package mcm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/model"
|
"go.etztech.xyz/go-mcm/model"
|
||||||
"go.etztech.xyz/go-mcm/web"
|
"go.etztech.xyz/go-mcm/web"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MCM struct {
|
type MCM struct {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
@ -15,7 +16,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,30 +17,40 @@ type Builder struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBuilder(token string) *Builder {
|
func NewBuilder(token string) *Builder {
|
||||||
return &Builder{[]string{fmt.Sprintf("api=%s", token)}}
|
return &Builder{[]string{fmt.Sprintf("api=%v", token)}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) QueryString() string {
|
func (db *Builder) QueryString() string {
|
||||||
return "?" + strings.Join(db.Params, "&")
|
return "?" + strings.Join(db.Params, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Exact(field Field, value string) *Builder {
|
func (db *Builder) Eq(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%__eq=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IExact(field Field, value string) *Builder {
|
func (db *Builder) Ne(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__ne=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Contains(field Field, value string) *Builder {
|
func (db *Builder) Exact(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__contains=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IContains(field Field, value string) *Builder {
|
func (db *Builder) IExact(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__icontains=%s", field, value))
|
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))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,43 +59,43 @@ func (db *Builder) In(field string, values ...string) *Builder {
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Gt(field Field, value string) *Builder {
|
func (db *Builder) Gt(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Gte(field Field, value string) *Builder {
|
func (db *Builder) Gte(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Lt(field Field, value string) *Builder {
|
func (db *Builder) Lt(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Lte(field Field, value string) *Builder {
|
func (db *Builder) Lte(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Startswith(field Field, value string) *Builder {
|
func (db *Builder) Startswith(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IStartswith(field Field, value string) *Builder {
|
func (db *Builder) IStartswith(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Endswith(field Field, value string) *Builder {
|
func (db *Builder) Endswith(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IEndswith(field Field, value string) *Builder {
|
func (db *Builder) IEndswith(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,72 +104,72 @@ func (db *Builder) Range(field Field, from, to string) *Builder {
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Date(field Field, value string) *Builder {
|
func (db *Builder) Date(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__date=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__date=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Year(field Field, value string) *Builder {
|
func (db *Builder) Year(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__year=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__year=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Month(field Field, value string) *Builder {
|
func (db *Builder) Month(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__month=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__month=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Day(field Field, value string) *Builder {
|
func (db *Builder) Day(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__day=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__day=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Week(field Field, value string) *Builder {
|
func (db *Builder) Week(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__week=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__week=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) WeekDay(field Field, value string) *Builder {
|
func (db *Builder) WeekDay(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Quarter(field Field, value string) *Builder {
|
func (db *Builder) Quarter(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Time(field Field, value string) *Builder {
|
func (db *Builder) Time(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__time=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__time=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Hour(field Field, value string) *Builder {
|
func (db *Builder) Hour(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Minute(field Field, value string) *Builder {
|
func (db *Builder) Minute(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Second(field Field, value string) *Builder {
|
func (db *Builder) Second(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__second=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__second=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) IsNull(field Field, value string) *Builder {
|
func (db *Builder) IsNull(field Field, value interface{}) *Builder {
|
||||||
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%s", field, value))
|
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%v", field, value))
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Builder) Regex(field Field, value string) *Builder {
|
func (db *Builder) Regex(field Field, value interface{}) *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 string) *Builder {
|
func (db *Builder) IRegex(field Field, value interface{}) *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
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,10 +2,11 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Model struct {
|
type Model struct {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
"go.etztech.xyz/go-mcm/model/django"
|
"go.etztech.xyz/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.etztech.xyz/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,8 +1,9 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.etztech.xyz/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,6 +3,7 @@ package web
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package web
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"go.etztech.xyz/go-mcm/internal"
|
"go.etztech.xyz/go-mcm/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue