Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth

This commit is contained in:
eson
2023-08-09 10:29:53 +08:00
15 changed files with 261 additions and 126 deletions

View File

@@ -6,12 +6,12 @@ import (
// fs_product_tag_prop 产品标签相关属性表
type FsProductTagProp struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
TagId *int64 `gorm:"default:0;" json:"tag_id"` // 模板标签id
Cover *string `gorm:"default:'';" json:"cover"` //
Status *int64 `gorm:"default:1;" json:"status"` // 状态
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
TemplateTagId *int64 `gorm:"default:0;" json:"template_tag_id"` // 模板标签id
Cover *string `gorm:"default:'';" json:"cover"` //
Status *int64 `gorm:"default:1;" json:"status"` // 状态
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
}
type FsProductTagPropModel struct {
db *gorm.DB

View File

@@ -1,2 +1,21 @@
package gmodel
// TODO: 使用model的属性做你想做的
import "context"
// TODO: 使用model的属性做你想做的
type GetTagPropByProductIdsWithProductTagRsp struct {
FsProductTagProp
Title string `json:"title"`
}
func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context.Context, productIds []int64) (resp []GetTagPropByProductIdsWithProductTagRsp, err error) {
if len(productIds) == 0 {
return
}
err = p.db.WithContext(ctx).Table(p.name+" as p ").
Joins("left join fs_product_template_tags as t on p.template_tag_id = t.id").
Select("p.*,t.title as title").
Where("p.product_id in (?) and p.status = ? and t.status = ?", productIds, 1, 1).
Find(&resp).Error
return resp, err
}

View File

@@ -1,3 +1,13 @@
package gmodel
import "context"
// TODO: 使用model的属性做你想做的
func (e *FsProductTemplateElementModel) FindOneByModelId(ctx context.Context, modelId int64) (resp *FsProductTemplateElement, err error) {
err = e.db.WithContext(ctx).Model(&FsProductTemplateElement{}).
//以前的神仙员工把表model_id变成product_template_id
Where("`product_template_id` = ?", modelId).
Take(&resp).Error
return resp, err
}

View File

@@ -57,6 +57,9 @@ func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelI
return
}
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `is_del` = ? and `status` = ?", modelIds, 0, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
switch orderBy {
case "":
db = db.Order("id DESC")
@@ -119,3 +122,20 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont
Take(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Context, modelIds []int64, templateTag string, orderBy string, fields ...string) (resp []FsProductTemplateV2, err error) {
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)
if len(fields) != 0 {
db = db.Select(fields[0])
}
switch orderBy {
case "":
db = db.Order("id DESC")
default:
db = db.Order(orderBy)
}
err = db.Find(&resp).Error
return resp, err
}