fix
This commit is contained in:
@@ -6,12 +6,12 @@ import (
|
||||
|
||||
// fs_product_template_tags 模板标签表
|
||||
type FsProductTemplateTags struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
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"` // 创建时间
|
||||
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
TemplateTag *string `gorm:"unique_key;default:'';" json:"template_tag"` // 标题
|
||||
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息
|
||||
}
|
||||
type FsProductTemplateTagsModel struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -36,7 +36,7 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag
|
||||
if len(tagNames) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", tagNames, 1)
|
||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` in (?) and `status` = ?", tagNames, 1)
|
||||
if orderBy != "" {
|
||||
db = db.Order(orderBy)
|
||||
}
|
||||
@@ -44,6 +44,6 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag
|
||||
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
|
||||
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type FsProductTemplateV2 struct {
|
||||
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
Tag *string `gorm:"default:'';" json:"tag"` //
|
||||
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
|
||||
GroupOptions *string `gorm:"default:'';" json:"group_options"` //
|
||||
|
||||
@@ -115,7 +115,7 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont
|
||||
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, templateTag).
|
||||
Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag).
|
||||
Where("t.status = ? and t.is_del = ?", 1, 0).
|
||||
Where("s.status = ?", 1).
|
||||
Order("s.sort ASC").
|
||||
@@ -126,7 +126,7 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont
|
||||
if len(modelIds) == 0 {
|
||||
return
|
||||
}
|
||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1)
|
||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `template_tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1)
|
||||
if len(fields) != 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont
|
||||
// 获取产品在指定模板标签下的所有模板
|
||||
func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||
Where("tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0)
|
||||
Where("template_tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user