improve image sharing function

This commit is contained in:
2025-02-20 23:04:58 +08:00
parent b196e50aee
commit db4c59f6f6
37 changed files with 2188 additions and 95 deletions

View File

@@ -118,6 +118,8 @@ func main() {
scaStorageAlbum := g.GenerateModel("sca_storage_album", fieldOpts...)
scaStorageLocation := g.GenerateModel("sca_storage_location", fieldOpts...)
scaStorageThumb := g.GenerateModel("sca_storage_thumb", fieldOpts...)
scaStorageShare := g.GenerateModel("sca_storage_share", fieldOpts...)
scaStorageShareVisit := g.GenerateModel("sca_storage_share_visit", fieldOpts...)
g.ApplyBasic(
scaAuthMenu,
@@ -139,6 +141,8 @@ func main() {
scaStorageAlbum,
scaStorageLocation,
scaStorageThumb,
scaStorageShare,
scaStorageShareVisit,
)
g.Execute()

View File

@@ -17,8 +17,8 @@ type ScaStorageAlbum struct {
ID int64 `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键;primary_key" json:"id,string"` // 主键
UserID string `gorm:"column:user_id;type:varchar(50);comment:用户ID" json:"user_id"` // 用户ID
AlbumName string `gorm:"column:album_name;type:varchar(50);comment:相册名称" json:"album_name"` // 相册名称
AlbumType string `gorm:"column:album_type;type:varchar(50);comment:相册类型" json:"album_type"` // 相册类型
CoverImage string `gorm:"column:cover_image;type:text;comment:封面图片" json:"cover_image"` // 封面图片
AlbumType int64 `gorm:"column:album_type;type:tinyint(4);comment:相册类型(0 我的 1 分享 2 收藏)" json:"album_type"` // 相册类型(0 我的 1 分享 2 收藏)
CoverImage string `gorm:"column:cover_image;type:longtext;comment:封面图片" json:"cover_image"` // 封面图片
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;autoUpdateTime;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp;comment:删除时间" json:"deleted_at"` // 删除时间

View File

@@ -0,0 +1,36 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"time"
"gorm.io/gorm"
"gorm.io/plugin/optimisticlock"
)
const TableNameScaStorageShare = "sca_storage_share"
// ScaStorageShare 快传分享表
type ScaStorageShare struct {
ID int64 `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键;primary_key" json:"id,string"` // 主键
UserID string `gorm:"column:user_id;type:varchar(50);comment:用户ID" json:"user_id"` // 用户ID
AlbumID int64 `gorm:"column:album_id;type:bigint(20);comment:相册ID" json:"album_id"` // 相册ID
ShareCode string `gorm:"column:share_code;type:varchar(50);comment:分享码(用于访问分享链接)" json:"share_code"` // 分享码(用于访问分享链接)
ExpireTime time.Time `gorm:"column:expire_time;type:datetime;comment:过期时间" json:"expire_time"` // 过期时间
ValidityPeriod int64 `gorm:"column:validity_period;type:int(11);comment:有效期" json:"validity_period"` // 有效期
Status int64 `gorm:"column:status;type:tinyint(4);comment:是否失效0 有效 -1已失效 1 永久)" json:"status"` // 是否失效0 有效 -1已失效 1 永久)
AccessPassword string `gorm:"column:access_password;type:varchar(50);comment:访问密码" json:"access_password"` // 访问密码
VisitLimit int64 `gorm:"column:visit_limit;type:bigint(20);comment:限制次数" json:"visit_limit"` // 限制次数
Version optimisticlock.Version `gorm:"column:version;type:bigint(20);comment:版本" json:"version"` // 版本
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;autoUpdateTime;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName ScaStorageShare's table name
func (*ScaStorageShare) TableName() string {
return TableNameScaStorageShare
}

View File

@@ -0,0 +1,31 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"time"
"gorm.io/gorm"
"gorm.io/plugin/optimisticlock"
)
const TableNameScaStorageShareVisit = "sca_storage_share_visit"
// ScaStorageShareVisit 分享浏览记录
type ScaStorageShareVisit struct {
ID int64 `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键;primary_key" json:"id,string"` // 主键
UserID string `gorm:"column:user_id;type:varchar(50);comment:用户ID" json:"user_id"` // 用户ID
ShareID int64 `gorm:"column:share_id;type:bigint(20);comment:分享ID" json:"share_id"` // 分享ID
Views int64 `gorm:"column:views;type:bigint(20);comment:浏览次数" json:"views"` // 浏览次数
Version optimisticlock.Version `gorm:"column:version;type:bigint(20);comment:版本" json:"version"` // 版本
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;autoUpdateTime;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName ScaStorageShareVisit's table name
func (*ScaStorageShareVisit) TableName() string {
return TableNameScaStorageShareVisit
}

View File

@@ -12,7 +12,7 @@ import (
const TableNameScaStorageThumb = "sca_storage_thumb"
// ScaStorageThumb mapped from table <sca_storage_thumb>
// ScaStorageThumb 缩略图表
type ScaStorageThumb struct {
ID int64 `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键;primary_key" json:"id,string"` // 主键
UserID string `gorm:"column:user_id;type:varchar(50);not null;comment:用户ID" json:"user_id"` // 用户ID

View File

@@ -30,6 +30,8 @@ var (
ScaStorageConfig *scaStorageConfig
ScaStorageInfo *scaStorageInfo
ScaStorageLocation *scaStorageLocation
ScaStorageShare *scaStorageShare
ScaStorageShareVisit *scaStorageShareVisit
ScaStorageTag *scaStorageTag
ScaStorageTagInfo *scaStorageTagInfo
ScaStorageThumb *scaStorageThumb
@@ -53,6 +55,8 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
ScaStorageConfig = &Q.ScaStorageConfig
ScaStorageInfo = &Q.ScaStorageInfo
ScaStorageLocation = &Q.ScaStorageLocation
ScaStorageShare = &Q.ScaStorageShare
ScaStorageShareVisit = &Q.ScaStorageShareVisit
ScaStorageTag = &Q.ScaStorageTag
ScaStorageTagInfo = &Q.ScaStorageTagInfo
ScaStorageThumb = &Q.ScaStorageThumb
@@ -77,6 +81,8 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
ScaStorageConfig: newScaStorageConfig(db, opts...),
ScaStorageInfo: newScaStorageInfo(db, opts...),
ScaStorageLocation: newScaStorageLocation(db, opts...),
ScaStorageShare: newScaStorageShare(db, opts...),
ScaStorageShareVisit: newScaStorageShareVisit(db, opts...),
ScaStorageTag: newScaStorageTag(db, opts...),
ScaStorageTagInfo: newScaStorageTagInfo(db, opts...),
ScaStorageThumb: newScaStorageThumb(db, opts...),
@@ -102,6 +108,8 @@ type Query struct {
ScaStorageConfig scaStorageConfig
ScaStorageInfo scaStorageInfo
ScaStorageLocation scaStorageLocation
ScaStorageShare scaStorageShare
ScaStorageShareVisit scaStorageShareVisit
ScaStorageTag scaStorageTag
ScaStorageTagInfo scaStorageTagInfo
ScaStorageThumb scaStorageThumb
@@ -128,6 +136,8 @@ func (q *Query) clone(db *gorm.DB) *Query {
ScaStorageConfig: q.ScaStorageConfig.clone(db),
ScaStorageInfo: q.ScaStorageInfo.clone(db),
ScaStorageLocation: q.ScaStorageLocation.clone(db),
ScaStorageShare: q.ScaStorageShare.clone(db),
ScaStorageShareVisit: q.ScaStorageShareVisit.clone(db),
ScaStorageTag: q.ScaStorageTag.clone(db),
ScaStorageTagInfo: q.ScaStorageTagInfo.clone(db),
ScaStorageThumb: q.ScaStorageThumb.clone(db),
@@ -161,6 +171,8 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
ScaStorageConfig: q.ScaStorageConfig.replaceDB(db),
ScaStorageInfo: q.ScaStorageInfo.replaceDB(db),
ScaStorageLocation: q.ScaStorageLocation.replaceDB(db),
ScaStorageShare: q.ScaStorageShare.replaceDB(db),
ScaStorageShareVisit: q.ScaStorageShareVisit.replaceDB(db),
ScaStorageTag: q.ScaStorageTag.replaceDB(db),
ScaStorageTagInfo: q.ScaStorageTagInfo.replaceDB(db),
ScaStorageThumb: q.ScaStorageThumb.replaceDB(db),
@@ -184,6 +196,8 @@ type queryCtx struct {
ScaStorageConfig IScaStorageConfigDo
ScaStorageInfo IScaStorageInfoDo
ScaStorageLocation IScaStorageLocationDo
ScaStorageShare IScaStorageShareDo
ScaStorageShareVisit IScaStorageShareVisitDo
ScaStorageTag IScaStorageTagDo
ScaStorageTagInfo IScaStorageTagInfoDo
ScaStorageThumb IScaStorageThumbDo
@@ -207,6 +221,8 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
ScaStorageConfig: q.ScaStorageConfig.WithContext(ctx),
ScaStorageInfo: q.ScaStorageInfo.WithContext(ctx),
ScaStorageLocation: q.ScaStorageLocation.WithContext(ctx),
ScaStorageShare: q.ScaStorageShare.WithContext(ctx),
ScaStorageShareVisit: q.ScaStorageShareVisit.WithContext(ctx),
ScaStorageTag: q.ScaStorageTag.WithContext(ctx),
ScaStorageTagInfo: q.ScaStorageTagInfo.WithContext(ctx),
ScaStorageThumb: q.ScaStorageThumb.WithContext(ctx),

View File

@@ -30,7 +30,7 @@ func newScaStorageAlbum(db *gorm.DB, opts ...gen.DOOption) scaStorageAlbum {
_scaStorageAlbum.ID = field.NewInt64(tableName, "id")
_scaStorageAlbum.UserID = field.NewString(tableName, "user_id")
_scaStorageAlbum.AlbumName = field.NewString(tableName, "album_name")
_scaStorageAlbum.AlbumType = field.NewString(tableName, "album_type")
_scaStorageAlbum.AlbumType = field.NewInt64(tableName, "album_type")
_scaStorageAlbum.CoverImage = field.NewString(tableName, "cover_image")
_scaStorageAlbum.CreatedAt = field.NewTime(tableName, "created_at")
_scaStorageAlbum.UpdatedAt = field.NewTime(tableName, "updated_at")
@@ -49,7 +49,7 @@ type scaStorageAlbum struct {
ID field.Int64 // 主键
UserID field.String // 用户ID
AlbumName field.String // 相册名称
AlbumType field.String // 相册类型
AlbumType field.Int64 // 相册类型(0 我的 1 分享 2 收藏)
CoverImage field.String // 封面图片
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
@@ -73,7 +73,7 @@ func (s *scaStorageAlbum) updateTableName(table string) *scaStorageAlbum {
s.ID = field.NewInt64(table, "id")
s.UserID = field.NewString(table, "user_id")
s.AlbumName = field.NewString(table, "album_name")
s.AlbumType = field.NewString(table, "album_type")
s.AlbumType = field.NewInt64(table, "album_type")
s.CoverImage = field.NewString(table, "cover_image")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")

View File

@@ -0,0 +1,429 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
)
func newScaStorageShare(db *gorm.DB, opts ...gen.DOOption) scaStorageShare {
_scaStorageShare := scaStorageShare{}
_scaStorageShare.scaStorageShareDo.UseDB(db, opts...)
_scaStorageShare.scaStorageShareDo.UseModel(&model.ScaStorageShare{})
tableName := _scaStorageShare.scaStorageShareDo.TableName()
_scaStorageShare.ALL = field.NewAsterisk(tableName)
_scaStorageShare.ID = field.NewInt64(tableName, "id")
_scaStorageShare.UserID = field.NewString(tableName, "user_id")
_scaStorageShare.AlbumID = field.NewInt64(tableName, "album_id")
_scaStorageShare.ShareCode = field.NewString(tableName, "share_code")
_scaStorageShare.ExpireTime = field.NewTime(tableName, "expire_time")
_scaStorageShare.ValidityPeriod = field.NewInt64(tableName, "validity_period")
_scaStorageShare.Status = field.NewInt64(tableName, "status")
_scaStorageShare.AccessPassword = field.NewString(tableName, "access_password")
_scaStorageShare.VisitLimit = field.NewInt64(tableName, "visit_limit")
_scaStorageShare.Version = field.NewField(tableName, "version")
_scaStorageShare.CreatedAt = field.NewTime(tableName, "created_at")
_scaStorageShare.UpdatedAt = field.NewTime(tableName, "updated_at")
_scaStorageShare.DeletedAt = field.NewField(tableName, "deleted_at")
_scaStorageShare.fillFieldMap()
return _scaStorageShare
}
// scaStorageShare 快传分享表
type scaStorageShare struct {
scaStorageShareDo
ALL field.Asterisk
ID field.Int64 // 主键
UserID field.String // 用户ID
AlbumID field.Int64 // 相册ID
ShareCode field.String // 分享码(用于访问分享链接)
ExpireTime field.Time // 过期时间
ValidityPeriod field.Int64 // 有效期
Status field.Int64 // 是否失效0 有效 -1已失效 1 永久)
AccessPassword field.String // 访问密码
VisitLimit field.Int64 // 限制次数
Version field.Field // 版本
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
fieldMap map[string]field.Expr
}
func (s scaStorageShare) Table(newTableName string) *scaStorageShare {
s.scaStorageShareDo.UseTable(newTableName)
return s.updateTableName(newTableName)
}
func (s scaStorageShare) As(alias string) *scaStorageShare {
s.scaStorageShareDo.DO = *(s.scaStorageShareDo.As(alias).(*gen.DO))
return s.updateTableName(alias)
}
func (s *scaStorageShare) updateTableName(table string) *scaStorageShare {
s.ALL = field.NewAsterisk(table)
s.ID = field.NewInt64(table, "id")
s.UserID = field.NewString(table, "user_id")
s.AlbumID = field.NewInt64(table, "album_id")
s.ShareCode = field.NewString(table, "share_code")
s.ExpireTime = field.NewTime(table, "expire_time")
s.ValidityPeriod = field.NewInt64(table, "validity_period")
s.Status = field.NewInt64(table, "status")
s.AccessPassword = field.NewString(table, "access_password")
s.VisitLimit = field.NewInt64(table, "visit_limit")
s.Version = field.NewField(table, "version")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")
s.DeletedAt = field.NewField(table, "deleted_at")
s.fillFieldMap()
return s
}
func (s *scaStorageShare) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := s.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (s *scaStorageShare) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 13)
s.fieldMap["id"] = s.ID
s.fieldMap["user_id"] = s.UserID
s.fieldMap["album_id"] = s.AlbumID
s.fieldMap["share_code"] = s.ShareCode
s.fieldMap["expire_time"] = s.ExpireTime
s.fieldMap["validity_period"] = s.ValidityPeriod
s.fieldMap["status"] = s.Status
s.fieldMap["access_password"] = s.AccessPassword
s.fieldMap["visit_limit"] = s.VisitLimit
s.fieldMap["version"] = s.Version
s.fieldMap["created_at"] = s.CreatedAt
s.fieldMap["updated_at"] = s.UpdatedAt
s.fieldMap["deleted_at"] = s.DeletedAt
}
func (s scaStorageShare) clone(db *gorm.DB) scaStorageShare {
s.scaStorageShareDo.ReplaceConnPool(db.Statement.ConnPool)
return s
}
func (s scaStorageShare) replaceDB(db *gorm.DB) scaStorageShare {
s.scaStorageShareDo.ReplaceDB(db)
return s
}
type scaStorageShareDo struct{ gen.DO }
type IScaStorageShareDo interface {
gen.SubQuery
Debug() IScaStorageShareDo
WithContext(ctx context.Context) IScaStorageShareDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IScaStorageShareDo
WriteDB() IScaStorageShareDo
As(alias string) gen.Dao
Session(config *gorm.Session) IScaStorageShareDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IScaStorageShareDo
Not(conds ...gen.Condition) IScaStorageShareDo
Or(conds ...gen.Condition) IScaStorageShareDo
Select(conds ...field.Expr) IScaStorageShareDo
Where(conds ...gen.Condition) IScaStorageShareDo
Order(conds ...field.Expr) IScaStorageShareDo
Distinct(cols ...field.Expr) IScaStorageShareDo
Omit(cols ...field.Expr) IScaStorageShareDo
Join(table schema.Tabler, on ...field.Expr) IScaStorageShareDo
LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareDo
RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareDo
Group(cols ...field.Expr) IScaStorageShareDo
Having(conds ...gen.Condition) IScaStorageShareDo
Limit(limit int) IScaStorageShareDo
Offset(offset int) IScaStorageShareDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageShareDo
Unscoped() IScaStorageShareDo
Create(values ...*model.ScaStorageShare) error
CreateInBatches(values []*model.ScaStorageShare, batchSize int) error
Save(values ...*model.ScaStorageShare) error
First() (*model.ScaStorageShare, error)
Take() (*model.ScaStorageShare, error)
Last() (*model.ScaStorageShare, error)
Find() ([]*model.ScaStorageShare, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageShare, err error)
FindInBatches(result *[]*model.ScaStorageShare, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.ScaStorageShare) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IScaStorageShareDo
Assign(attrs ...field.AssignExpr) IScaStorageShareDo
Joins(fields ...field.RelationField) IScaStorageShareDo
Preload(fields ...field.RelationField) IScaStorageShareDo
FirstOrInit() (*model.ScaStorageShare, error)
FirstOrCreate() (*model.ScaStorageShare, error)
FindByPage(offset int, limit int) (result []*model.ScaStorageShare, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IScaStorageShareDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (s scaStorageShareDo) Debug() IScaStorageShareDo {
return s.withDO(s.DO.Debug())
}
func (s scaStorageShareDo) WithContext(ctx context.Context) IScaStorageShareDo {
return s.withDO(s.DO.WithContext(ctx))
}
func (s scaStorageShareDo) ReadDB() IScaStorageShareDo {
return s.Clauses(dbresolver.Read)
}
func (s scaStorageShareDo) WriteDB() IScaStorageShareDo {
return s.Clauses(dbresolver.Write)
}
func (s scaStorageShareDo) Session(config *gorm.Session) IScaStorageShareDo {
return s.withDO(s.DO.Session(config))
}
func (s scaStorageShareDo) Clauses(conds ...clause.Expression) IScaStorageShareDo {
return s.withDO(s.DO.Clauses(conds...))
}
func (s scaStorageShareDo) Returning(value interface{}, columns ...string) IScaStorageShareDo {
return s.withDO(s.DO.Returning(value, columns...))
}
func (s scaStorageShareDo) Not(conds ...gen.Condition) IScaStorageShareDo {
return s.withDO(s.DO.Not(conds...))
}
func (s scaStorageShareDo) Or(conds ...gen.Condition) IScaStorageShareDo {
return s.withDO(s.DO.Or(conds...))
}
func (s scaStorageShareDo) Select(conds ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.Select(conds...))
}
func (s scaStorageShareDo) Where(conds ...gen.Condition) IScaStorageShareDo {
return s.withDO(s.DO.Where(conds...))
}
func (s scaStorageShareDo) Order(conds ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.Order(conds...))
}
func (s scaStorageShareDo) Distinct(cols ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.Distinct(cols...))
}
func (s scaStorageShareDo) Omit(cols ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.Omit(cols...))
}
func (s scaStorageShareDo) Join(table schema.Tabler, on ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.Join(table, on...))
}
func (s scaStorageShareDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.LeftJoin(table, on...))
}
func (s scaStorageShareDo) RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.RightJoin(table, on...))
}
func (s scaStorageShareDo) Group(cols ...field.Expr) IScaStorageShareDo {
return s.withDO(s.DO.Group(cols...))
}
func (s scaStorageShareDo) Having(conds ...gen.Condition) IScaStorageShareDo {
return s.withDO(s.DO.Having(conds...))
}
func (s scaStorageShareDo) Limit(limit int) IScaStorageShareDo {
return s.withDO(s.DO.Limit(limit))
}
func (s scaStorageShareDo) Offset(offset int) IScaStorageShareDo {
return s.withDO(s.DO.Offset(offset))
}
func (s scaStorageShareDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageShareDo {
return s.withDO(s.DO.Scopes(funcs...))
}
func (s scaStorageShareDo) Unscoped() IScaStorageShareDo {
return s.withDO(s.DO.Unscoped())
}
func (s scaStorageShareDo) Create(values ...*model.ScaStorageShare) error {
if len(values) == 0 {
return nil
}
return s.DO.Create(values)
}
func (s scaStorageShareDo) CreateInBatches(values []*model.ScaStorageShare, batchSize int) error {
return s.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (s scaStorageShareDo) Save(values ...*model.ScaStorageShare) error {
if len(values) == 0 {
return nil
}
return s.DO.Save(values)
}
func (s scaStorageShareDo) First() (*model.ScaStorageShare, error) {
if result, err := s.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShare), nil
}
}
func (s scaStorageShareDo) Take() (*model.ScaStorageShare, error) {
if result, err := s.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShare), nil
}
}
func (s scaStorageShareDo) Last() (*model.ScaStorageShare, error) {
if result, err := s.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShare), nil
}
}
func (s scaStorageShareDo) Find() ([]*model.ScaStorageShare, error) {
result, err := s.DO.Find()
return result.([]*model.ScaStorageShare), err
}
func (s scaStorageShareDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageShare, err error) {
buf := make([]*model.ScaStorageShare, 0, batchSize)
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (s scaStorageShareDo) FindInBatches(result *[]*model.ScaStorageShare, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return s.DO.FindInBatches(result, batchSize, fc)
}
func (s scaStorageShareDo) Attrs(attrs ...field.AssignExpr) IScaStorageShareDo {
return s.withDO(s.DO.Attrs(attrs...))
}
func (s scaStorageShareDo) Assign(attrs ...field.AssignExpr) IScaStorageShareDo {
return s.withDO(s.DO.Assign(attrs...))
}
func (s scaStorageShareDo) Joins(fields ...field.RelationField) IScaStorageShareDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Joins(_f))
}
return &s
}
func (s scaStorageShareDo) Preload(fields ...field.RelationField) IScaStorageShareDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Preload(_f))
}
return &s
}
func (s scaStorageShareDo) FirstOrInit() (*model.ScaStorageShare, error) {
if result, err := s.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShare), nil
}
}
func (s scaStorageShareDo) FirstOrCreate() (*model.ScaStorageShare, error) {
if result, err := s.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShare), nil
}
}
func (s scaStorageShareDo) FindByPage(offset int, limit int) (result []*model.ScaStorageShare, count int64, err error) {
result, err = s.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = s.Offset(-1).Limit(-1).Count()
return
}
func (s scaStorageShareDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = s.Count()
if err != nil {
return
}
err = s.Offset(offset).Limit(limit).Scan(result)
return
}
func (s scaStorageShareDo) Scan(result interface{}) (err error) {
return s.DO.Scan(result)
}
func (s scaStorageShareDo) Delete(models ...*model.ScaStorageShare) (result gen.ResultInfo, err error) {
return s.DO.Delete(models)
}
func (s *scaStorageShareDo) withDO(do gen.Dao) *scaStorageShareDo {
s.DO = *do.(*gen.DO)
return s
}

View File

@@ -0,0 +1,409 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
)
func newScaStorageShareVisit(db *gorm.DB, opts ...gen.DOOption) scaStorageShareVisit {
_scaStorageShareVisit := scaStorageShareVisit{}
_scaStorageShareVisit.scaStorageShareVisitDo.UseDB(db, opts...)
_scaStorageShareVisit.scaStorageShareVisitDo.UseModel(&model.ScaStorageShareVisit{})
tableName := _scaStorageShareVisit.scaStorageShareVisitDo.TableName()
_scaStorageShareVisit.ALL = field.NewAsterisk(tableName)
_scaStorageShareVisit.ID = field.NewInt64(tableName, "id")
_scaStorageShareVisit.UserID = field.NewString(tableName, "user_id")
_scaStorageShareVisit.ShareID = field.NewInt64(tableName, "share_id")
_scaStorageShareVisit.Views = field.NewInt64(tableName, "views")
_scaStorageShareVisit.Version = field.NewField(tableName, "version")
_scaStorageShareVisit.CreatedAt = field.NewTime(tableName, "created_at")
_scaStorageShareVisit.UpdatedAt = field.NewTime(tableName, "updated_at")
_scaStorageShareVisit.DeletedAt = field.NewField(tableName, "deleted_at")
_scaStorageShareVisit.fillFieldMap()
return _scaStorageShareVisit
}
// scaStorageShareVisit 分享浏览记录
type scaStorageShareVisit struct {
scaStorageShareVisitDo
ALL field.Asterisk
ID field.Int64 // 主键
UserID field.String // 用户ID
ShareID field.Int64 // 分享ID
Views field.Int64 // 浏览次数
Version field.Field // 版本
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
fieldMap map[string]field.Expr
}
func (s scaStorageShareVisit) Table(newTableName string) *scaStorageShareVisit {
s.scaStorageShareVisitDo.UseTable(newTableName)
return s.updateTableName(newTableName)
}
func (s scaStorageShareVisit) As(alias string) *scaStorageShareVisit {
s.scaStorageShareVisitDo.DO = *(s.scaStorageShareVisitDo.As(alias).(*gen.DO))
return s.updateTableName(alias)
}
func (s *scaStorageShareVisit) updateTableName(table string) *scaStorageShareVisit {
s.ALL = field.NewAsterisk(table)
s.ID = field.NewInt64(table, "id")
s.UserID = field.NewString(table, "user_id")
s.ShareID = field.NewInt64(table, "share_id")
s.Views = field.NewInt64(table, "views")
s.Version = field.NewField(table, "version")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")
s.DeletedAt = field.NewField(table, "deleted_at")
s.fillFieldMap()
return s
}
func (s *scaStorageShareVisit) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := s.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (s *scaStorageShareVisit) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 8)
s.fieldMap["id"] = s.ID
s.fieldMap["user_id"] = s.UserID
s.fieldMap["share_id"] = s.ShareID
s.fieldMap["views"] = s.Views
s.fieldMap["version"] = s.Version
s.fieldMap["created_at"] = s.CreatedAt
s.fieldMap["updated_at"] = s.UpdatedAt
s.fieldMap["deleted_at"] = s.DeletedAt
}
func (s scaStorageShareVisit) clone(db *gorm.DB) scaStorageShareVisit {
s.scaStorageShareVisitDo.ReplaceConnPool(db.Statement.ConnPool)
return s
}
func (s scaStorageShareVisit) replaceDB(db *gorm.DB) scaStorageShareVisit {
s.scaStorageShareVisitDo.ReplaceDB(db)
return s
}
type scaStorageShareVisitDo struct{ gen.DO }
type IScaStorageShareVisitDo interface {
gen.SubQuery
Debug() IScaStorageShareVisitDo
WithContext(ctx context.Context) IScaStorageShareVisitDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IScaStorageShareVisitDo
WriteDB() IScaStorageShareVisitDo
As(alias string) gen.Dao
Session(config *gorm.Session) IScaStorageShareVisitDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IScaStorageShareVisitDo
Not(conds ...gen.Condition) IScaStorageShareVisitDo
Or(conds ...gen.Condition) IScaStorageShareVisitDo
Select(conds ...field.Expr) IScaStorageShareVisitDo
Where(conds ...gen.Condition) IScaStorageShareVisitDo
Order(conds ...field.Expr) IScaStorageShareVisitDo
Distinct(cols ...field.Expr) IScaStorageShareVisitDo
Omit(cols ...field.Expr) IScaStorageShareVisitDo
Join(table schema.Tabler, on ...field.Expr) IScaStorageShareVisitDo
LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareVisitDo
RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareVisitDo
Group(cols ...field.Expr) IScaStorageShareVisitDo
Having(conds ...gen.Condition) IScaStorageShareVisitDo
Limit(limit int) IScaStorageShareVisitDo
Offset(offset int) IScaStorageShareVisitDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageShareVisitDo
Unscoped() IScaStorageShareVisitDo
Create(values ...*model.ScaStorageShareVisit) error
CreateInBatches(values []*model.ScaStorageShareVisit, batchSize int) error
Save(values ...*model.ScaStorageShareVisit) error
First() (*model.ScaStorageShareVisit, error)
Take() (*model.ScaStorageShareVisit, error)
Last() (*model.ScaStorageShareVisit, error)
Find() ([]*model.ScaStorageShareVisit, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageShareVisit, err error)
FindInBatches(result *[]*model.ScaStorageShareVisit, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.ScaStorageShareVisit) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IScaStorageShareVisitDo
Assign(attrs ...field.AssignExpr) IScaStorageShareVisitDo
Joins(fields ...field.RelationField) IScaStorageShareVisitDo
Preload(fields ...field.RelationField) IScaStorageShareVisitDo
FirstOrInit() (*model.ScaStorageShareVisit, error)
FirstOrCreate() (*model.ScaStorageShareVisit, error)
FindByPage(offset int, limit int) (result []*model.ScaStorageShareVisit, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IScaStorageShareVisitDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (s scaStorageShareVisitDo) Debug() IScaStorageShareVisitDo {
return s.withDO(s.DO.Debug())
}
func (s scaStorageShareVisitDo) WithContext(ctx context.Context) IScaStorageShareVisitDo {
return s.withDO(s.DO.WithContext(ctx))
}
func (s scaStorageShareVisitDo) ReadDB() IScaStorageShareVisitDo {
return s.Clauses(dbresolver.Read)
}
func (s scaStorageShareVisitDo) WriteDB() IScaStorageShareVisitDo {
return s.Clauses(dbresolver.Write)
}
func (s scaStorageShareVisitDo) Session(config *gorm.Session) IScaStorageShareVisitDo {
return s.withDO(s.DO.Session(config))
}
func (s scaStorageShareVisitDo) Clauses(conds ...clause.Expression) IScaStorageShareVisitDo {
return s.withDO(s.DO.Clauses(conds...))
}
func (s scaStorageShareVisitDo) Returning(value interface{}, columns ...string) IScaStorageShareVisitDo {
return s.withDO(s.DO.Returning(value, columns...))
}
func (s scaStorageShareVisitDo) Not(conds ...gen.Condition) IScaStorageShareVisitDo {
return s.withDO(s.DO.Not(conds...))
}
func (s scaStorageShareVisitDo) Or(conds ...gen.Condition) IScaStorageShareVisitDo {
return s.withDO(s.DO.Or(conds...))
}
func (s scaStorageShareVisitDo) Select(conds ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Select(conds...))
}
func (s scaStorageShareVisitDo) Where(conds ...gen.Condition) IScaStorageShareVisitDo {
return s.withDO(s.DO.Where(conds...))
}
func (s scaStorageShareVisitDo) Order(conds ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Order(conds...))
}
func (s scaStorageShareVisitDo) Distinct(cols ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Distinct(cols...))
}
func (s scaStorageShareVisitDo) Omit(cols ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Omit(cols...))
}
func (s scaStorageShareVisitDo) Join(table schema.Tabler, on ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Join(table, on...))
}
func (s scaStorageShareVisitDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.LeftJoin(table, on...))
}
func (s scaStorageShareVisitDo) RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.RightJoin(table, on...))
}
func (s scaStorageShareVisitDo) Group(cols ...field.Expr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Group(cols...))
}
func (s scaStorageShareVisitDo) Having(conds ...gen.Condition) IScaStorageShareVisitDo {
return s.withDO(s.DO.Having(conds...))
}
func (s scaStorageShareVisitDo) Limit(limit int) IScaStorageShareVisitDo {
return s.withDO(s.DO.Limit(limit))
}
func (s scaStorageShareVisitDo) Offset(offset int) IScaStorageShareVisitDo {
return s.withDO(s.DO.Offset(offset))
}
func (s scaStorageShareVisitDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageShareVisitDo {
return s.withDO(s.DO.Scopes(funcs...))
}
func (s scaStorageShareVisitDo) Unscoped() IScaStorageShareVisitDo {
return s.withDO(s.DO.Unscoped())
}
func (s scaStorageShareVisitDo) Create(values ...*model.ScaStorageShareVisit) error {
if len(values) == 0 {
return nil
}
return s.DO.Create(values)
}
func (s scaStorageShareVisitDo) CreateInBatches(values []*model.ScaStorageShareVisit, batchSize int) error {
return s.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (s scaStorageShareVisitDo) Save(values ...*model.ScaStorageShareVisit) error {
if len(values) == 0 {
return nil
}
return s.DO.Save(values)
}
func (s scaStorageShareVisitDo) First() (*model.ScaStorageShareVisit, error) {
if result, err := s.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShareVisit), nil
}
}
func (s scaStorageShareVisitDo) Take() (*model.ScaStorageShareVisit, error) {
if result, err := s.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShareVisit), nil
}
}
func (s scaStorageShareVisitDo) Last() (*model.ScaStorageShareVisit, error) {
if result, err := s.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShareVisit), nil
}
}
func (s scaStorageShareVisitDo) Find() ([]*model.ScaStorageShareVisit, error) {
result, err := s.DO.Find()
return result.([]*model.ScaStorageShareVisit), err
}
func (s scaStorageShareVisitDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageShareVisit, err error) {
buf := make([]*model.ScaStorageShareVisit, 0, batchSize)
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (s scaStorageShareVisitDo) FindInBatches(result *[]*model.ScaStorageShareVisit, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return s.DO.FindInBatches(result, batchSize, fc)
}
func (s scaStorageShareVisitDo) Attrs(attrs ...field.AssignExpr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Attrs(attrs...))
}
func (s scaStorageShareVisitDo) Assign(attrs ...field.AssignExpr) IScaStorageShareVisitDo {
return s.withDO(s.DO.Assign(attrs...))
}
func (s scaStorageShareVisitDo) Joins(fields ...field.RelationField) IScaStorageShareVisitDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Joins(_f))
}
return &s
}
func (s scaStorageShareVisitDo) Preload(fields ...field.RelationField) IScaStorageShareVisitDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Preload(_f))
}
return &s
}
func (s scaStorageShareVisitDo) FirstOrInit() (*model.ScaStorageShareVisit, error) {
if result, err := s.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShareVisit), nil
}
}
func (s scaStorageShareVisitDo) FirstOrCreate() (*model.ScaStorageShareVisit, error) {
if result, err := s.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageShareVisit), nil
}
}
func (s scaStorageShareVisitDo) FindByPage(offset int, limit int) (result []*model.ScaStorageShareVisit, count int64, err error) {
result, err = s.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = s.Offset(-1).Limit(-1).Count()
return
}
func (s scaStorageShareVisitDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = s.Count()
if err != nil {
return
}
err = s.Offset(offset).Limit(limit).Scan(result)
return
}
func (s scaStorageShareVisitDo) Scan(result interface{}) (err error) {
return s.DO.Scan(result)
}
func (s scaStorageShareVisitDo) Delete(models ...*model.ScaStorageShareVisit) (result gen.ResultInfo, err error) {
return s.DO.Delete(models)
}
func (s *scaStorageShareVisitDo) withDO(do gen.Dao) *scaStorageShareVisitDo {
s.DO = *do.(*gen.DO)
return s
}

View File

@@ -42,6 +42,7 @@ func newScaStorageThumb(db *gorm.DB, opts ...gen.DOOption) scaStorageThumb {
return _scaStorageThumb
}
// scaStorageThumb 缩略图表
type scaStorageThumb struct {
scaStorageThumbDo