3
0

add basic change indicator

This commit is contained in:
Tit Petric 2018-07-05 11:46:39 +02:00
parent 2608f1940e
commit 1696e06d28
7 changed files with 110 additions and 24 deletions

View File

@ -5,6 +5,8 @@ type Channel struct {
ID uint64
Name string
Topic string
changed []string
}
func (Channel) new() *Channel {
@ -16,7 +18,10 @@ func (c *Channel) GetID() uint64 {
}
func (c *Channel) SetID(value uint64) *Channel {
c.ID = value
if c.ID != value {
c.changed = append(c.changed, "id")
c.ID = value
}
return c
}
func (c *Channel) GetName() string {
@ -24,7 +29,10 @@ func (c *Channel) GetName() string {
}
func (c *Channel) SetName(value string) *Channel {
c.Name = value
if c.Name != value {
c.changed = append(c.changed, "name")
c.Name = value
}
return c
}
func (c *Channel) GetTopic() string {
@ -32,6 +40,9 @@ func (c *Channel) GetTopic() string {
}
func (c *Channel) SetTopic(value string) *Channel {
c.Topic = value
if c.Topic != value {
c.changed = append(c.changed, "topic")
c.Topic = value
}
return c
}

View File

@ -11,6 +11,8 @@ type Message struct {
Message string
MessageID string
Type MessageType
changed []string
}
func (Message) new() *Message {
@ -22,7 +24,10 @@ func (m *Message) GetService() string {
}
func (m *Message) SetService(value string) *Message {
m.Service = value
if m.Service != value {
m.changed = append(m.changed, "service")
m.Service = value
}
return m
}
func (m *Message) GetChannel() string {
@ -30,7 +35,10 @@ func (m *Message) GetChannel() string {
}
func (m *Message) SetChannel(value string) *Message {
m.Channel = value
if m.Channel != value {
m.changed = append(m.changed, "channel")
m.Channel = value
}
return m
}
func (m *Message) GetUserName() string {
@ -38,7 +46,10 @@ func (m *Message) GetUserName() string {
}
func (m *Message) SetUserName(value string) *Message {
m.UserName = value
if m.UserName != value {
m.changed = append(m.changed, "username")
m.UserName = value
}
return m
}
func (m *Message) GetUserID() uint64 {
@ -46,7 +57,10 @@ func (m *Message) GetUserID() uint64 {
}
func (m *Message) SetUserID(value uint64) *Message {
m.UserID = value
if m.UserID != value {
m.changed = append(m.changed, "userid")
m.UserID = value
}
return m
}
func (m *Message) GetUser() *User {
@ -54,7 +68,10 @@ func (m *Message) GetUser() *User {
}
func (m *Message) SetUser(value *User) *Message {
m.User = value
if m.User != value {
m.changed = append(m.changed, "user")
m.User = value
}
return m
}
func (m *Message) GetUserAvatar() string {
@ -62,7 +79,10 @@ func (m *Message) GetUserAvatar() string {
}
func (m *Message) SetUserAvatar(value string) *Message {
m.UserAvatar = value
if m.UserAvatar != value {
m.changed = append(m.changed, "useravatar")
m.UserAvatar = value
}
return m
}
func (m *Message) GetMessage() string {
@ -70,7 +90,10 @@ func (m *Message) GetMessage() string {
}
func (m *Message) SetMessage(value string) *Message {
m.Message = value
if m.Message != value {
m.changed = append(m.changed, "message")
m.Message = value
}
return m
}
func (m *Message) GetMessageID() string {
@ -78,7 +101,10 @@ func (m *Message) GetMessageID() string {
}
func (m *Message) SetMessageID(value string) *Message {
m.MessageID = value
if m.MessageID != value {
m.changed = append(m.changed, "messageid")
m.MessageID = value
}
return m
}
func (m *Message) GetType() MessageType {
@ -86,6 +112,9 @@ func (m *Message) GetType() MessageType {
}
func (m *Message) SetType(value MessageType) *Message {
m.Type = value
if m.Type != value {
m.changed = append(m.changed, "type")
m.Type = value
}
return m
}

View File

@ -4,6 +4,8 @@ package sam
type Organisation struct {
ID uint64
Name string
changed []string
}
func (Organisation) new() *Organisation {
@ -15,7 +17,10 @@ func (o *Organisation) GetID() uint64 {
}
func (o *Organisation) SetID(value uint64) *Organisation {
o.ID = value
if o.ID != value {
o.changed = append(o.changed, "id")
o.ID = value
}
return o
}
func (o *Organisation) GetName() string {
@ -23,6 +28,9 @@ func (o *Organisation) GetName() string {
}
func (o *Organisation) SetName(value string) *Organisation {
o.Name = value
if o.Name != value {
o.changed = append(o.changed, "name")
o.Name = value
}
return o
}

View File

@ -6,6 +6,8 @@ type Team struct {
Name string
MemberIDs []uint64 `json:"-"`
Members []User `json:",omitempty"`
changed []string
}
func (Team) new() *Team {
@ -17,7 +19,10 @@ func (t *Team) GetID() uint64 {
}
func (t *Team) SetID(value uint64) *Team {
t.ID = value
if t.ID != value {
t.changed = append(t.changed, "id")
t.ID = value
}
return t
}
func (t *Team) GetName() string {
@ -25,7 +30,10 @@ func (t *Team) GetName() string {
}
func (t *Team) SetName(value string) *Team {
t.Name = value
if t.Name != value {
t.changed = append(t.changed, "name")
t.Name = value
}
return t
}
func (t *Team) GetMemberIDs() []uint64 {
@ -33,7 +41,10 @@ func (t *Team) GetMemberIDs() []uint64 {
}
func (t *Team) SetMemberIDs(value []uint64) *Team {
t.MemberIDs = value
if t.MemberIDs != value {
t.changed = append(t.changed, "memberids")
t.MemberIDs = value
}
return t
}
func (t *Team) GetMembers() []User {
@ -41,6 +52,9 @@ func (t *Team) GetMembers() []User {
}
func (t *Team) SetMembers(value []User) *Team {
t.Members = value
if t.Members != value {
t.changed = append(t.changed, "members")
t.Members = value
}
return t
}

View File

@ -10,6 +10,8 @@ package {package}
{foreach $fields as $field}
{field.name} {field.type}{if $field.tag} `{$field.tag}`{/if}{newline}
{/foreach}
changed []string
}
func ({name}) new() *{name} {
@ -24,7 +26,10 @@ func ({self} *{name}) Get{field.name}() {field.type} {
}
func ({self} *{name}) Set{field.name}(value {field.type}) *{name} {
{self}.{field.name} = value
if {self}.{field.name} != value {
{self}.changed = append({self}.changed, "{field.name|strtolower}")
{self}.{field.name} = value
}
return {self}
}
{/foreach}

View File

@ -5,6 +5,8 @@ type User struct {
ID uint64
Username string
Password string `json:"-"`
changed []string
}
func (User) new() *User {
@ -16,7 +18,10 @@ func (u *User) GetID() uint64 {
}
func (u *User) SetID(value uint64) *User {
u.ID = value
if u.ID != value {
u.changed = append(u.changed, "id")
u.ID = value
}
return u
}
func (u *User) GetUsername() string {
@ -24,7 +29,10 @@ func (u *User) GetUsername() string {
}
func (u *User) SetUsername(value string) *User {
u.Username = value
if u.Username != value {
u.changed = append(u.changed, "username")
u.Username = value
}
return u
}
func (u *User) GetPassword() string {
@ -32,6 +40,9 @@ func (u *User) GetPassword() string {
}
func (u *User) SetPassword(value string) *User {
u.Password = value
if u.Password != value {
u.changed = append(u.changed, "password")
u.Password = value
}
return u
}

View File

@ -4,6 +4,8 @@ package sam
type Websocket struct {
UserID uint64
User User
changed []string
}
func (Websocket) new() *Websocket {
@ -15,7 +17,10 @@ func (w *Websocket) GetUserID() uint64 {
}
func (w *Websocket) SetUserID(value uint64) *Websocket {
w.UserID = value
if w.UserID != value {
w.changed = append(w.changed, "userid")
w.UserID = value
}
return w
}
func (w *Websocket) GetUser() User {
@ -23,6 +28,9 @@ func (w *Websocket) GetUser() User {
}
func (w *Websocket) SetUser(value User) *Websocket {
w.User = value
if w.User != value {
w.changed = append(w.changed, "user")
w.User = value
}
return w
}