55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
|
package model
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"go.etztech.xyz/go-mcm/model/django"
|
||
|
)
|
||
|
|
||
|
type Priority string
|
||
|
|
||
|
const (
|
||
|
PriorityLow Priority = "L"
|
||
|
PriorityMedium Priority = "M"
|
||
|
PriorityHigh Priority = "H"
|
||
|
)
|
||
|
|
||
|
type World string
|
||
|
|
||
|
const (
|
||
|
WorldOverworld World = "O"
|
||
|
WorldNether World = "N"
|
||
|
WorldTheEnd World = "E"
|
||
|
)
|
||
|
|
||
|
type Ticket struct {
|
||
|
ID int64 `json:"id"`
|
||
|
PlayerID int64 `json:"player_id"`
|
||
|
Message string `json:"message"`
|
||
|
Priority Priority `json:"priority"`
|
||
|
StaffID int64 `json:"staff_id"`
|
||
|
Resolved bool `json:"resolved"`
|
||
|
World World `json:"world"`
|
||
|
X string `json:"x"`
|
||
|
Y string `json:"Y"`
|
||
|
Z string `json:"Z"`
|
||
|
Date string `json:"date"`
|
||
|
Link string `json:"link"`
|
||
|
}
|
||
|
|
||
|
func (q *Query) Ticket(builder *django.Builder) ([]*Ticket, error) {
|
||
|
endpoint := q.endpoint("ticket", builder.QueryString())
|
||
|
tickets := make([]*Ticket, 0)
|
||
|
|
||
|
resp, err := response(endpoint)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
err = json.Unmarshal(resp, &tickets)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return tickets, nil
|
||
|
}
|