2016-03-06 05:15:49 +08:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2016-03-11 22:30:05 +08:00
|
|
|
"time"
|
2016-03-06 05:15:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
var (
|
2016-03-07 04:32:22 +08:00
|
|
|
ErrPreferencesNotFound = errors.New("Preferences not found")
|
2016-03-06 05:15:49 +08:00
|
|
|
)
|
|
|
|
|
2016-03-06 19:47:39 +08:00
|
|
|
type Preferences struct {
|
2016-03-11 22:30:05 +08:00
|
|
|
Id int64
|
|
|
|
OrgId int64
|
|
|
|
UserId int64
|
|
|
|
Version int
|
|
|
|
Preference map[string]interface{}
|
|
|
|
Created time.Time
|
|
|
|
Updated time.Time
|
2016-03-06 05:15:49 +08:00
|
|
|
}
|
|
|
|
|
2016-03-07 03:42:15 +08:00
|
|
|
// ---------------------
|
|
|
|
// QUERIES
|
|
|
|
|
|
|
|
type GetPreferencesQuery struct {
|
2016-03-11 22:30:05 +08:00
|
|
|
Id int64
|
|
|
|
OrgId int64
|
|
|
|
UserId int64
|
2016-03-07 03:42:15 +08:00
|
|
|
|
2016-03-07 04:32:22 +08:00
|
|
|
Result *Preferences
|
2016-03-07 03:42:15 +08:00
|
|
|
}
|
|
|
|
|
2016-03-06 05:15:49 +08:00
|
|
|
// ---------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
2016-03-06 19:47:39 +08:00
|
|
|
type SavePreferencesCommand struct {
|
2016-03-11 22:30:05 +08:00
|
|
|
Preference map[string]interface{} `json:"Preference" binding:"Required"`
|
|
|
|
UserId int64 `json:"-"`
|
|
|
|
OrgId int64 `json:"-"`
|
2016-03-06 05:15:49 +08:00
|
|
|
}
|
2016-03-07 03:42:15 +08:00
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// DTO & Projections
|
|
|
|
|
|
|
|
type PreferencesDTO struct {
|
2016-03-11 22:30:05 +08:00
|
|
|
Id int64 `json:"Id"`
|
|
|
|
UserId int64 `json:"UserId"`
|
|
|
|
OrgId int64 `json:"OrgId"`
|
|
|
|
Preference map[string]interface{} `json:"Preference"`
|
2016-03-07 03:42:15 +08:00
|
|
|
}
|