feat: publish complete
This commit is contained in:
@@ -207,7 +207,7 @@ func (svc *Service) GetTenantUUIDs(ctx context.Context, tenantId int64) ([]strin
|
||||
}
|
||||
|
||||
// PublishTenant
|
||||
func (svc *Service) PublishTenantMedia(ctx context.Context, tenantId int64, uuid uuid.UUID, name string) error {
|
||||
func (svc *Service) PublishTenantMedia(ctx context.Context, tenantId int64, uuid uuid.UUID, name string, price uint) error {
|
||||
log := svc.log.WithField("method", "PublishTenant")
|
||||
|
||||
resources := pg.MediaResources{}
|
||||
@@ -225,8 +225,8 @@ func (svc *Service) PublishTenantMedia(ctx context.Context, tenantId int64, uuid
|
||||
|
||||
tbl := table.Medias
|
||||
stmt := tbl.
|
||||
INSERT(tbl.TenantID, tbl.UUID, tbl.Title, tbl.Resources).
|
||||
VALUES(Int(tenantId), UUID(uuid), String(name), Json(resources.MustValue()))
|
||||
INSERT(tbl.TenantID, tbl.UUID, tbl.Title, tbl.Price, tbl.Resources, tbl.Publish).
|
||||
VALUES(Int(tenantId), UUID(uuid), String(name), Int(int64(price)), Json(resources.MustValue()), Bool(true))
|
||||
log.Debug(stmt.DebugSql())
|
||||
|
||||
if _, err := stmt.ExecContext(ctx, svc.db); err != nil {
|
||||
|
||||
@@ -195,13 +195,13 @@ func TestService_PublishTenant(t *testing.T) {
|
||||
}
|
||||
So(svc.Prepare(), ShouldBeNil)
|
||||
|
||||
err := svc.PublishTenantMedia(context.TODO(), 1, items[0].UUID, items[0].Title)
|
||||
err := svc.PublishTenantMedia(context.TODO(), 1, items[0].UUID, items[0].Title, 100)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
err = svc.PublishTenantMedia(context.TODO(), 1, items[1].UUID, items[1].Title)
|
||||
err = svc.PublishTenantMedia(context.TODO(), 1, items[1].UUID, items[1].Title, 200)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
err = svc.PublishTenantMedia(context.TODO(), 1, items[2].UUID, items[2].Title)
|
||||
err = svc.PublishTenantMedia(context.TODO(), 1, items[2].UUID, items[2].Title, 300)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user