use gorm model
This commit is contained in:
@@ -1166,8 +1166,12 @@ func (s *Submission) encodeFields(e *jx.Encoder) {
|
||||
e.Int32(s.GameID)
|
||||
}
|
||||
{
|
||||
e.FieldStart("Date")
|
||||
e.Int64(s.Date)
|
||||
e.FieldStart("CreatedAt")
|
||||
e.Int64(s.CreatedAt)
|
||||
}
|
||||
{
|
||||
e.FieldStart("UpdatedAt")
|
||||
e.Int64(s.UpdatedAt)
|
||||
}
|
||||
{
|
||||
e.FieldStart("Submitter")
|
||||
@@ -1201,19 +1205,20 @@ func (s *Submission) encodeFields(e *jx.Encoder) {
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfSubmission = [12]string{
|
||||
var jsonFieldsNameOfSubmission = [13]string{
|
||||
0: "ID",
|
||||
1: "DisplayName",
|
||||
2: "Creator",
|
||||
3: "GameID",
|
||||
4: "Date",
|
||||
5: "Submitter",
|
||||
6: "AssetID",
|
||||
7: "AssetVersion",
|
||||
8: "Completed",
|
||||
9: "SubmissionType",
|
||||
10: "TargetAssetID",
|
||||
11: "StatusID",
|
||||
4: "CreatedAt",
|
||||
5: "UpdatedAt",
|
||||
6: "Submitter",
|
||||
7: "AssetID",
|
||||
8: "AssetVersion",
|
||||
9: "Completed",
|
||||
10: "SubmissionType",
|
||||
11: "TargetAssetID",
|
||||
12: "StatusID",
|
||||
}
|
||||
|
||||
// Decode decodes Submission from json.
|
||||
@@ -1273,20 +1278,32 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"GameID\"")
|
||||
}
|
||||
case "Date":
|
||||
case "CreatedAt":
|
||||
requiredBitSet[0] |= 1 << 4
|
||||
if err := func() error {
|
||||
v, err := d.Int64()
|
||||
s.Date = int64(v)
|
||||
s.CreatedAt = int64(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"Date\"")
|
||||
return errors.Wrap(err, "decode field \"CreatedAt\"")
|
||||
}
|
||||
case "UpdatedAt":
|
||||
requiredBitSet[0] |= 1 << 5
|
||||
if err := func() error {
|
||||
v, err := d.Int64()
|
||||
s.UpdatedAt = int64(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"UpdatedAt\"")
|
||||
}
|
||||
case "Submitter":
|
||||
requiredBitSet[0] |= 1 << 5
|
||||
requiredBitSet[0] |= 1 << 6
|
||||
if err := func() error {
|
||||
v, err := d.Int64()
|
||||
s.Submitter = int64(v)
|
||||
@@ -1298,7 +1315,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"Submitter\"")
|
||||
}
|
||||
case "AssetID":
|
||||
requiredBitSet[0] |= 1 << 6
|
||||
requiredBitSet[0] |= 1 << 7
|
||||
if err := func() error {
|
||||
v, err := d.Int64()
|
||||
s.AssetID = int64(v)
|
||||
@@ -1310,7 +1327,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"AssetID\"")
|
||||
}
|
||||
case "AssetVersion":
|
||||
requiredBitSet[0] |= 1 << 7
|
||||
requiredBitSet[1] |= 1 << 0
|
||||
if err := func() error {
|
||||
v, err := d.Int64()
|
||||
s.AssetVersion = int64(v)
|
||||
@@ -1322,7 +1339,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"AssetVersion\"")
|
||||
}
|
||||
case "Completed":
|
||||
requiredBitSet[1] |= 1 << 0
|
||||
requiredBitSet[1] |= 1 << 1
|
||||
if err := func() error {
|
||||
v, err := d.Bool()
|
||||
s.Completed = bool(v)
|
||||
@@ -1334,7 +1351,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"Completed\"")
|
||||
}
|
||||
case "SubmissionType":
|
||||
requiredBitSet[1] |= 1 << 1
|
||||
requiredBitSet[1] |= 1 << 2
|
||||
if err := func() error {
|
||||
v, err := d.Int32()
|
||||
s.SubmissionType = int32(v)
|
||||
@@ -1356,7 +1373,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
return errors.Wrap(err, "decode field \"TargetAssetID\"")
|
||||
}
|
||||
case "StatusID":
|
||||
requiredBitSet[1] |= 1 << 3
|
||||
requiredBitSet[1] |= 1 << 4
|
||||
if err := func() error {
|
||||
v, err := d.Int32()
|
||||
s.StatusID = int32(v)
|
||||
@@ -1378,7 +1395,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [2]uint8{
|
||||
0b11111111,
|
||||
0b00001011,
|
||||
0b00010111,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
|
||||
@@ -1022,7 +1022,7 @@ func decodeListSubmissionsParams(args [0]string, argsEscaped bool, r *http.Reque
|
||||
Name: "filter",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
Fields: []uri.QueryParameterObjectField{{Name: "ID", Required: true}, {Name: "DisplayName", Required: false}, {Name: "Creator", Required: false}, {Name: "GameID", Required: false}, {Name: "Date", Required: false}},
|
||||
Fields: []uri.QueryParameterObjectField{{Name: "ID", Required: true}, {Name: "DisplayName", Required: false}, {Name: "Creator", Required: false}, {Name: "GameID", Required: false}},
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
|
||||
@@ -585,7 +585,8 @@ type Submission struct {
|
||||
DisplayName string `json:"DisplayName"`
|
||||
Creator string `json:"Creator"`
|
||||
GameID int32 `json:"GameID"`
|
||||
Date int64 `json:"Date"`
|
||||
CreatedAt int64 `json:"CreatedAt"`
|
||||
UpdatedAt int64 `json:"UpdatedAt"`
|
||||
Submitter int64 `json:"Submitter"`
|
||||
AssetID int64 `json:"AssetID"`
|
||||
AssetVersion int64 `json:"AssetVersion"`
|
||||
@@ -615,9 +616,14 @@ func (s *Submission) GetGameID() int32 {
|
||||
return s.GameID
|
||||
}
|
||||
|
||||
// GetDate returns the value of Date.
|
||||
func (s *Submission) GetDate() int64 {
|
||||
return s.Date
|
||||
// GetCreatedAt returns the value of CreatedAt.
|
||||
func (s *Submission) GetCreatedAt() int64 {
|
||||
return s.CreatedAt
|
||||
}
|
||||
|
||||
// GetUpdatedAt returns the value of UpdatedAt.
|
||||
func (s *Submission) GetUpdatedAt() int64 {
|
||||
return s.UpdatedAt
|
||||
}
|
||||
|
||||
// GetSubmitter returns the value of Submitter.
|
||||
@@ -675,9 +681,14 @@ func (s *Submission) SetGameID(val int32) {
|
||||
s.GameID = val
|
||||
}
|
||||
|
||||
// SetDate sets the value of Date.
|
||||
func (s *Submission) SetDate(val int64) {
|
||||
s.Date = val
|
||||
// SetCreatedAt sets the value of CreatedAt.
|
||||
func (s *Submission) SetCreatedAt(val int64) {
|
||||
s.CreatedAt = val
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the value of UpdatedAt.
|
||||
func (s *Submission) SetUpdatedAt(val int64) {
|
||||
s.UpdatedAt = val
|
||||
}
|
||||
|
||||
// SetSubmitter sets the value of Submitter.
|
||||
@@ -791,7 +802,6 @@ type SubmissionFilter struct {
|
||||
DisplayName OptString `json:"DisplayName"`
|
||||
Creator OptString `json:"Creator"`
|
||||
GameID OptInt32 `json:"GameID"`
|
||||
Date OptInt64 `json:"Date"`
|
||||
}
|
||||
|
||||
// GetID returns the value of ID.
|
||||
@@ -814,11 +824,6 @@ func (s *SubmissionFilter) GetGameID() OptInt32 {
|
||||
return s.GameID
|
||||
}
|
||||
|
||||
// GetDate returns the value of Date.
|
||||
func (s *SubmissionFilter) GetDate() OptInt64 {
|
||||
return s.Date
|
||||
}
|
||||
|
||||
// SetID sets the value of ID.
|
||||
func (s *SubmissionFilter) SetID(val int64) {
|
||||
s.ID = val
|
||||
@@ -839,11 +844,6 @@ func (s *SubmissionFilter) SetGameID(val OptInt32) {
|
||||
s.GameID = val
|
||||
}
|
||||
|
||||
// SetDate sets the value of Date.
|
||||
func (s *SubmissionFilter) SetDate(val OptInt64) {
|
||||
s.Date = val
|
||||
}
|
||||
|
||||
// UpdateScriptOK is response for UpdateScript operation.
|
||||
type UpdateScriptOK struct{}
|
||||
|
||||
|
||||
@@ -152,23 +152,14 @@ func (s *SubmissionFilter) EncodeURI(e uri.Encoder) error {
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode field \"GameID\"")
|
||||
}
|
||||
if err := e.EncodeField("Date", func(e uri.Encoder) error {
|
||||
if val, ok := s.Date.Get(); ok {
|
||||
return e.EncodeValue(conv.Int64ToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode field \"Date\"")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var uriFieldsNameOfSubmissionFilter = [5]string{
|
||||
var uriFieldsNameOfSubmissionFilter = [4]string{
|
||||
0: "ID",
|
||||
1: "DisplayName",
|
||||
2: "Creator",
|
||||
3: "GameID",
|
||||
4: "Date",
|
||||
}
|
||||
|
||||
// DecodeURI decodes SubmissionFilter from URI form.
|
||||
@@ -270,30 +261,6 @@ func (s *SubmissionFilter) DecodeURI(d uri.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"GameID\"")
|
||||
}
|
||||
case "Date":
|
||||
if err := func() error {
|
||||
var sDotDateVal int64
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt64(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sDotDateVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
s.Date.SetTo(sDotDateVal)
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"Date\"")
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user