Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
// fs_product_template_tags 模板标签表
|
||||
type FsProductTemplateTags struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
Title *string `gorm:"default:'';" json:"title"` // 标题
|
||||
Title *string `gorm:"unique_key;default:'';" json:"title"` // 标题
|
||||
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||
|
||||
@@ -32,14 +32,18 @@ func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit i
|
||||
err = db.Offset(offset).Limit(limit).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (pt *FsProductTemplateTagsModel) GetListByTitles(ctx context.Context, titles []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) {
|
||||
if len(titles) == 0 {
|
||||
func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tagNames []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) {
|
||||
if len(tagNames) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", titles, 1)
|
||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", tagNames, 1)
|
||||
if orderBy != "" {
|
||||
db = db.Order(orderBy)
|
||||
}
|
||||
err = db.Limit(limit).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string) (resp *FsProductTemplateTags, err error) {
|
||||
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` = ? and `status` = ?", tagName, 1).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ type FsProductTemplateV2 struct {
|
||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
|
||||
GroupOptions *string `gorm:"default:'';" json:"group_options"` //
|
||||
Version *int64 `gorm:"default:0;" json:"version"` //
|
||||
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
|
||||
}
|
||||
type FsProductTemplateV2Model struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -111,11 +111,11 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co
|
||||
}
|
||||
|
||||
// 获取第一个尺寸下的模板
|
||||
func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, tagId string) (resp *FsProductTemplateV2, err error) {
|
||||
func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Table(t.name+" as t").
|
||||
Joins("left join fs_product_size as s on t.product_id = s.product_id").
|
||||
Select("t.*").
|
||||
Where("t.product_id = ? and t.tag = ? ", productId, tagId).
|
||||
Where("t.product_id = ? and t.tag = ? ", productId, templateTag).
|
||||
Where("t.status = ? and t.is_del = ?", 1, 0).
|
||||
Where("s.status = ?", 1).
|
||||
Order("s.sort ASC").
|
||||
|
||||
Reference in New Issue
Block a user