feat: update medias
This commit is contained in:
@@ -74,7 +74,7 @@ func (e *PostCreated) Handler(msg *message.Message) ([]*message.Message, error)
|
|||||||
// cut video
|
// cut video
|
||||||
_, err = job.Insert(context.Background(), jobs.PostVideoCutJob{
|
_, err = job.Insert(context.Background(), jobs.PostVideoCutJob{
|
||||||
PostID: post.ID,
|
PostID: post.ID,
|
||||||
Hash: video.Hash,
|
MediaID: video.Media,
|
||||||
TenantID: post.TenantID,
|
TenantID: post.TenantID,
|
||||||
UserID: post.UserID,
|
UserID: post.UserID,
|
||||||
}, nil)
|
}, nil)
|
||||||
@@ -85,7 +85,7 @@ func (e *PostCreated) Handler(msg *message.Message) ([]*message.Message, error)
|
|||||||
// extract audio
|
// extract audio
|
||||||
_, err = job.Insert(context.Background(), jobs.PostVideoExtractAudioJob{
|
_, err = job.Insert(context.Background(), jobs.PostVideoExtractAudioJob{
|
||||||
PostID: post.ID,
|
PostID: post.ID,
|
||||||
Hash: video.Hash,
|
MediaID: video.Media,
|
||||||
TenantID: post.TenantID,
|
TenantID: post.TenantID,
|
||||||
UserID: post.UserID,
|
UserID: post.UserID,
|
||||||
Mark: "audio-preview",
|
Mark: "audio-preview",
|
||||||
@@ -96,7 +96,7 @@ func (e *PostCreated) Handler(msg *message.Message) ([]*message.Message, error)
|
|||||||
|
|
||||||
_, err = job.Insert(context.Background(), jobs.PostVideoExtractAudioJob{
|
_, err = job.Insert(context.Background(), jobs.PostVideoExtractAudioJob{
|
||||||
PostID: post.ID,
|
PostID: post.ID,
|
||||||
Hash: video.Hash,
|
MediaID: video.Media,
|
||||||
TenantID: post.TenantID,
|
TenantID: post.TenantID,
|
||||||
UserID: post.UserID,
|
UserID: post.UserID,
|
||||||
Mark: "audio",
|
Mark: "audio",
|
||||||
|
|||||||
@@ -52,17 +52,9 @@ func (ctl *Controller) Upload(ctx fiber.Ctx, claim *jwt.Claims, file *multipart.
|
|||||||
return uploadedFile, nil
|
return uploadedFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadedFile, err = storage.Build(defaultStorage).Save(ctx.Context(), uploadedFile)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// save to db
|
// save to db
|
||||||
_, err = ctl.svc.Create(ctx.Context(), &model.Medias{
|
userMediaID, err := ctl.svc.Create(ctx.Context(), *claim.TenantID, claim.UserID, &model.Medias{
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
TenantID: *claim.TenantID,
|
|
||||||
UserID: claim.UserID,
|
|
||||||
StorageID: defaultStorage.ID,
|
StorageID: defaultStorage.ID,
|
||||||
Hash: uploadedFile.Hash,
|
Hash: uploadedFile.Hash,
|
||||||
Name: uploadedFile.Name,
|
Name: uploadedFile.Name,
|
||||||
@@ -70,6 +62,7 @@ func (ctl *Controller) Upload(ctx fiber.Ctx, claim *jwt.Claims, file *multipart.
|
|||||||
Size: uploadedFile.Size,
|
Size: uploadedFile.Size,
|
||||||
Path: uploadedFile.Path,
|
Path: uploadedFile.Path,
|
||||||
})
|
})
|
||||||
|
uploadedFile.ID = userMediaID
|
||||||
uploadedFile.Preview = ""
|
uploadedFile.Preview = ""
|
||||||
|
|
||||||
return uploadedFile, err
|
return uploadedFile, err
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"backend/providers/otel"
|
"backend/providers/otel"
|
||||||
|
|
||||||
. "github.com/go-jet/jet/v2/postgres"
|
. "github.com/go-jet/jet/v2/postgres"
|
||||||
|
"github.com/go-jet/jet/v2/qrm"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
|
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
|
||||||
@@ -28,7 +29,7 @@ func (svc *Service) Prepare() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create
|
// Create
|
||||||
func (svc *Service) Create(ctx context.Context, m *model.Medias) (*model.Medias, error) {
|
func (svc *Service) Create(ctx context.Context, tenantID, userID int64, m *model.Medias) (int64, error) {
|
||||||
_, span := otel.Start(ctx, "medias.service.Create")
|
_, span := otel.Start(ctx, "medias.service.Create")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@@ -36,40 +37,50 @@ func (svc *Service) Create(ctx context.Context, m *model.Medias) (*model.Medias,
|
|||||||
m.CreatedAt = time.Now()
|
m.CreatedAt = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.UpdatedAt.IsZero() {
|
|
||||||
m.UpdatedAt = time.Now()
|
|
||||||
}
|
|
||||||
|
|
||||||
tbl := table.Medias
|
tbl := table.Medias
|
||||||
stmt := tbl.INSERT(tbl.MutableColumns).MODEL(m).RETURNING(tbl.AllColumns)
|
stmt := tbl.INSERT(tbl.MutableColumns).MODEL(m).RETURNING(tbl.AllColumns)
|
||||||
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
||||||
|
|
||||||
var ret model.Medias
|
var media model.Medias
|
||||||
if err := stmt.QueryContext(ctx, svc.db, &ret); err != nil {
|
if err := stmt.QueryContext(ctx, svc.db, &media); err != nil {
|
||||||
return nil, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return &ret, nil
|
|
||||||
|
userMediaTbl := table.UserMedias
|
||||||
|
userMediaStmt := userMediaTbl.INSERT(userMediaTbl.TenantID, userMediaTbl.UserID, userMediaTbl.MediaID).VALUES(tenantID, userID, media.ID).RETURNING(tbl.AllColumns)
|
||||||
|
span.SetAttributes(semconv.DBStatementKey.String(userMediaStmt.DebugSql()))
|
||||||
|
|
||||||
|
var ret model.UserMedias
|
||||||
|
if err := userMediaStmt.QueryContext(ctx, svc.db, &ret); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMediasByHash
|
// GetMediasByHash
|
||||||
func (svc *Service) GetMediasByHash(ctx context.Context, tenantID, userID int64, hashes []string) ([]*model.Medias, error) {
|
func (svc *Service) GetMediasByIDs(ctx context.Context, tenantID, userID int64, ids []int64) ([]*model.Medias, error) {
|
||||||
_, span := otel.Start(ctx, "medias.service.GetMediasByHash")
|
_, span := otel.Start(ctx, "medias.service.GetMediasByIDs")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
hashExpr := lo.Map(hashes, func(item string, index int) Expression { return String(item) })
|
idExprs := lo.Map(ids, func(item int64, index int) Expression { return Int64(item) })
|
||||||
|
|
||||||
tbl := table.Medias
|
stmt := SELECT(table.Medias.AllColumns).
|
||||||
stmt := tbl.
|
FROM(
|
||||||
SELECT(tbl.AllColumns).
|
table.Medias.RIGHT_JOIN(
|
||||||
WHERE(
|
table.UserMedias,
|
||||||
tbl.TenantID.
|
table.UserMedias.TenantID.
|
||||||
EQ(Int64(tenantID)).
|
EQ(Int64(tenantID)).
|
||||||
AND(
|
AND(
|
||||||
tbl.UserID.EQ(Int64(userID)),
|
table.UserMedias.UserID.EQ(Int64(userID)),
|
||||||
).
|
).
|
||||||
AND(
|
AND(
|
||||||
tbl.Hash.IN(hashExpr...),
|
table.UserMedias.ID.IN(idExprs...),
|
||||||
),
|
).
|
||||||
|
AND(
|
||||||
|
table.Medias.ID.EQ(table.UserMedias.MediaID),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
||||||
|
|
||||||
@@ -82,31 +93,20 @@ func (svc *Service) GetMediasByHash(ctx context.Context, tenantID, userID int64,
|
|||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *Service) GetMediaByHash(ctx context.Context, tenantID, userID int64, hash string) (*model.Medias, error) {
|
func (svc *Service) GetMediaByID(ctx context.Context, tenantID, userID, userMediaID int64) (*model.Medias, error) {
|
||||||
_, span := otel.Start(ctx, "medias.service.GetMediasByHash")
|
_, span := otel.Start(ctx, "medias.service.GetMediasByHash")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
tbl := table.Medias
|
medias, err := svc.GetMediasByIDs(ctx, tenantID, userID, []int64{userMediaID})
|
||||||
stmt := tbl.
|
if err != nil {
|
||||||
SELECT(tbl.AllColumns).
|
|
||||||
LIMIT(1).
|
|
||||||
WHERE(
|
|
||||||
tbl.TenantID.
|
|
||||||
EQ(Int64(tenantID)).
|
|
||||||
AND(
|
|
||||||
tbl.UserID.EQ(Int64(userID)),
|
|
||||||
).
|
|
||||||
AND(
|
|
||||||
tbl.Hash.EQ(String(hash)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
|
||||||
|
|
||||||
var ret model.Medias
|
|
||||||
if err := stmt.QueryContext(ctx, svc.db, &ret); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ret, nil
|
|
||||||
|
if len(medias) == 0 {
|
||||||
|
return nil, qrm.ErrNoRows
|
||||||
|
}
|
||||||
|
|
||||||
|
return medias[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *Service) DeleteByID(ctx context.Context, id ...int64) error {
|
func (svc *Service) DeleteByID(ctx context.Context, id ...int64) error {
|
||||||
@@ -117,7 +117,7 @@ func (svc *Service) DeleteByID(ctx context.Context, id ...int64) error {
|
|||||||
_, span := otel.Start(ctx, "medias.service.DeleteByID")
|
_, span := otel.Start(ctx, "medias.service.DeleteByID")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
tbl := table.Medias
|
tbl := table.UserMedias
|
||||||
stmt := tbl.DELETE().WHERE(tbl.ID.IN(lo.Map(id, func(item int64, _ int) Expression { return Int64(item) })...))
|
stmt := tbl.DELETE().WHERE(tbl.ID.IN(lo.Map(id, func(item int64, _ int) Expression { return Int64(item) })...))
|
||||||
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
span.SetAttributes(semconv.DBStatementKey.String(stmt.DebugSql()))
|
||||||
|
|
||||||
|
|||||||
@@ -138,13 +138,13 @@ func (ctl *Controller) Create(ctx fiber.Ctx, claim *jwt.Claims, tenantSlug strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check media assets exists
|
// check media assets exists
|
||||||
hashes := lo.Map(body.Assets.Data, func(item fields.MediaAsset, _ int) string { return item.Hash })
|
ids := lo.Map(body.Assets.Data, func(item fields.MediaAsset, _ int) int64 { return item.Media })
|
||||||
medias, err := ctl.mediaSvc.GetMediasByHash(ctx.Context(), tenant.ID, user.ID, hashes)
|
medias, err := ctl.mediaSvc.GetMediasByIDs(ctx.Context(), tenant.ID, user.ID, ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(medias) != len(lo.Uniq(hashes)) {
|
if len(medias) != len(lo.Uniq(ids)) {
|
||||||
return errorx.BadRequest
|
return errorx.BadRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,13 +218,13 @@ func (ctl *Controller) Update(ctx fiber.Ctx, claim *jwt.Claims, hash string, bod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check media assets exists
|
// check media assets exists
|
||||||
hashes := lo.Map(body.Assets.Data, func(item fields.MediaAsset, _ int) string { return item.Hash })
|
ids := lo.Map(body.Assets.Data, func(item fields.MediaAsset, _ int) int64 { return item.Media })
|
||||||
medias, err := ctl.mediaSvc.GetMediasByHash(ctx.Context(), *claim.TenantID, post.UserID, hashes)
|
medias, err := ctl.mediaSvc.GetMediasByIDs(ctx.Context(), *claim.TenantID, post.UserID, ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(medias) != len(lo.Uniq(hashes)) {
|
if len(medias) != len(lo.Uniq(ids)) {
|
||||||
return errorx.BadRequest
|
return errorx.BadRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,5 +247,6 @@ func (ctl *Controller) Update(ctx fiber.Ctx, claim *jwt.Claims, hash string, bod
|
|||||||
if err := ctl.svc.Update(ctx.Context(), post.TenantID, post.UserID, post.ID, m); err != nil {
|
if err := ctl.svc.Update(ctx.Context(), post.TenantID, post.UserID, post.ID, m); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// todo: trigger event post updated
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,13 +70,13 @@ func (w *PostDeleteAssetsJobWorker) Work(ctx context.Context, job *Job[PostDelet
|
|||||||
return errors.Wrapf(err, "failed to get post(%d) by id", job.Args.PostID)
|
return errors.Wrapf(err, "failed to get post(%d) by id", job.Args.PostID)
|
||||||
}
|
}
|
||||||
|
|
||||||
hashes := lo.Map(post.Assets.Data, func(asset fields.MediaAsset, _ int) string {
|
mediaIDs := lo.Map(post.Assets.Data, func(asset fields.MediaAsset, _ int) int64 {
|
||||||
return asset.Hash
|
return asset.Media
|
||||||
})
|
})
|
||||||
|
|
||||||
medias, err := w.mediaSvc.GetMediasByHash(ctx, post.TenantID, post.UserID, hashes)
|
medias, err := w.mediaSvc.GetMediasByIDs(ctx, post.TenantID, post.UserID, mediaIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to get medias by hashes(%v)", hashes)
|
return errors.Wrapf(err, "failed to get medias by ids(%v)", mediaIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
storageIds := lo.Map(medias, func(media *model.Medias, _ int) int64 { return media.StorageID })
|
storageIds := lo.Map(medias, func(media *model.Medias, _ int) int64 { return media.StorageID })
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type PostVideoCutJob struct {
|
|||||||
PostID int64
|
PostID int64
|
||||||
TenantID int64
|
TenantID int64
|
||||||
UserID int64
|
UserID int64
|
||||||
Hash string
|
MediaID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertOpts implements JobArgsWithInsertOpts.
|
// InsertOpts implements JobArgsWithInsertOpts.
|
||||||
@@ -81,9 +81,9 @@ func (w *PostVideoCutJobWorker) Work(ctx context.Context, job *Job[PostVideoCutJ
|
|||||||
return errors.Wrapf(err, "get post(%d) failed", job.Args.PostID)
|
return errors.Wrapf(err, "get post(%d) failed", job.Args.PostID)
|
||||||
}
|
}
|
||||||
|
|
||||||
media, err := w.mediaSvc.GetMediaByHash(ctx, job.Args.TenantID, job.Args.UserID, job.Args.Hash)
|
media, err := w.mediaSvc.GetMediaByID(ctx, job.Args.TenantID, job.Args.UserID, job.Args.MediaID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "get media by hash(%s) failed", job.Args.Hash)
|
return errors.Wrapf(err, "get media by user_media id(%s) failed", job.Args.MediaID)
|
||||||
}
|
}
|
||||||
|
|
||||||
videoPath := media.Path
|
videoPath := media.Path
|
||||||
@@ -108,7 +108,7 @@ func (w *PostVideoCutJobWorker) Work(ctx context.Context, job *Job[PostVideoCutJ
|
|||||||
return errors.Wrapf(err, "get preview video(%s) file md5 failed", previewVideoPath)
|
return errors.Wrapf(err, "get preview video(%s) file md5 failed", previewVideoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Rename(previewVideoPath, strings.Replace(videoPath, job.Args.Hash, fileMd5, 1)); err != nil {
|
if err := os.Rename(previewVideoPath, strings.Replace(videoPath, media.Hash, fileMd5, 1)); err != nil {
|
||||||
return errors.Wrapf(err, "rename video(%s) file failed", videoPath)
|
return errors.Wrapf(err, "rename video(%s) file failed", videoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +118,7 @@ func (w *PostVideoCutJobWorker) Work(ctx context.Context, job *Job[PostVideoCutJ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save to medias
|
// save to medias
|
||||||
_, err = w.mediaSvc.Create(ctx, &model.Medias{
|
mediaID, err := w.mediaSvc.Create(ctx, job.Args.TenantID, job.Args.UserID, &model.Medias{
|
||||||
TenantID: job.Args.TenantID,
|
|
||||||
UserID: job.Args.UserID,
|
|
||||||
PostID: post.ID,
|
|
||||||
StorageID: storage.ID,
|
StorageID: storage.ID,
|
||||||
Hash: fileMd5,
|
Hash: fileMd5,
|
||||||
Name: post.Title,
|
Name: post.Title,
|
||||||
@@ -135,9 +132,9 @@ func (w *PostVideoCutJobWorker) Work(ctx context.Context, job *Job[PostVideoCutJ
|
|||||||
|
|
||||||
assets := []fields.MediaAsset{
|
assets := []fields.MediaAsset{
|
||||||
{
|
{
|
||||||
Type: fields.MediaAssetTypeVideo,
|
Type: fields.MediaAssetTypeVideo,
|
||||||
Hash: fileMd5,
|
Media: mediaID,
|
||||||
Mark: lo.ToPtr("video-preview"),
|
Mark: lo.ToPtr("video-preview"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type PostVideoExtractAudioJob struct {
|
|||||||
PostID int64
|
PostID int64
|
||||||
TenantID int64
|
TenantID int64
|
||||||
UserID int64
|
UserID int64
|
||||||
Hash string
|
MediaID int64
|
||||||
Mark string
|
Mark string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ func (w *PostVideoExtractAudioJobWorker) Work(ctx context.Context, job *Job[Post
|
|||||||
return errors.Wrapf(err, "get post(%d) failed", job.Args.PostID)
|
return errors.Wrapf(err, "get post(%d) failed", job.Args.PostID)
|
||||||
}
|
}
|
||||||
|
|
||||||
media, err := w.mediaSvc.GetMediaByHash(ctx, job.Args.TenantID, job.Args.UserID, job.Args.Hash)
|
media, err := w.mediaSvc.GetMediaByID(ctx, job.Args.TenantID, job.Args.UserID, job.Args.MediaID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "get media by hash(%s) failed", job.Args.Hash)
|
return errors.Wrapf(err, "get media by user_media id(%s) failed", job.Args.MediaID)
|
||||||
}
|
}
|
||||||
|
|
||||||
videoPath := media.Path
|
videoPath := media.Path
|
||||||
@@ -111,7 +111,7 @@ func (w *PostVideoExtractAudioJobWorker) Work(ctx context.Context, job *Job[Post
|
|||||||
return errors.Wrapf(err, "get audio(%s) file md5 failed", audioPath)
|
return errors.Wrapf(err, "get audio(%s) file md5 failed", audioPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Rename(audioPath, strings.Replace(audioPath, job.Args.Hash, fileMd5, 1)); err != nil {
|
if err := os.Rename(audioPath, strings.Replace(audioPath, media.Hash, fileMd5, 1)); err != nil {
|
||||||
return errors.Wrapf(err, "rename audio(%s) file failed", audioPath)
|
return errors.Wrapf(err, "rename audio(%s) file failed", audioPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +121,7 @@ func (w *PostVideoExtractAudioJobWorker) Work(ctx context.Context, job *Job[Post
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save to medias
|
// save to medias
|
||||||
_, err = w.mediaSvc.Create(ctx, &model.Medias{
|
mediaID, err := w.mediaSvc.Create(ctx, job.Args.TenantID, job.Args.UserID, &model.Medias{
|
||||||
TenantID: job.Args.TenantID,
|
|
||||||
UserID: job.Args.UserID,
|
|
||||||
PostID: post.ID,
|
|
||||||
StorageID: storage.ID,
|
StorageID: storage.ID,
|
||||||
Hash: fileMd5,
|
Hash: fileMd5,
|
||||||
Name: post.Title,
|
Name: post.Title,
|
||||||
@@ -138,9 +135,9 @@ func (w *PostVideoExtractAudioJobWorker) Work(ctx context.Context, job *Job[Post
|
|||||||
|
|
||||||
assets := []fields.MediaAsset{
|
assets := []fields.MediaAsset{
|
||||||
{
|
{
|
||||||
Type: fields.MediaAssetTypeAudio,
|
Type: fields.MediaAssetTypeAudio,
|
||||||
Hash: fileMd5,
|
Media: mediaID,
|
||||||
Mark: lo.ToPtr(job.Args.Mark),
|
Mark: lo.ToPtr(job.Args.Mark),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package fields
|
package fields
|
||||||
|
|
||||||
type MediaAsset struct {
|
type MediaAsset struct {
|
||||||
Type MediaAssetType `json:"type"`
|
Type MediaAssetType `json:"type"`
|
||||||
Hash string `json:"hash"`
|
Media int64 `json:"media"`
|
||||||
Mark *string `json:"mark,omitempty"`
|
Mark *string `json:"mark,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// swagger:enum MediaAssetType
|
// swagger:enum MediaAssetType
|
||||||
|
|||||||
@@ -4,11 +4,6 @@
|
|||||||
CREATE TABLE medias (
|
CREATE TABLE medias (
|
||||||
id SERIAL8 PRIMARY KEY,
|
id SERIAL8 PRIMARY KEY,
|
||||||
created_at timestamp NOT NULL default now(),
|
created_at timestamp NOT NULL default now(),
|
||||||
updated_at timestamp NOT NULL default now(),
|
|
||||||
|
|
||||||
tenant_id INT8 NOT NULL,
|
|
||||||
user_id INT8 NOT NULL,
|
|
||||||
post_id INT8 NOT NULL,
|
|
||||||
storage_id INT8 NOT NULL,
|
storage_id INT8 NOT NULL,
|
||||||
hash VARCHAR(32) NOT NULL,
|
hash VARCHAR(32) NOT NULL,
|
||||||
name VARCHAR(255) NOT NULL default '',
|
name VARCHAR(255) NOT NULL default '',
|
||||||
@@ -17,13 +12,24 @@ CREATE TABLE medias (
|
|||||||
path VARCHAR(255) NOT NULL default ''
|
path VARCHAR(255) NOT NULL default ''
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX medias_tenant_id_index ON medias (tenant_id);
|
-- index
|
||||||
CREATE INDEX medias_user_id_index ON medias (user_id);
|
CREATE UNIQUE INDEX medias_hash_idx ON medias (hash);
|
||||||
CREATE INDEX medias_post_id_index ON medias (post_id);
|
|
||||||
CREATE INDEX medias_storage_id_index ON medias (storage_id);
|
|
||||||
|
-- user medias
|
||||||
|
CREATE TABLE user_medias (
|
||||||
|
id SERIAL8 PRIMARY KEY,
|
||||||
|
created_at timestamp NOT NULL default now(),
|
||||||
|
updated_at timestamp NOT NULL default now(),
|
||||||
|
|
||||||
|
tenant_id INT8 NOT NULL,
|
||||||
|
user_id INT8 NOT NULL,
|
||||||
|
media_id INT8 NOT NULL
|
||||||
|
)
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
-- +goose StatementBegin
|
-- +goose StatementBegin
|
||||||
DROP TABLE medias;
|
DROP TABLE medias;
|
||||||
|
DROP TABLE user_medias;
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ import (
|
|||||||
type Medias struct {
|
type Medias struct {
|
||||||
ID int64 `sql:"primary_key" json:"id"`
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
|
||||||
TenantID int64 `json:"tenant_id"`
|
|
||||||
UserID int64 `json:"user_id"`
|
|
||||||
PostID int64 `json:"post_id"`
|
|
||||||
StorageID int64 `json:"storage_id"`
|
StorageID int64 `json:"storage_id"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|||||||
21
backend/database/models/qvyun_v2/public/model/user_medias.go
Normal file
21
backend/database/models/qvyun_v2/public/model/user_medias.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// 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 UserMedias struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
MediaID int64 `json:"media_id"`
|
||||||
|
}
|
||||||
@@ -19,10 +19,6 @@ type mediasTable struct {
|
|||||||
// Columns
|
// Columns
|
||||||
ID postgres.ColumnInteger
|
ID postgres.ColumnInteger
|
||||||
CreatedAt postgres.ColumnTimestamp
|
CreatedAt postgres.ColumnTimestamp
|
||||||
UpdatedAt postgres.ColumnTimestamp
|
|
||||||
TenantID postgres.ColumnInteger
|
|
||||||
UserID postgres.ColumnInteger
|
|
||||||
PostID postgres.ColumnInteger
|
|
||||||
StorageID postgres.ColumnInteger
|
StorageID postgres.ColumnInteger
|
||||||
Hash postgres.ColumnString
|
Hash postgres.ColumnString
|
||||||
Name postgres.ColumnString
|
Name postgres.ColumnString
|
||||||
@@ -71,18 +67,14 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
|
|||||||
var (
|
var (
|
||||||
IDColumn = postgres.IntegerColumn("id")
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
|
||||||
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
|
||||||
UserIDColumn = postgres.IntegerColumn("user_id")
|
|
||||||
PostIDColumn = postgres.IntegerColumn("post_id")
|
|
||||||
StorageIDColumn = postgres.IntegerColumn("storage_id")
|
StorageIDColumn = postgres.IntegerColumn("storage_id")
|
||||||
HashColumn = postgres.StringColumn("hash")
|
HashColumn = postgres.StringColumn("hash")
|
||||||
NameColumn = postgres.StringColumn("name")
|
NameColumn = postgres.StringColumn("name")
|
||||||
MimeTypeColumn = postgres.StringColumn("mime_type")
|
MimeTypeColumn = postgres.StringColumn("mime_type")
|
||||||
SizeColumn = postgres.IntegerColumn("size")
|
SizeColumn = postgres.IntegerColumn("size")
|
||||||
PathColumn = postgres.StringColumn("path")
|
PathColumn = postgres.StringColumn("path")
|
||||||
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, StorageIDColumn, HashColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, StorageIDColumn, HashColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
|
||||||
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, StorageIDColumn, HashColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, StorageIDColumn, HashColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
|
||||||
)
|
)
|
||||||
|
|
||||||
return mediasTable{
|
return mediasTable{
|
||||||
@@ -91,10 +83,6 @@ func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
|
|||||||
//Columns
|
//Columns
|
||||||
ID: IDColumn,
|
ID: IDColumn,
|
||||||
CreatedAt: CreatedAtColumn,
|
CreatedAt: CreatedAtColumn,
|
||||||
UpdatedAt: UpdatedAtColumn,
|
|
||||||
TenantID: TenantIDColumn,
|
|
||||||
UserID: UserIDColumn,
|
|
||||||
PostID: PostIDColumn,
|
|
||||||
StorageID: StorageIDColumn,
|
StorageID: StorageIDColumn,
|
||||||
Hash: HashColumn,
|
Hash: HashColumn,
|
||||||
Name: NameColumn,
|
Name: NameColumn,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ func UseSchema(schema string) {
|
|||||||
TenantUsers = TenantUsers.FromSchema(schema)
|
TenantUsers = TenantUsers.FromSchema(schema)
|
||||||
Tenants = Tenants.FromSchema(schema)
|
Tenants = Tenants.FromSchema(schema)
|
||||||
UserBoughtPosts = UserBoughtPosts.FromSchema(schema)
|
UserBoughtPosts = UserBoughtPosts.FromSchema(schema)
|
||||||
|
UserMedias = UserMedias.FromSchema(schema)
|
||||||
UserOauths = UserOauths.FromSchema(schema)
|
UserOauths = UserOauths.FromSchema(schema)
|
||||||
Users = Users.FromSchema(schema)
|
Users = Users.FromSchema(schema)
|
||||||
}
|
}
|
||||||
|
|||||||
90
backend/database/models/qvyun_v2/public/table/user_medias.go
Normal file
90
backend/database/models/qvyun_v2/public/table/user_medias.go
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var UserMedias = newUserMediasTable("public", "user_medias", "")
|
||||||
|
|
||||||
|
type userMediasTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
MediaID postgres.ColumnInteger
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserMediasTable struct {
|
||||||
|
userMediasTable
|
||||||
|
|
||||||
|
EXCLUDED userMediasTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new UserMediasTable with assigned alias
|
||||||
|
func (a UserMediasTable) AS(alias string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new UserMediasTable with assigned schema name
|
||||||
|
func (a UserMediasTable) FromSchema(schemaName string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new UserMediasTable with assigned table prefix
|
||||||
|
func (a UserMediasTable) WithPrefix(prefix string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new UserMediasTable with assigned table suffix
|
||||||
|
func (a UserMediasTable) WithSuffix(suffix string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserMediasTable(schemaName, tableName, alias string) *UserMediasTable {
|
||||||
|
return &UserMediasTable{
|
||||||
|
userMediasTable: newUserMediasTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newUserMediasTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserMediasTableImpl(schemaName, tableName, alias string) userMediasTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
MediaIDColumn = postgres.IntegerColumn("media_id")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, MediaIDColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, MediaIDColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return userMediasTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
MediaID: MediaIDColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ type Uploader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UploadedFile struct {
|
type UploadedFile struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Size int64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"folders": [
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "test"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend"
|
"path": "frontend"
|
||||||
},
|
},
|
||||||
|
|||||||
39
test/config.toml
Normal file
39
test/config.toml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
[App]
|
||||||
|
Mode = "development"
|
||||||
|
BaseURI = "https://qvyun.mp.jdwan.com"
|
||||||
|
|
||||||
|
[Http]
|
||||||
|
Port = 9600
|
||||||
|
|
||||||
|
[Database]
|
||||||
|
Host = "10.1.1.3"
|
||||||
|
Database = "qvyun_v2"
|
||||||
|
Password = "xixi0202"
|
||||||
|
|
||||||
|
[Wechat]
|
||||||
|
AppId = "wx45745a8c51091ae0"
|
||||||
|
AppSecret = "2ab33bc79d9b47efa4abef19d66e1977"
|
||||||
|
Token = "W8Xhw5TivYBgY"
|
||||||
|
AesKey = "F6AqCxAV4W1eCrY6llJ2zapphKK49CQN3RgtPDrjhnI"
|
||||||
|
DevMode = true
|
||||||
|
|
||||||
|
[JWT]
|
||||||
|
ExpiresTime = "168h"
|
||||||
|
SigningKey = "LiXi.Y@140202"
|
||||||
|
|
||||||
|
[HashIDs]
|
||||||
|
Salt = "LiXi.Y@140202"
|
||||||
|
|
||||||
|
[Storage]
|
||||||
|
Type = "local"
|
||||||
|
Path = "/mnt/yangpingliang/processed"
|
||||||
|
Asset = "/projects/qvyun/frontend/dist"
|
||||||
|
|
||||||
|
|
||||||
|
[Pay]
|
||||||
|
WechatAppId = "wx45745a8c51091ae0"
|
||||||
|
WechatMechID = ""
|
||||||
|
WechatSubMechID = ""
|
||||||
|
WechatSerialNo = ""
|
||||||
|
WechatApiV3Key = ""
|
||||||
|
WechatPrivateKey = ""
|
||||||
40
test/database/database.go
Normal file
40
test/database/database.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-jet/jet/v2/qrm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CtxDB struct{}
|
||||||
|
|
||||||
|
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
||||||
|
if tx, ok := ctx.Value(CtxDB{}).(*sql.Tx); ok {
|
||||||
|
return tx
|
||||||
|
}
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
||||||
|
func Truncate(ctx context.Context, db *sql.DB, tableName ...string) error {
|
||||||
|
for _, name := range tableName {
|
||||||
|
sql := fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", name)
|
||||||
|
if _, err := db.ExecContext(ctx, sql); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func WrapLike(v string) string {
|
||||||
|
return "%" + v + "%"
|
||||||
|
}
|
||||||
|
|
||||||
|
func WrapLikeLeft(v string) string {
|
||||||
|
return "%" + v
|
||||||
|
}
|
||||||
|
|
||||||
|
func WrapLikeRight(v string) string {
|
||||||
|
return "%" + v
|
||||||
|
}
|
||||||
23
test/database/models/qvyun_v2/public/model/medias.go
Normal file
23
test/database/models/qvyun_v2/public/model/medias.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// 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 Medias struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
StorageID int64 `json:"storage_id"`
|
||||||
|
Hash string `json:"hash"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
MimeType string `json:"mime_type"`
|
||||||
|
Size int64 `json:"size"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
}
|
||||||
32
test/database/models/qvyun_v2/public/model/orders.go
Normal file
32
test/database/models/qvyun_v2/public/model/orders.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// 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 Orders struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
Type int16 `json:"type"`
|
||||||
|
Status int16 `json:"status"`
|
||||||
|
OrderSerial string `json:"order_serial"`
|
||||||
|
RemoteOrderSerial string `json:"remote_order_serial"`
|
||||||
|
RefundSerial string `json:"refund_serial"`
|
||||||
|
RemoteRefundSerial string `json:"remote_refund_serial"`
|
||||||
|
Amount int64 `json:"amount"`
|
||||||
|
Currency string `json:"currency"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Description *string `json:"description"`
|
||||||
|
Meta *string `json:"meta"`
|
||||||
|
}
|
||||||
34
test/database/models/qvyun_v2/public/model/posts.go
Normal file
34
test/database/models/qvyun_v2/public/model/posts.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// 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 Posts struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at"`
|
||||||
|
Type int16 `json:"type"`
|
||||||
|
Stage int16 `json:"stage"`
|
||||||
|
Status int16 `json:"status"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
Price int64 `json:"price"`
|
||||||
|
Discount int16 `json:"discount"`
|
||||||
|
Views int64 `json:"views"`
|
||||||
|
Likes int64 `json:"likes"`
|
||||||
|
Meta *string `json:"meta"`
|
||||||
|
Tags *string `json:"tags"`
|
||||||
|
Assets *string `json:"assets"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
//
|
||||||
|
// 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 "errors"
|
||||||
|
|
||||||
|
type RiverJobState string
|
||||||
|
|
||||||
|
const (
|
||||||
|
RiverJobState_Available RiverJobState = "available"
|
||||||
|
RiverJobState_Cancelled RiverJobState = "cancelled"
|
||||||
|
RiverJobState_Completed RiverJobState = "completed"
|
||||||
|
RiverJobState_Discarded RiverJobState = "discarded"
|
||||||
|
RiverJobState_Pending RiverJobState = "pending"
|
||||||
|
RiverJobState_Retryable RiverJobState = "retryable"
|
||||||
|
RiverJobState_Running RiverJobState = "running"
|
||||||
|
RiverJobState_Scheduled RiverJobState = "scheduled"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RiverJobStateAllValues = []RiverJobState{
|
||||||
|
RiverJobState_Available,
|
||||||
|
RiverJobState_Cancelled,
|
||||||
|
RiverJobState_Completed,
|
||||||
|
RiverJobState_Discarded,
|
||||||
|
RiverJobState_Pending,
|
||||||
|
RiverJobState_Retryable,
|
||||||
|
RiverJobState_Running,
|
||||||
|
RiverJobState_Scheduled,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *RiverJobState) Scan(value interface{}) error {
|
||||||
|
var enumValue string
|
||||||
|
switch val := value.(type) {
|
||||||
|
case string:
|
||||||
|
enumValue = val
|
||||||
|
case []byte:
|
||||||
|
enumValue = string(val)
|
||||||
|
default:
|
||||||
|
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch enumValue {
|
||||||
|
case "available":
|
||||||
|
*e = RiverJobState_Available
|
||||||
|
case "cancelled":
|
||||||
|
*e = RiverJobState_Cancelled
|
||||||
|
case "completed":
|
||||||
|
*e = RiverJobState_Completed
|
||||||
|
case "discarded":
|
||||||
|
*e = RiverJobState_Discarded
|
||||||
|
case "pending":
|
||||||
|
*e = RiverJobState_Pending
|
||||||
|
case "retryable":
|
||||||
|
*e = RiverJobState_Retryable
|
||||||
|
case "running":
|
||||||
|
*e = RiverJobState_Running
|
||||||
|
case "scheduled":
|
||||||
|
*e = RiverJobState_Scheduled
|
||||||
|
default:
|
||||||
|
return errors.New("jet: Invalid scan value '" + enumValue + "' for RiverJobState enum")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e RiverJobState) String() string {
|
||||||
|
return string(e)
|
||||||
|
}
|
||||||
22
test/database/models/qvyun_v2/public/model/storages.go
Normal file
22
test/database/models/qvyun_v2/public/model/storages.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// 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 Storages struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
IsDefault bool `json:"is_default"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type int16 `json:"type"`
|
||||||
|
Config string `json:"config"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// 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 TenantUserBalances struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
Balance int64 `json:"balance"`
|
||||||
|
}
|
||||||
23
test/database/models/qvyun_v2/public/model/tenant_users.go
Normal file
23
test/database/models/qvyun_v2/public/model/tenant_users.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// 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 TenantUsers struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
Status int16 `json:"status"`
|
||||||
|
Role int16 `json:"role"`
|
||||||
|
}
|
||||||
23
test/database/models/qvyun_v2/public/model/tenants.go
Normal file
23
test/database/models/qvyun_v2/public/model/tenants.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// 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 Tenants struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
ExpiredAt time.Time `json:"expired_at"`
|
||||||
|
CreatedByUserID int64 `json:"created_by_user_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
Description *string `json:"description"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// 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 UserBoughtPosts struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
PostID int64 `json:"post_id"`
|
||||||
|
Price int64 `json:"price"`
|
||||||
|
Discount int16 `json:"discount"`
|
||||||
|
Meta *string `json:"meta"`
|
||||||
|
}
|
||||||
21
test/database/models/qvyun_v2/public/model/user_medias.go
Normal file
21
test/database/models/qvyun_v2/public/model/user_medias.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// 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 UserMedias struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
TenantID int64 `json:"tenant_id"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
MediaID int64 `json:"media_id"`
|
||||||
|
}
|
||||||
27
test/database/models/qvyun_v2/public/model/user_oauths.go
Normal file
27
test/database/models/qvyun_v2/public/model/user_oauths.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// 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 UserOauths struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at"`
|
||||||
|
Channel int16 `json:"channel"`
|
||||||
|
UserID int64 `json:"user_id"`
|
||||||
|
UnionID *string `json:"union_id"`
|
||||||
|
OpenID string `json:"open_id"`
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
ExpireAt time.Time `json:"expire_at"`
|
||||||
|
Meta *string `json:"meta"`
|
||||||
|
}
|
||||||
28
test/database/models/qvyun_v2/public/model/users.go
Normal file
28
test/database/models/qvyun_v2/public/model/users.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// 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 Users struct {
|
||||||
|
ID int64 `sql:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt *time.Time `json:"deleted_at"`
|
||||||
|
Status int16 `json:"status"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Nickname *string `json:"nickname"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Age int16 `json:"age"`
|
||||||
|
Sex int16 `json:"sex"`
|
||||||
|
Avatar *string `json:"avatar"`
|
||||||
|
}
|
||||||
96
test/database/models/qvyun_v2/public/table/medias.go
Normal file
96
test/database/models/qvyun_v2/public/table/medias.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Medias = newMediasTable("public", "medias", "")
|
||||||
|
|
||||||
|
type mediasTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
StorageID postgres.ColumnInteger
|
||||||
|
Hash postgres.ColumnString
|
||||||
|
Name postgres.ColumnString
|
||||||
|
MimeType postgres.ColumnString
|
||||||
|
Size postgres.ColumnInteger
|
||||||
|
Path postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type MediasTable struct {
|
||||||
|
mediasTable
|
||||||
|
|
||||||
|
EXCLUDED mediasTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new MediasTable with assigned alias
|
||||||
|
func (a MediasTable) AS(alias string) *MediasTable {
|
||||||
|
return newMediasTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new MediasTable with assigned schema name
|
||||||
|
func (a MediasTable) FromSchema(schemaName string) *MediasTable {
|
||||||
|
return newMediasTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new MediasTable with assigned table prefix
|
||||||
|
func (a MediasTable) WithPrefix(prefix string) *MediasTable {
|
||||||
|
return newMediasTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new MediasTable with assigned table suffix
|
||||||
|
func (a MediasTable) WithSuffix(suffix string) *MediasTable {
|
||||||
|
return newMediasTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMediasTable(schemaName, tableName, alias string) *MediasTable {
|
||||||
|
return &MediasTable{
|
||||||
|
mediasTable: newMediasTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newMediasTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
StorageIDColumn = postgres.IntegerColumn("storage_id")
|
||||||
|
HashColumn = postgres.StringColumn("hash")
|
||||||
|
NameColumn = postgres.StringColumn("name")
|
||||||
|
MimeTypeColumn = postgres.StringColumn("mime_type")
|
||||||
|
SizeColumn = postgres.IntegerColumn("size")
|
||||||
|
PathColumn = postgres.StringColumn("path")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, StorageIDColumn, HashColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, StorageIDColumn, HashColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return mediasTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
StorageID: StorageIDColumn,
|
||||||
|
Hash: HashColumn,
|
||||||
|
Name: NameColumn,
|
||||||
|
MimeType: MimeTypeColumn,
|
||||||
|
Size: SizeColumn,
|
||||||
|
Path: PathColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
123
test/database/models/qvyun_v2/public/table/orders.go
Normal file
123
test/database/models/qvyun_v2/public/table/orders.go
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Orders = newOrdersTable("public", "orders", "")
|
||||||
|
|
||||||
|
type ordersTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
DeletedAt postgres.ColumnTimestamp
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
Type postgres.ColumnInteger
|
||||||
|
Status postgres.ColumnInteger
|
||||||
|
OrderSerial postgres.ColumnString
|
||||||
|
RemoteOrderSerial postgres.ColumnString
|
||||||
|
RefundSerial postgres.ColumnString
|
||||||
|
RemoteRefundSerial postgres.ColumnString
|
||||||
|
Amount postgres.ColumnInteger
|
||||||
|
Currency postgres.ColumnString
|
||||||
|
Title postgres.ColumnString
|
||||||
|
Description postgres.ColumnString
|
||||||
|
Meta postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrdersTable struct {
|
||||||
|
ordersTable
|
||||||
|
|
||||||
|
EXCLUDED ordersTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new OrdersTable with assigned alias
|
||||||
|
func (a OrdersTable) AS(alias string) *OrdersTable {
|
||||||
|
return newOrdersTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new OrdersTable with assigned schema name
|
||||||
|
func (a OrdersTable) FromSchema(schemaName string) *OrdersTable {
|
||||||
|
return newOrdersTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new OrdersTable with assigned table prefix
|
||||||
|
func (a OrdersTable) WithPrefix(prefix string) *OrdersTable {
|
||||||
|
return newOrdersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new OrdersTable with assigned table suffix
|
||||||
|
func (a OrdersTable) WithSuffix(suffix string) *OrdersTable {
|
||||||
|
return newOrdersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newOrdersTable(schemaName, tableName, alias string) *OrdersTable {
|
||||||
|
return &OrdersTable{
|
||||||
|
ordersTable: newOrdersTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newOrdersTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newOrdersTableImpl(schemaName, tableName, alias string) ordersTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
TypeColumn = postgres.IntegerColumn("type")
|
||||||
|
StatusColumn = postgres.IntegerColumn("status")
|
||||||
|
OrderSerialColumn = postgres.StringColumn("order_serial")
|
||||||
|
RemoteOrderSerialColumn = postgres.StringColumn("remote_order_serial")
|
||||||
|
RefundSerialColumn = postgres.StringColumn("refund_serial")
|
||||||
|
RemoteRefundSerialColumn = postgres.StringColumn("remote_refund_serial")
|
||||||
|
AmountColumn = postgres.IntegerColumn("amount")
|
||||||
|
CurrencyColumn = postgres.StringColumn("currency")
|
||||||
|
TitleColumn = postgres.StringColumn("title")
|
||||||
|
DescriptionColumn = postgres.StringColumn("description")
|
||||||
|
MetaColumn = postgres.StringColumn("meta")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, TypeColumn, StatusColumn, OrderSerialColumn, RemoteOrderSerialColumn, RefundSerialColumn, RemoteRefundSerialColumn, AmountColumn, CurrencyColumn, TitleColumn, DescriptionColumn, MetaColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, TypeColumn, StatusColumn, OrderSerialColumn, RemoteOrderSerialColumn, RefundSerialColumn, RemoteRefundSerialColumn, AmountColumn, CurrencyColumn, TitleColumn, DescriptionColumn, MetaColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return ordersTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
DeletedAt: DeletedAtColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
Type: TypeColumn,
|
||||||
|
Status: StatusColumn,
|
||||||
|
OrderSerial: OrderSerialColumn,
|
||||||
|
RemoteOrderSerial: RemoteOrderSerialColumn,
|
||||||
|
RefundSerial: RefundSerialColumn,
|
||||||
|
RemoteRefundSerial: RemoteRefundSerialColumn,
|
||||||
|
Amount: AmountColumn,
|
||||||
|
Currency: CurrencyColumn,
|
||||||
|
Title: TitleColumn,
|
||||||
|
Description: DescriptionColumn,
|
||||||
|
Meta: MetaColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
129
test/database/models/qvyun_v2/public/table/posts.go
Normal file
129
test/database/models/qvyun_v2/public/table/posts.go
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Posts = newPostsTable("public", "posts", "")
|
||||||
|
|
||||||
|
type postsTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
DeletedAt postgres.ColumnTimestamp
|
||||||
|
Type postgres.ColumnInteger
|
||||||
|
Stage postgres.ColumnInteger
|
||||||
|
Status postgres.ColumnInteger
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
Title postgres.ColumnString
|
||||||
|
Description postgres.ColumnString
|
||||||
|
Content postgres.ColumnString
|
||||||
|
Price postgres.ColumnInteger
|
||||||
|
Discount postgres.ColumnInteger
|
||||||
|
Views postgres.ColumnInteger
|
||||||
|
Likes postgres.ColumnInteger
|
||||||
|
Meta postgres.ColumnString
|
||||||
|
Tags postgres.ColumnString
|
||||||
|
Assets postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostsTable struct {
|
||||||
|
postsTable
|
||||||
|
|
||||||
|
EXCLUDED postsTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new PostsTable with assigned alias
|
||||||
|
func (a PostsTable) AS(alias string) *PostsTable {
|
||||||
|
return newPostsTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new PostsTable with assigned schema name
|
||||||
|
func (a PostsTable) FromSchema(schemaName string) *PostsTable {
|
||||||
|
return newPostsTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new PostsTable with assigned table prefix
|
||||||
|
func (a PostsTable) WithPrefix(prefix string) *PostsTable {
|
||||||
|
return newPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new PostsTable with assigned table suffix
|
||||||
|
func (a PostsTable) WithSuffix(suffix string) *PostsTable {
|
||||||
|
return newPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPostsTable(schemaName, tableName, alias string) *PostsTable {
|
||||||
|
return &PostsTable{
|
||||||
|
postsTable: newPostsTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newPostsTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
|
||||||
|
TypeColumn = postgres.IntegerColumn("type")
|
||||||
|
StageColumn = postgres.IntegerColumn("stage")
|
||||||
|
StatusColumn = postgres.IntegerColumn("status")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
TitleColumn = postgres.StringColumn("title")
|
||||||
|
DescriptionColumn = postgres.StringColumn("description")
|
||||||
|
ContentColumn = postgres.StringColumn("content")
|
||||||
|
PriceColumn = postgres.IntegerColumn("price")
|
||||||
|
DiscountColumn = postgres.IntegerColumn("discount")
|
||||||
|
ViewsColumn = postgres.IntegerColumn("views")
|
||||||
|
LikesColumn = postgres.IntegerColumn("likes")
|
||||||
|
MetaColumn = postgres.StringColumn("meta")
|
||||||
|
TagsColumn = postgres.StringColumn("tags")
|
||||||
|
AssetsColumn = postgres.StringColumn("assets")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TypeColumn, StageColumn, StatusColumn, TenantIDColumn, UserIDColumn, TitleColumn, DescriptionColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, TagsColumn, AssetsColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TypeColumn, StageColumn, StatusColumn, TenantIDColumn, UserIDColumn, TitleColumn, DescriptionColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, TagsColumn, AssetsColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return postsTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
DeletedAt: DeletedAtColumn,
|
||||||
|
Type: TypeColumn,
|
||||||
|
Stage: StageColumn,
|
||||||
|
Status: StatusColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
Title: TitleColumn,
|
||||||
|
Description: DescriptionColumn,
|
||||||
|
Content: ContentColumn,
|
||||||
|
Price: PriceColumn,
|
||||||
|
Discount: DiscountColumn,
|
||||||
|
Views: ViewsColumn,
|
||||||
|
Likes: LikesColumn,
|
||||||
|
Meta: MetaColumn,
|
||||||
|
Tags: TagsColumn,
|
||||||
|
Assets: AssetsColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
93
test/database/models/qvyun_v2/public/table/storages.go
Normal file
93
test/database/models/qvyun_v2/public/table/storages.go
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Storages = newStoragesTable("public", "storages", "")
|
||||||
|
|
||||||
|
type storagesTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
IsDefault postgres.ColumnBool
|
||||||
|
Name postgres.ColumnString
|
||||||
|
Type postgres.ColumnInteger
|
||||||
|
Config postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type StoragesTable struct {
|
||||||
|
storagesTable
|
||||||
|
|
||||||
|
EXCLUDED storagesTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new StoragesTable with assigned alias
|
||||||
|
func (a StoragesTable) AS(alias string) *StoragesTable {
|
||||||
|
return newStoragesTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new StoragesTable with assigned schema name
|
||||||
|
func (a StoragesTable) FromSchema(schemaName string) *StoragesTable {
|
||||||
|
return newStoragesTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new StoragesTable with assigned table prefix
|
||||||
|
func (a StoragesTable) WithPrefix(prefix string) *StoragesTable {
|
||||||
|
return newStoragesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new StoragesTable with assigned table suffix
|
||||||
|
func (a StoragesTable) WithSuffix(suffix string) *StoragesTable {
|
||||||
|
return newStoragesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStoragesTable(schemaName, tableName, alias string) *StoragesTable {
|
||||||
|
return &StoragesTable{
|
||||||
|
storagesTable: newStoragesTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newStoragesTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStoragesTableImpl(schemaName, tableName, alias string) storagesTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
IsDefaultColumn = postgres.BoolColumn("is_default")
|
||||||
|
NameColumn = postgres.StringColumn("name")
|
||||||
|
TypeColumn = postgres.IntegerColumn("type")
|
||||||
|
ConfigColumn = postgres.StringColumn("config")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, IsDefaultColumn, NameColumn, TypeColumn, ConfigColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, IsDefaultColumn, NameColumn, TypeColumn, ConfigColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return storagesTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
IsDefault: IsDefaultColumn,
|
||||||
|
Name: NameColumn,
|
||||||
|
Type: TypeColumn,
|
||||||
|
Config: ConfigColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
// UseSchema sets a new schema name for all generated table SQL builder types. It is recommended to invoke
|
||||||
|
// this method only once at the beginning of the program.
|
||||||
|
func UseSchema(schema string) {
|
||||||
|
Medias = Medias.FromSchema(schema)
|
||||||
|
Orders = Orders.FromSchema(schema)
|
||||||
|
Posts = Posts.FromSchema(schema)
|
||||||
|
Storages = Storages.FromSchema(schema)
|
||||||
|
TenantUserBalances = TenantUserBalances.FromSchema(schema)
|
||||||
|
TenantUsers = TenantUsers.FromSchema(schema)
|
||||||
|
Tenants = Tenants.FromSchema(schema)
|
||||||
|
UserBoughtPosts = UserBoughtPosts.FromSchema(schema)
|
||||||
|
UserMedias = UserMedias.FromSchema(schema)
|
||||||
|
UserOauths = UserOauths.FromSchema(schema)
|
||||||
|
Users = Users.FromSchema(schema)
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var TenantUserBalances = newTenantUserBalancesTable("public", "tenant_user_balances", "")
|
||||||
|
|
||||||
|
type tenantUserBalancesTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
Balance postgres.ColumnInteger
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type TenantUserBalancesTable struct {
|
||||||
|
tenantUserBalancesTable
|
||||||
|
|
||||||
|
EXCLUDED tenantUserBalancesTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new TenantUserBalancesTable with assigned alias
|
||||||
|
func (a TenantUserBalancesTable) AS(alias string) *TenantUserBalancesTable {
|
||||||
|
return newTenantUserBalancesTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new TenantUserBalancesTable with assigned schema name
|
||||||
|
func (a TenantUserBalancesTable) FromSchema(schemaName string) *TenantUserBalancesTable {
|
||||||
|
return newTenantUserBalancesTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new TenantUserBalancesTable with assigned table prefix
|
||||||
|
func (a TenantUserBalancesTable) WithPrefix(prefix string) *TenantUserBalancesTable {
|
||||||
|
return newTenantUserBalancesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new TenantUserBalancesTable with assigned table suffix
|
||||||
|
func (a TenantUserBalancesTable) WithSuffix(suffix string) *TenantUserBalancesTable {
|
||||||
|
return newTenantUserBalancesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTenantUserBalancesTable(schemaName, tableName, alias string) *TenantUserBalancesTable {
|
||||||
|
return &TenantUserBalancesTable{
|
||||||
|
tenantUserBalancesTable: newTenantUserBalancesTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newTenantUserBalancesTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTenantUserBalancesTableImpl(schemaName, tableName, alias string) tenantUserBalancesTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
BalanceColumn = postgres.IntegerColumn("balance")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, BalanceColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, BalanceColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return tenantUserBalancesTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
Balance: BalanceColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
96
test/database/models/qvyun_v2/public/table/tenant_users.go
Normal file
96
test/database/models/qvyun_v2/public/table/tenant_users.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var TenantUsers = newTenantUsersTable("public", "tenant_users", "")
|
||||||
|
|
||||||
|
type tenantUsersTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
DeletedAt postgres.ColumnTimestamp
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
Status postgres.ColumnInteger
|
||||||
|
Role postgres.ColumnInteger
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type TenantUsersTable struct {
|
||||||
|
tenantUsersTable
|
||||||
|
|
||||||
|
EXCLUDED tenantUsersTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new TenantUsersTable with assigned alias
|
||||||
|
func (a TenantUsersTable) AS(alias string) *TenantUsersTable {
|
||||||
|
return newTenantUsersTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new TenantUsersTable with assigned schema name
|
||||||
|
func (a TenantUsersTable) FromSchema(schemaName string) *TenantUsersTable {
|
||||||
|
return newTenantUsersTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new TenantUsersTable with assigned table prefix
|
||||||
|
func (a TenantUsersTable) WithPrefix(prefix string) *TenantUsersTable {
|
||||||
|
return newTenantUsersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new TenantUsersTable with assigned table suffix
|
||||||
|
func (a TenantUsersTable) WithSuffix(suffix string) *TenantUsersTable {
|
||||||
|
return newTenantUsersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTenantUsersTable(schemaName, tableName, alias string) *TenantUsersTable {
|
||||||
|
return &TenantUsersTable{
|
||||||
|
tenantUsersTable: newTenantUsersTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newTenantUsersTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTenantUsersTableImpl(schemaName, tableName, alias string) tenantUsersTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
StatusColumn = postgres.IntegerColumn("status")
|
||||||
|
RoleColumn = postgres.IntegerColumn("role")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, StatusColumn, RoleColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, StatusColumn, RoleColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return tenantUsersTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
DeletedAt: DeletedAtColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
Status: StatusColumn,
|
||||||
|
Role: RoleColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
96
test/database/models/qvyun_v2/public/table/tenants.go
Normal file
96
test/database/models/qvyun_v2/public/table/tenants.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Tenants = newTenantsTable("public", "tenants", "")
|
||||||
|
|
||||||
|
type tenantsTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
ExpiredAt postgres.ColumnTimestamp
|
||||||
|
CreatedByUserID postgres.ColumnInteger
|
||||||
|
Name postgres.ColumnString
|
||||||
|
Slug postgres.ColumnString
|
||||||
|
Description postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type TenantsTable struct {
|
||||||
|
tenantsTable
|
||||||
|
|
||||||
|
EXCLUDED tenantsTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new TenantsTable with assigned alias
|
||||||
|
func (a TenantsTable) AS(alias string) *TenantsTable {
|
||||||
|
return newTenantsTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new TenantsTable with assigned schema name
|
||||||
|
func (a TenantsTable) FromSchema(schemaName string) *TenantsTable {
|
||||||
|
return newTenantsTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new TenantsTable with assigned table prefix
|
||||||
|
func (a TenantsTable) WithPrefix(prefix string) *TenantsTable {
|
||||||
|
return newTenantsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new TenantsTable with assigned table suffix
|
||||||
|
func (a TenantsTable) WithSuffix(suffix string) *TenantsTable {
|
||||||
|
return newTenantsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTenantsTable(schemaName, tableName, alias string) *TenantsTable {
|
||||||
|
return &TenantsTable{
|
||||||
|
tenantsTable: newTenantsTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newTenantsTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTenantsTableImpl(schemaName, tableName, alias string) tenantsTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
ExpiredAtColumn = postgres.TimestampColumn("expired_at")
|
||||||
|
CreatedByUserIDColumn = postgres.IntegerColumn("created_by_user_id")
|
||||||
|
NameColumn = postgres.StringColumn("name")
|
||||||
|
SlugColumn = postgres.StringColumn("slug")
|
||||||
|
DescriptionColumn = postgres.StringColumn("description")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, ExpiredAtColumn, CreatedByUserIDColumn, NameColumn, SlugColumn, DescriptionColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, ExpiredAtColumn, CreatedByUserIDColumn, NameColumn, SlugColumn, DescriptionColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return tenantsTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
ExpiredAt: ExpiredAtColumn,
|
||||||
|
CreatedByUserID: CreatedByUserIDColumn,
|
||||||
|
Name: NameColumn,
|
||||||
|
Slug: SlugColumn,
|
||||||
|
Description: DescriptionColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var UserBoughtPosts = newUserBoughtPostsTable("public", "user_bought_posts", "")
|
||||||
|
|
||||||
|
type userBoughtPostsTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
PostID postgres.ColumnInteger
|
||||||
|
Price postgres.ColumnInteger
|
||||||
|
Discount postgres.ColumnInteger
|
||||||
|
Meta postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserBoughtPostsTable struct {
|
||||||
|
userBoughtPostsTable
|
||||||
|
|
||||||
|
EXCLUDED userBoughtPostsTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new UserBoughtPostsTable with assigned alias
|
||||||
|
func (a UserBoughtPostsTable) AS(alias string) *UserBoughtPostsTable {
|
||||||
|
return newUserBoughtPostsTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new UserBoughtPostsTable with assigned schema name
|
||||||
|
func (a UserBoughtPostsTable) FromSchema(schemaName string) *UserBoughtPostsTable {
|
||||||
|
return newUserBoughtPostsTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new UserBoughtPostsTable with assigned table prefix
|
||||||
|
func (a UserBoughtPostsTable) WithPrefix(prefix string) *UserBoughtPostsTable {
|
||||||
|
return newUserBoughtPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new UserBoughtPostsTable with assigned table suffix
|
||||||
|
func (a UserBoughtPostsTable) WithSuffix(suffix string) *UserBoughtPostsTable {
|
||||||
|
return newUserBoughtPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserBoughtPostsTable(schemaName, tableName, alias string) *UserBoughtPostsTable {
|
||||||
|
return &UserBoughtPostsTable{
|
||||||
|
userBoughtPostsTable: newUserBoughtPostsTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newUserBoughtPostsTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserBoughtPostsTableImpl(schemaName, tableName, alias string) userBoughtPostsTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
PostIDColumn = postgres.IntegerColumn("post_id")
|
||||||
|
PriceColumn = postgres.IntegerColumn("price")
|
||||||
|
DiscountColumn = postgres.IntegerColumn("discount")
|
||||||
|
MetaColumn = postgres.StringColumn("meta")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, PriceColumn, DiscountColumn, MetaColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, PostIDColumn, PriceColumn, DiscountColumn, MetaColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return userBoughtPostsTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
PostID: PostIDColumn,
|
||||||
|
Price: PriceColumn,
|
||||||
|
Discount: DiscountColumn,
|
||||||
|
Meta: MetaColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
90
test/database/models/qvyun_v2/public/table/user_medias.go
Normal file
90
test/database/models/qvyun_v2/public/table/user_medias.go
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var UserMedias = newUserMediasTable("public", "user_medias", "")
|
||||||
|
|
||||||
|
type userMediasTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
TenantID postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
MediaID postgres.ColumnInteger
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserMediasTable struct {
|
||||||
|
userMediasTable
|
||||||
|
|
||||||
|
EXCLUDED userMediasTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new UserMediasTable with assigned alias
|
||||||
|
func (a UserMediasTable) AS(alias string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new UserMediasTable with assigned schema name
|
||||||
|
func (a UserMediasTable) FromSchema(schemaName string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new UserMediasTable with assigned table prefix
|
||||||
|
func (a UserMediasTable) WithPrefix(prefix string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new UserMediasTable with assigned table suffix
|
||||||
|
func (a UserMediasTable) WithSuffix(suffix string) *UserMediasTable {
|
||||||
|
return newUserMediasTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserMediasTable(schemaName, tableName, alias string) *UserMediasTable {
|
||||||
|
return &UserMediasTable{
|
||||||
|
userMediasTable: newUserMediasTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newUserMediasTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserMediasTableImpl(schemaName, tableName, alias string) userMediasTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
TenantIDColumn = postgres.IntegerColumn("tenant_id")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
MediaIDColumn = postgres.IntegerColumn("media_id")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, MediaIDColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, MediaIDColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return userMediasTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
TenantID: TenantIDColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
MediaID: MediaIDColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
108
test/database/models/qvyun_v2/public/table/user_oauths.go
Normal file
108
test/database/models/qvyun_v2/public/table/user_oauths.go
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var UserOauths = newUserOauthsTable("public", "user_oauths", "")
|
||||||
|
|
||||||
|
type userOauthsTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
DeletedAt postgres.ColumnTimestamp
|
||||||
|
Channel postgres.ColumnInteger
|
||||||
|
UserID postgres.ColumnInteger
|
||||||
|
UnionID postgres.ColumnString
|
||||||
|
OpenID postgres.ColumnString
|
||||||
|
AccessToken postgres.ColumnString
|
||||||
|
RefreshToken postgres.ColumnString
|
||||||
|
ExpireAt postgres.ColumnTimestamp
|
||||||
|
Meta postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserOauthsTable struct {
|
||||||
|
userOauthsTable
|
||||||
|
|
||||||
|
EXCLUDED userOauthsTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new UserOauthsTable with assigned alias
|
||||||
|
func (a UserOauthsTable) AS(alias string) *UserOauthsTable {
|
||||||
|
return newUserOauthsTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new UserOauthsTable with assigned schema name
|
||||||
|
func (a UserOauthsTable) FromSchema(schemaName string) *UserOauthsTable {
|
||||||
|
return newUserOauthsTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new UserOauthsTable with assigned table prefix
|
||||||
|
func (a UserOauthsTable) WithPrefix(prefix string) *UserOauthsTable {
|
||||||
|
return newUserOauthsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new UserOauthsTable with assigned table suffix
|
||||||
|
func (a UserOauthsTable) WithSuffix(suffix string) *UserOauthsTable {
|
||||||
|
return newUserOauthsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserOauthsTable(schemaName, tableName, alias string) *UserOauthsTable {
|
||||||
|
return &UserOauthsTable{
|
||||||
|
userOauthsTable: newUserOauthsTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newUserOauthsTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUserOauthsTableImpl(schemaName, tableName, alias string) userOauthsTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
|
||||||
|
ChannelColumn = postgres.IntegerColumn("channel")
|
||||||
|
UserIDColumn = postgres.IntegerColumn("user_id")
|
||||||
|
UnionIDColumn = postgres.StringColumn("union_id")
|
||||||
|
OpenIDColumn = postgres.StringColumn("open_id")
|
||||||
|
AccessTokenColumn = postgres.StringColumn("access_token")
|
||||||
|
RefreshTokenColumn = postgres.StringColumn("refresh_token")
|
||||||
|
ExpireAtColumn = postgres.TimestampColumn("expire_at")
|
||||||
|
MetaColumn = postgres.StringColumn("meta")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, ChannelColumn, UserIDColumn, UnionIDColumn, OpenIDColumn, AccessTokenColumn, RefreshTokenColumn, ExpireAtColumn, MetaColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, ChannelColumn, UserIDColumn, UnionIDColumn, OpenIDColumn, AccessTokenColumn, RefreshTokenColumn, ExpireAtColumn, MetaColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return userOauthsTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
DeletedAt: DeletedAtColumn,
|
||||||
|
Channel: ChannelColumn,
|
||||||
|
UserID: UserIDColumn,
|
||||||
|
UnionID: UnionIDColumn,
|
||||||
|
OpenID: OpenIDColumn,
|
||||||
|
AccessToken: AccessTokenColumn,
|
||||||
|
RefreshToken: RefreshTokenColumn,
|
||||||
|
ExpireAt: ExpireAtColumn,
|
||||||
|
Meta: MetaColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
111
test/database/models/qvyun_v2/public/table/users.go
Normal file
111
test/database/models/qvyun_v2/public/table/users.go
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
//
|
||||||
|
// 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 table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Users = newUsersTable("public", "users", "")
|
||||||
|
|
||||||
|
type usersTable struct {
|
||||||
|
postgres.Table
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
ID postgres.ColumnInteger
|
||||||
|
CreatedAt postgres.ColumnTimestamp
|
||||||
|
UpdatedAt postgres.ColumnTimestamp
|
||||||
|
DeletedAt postgres.ColumnTimestamp
|
||||||
|
Status postgres.ColumnInteger
|
||||||
|
Email postgres.ColumnString
|
||||||
|
Phone postgres.ColumnString
|
||||||
|
Username postgres.ColumnString
|
||||||
|
Nickname postgres.ColumnString
|
||||||
|
Password postgres.ColumnString
|
||||||
|
Age postgres.ColumnInteger
|
||||||
|
Sex postgres.ColumnInteger
|
||||||
|
Avatar postgres.ColumnString
|
||||||
|
|
||||||
|
AllColumns postgres.ColumnList
|
||||||
|
MutableColumns postgres.ColumnList
|
||||||
|
}
|
||||||
|
|
||||||
|
type UsersTable struct {
|
||||||
|
usersTable
|
||||||
|
|
||||||
|
EXCLUDED usersTable
|
||||||
|
}
|
||||||
|
|
||||||
|
// AS creates new UsersTable with assigned alias
|
||||||
|
func (a UsersTable) AS(alias string) *UsersTable {
|
||||||
|
return newUsersTable(a.SchemaName(), a.TableName(), alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema creates new UsersTable with assigned schema name
|
||||||
|
func (a UsersTable) FromSchema(schemaName string) *UsersTable {
|
||||||
|
return newUsersTable(schemaName, a.TableName(), a.Alias())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPrefix creates new UsersTable with assigned table prefix
|
||||||
|
func (a UsersTable) WithPrefix(prefix string) *UsersTable {
|
||||||
|
return newUsersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSuffix creates new UsersTable with assigned table suffix
|
||||||
|
func (a UsersTable) WithSuffix(suffix string) *UsersTable {
|
||||||
|
return newUsersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUsersTable(schemaName, tableName, alias string) *UsersTable {
|
||||||
|
return &UsersTable{
|
||||||
|
usersTable: newUsersTableImpl(schemaName, tableName, alias),
|
||||||
|
EXCLUDED: newUsersTableImpl("", "excluded", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newUsersTableImpl(schemaName, tableName, alias string) usersTable {
|
||||||
|
var (
|
||||||
|
IDColumn = postgres.IntegerColumn("id")
|
||||||
|
CreatedAtColumn = postgres.TimestampColumn("created_at")
|
||||||
|
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
|
||||||
|
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
|
||||||
|
StatusColumn = postgres.IntegerColumn("status")
|
||||||
|
EmailColumn = postgres.StringColumn("email")
|
||||||
|
PhoneColumn = postgres.StringColumn("phone")
|
||||||
|
UsernameColumn = postgres.StringColumn("username")
|
||||||
|
NicknameColumn = postgres.StringColumn("nickname")
|
||||||
|
PasswordColumn = postgres.StringColumn("password")
|
||||||
|
AgeColumn = postgres.IntegerColumn("age")
|
||||||
|
SexColumn = postgres.IntegerColumn("sex")
|
||||||
|
AvatarColumn = postgres.StringColumn("avatar")
|
||||||
|
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, EmailColumn, PhoneColumn, UsernameColumn, NicknameColumn, PasswordColumn, AgeColumn, SexColumn, AvatarColumn}
|
||||||
|
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, EmailColumn, PhoneColumn, UsernameColumn, NicknameColumn, PasswordColumn, AgeColumn, SexColumn, AvatarColumn}
|
||||||
|
)
|
||||||
|
|
||||||
|
return usersTable{
|
||||||
|
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||||
|
|
||||||
|
//Columns
|
||||||
|
ID: IDColumn,
|
||||||
|
CreatedAt: CreatedAtColumn,
|
||||||
|
UpdatedAt: UpdatedAtColumn,
|
||||||
|
DeletedAt: DeletedAtColumn,
|
||||||
|
Status: StatusColumn,
|
||||||
|
Email: EmailColumn,
|
||||||
|
Phone: PhoneColumn,
|
||||||
|
Username: UsernameColumn,
|
||||||
|
Nickname: NicknameColumn,
|
||||||
|
Password: PasswordColumn,
|
||||||
|
Age: AgeColumn,
|
||||||
|
Sex: SexColumn,
|
||||||
|
Avatar: AvatarColumn,
|
||||||
|
|
||||||
|
AllColumns: allColumns,
|
||||||
|
MutableColumns: mutableColumns,
|
||||||
|
}
|
||||||
|
}
|
||||||
9
test/database/transform.yaml
Normal file
9
test/database/transform.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
ignores:
|
||||||
|
- migrations
|
||||||
|
- river_client
|
||||||
|
- river_client_queue
|
||||||
|
- river_job
|
||||||
|
- river_job_state
|
||||||
|
- river_leader
|
||||||
|
- river_queue
|
||||||
|
types:
|
||||||
13
test/go.mod
Normal file
13
test/go.mod
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module test
|
||||||
|
|
||||||
|
go 1.23.2
|
||||||
|
|
||||||
|
require github.com/go-jet/jet/v2 v2.12.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.9.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
16
test/go.sum
Normal file
16
test/go.sum
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/go-jet/jet/v2 v2.12.0 h1:z2JfvBAZgsfxlQz6NXBYdZTXc7ep3jhbszTLtETv1JE=
|
||||||
|
github.com/go-jet/jet/v2 v2.12.0/go.mod h1:ufQVRQeI1mbcO5R8uCEVcVf3Foej9kReBdwDx7YMWUM=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
20
test/main_test.go
Normal file
20
test/main_test.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"test/database/models/qvyun_v2/public/table"
|
||||||
|
|
||||||
|
. "github.com/go-jet/jet/v2/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_Join(t *testing.T) {
|
||||||
|
t1 := table.Medias
|
||||||
|
t2 := table.UserMedias
|
||||||
|
|
||||||
|
stmt := SELECT(t1.AllColumns).
|
||||||
|
FROM(
|
||||||
|
t1.RIGHT_JOIN(t2, t2.UserID.EQ(Int64(10)).AND(t2.TenantID.EQ(Int64(1)).AND(t2.MediaID.EQ(t1.ID)))),
|
||||||
|
)
|
||||||
|
t.Log(stmt.DebugSql())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user