a7fec11170
Added the subscription and attachment stores. Refactored the routes to use the new subscription and attachment stores. Fixed up the buttons on the profile comments for Cosora. Made various enhancements to Cosora. Renamed routePanel to routePanelDashboard. Changed routeCreateTopicSubmit into an upload action and moved it into /routes/topic.go and refactored some of the redundant bits away.
30 lines
855 B
Go
30 lines
855 B
Go
package common
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"../query_gen/lib"
|
|
)
|
|
|
|
var Attachments AttachmentStore
|
|
|
|
type AttachmentStore interface {
|
|
Add(sectionID int, sectionTable string, originID int, originTable string, uploadedBy int, path string) error
|
|
}
|
|
|
|
type DefaultAttachmentStore struct {
|
|
add *sql.Stmt
|
|
}
|
|
|
|
func NewDefaultAttachmentStore() (*DefaultAttachmentStore, error) {
|
|
acc := qgen.Builder.Accumulator()
|
|
return &DefaultAttachmentStore{
|
|
add: acc.Insert("attachments").Columns("sectionID, sectionTable, originID, originTable, uploadedBy, path").Fields("?,?,?,?,?,?").Prepare(),
|
|
}, acc.FirstError()
|
|
}
|
|
|
|
func (store *DefaultAttachmentStore) Add(sectionID int, sectionTable string, originID int, originTable string, uploadedBy int, path string) error {
|
|
_, err := store.add.Exec(sectionID, sectionTable, originID, originTable, uploadedBy, path)
|
|
return err
|
|
}
|