Add ID to model.Client & model.Application

This commit is contained in:
Jannis Mattheis 2018-03-10 21:18:12 +01:00 committed by Jannis Mattheis
parent a26e2cf216
commit 6aa10ad917
3 changed files with 26 additions and 14 deletions

View File

@ -6,18 +6,24 @@ package model
// //
// swagger:model Application // swagger:model Application
type Application struct { type Application struct {
// The application id. Can be used as `appToken`. See Authentication. // The application id.
//
// read only: true
// required: true
// example: 5
ID uint `gorm:"primary_key;unique_index;AUTO_INCREMENT" json:"id"`
// The application token. Can be used as `appToken`. See Authentication.
// //
// read only: true // read only: true
// required: true // required: true
// example: AWH0wZ5r0Mbac.r // example: AWH0wZ5r0Mbac.r
ID string `gorm:"primary_key;unique_index" json:"id"` Token string `gorm:"unique_index" json:"token"`
UserID uint `gorm:"index" json:"-"` UserID uint `gorm:"index" json:"-"`
// The application name. This is how the application should be displayed to the user. // The application name. This is how the application should be displayed to the user.
// //
// required: true // required: true
// example: Backup Server // example: Backup Server
Name string `form:"name" query:"name" json:"name" binding:"required"` Name string `form:"name" query:"name" json:"name" binding:"required"`
// The description of the application. // The description of the application.
// //
// required: true // required: true

View File

@ -6,16 +6,22 @@ package model
// //
// swagger:model Client // swagger:model Client
type Client struct { type Client struct {
// The client id. Can be used as `clientToken`. See Authentication. // The client id.
//
// read only: true
// required: true
// example: 5
ID uint `gorm:"primary_key;unique_index;AUTO_INCREMENT" json:"id"`
// The client token. Can be used as `clientToken`. See Authentication.
// //
// read only: true // read only: true
// required: true // required: true
// example: CWH0wZ5r0Mbac.r // example: CWH0wZ5r0Mbac.r
ID string `gorm:"primary_key;unique_index" json:"id"` Token string `gorm:"unique_index" json:"token"`
UserID uint `gorm:"index" json:"-"` UserID uint `gorm:"index" json:"-"`
// The client name. This is how the client should be displayed to the user. // The client name. This is how the client should be displayed to the user.
// //
// required: true // required: true
// example: Android Phone // example: Android Phone
Name string `form:"name" query:"name" json:"name" binding:"required"` Name string `form:"name" query:"name" json:"name" binding:"required"`
} }

View File

@ -13,31 +13,31 @@ type Message struct {
// read only: true // read only: true
// required: true // required: true
// example: 25 // example: 25
ID uint `gorm:"AUTO_INCREMENT;primary_key;index" json:"id"` ID uint `gorm:"AUTO_INCREMENT;primary_key;index" json:"id"`
// The application id that send this message. // The application id that send this message.
// //
// read only: true // read only: true
// required: true // required: true
// example: AWH0wZ5r0Mbac.r // example: 5
ApplicationID string `json:"appid"` ApplicationID uint `json:"appid"`
// The actual message. // The actual message.
// //
// required: true // required: true
// example: Backup was successfully finished. // example: Backup was successfully finished.
Message string `form:"message" query:"message" json:"message" binding:"required"` Message string `form:"message" query:"message" json:"message" binding:"required"`
// The title of the message. // The title of the message.
// //
// required: true // required: true
// example: Backup // example: Backup
Title string `form:"title" query:"title" json:"title" binding:"required"` Title string `form:"title" query:"title" json:"title" binding:"required"`
// The priority of the message. // The priority of the message.
// //
// example: 2 // example: 2
Priority int `form:"priority" query:"priority" json:"priority"` Priority int `form:"priority" query:"priority" json:"priority"`
// The date the message was created. // The date the message was created.
// //
// read only: true // read only: true
// required: true // required: true
// example: 2018-02-27T19:36:10.5045044+01:00 // example: 2018-02-27T19:36:10.5045044+01:00
Date time.Time `json:"date"` Date time.Time `json:"date"`
} }