Added Channel model and API for it
This commit is contained in:
+9
-3
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user