This commit is contained in:
laodaming 2023-08-02 15:06:04 +08:00
parent c08c1e7eba
commit 4aaa5c169d
6 changed files with 37 additions and 0 deletions

View File

@ -18,6 +18,7 @@ type FsTags struct {
Description *string `gorm:"default:'';" json:"description"` // 介绍 Seo
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` //
RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` //
Categroy *int64 `gorm:"default:1;" json:"categroy"` // 分类1前台用的 2后台用的
}
type FsTagsModel struct {
db *gorm.DB

View File

@ -36,6 +36,7 @@ type GetAllTagByParamsReq struct {
OrderBy string
LevelPrefixLeftLike string //右模糊
WithChild bool //是否包含子层级
Category int64
}
func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByParamsReq) (resp []FsTags, err error) {
@ -46,6 +47,9 @@ func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByPara
if req.Status != nil {
db = db.Where("`status` = ?", *req.Status)
}
if req.Category != 0 {
db = db.Where("`category` = ?", req.Category)
}
if req.LevelPrefixLeftLike != "" {
//查询子集
if req.WithChild {

View File

@ -0,0 +1,24 @@
package gmodel
import (
"gorm.io/gorm"
)
// fs_user_material 用户素材表
type FsUserMaterial struct {
Id int64 `gorm:"primary_key;default:0;" json:"id"` // 用户 ID
Module *string `gorm:"default:'';" json:"module"` // 所属模块
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID
ResourceId *string `gorm:"default:'';" json:"resource_id"` // 资源ID
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 上传时间
}
type FsUserMaterialModel struct {
db *gorm.DB
name string
}
func NewFsUserMaterialModel(db *gorm.DB) *FsUserMaterialModel {
return &FsUserMaterialModel{db: db, name: "fs_user_material"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -90,6 +90,7 @@ type AllModelsGen struct {
FsTrade *FsTradeModel // fs_trade
FsUser *FsUserModel // fs_user 用户表
FsUserDesign *FsUserDesignModel // fs_user_design 废弃表
FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表
FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存
FsWebSet *FsWebSetModel // fs_web_set 网站配置表
@ -183,6 +184,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
FsTrade: NewFsTradeModel(gdb),
FsUser: NewFsUserModel(gdb),
FsUserDesign: NewFsUserDesignModel(gdb),
FsUserMaterial: NewFsUserMaterialModel(gdb),
FsUserStock: NewFsUserStockModel(gdb),
FsWebSet: NewFsWebSetModel(gdb),
}

View File

@ -50,6 +50,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
Status: &tStatus,
OrderBy: "`sort` DESC",
WithChild: true, //需要子集
Category: 1, //前台网站用的
}
//传入分类id
if req.Cid > 0 {
@ -62,6 +63,9 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info")
}
if *tagData.Categroy != 1 {
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag")
}
tReq.LevelPrefixLeftLike = *tagData.LevelPrefix
}
tagList, err := l.svcCtx.AllModels.FsTags.GetAllTagByParams(l.ctx, tReq)