Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
@@ -5,7 +5,7 @@ import "context"
|
||||
// TODO: 使用model的属性做你想做的
|
||||
type GetTagPropByProductIdsWithProductTagRsp struct {
|
||||
FsProductTagProp
|
||||
Title string `json:"title"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
}
|
||||
|
||||
func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context.Context, productIds []int64) (resp []GetTagPropByProductIdsWithProductTagRsp, err error) {
|
||||
@@ -14,7 +14,7 @@ func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context
|
||||
}
|
||||
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").
|
||||
Select("p.*,t.template_tag as template_tag").
|
||||
Where("p.product_id in (?) and p.status = ? and t.status = ?", productIds, 1, 1).
|
||||
Find(&resp).Error
|
||||
return resp, err
|
||||
|
||||
@@ -6,26 +6,26 @@ import (
|
||||
|
||||
// fs_product_template_element 云渲染配置表
|
||||
type FsProductTemplateElement struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
||||
Main *string `gorm:"default:'';" json:"main"` //
|
||||
Second *string `gorm:"default:'';" json:"second"` //
|
||||
Base *string `gorm:"default:'';" json:"base"` //
|
||||
Paper *string `gorm:"default:'';" json:"paper"` //
|
||||
Spoon *string `gorm:"default:'';" json:"spoon"` //
|
||||
Fork *string `gorm:"default:'';" json:"fork"` //
|
||||
Toothpick *string `gorm:"default:'';" json:"toothpick"` //
|
||||
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` //
|
||||
Shadow *string `gorm:"default:'';" json:"shadow"` //
|
||||
Cover *string `gorm:"default:'';" json:"cover"` //
|
||||
Cover1 *string `gorm:"default:'';" json:"cover1"` //
|
||||
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||
Light *int64 `gorm:"default:0;" json:"light"` //
|
||||
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
||||
Scale *string `gorm:"default:'';" json:"scale"` //
|
||||
ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据
|
||||
Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||
ModelId *int64 `gorm:"index;default:0;" json:"model_id"` // 模型id
|
||||
Main *string `gorm:"default:'';" json:"main"` //
|
||||
Second *string `gorm:"default:'';" json:"second"` //
|
||||
Base *string `gorm:"default:'';" json:"base"` //
|
||||
Paper *string `gorm:"default:'';" json:"paper"` //
|
||||
Spoon *string `gorm:"default:'';" json:"spoon"` //
|
||||
Fork *string `gorm:"default:'';" json:"fork"` //
|
||||
Toothpick *string `gorm:"default:'';" json:"toothpick"` //
|
||||
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` //
|
||||
Shadow *string `gorm:"default:'';" json:"shadow"` //
|
||||
Cover *string `gorm:"default:'';" json:"cover"` //
|
||||
Cover1 *string `gorm:"default:'';" json:"cover1"` //
|
||||
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||
Light *int64 `gorm:"default:0;" json:"light"` //
|
||||
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
||||
Scale *string `gorm:"default:'';" json:"scale"` //
|
||||
ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据
|
||||
Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组
|
||||
}
|
||||
type FsProductTemplateElementModel struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -7,7 +7,7 @@ import "context"
|
||||
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).
|
||||
Where("`model_id` = ?", modelId).
|
||||
Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -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,14 +36,18 @@ 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)
|
||||
}
|
||||
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
|
||||
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string, fields ...string) (resp *FsProductTemplateTags, err error) {
|
||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1)
|
||||
if len(fields) != 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -20,10 +20,9 @@ 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"` //
|
||||
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
|
||||
}
|
||||
type FsProductTemplateV2Model struct {
|
||||
|
||||
@@ -113,9 +113,9 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co
|
||||
// 获取第一个尺寸下的模板
|
||||
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").
|
||||
Joins("inner 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])
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ type FsResource struct {
|
||||
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
|
||||
ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内
|
||||
BucketName *string `gorm:"default:'';" json:"bucket_name"` // 存储桶名: 1=持久 2=缓存
|
||||
Source *string `gorm:"default:'';" json:"source"` // 来源
|
||||
}
|
||||
type FsResourceModel struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -16,8 +16,8 @@ type FsTags struct {
|
||||
Icon *string `gorm:"default:'';" json:"icon"` // 标签图标
|
||||
Status *int64 `gorm:"default:1;" json:"status"` // 状态 1:可用
|
||||
Description *string `gorm:"default:'';" json:"description"` // 介绍 Seo
|
||||
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` //
|
||||
RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` //
|
||||
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐产品id例如: 1,3,4,5
|
||||
RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` // 推荐排序例如:1324
|
||||
Category *int64 `gorm:"default:1;" json:"category"` // 分类:1前台用的 2后台用的
|
||||
}
|
||||
type FsTagsModel struct {
|
||||
|
||||
Reference in New Issue
Block a user