feat: update

This commit is contained in:
Rogee
2025-05-23 21:43:49 +08:00
parent f13ef4388e
commit 409a2e8304
9 changed files with 21 additions and 126 deletions

View File

@@ -97,12 +97,12 @@ func (m *Medias) BatchCreate(ctx context.Context, models []*Medias) error {
return nil
}
func (m *Medias) Create(ctx context.Context, medias *Medias) error {
medias.CreatedAt = time.Now()
stmt := table.Medias.INSERT(table.Medias.MutableColumns).MODEL(medias).RETURNING(table.Medias.AllColumns)
func (m *Medias) Create(ctx context.Context) error {
m.CreatedAt = time.Now()
stmt := table.Medias.INSERT(table.Medias.MutableColumns).MODEL(m).RETURNING(table.Medias.AllColumns)
m.log().Infof("sql: %s", stmt.DebugSql())
if err := stmt.QueryContext(ctx, db, medias); err != nil {
if err := stmt.QueryContext(ctx, db, m); err != nil {
m.log().Errorf("error creating media item: %v", err)
return err
}

View File

@@ -132,7 +132,7 @@ func (s *MediasTestSuite) Test_Create() {
Path: "path/to/media.pdf",
}
err := MediasModel().Create(context.Background(), model)
err := model.Create(context.Background())
Convey("Create should not return an error", func() {
So(err, ShouldBeNil)
})
@@ -165,7 +165,7 @@ func (s *MediasTestSuite) Test_Page() {
Path: "path/to/media.pdf",
}
err := MediasModel().Create(context.Background(), model)
err := model.Create(context.Background())
So(err, ShouldBeNil)
}
@@ -208,7 +208,7 @@ func (s *MediasTestSuite) Test_CreateGetID() {
Path: "path/to/media.pdf",
}
err := MediasModel().Create(context.Background(), model)
err := model.Create(context.Background())
So(err, ShouldBeNil)
So(model.ID, ShouldNotBeEmpty)

View File

@@ -1,19 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Migrations struct {
ID int32 `sql:"primary_key" json:"id"`
VersionID int64 `json:"version_id"`
IsApplied bool `json:"is_applied"`
Tstamp time.Time `json:"tstamp"`
}