import sources from develop/0.1.0

This commit is contained in:
Thomas Peetz
2025-04-29 12:52:55 +02:00
parent 304005822c
commit 4c96de27db
976 changed files with 58265 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package main
import (
"database/sql"
"log"
"time"
_ "github.com/go-sql-driver/mysql"
)
func main() {
connectionString := "kontor:kontor@tcp(127.0.0.1:3306)/kontor?parseTime=true"
db, err := sql.Open("mysql", connectionString)
if err != nil {
log.Printf("setup database error: %v", err)
return
}
db.SetConnMaxLifetime(time.Minute * 3)
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
log.Println("Database connected")
rows, err := db.Query("SELECT id, created_date, last_modified_date, version, url, title, review FROM media_file")
if err != nil {
log.Fatal((err.Error()))
}
defer rows.Close()
var rec MediaFile
for rows.Next() {
err = rows.Scan(&rec.ID, &rec.CreatedDate, &rec.LastModifiedDate, &rec.Version, &rec.Url, &rec.Title, &rec.Review)
if err != nil {
log.Fatal(err.Error())
}
log.Println(rec, string(rec.Url), string(rec.Title))
}
}
+25
View File
@@ -0,0 +1,25 @@
package main
import (
"time"
"github.com/google/uuid"
)
type AbstractEntity struct {
ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
Version uint `json:"version"`
CreatedDate time.Time `json:"createdDate"`
LastModifiedDate time.Time `json:"lastModifiedDate"`
}
type MediaFile struct {
AbstractEntity
Url []byte `json:"url"`
Review []uint8 `json:"review"`
ShouldDownload []uint8 `json:"shouldDownload"`
Title []byte `json:"title"`
CloudLink string `json:"cloudLink"`
FileName string `json:"fileName"`
Path string `json:"path"`
}