Added Channel model and API for it

This commit is contained in:
2018-06-16 20:52:35 +02:00
parent 1156375b11
commit fcce379dea
7 changed files with 407 additions and 3 deletions
+9 -3
View File
@@ -11,6 +11,7 @@ import (
"time"
"git.aiterp.net/rpdata/api/internal/store"
"git.aiterp.net/rpdata/api/model/channel"
"git.aiterp.net/rpdata/api/model/character"
"git.aiterp.net/rpdata/api/model/counter"
@@ -39,17 +40,22 @@ type Log struct {
}
// New creates a new Log
func New(date time.Time, channel, title, event, description string, open bool) (Log, error) {
func New(date time.Time, channelName, title, event, description string, open bool) (Log, error) {
nextID, err := counter.Next("auto_increment", "Log")
if err != nil {
return Log{}, err
}
_, err = channel.Ensure(channelName, open)
if err != nil {
return Log{}, err
}
log := Log{
ID: MakeLogID(date, channel),
ID: MakeLogID(date, channelName),
ShortID: "L" + strconv.Itoa(nextID),
Date: date,
Channel: channel,
Channel: channelName,
Title: title,
Event: event,
Description: description,