2018-03-06 11:36:49 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
// ActionType is the action type
|
|
|
|
type ActionType int
|
|
|
|
|
|
|
|
// Define action types
|
|
|
|
const (
|
2018-03-06 12:43:07 +00:00
|
|
|
ActionTypeUnknown ActionType = -1
|
2018-03-06 11:36:49 +00:00
|
|
|
ActionTypeBookAdded ActionType = iota
|
|
|
|
ActionTypeBookUpdated
|
|
|
|
ActionTypeBookDeleted
|
|
|
|
ActionTypeAuthorAdded
|
|
|
|
ActionTypeAuthorUpdated
|
|
|
|
ActionTypeAuthorDeleted
|
|
|
|
ActionTypePublisherAdded
|
|
|
|
ActionTypePublisherUpdated
|
|
|
|
ActionTypePublisherDeleted
|
|
|
|
ActionTypeItemAdded
|
|
|
|
ActionTypeItemUpdated
|
|
|
|
ActionTypeItemDeleted
|
|
|
|
ActionTypeUserAdded
|
|
|
|
ActionTypeUserUpdated
|
|
|
|
ActionTypeUserDeleted
|
|
|
|
ActionTypeChangedUserPassword
|
|
|
|
)
|
|
|
|
|
|
|
|
// LogAction logs a user action
|
|
|
|
func logAction(actionType ActionType, user *User, itemID int64) (err error) {
|
|
|
|
_, err = x.Insert(UserLog{Log: actionType, UserID: user.ID, ItemID: itemID})
|
|
|
|
return
|
2018-03-06 12:43:07 +00:00
|
|
|
}
|