Fixed returning of user infos when updating a todo item
This commit is contained in:
@ -8,7 +8,7 @@ type ListItem struct {
|
||||
Done bool `json:"done"`
|
||||
DueDateUnix int64 `xorm:"int(11)" json:"dueDate"`
|
||||
ReminderUnix int64 `xorm:"int(11)" json:"reminderDate"`
|
||||
CreatedByID int64 `xorm:"int(11)" json:"createdByID"` // ID of the user who put that item on the list
|
||||
CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that item on the list
|
||||
ListID int64 `xorm:"int(11)" json:"listID"`
|
||||
Created int64 `xorm:"created" json:"created"`
|
||||
Updated int64 `xorm:"updated" json:"updated"`
|
||||
|
@ -1,7 +1,7 @@
|
||||
package models
|
||||
|
||||
// CreateOrUpdateListItem adds or updates a todo item to a list
|
||||
func CreateOrUpdateListItem(item *ListItem) (err error) {
|
||||
func CreateOrUpdateListItem(item *ListItem) (newItem *ListItem, err error) {
|
||||
|
||||
// Check if the list exists
|
||||
_, err = GetListByID(item.ListID)
|
||||
@ -30,9 +30,12 @@ func CreateOrUpdateListItem(item *ListItem) (err error) {
|
||||
|
||||
// Check if we have at least a text
|
||||
if item.Text == "" {
|
||||
return ErrListItemCannotBeEmpty{}
|
||||
return newItem, ErrListItemCannotBeEmpty{}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
// Get the new/updated item
|
||||
finalItem, err := GetListItemByID(item.ID)
|
||||
|
||||
return &finalItem, err
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ type List struct {
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
|
||||
Title string `xorm:"varchar(250)" json:"title"`
|
||||
Description string `xorm:"varchar(1000)" json:"description"`
|
||||
OwnerID int64 `xorm:"int(11)" json:"ownerID"`
|
||||
OwnerID int64 `xorm:"int(11)" json:"-"`
|
||||
Owner User `xorm:"-" json:"owner"`
|
||||
Created int64 `xorm:"created" json:"created"`
|
||||
Updated int64 `xorm:"updated" json:"updated"`
|
||||
|
@ -16,10 +16,10 @@ type UserLogin struct {
|
||||
type User struct {
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
|
||||
Username string `xorm:"varchar(250) not null unique" json:"username"`
|
||||
Password string `xorm:"varchar(250) not null" json:"password"`
|
||||
Password string `xorm:"varchar(250) not null" json:"-"`
|
||||
Email string `xorm:"varchar(250)" json:"email"`
|
||||
Created int64 `xorm:"created" json:"created"`
|
||||
Updated int64 `xorm:"updated" json:"updated"`
|
||||
Created int64 `xorm:"created" json:"-"`
|
||||
Updated int64 `xorm:"updated" json:"-"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for users
|
||||
|
Reference in New Issue
Block a user