fix
This commit is contained in:
28
model/gmodel/fsaddressmodel.go
Executable file
28
model/gmodel/fsaddressmodel.go
Executable file
@@ -0,0 +1,28 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsAddress struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID
|
||||
Name *string `gorm:"default:''" json:"name"` // 地址名称
|
||||
FirstName *string `gorm:"default:''" json:"first_name"` // FirstName
|
||||
LastName *string `gorm:"default:''" json:"last_name"` // LastName
|
||||
Mobile *string `gorm:"default:''" json:"mobile"` // 手机号码
|
||||
Street *string `gorm:"default:''" json:"street"` // 街道
|
||||
Suite *string `gorm:"default:''" json:"suite"` // 房号
|
||||
City *string `gorm:"default:''" json:"city"` // 城市
|
||||
State *string `gorm:"default:''" json:"state"` // 州名
|
||||
Country *string `gorm:"default:''" json:"country"` // 国家
|
||||
ZipCode *string `gorm:"default:''" json:"zip_code"` // 邮编
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 1正常 0异常
|
||||
IsDefault *int64 `gorm:"default:0" json:"is_default"` // 1默认地址,0非默认地址
|
||||
}
|
||||
|
||||
type FsAddressModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsAddressModel(db *gorm.DB) *FsAddressModel {
|
||||
return &FsAddressModel{db}
|
||||
}
|
||||
42
model/gmodel/fscanteenproductmodel.go
Executable file
42
model/gmodel/fscanteenproductmodel.go
Executable file
@@ -0,0 +1,42 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsCanteenProduct struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
CanteenType *int64 `gorm:"default:0" json:"canteen_type"` // 餐厅类别id
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品id
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸id
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1启用0停用
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Sid *string `gorm:"default:''" json:"sid"` // 前端带入的id
|
||||
}
|
||||
|
||||
type FsCanteenProductModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsCanteenProductModel(db *gorm.DB) *FsCanteenProductModel {
|
||||
return &FsCanteenProductModel{db}
|
||||
}
|
||||
|
||||
func (c *FsCanteenProductModel) GetAllByCanteenTypeId(ctx context.Context, typeId int64) (resp []FsCanteenProduct, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`canteen_type` = ? and `status` = ?", typeId, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
func (c *FsCanteenProductModel) UpdateById(ctx context.Context, id int64, data *FsCanteenProduct) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` = ? ", id).Updates(&data).Error
|
||||
}
|
||||
func (c *FsCanteenProductModel) UpdateByIdArr(ctx context.Context, ids []int64, data *FsCanteenProduct) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` in (?) ", ids).Updates(&data).Error
|
||||
}
|
||||
func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProduct) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Create(data).Error
|
||||
}
|
||||
30
model/gmodel/fscanteentypemodel.go
Executable file
30
model/gmodel/fscanteentypemodel.go
Executable file
@@ -0,0 +1,30 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsCanteenType struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Name *string `gorm:"default:''" json:"name"` // 餐厅名字
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1启用0停用
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsCanteenTypeModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsCanteenTypeModel(db *gorm.DB) *FsCanteenTypeModel {
|
||||
return &FsCanteenTypeModel{db}
|
||||
}
|
||||
|
||||
func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp FsCanteenType, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ? and `status` = ? ", id, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCanteenType{}, err
|
||||
}
|
||||
return
|
||||
}
|
||||
24
model/gmodel/fsfaqmodel.go
Executable file
24
model/gmodel/fsfaqmodel.go
Executable file
@@ -0,0 +1,24 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsFaq struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
TagId *int64 `gorm:"default:0" json:"tag_id"` // 分类ID
|
||||
TagName *string `gorm:"default:''" json:"tag_name"` // 分类名称
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Content *string `gorm:"default:''" json:"content"` // 内容
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态(0:禁用,1:启用)
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Ctime *sql.NullInt64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsFaqModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsFaqModel(db *gorm.DB) *FsFaqModel {
|
||||
return &FsFaqModel{db}
|
||||
}
|
||||
18
model/gmodel/fsfontmodel.go
Executable file
18
model/gmodel/fsfontmodel.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsFont struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // id
|
||||
Title *string `gorm:"default:''" json:"title"` // 字体名字
|
||||
LinuxFontname *string `gorm:"default:''" json:"linux_fontname"` // linux对应字体名
|
||||
FilePath *string `gorm:"default:''" json:"file_path"` // 字体文件路径
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
}
|
||||
type FsFontModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsFontModel(db *gorm.DB) *FsFontModel {
|
||||
return &FsFontModel{db}
|
||||
}
|
||||
83
model/gmodel/fsproductmodel.go
Executable file
83
model/gmodel/fsproductmodel.go
Executable file
@@ -0,0 +1,83 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsProduct struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Sn *string `gorm:"default:''" json:"sn"` // 商品编号 P98f087j
|
||||
Type *int64 `gorm:"default:0" json:"type"` // 分类ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 名称
|
||||
TitleCn *string `gorm:"default:''" json:"title_cn"` // 中文名称
|
||||
Cover *string `gorm:"default:''" json:"cover"` // 封面图
|
||||
Imgs *string `gorm:"default:''" json:"imgs"` // 一个或多个介绍图或视频
|
||||
Keywords *string `gorm:"default:''" json:"keywords"` // 关键字
|
||||
Intro *string `gorm:"default:''" json:"intro"` // 简要描述
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
SelledNum *int64 `gorm:"default:0" json:"selled_num"` // 已卖数量
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
View *int64 `gorm:"default:0" json:"view"` // 浏览量
|
||||
SizeIds *string `gorm:"default:''" json:"size_ids"` // 尺寸 1,2,3,4
|
||||
MaterialIds *string `gorm:"default:''" json:"material_ids"` // 材质 1,2,3
|
||||
TagIds *string `gorm:"default:''" json:"tag_ids"` // 标签 逗号间隔
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 弃用
|
||||
ProduceDays *int64 `gorm:"default:0" json:"produce_days"` // 生产天数
|
||||
DeliveryDays *int64 `gorm:"default:0" json:"delivery_days"` // 运送天数
|
||||
CoverImg *string `gorm:"default:''" json:"cover_img"` // 背景图
|
||||
IsShelf *int64 `gorm:"default:1" json:"is_shelf"` // 是否上架
|
||||
IsRecommend *int64 `gorm:"default:1" json:"is_recommend"` // 是否推荐
|
||||
IsHot *int64 `gorm:"default:1" json:"is_hot"` // 是否热销
|
||||
IsProtection *int64 `gorm:"default:1" json:"is_protection"` // 是否环保
|
||||
IsMicrowave *int64 `gorm:"default:1" json:"is_microwave"` // 是否可微波炉
|
||||
IsDel *int64 `gorm:"default:0" json:"is_del"` // 是否删除
|
||||
RecommendProduct *string `gorm:"default:''" json:"recommend_product"` // 推荐产品id例如: 1,3,4,5
|
||||
RecommendProductSort *string `gorm:"default:''" json:"recommend_product_sort"` // 推荐排序例如:1324
|
||||
SceneIds *string `gorm:"default:''" json:"scene_ids"` // 关联的场景id
|
||||
}
|
||||
type FsProductModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductModel(db *gorm.DB) *FsProductModel {
|
||||
return &FsProductModel{db}
|
||||
}
|
||||
|
||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
||||
db := p.db.Model(&FsProduct{}).
|
||||
Where("`id` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productIds, 0, 1, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
db = db.Order("sort ASC")
|
||||
case "sort-desc":
|
||||
db = db.Order("sort DESC")
|
||||
}
|
||||
if err = db.Find(&resp).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *FsProductModel) GetProductListByTypeIds(ctx context.Context, productTypes []int64, sort string) (resp []FsProduct, err error) {
|
||||
db := p.db.WithContext(ctx).Model(&FsProductModel{}).Where("`type` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productTypes, 0, 1, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
db = db.Order("`sort` ASC")
|
||||
case "sort-desc":
|
||||
db = db.Order("`sort` DESC")
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (resp []FsProduct, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProductModel{}).
|
||||
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
18
model/gmodel/fsproductmodel3dlightmodel.go
Executable file
18
model/gmodel/fsproductmodel3dlightmodel.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsProductModel3dLight struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Name *string `gorm:"default:''" json:"name"` // 灯光名称
|
||||
Info *string `gorm:"default:''" json:"info"` // 灯光数据(json格式)
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态值(1:显示,0:删除)
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 创建时间
|
||||
}
|
||||
type FsProductModel3dLightModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductModel3dLightModel(db *gorm.DB) *FsProductModel3dLightModel {
|
||||
return &FsProductModel3dLightModel{db}
|
||||
}
|
||||
31
model/gmodel/fsproductmodel3dmodel.go
Executable file
31
model/gmodel/fsproductmodel3dmodel.go
Executable file
@@ -0,0 +1,31 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsProductModel3d struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
Tag *int64 `gorm:"default:1" json:"tag"` // 类别(1:模型,2:配件,3:场景)
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Name *string `gorm:"default:''" json:"name"` // 详情页展示名称
|
||||
ModelInfo *string `gorm:"default:''" json:"model_info"` // 模型详情
|
||||
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Light *int64 `gorm:"default:0" json:"light"` // 灯光组
|
||||
LightList *string `gorm:"default:''" json:"light_list"` // 灯光备选项
|
||||
PartId *int64 `gorm:"default:0" json:"part_id"` // 配件选项id(配件就是模型的id)
|
||||
PartList *string `gorm:"default:''" json:"part_list"` // 配件备选项
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1显示 0删除
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
OptionTemplate *int64 `gorm:"default:0" json:"option_template"` // 配件绑定的公共模板
|
||||
Price *int64 `gorm:"default:0" json:"price"` // 仅配件用,配件的价格, 单位:美分
|
||||
Sku *string `gorm:"default:''" json:"sku"` // sku
|
||||
}
|
||||
type FsProductModel3dModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductModel3dModel(db *gorm.DB) *FsProductModel3dModel {
|
||||
return &FsProductModel3dModel{db}
|
||||
}
|
||||
53
model/gmodel/fsproductpricemodel.go
Executable file
53
model/gmodel/fsproductpricemodel.go
Executable file
@@ -0,0 +1,53 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsProductPrice struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Sn *string `gorm:"default:''" json:"sn"` // 唯一编码
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题描述
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
|
||||
EachBoxNum *int64 `gorm:"default:0" json:"each_box_num"` // 每一箱的个数
|
||||
EachBoxWeight *float64 `gorm:"default:0" json:"each_box_weight"` // 每一箱的重量 单位KG
|
||||
MinBuyNum *int64 `gorm:"default:0" json:"min_buy_num"` // 最少购买量
|
||||
StepNum *string `gorm:"default:''" json:"step_num"` // 数量阶梯 eg:10,20,30
|
||||
StepPrice *string `gorm:"default:''" json:"step_price"` // 价格阶梯 eg:100,50,25
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 是否可用
|
||||
IsDefault *int64 `gorm:"default:0" json:"is_default"` // 是否默认
|
||||
}
|
||||
type FsProductPriceModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductPriceModel(db *gorm.DB) *FsProductPriceModel {
|
||||
return &FsProductPriceModel{db}
|
||||
}
|
||||
|
||||
type GetPriceListByProductIdsRsp struct {
|
||||
ProductId int64 `json:"product_id"`
|
||||
Price string `json:"price"`
|
||||
}
|
||||
|
||||
func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, productIds []int64) (resp []GetPriceListByProductIdsRsp, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
db := p.db.WithContext(ctx).Model(&FsProductPriceModel{}).Select("product_id,group_concat(step_price) as price").
|
||||
Where("`product_id` in (?) and `status` = ? group by product_id", productIds, 1)
|
||||
if err = db.Find(&resp).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (p *FsProductPriceModel) GetPriceListBySizeIds(ctx context.Context, sizeIds []int64) (resp []FsProductPrice, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPriceModel{}).Where("`size_id` in (?) and `status` = ? ", sizeIds, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
61
model/gmodel/fsproductsizemodel.go
Executable file
61
model/gmodel/fsproductsizemodel.go
Executable file
@@ -0,0 +1,61 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsProductSize struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题 10*10*20
|
||||
Cover *string `gorm:"default:''" json:"cover"` // 封面图
|
||||
CoverImg *string `gorm:"default:''" json:"cover_img"` // 背景图
|
||||
Capacity *string `gorm:"default:''" json:"capacity"` // 自己填的尺寸名称
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1显示 0删除
|
||||
Sort *int64 `gorm:"default:50" json:"sort"` // 排序
|
||||
Remark *string `gorm:"default:''" json:"remark"` // 备注信息
|
||||
PartsCanDeleted *int64 `gorm:"default:1" json:"parts_can_deleted"` // 配件是否可移除 1是0否
|
||||
}
|
||||
type FsProductSizeModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductSizeModel(db *gorm.DB) *FsProductSizeModel {
|
||||
return &FsProductSizeModel{db}
|
||||
}
|
||||
|
||||
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
|
||||
db := s.db.Model(&FsProductSizeModel{}).Where("`id` in (?) and `status` = ?", ids, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
db = db.Order("`sort` ASC")
|
||||
case "sort-desc":
|
||||
db = db.Order("`sort` DESC")
|
||||
}
|
||||
if err = db.Find(&resp).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (s *FsProductSizeModel) CountByStatus(ctx context.Context, status int) (total int64, err error) {
|
||||
err = s.db.WithContext(ctx).Model(&FsProductSizeModel{}).Where("`status` = ? ", status).Count(&total).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (s *FsProductSizeModel) GetAllByProductIds(ctx context.Context, productIds []int64, sort string) (resp []FsProductSize, err error) {
|
||||
db := s.db.WithContext(ctx).Model(&FsProductSizeModel{}).Where("`product_id` in(?) and `status` = ?", productIds, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
db = db.Order("`sort` ASC")
|
||||
case "sort-desc":
|
||||
db = db.Order("`sort` DESC")
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
17
model/gmodel/fsproducttemplatetagsmodel.go
Executable file
17
model/gmodel/fsproducttemplatetagsmodel.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsProductTemplateTags struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1:可用 0不可用
|
||||
CreateAt *int64 `gorm:"default:0" json:"create_at"` // 创建时间
|
||||
}
|
||||
type FsProductTemplateTagsModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductTemplateTagsModel(db *gorm.DB) *FsProductTemplateTagsModel {
|
||||
return &FsProductTemplateTagsModel{db}
|
||||
}
|
||||
39
model/gmodel/fsproducttemplatev2model.go
Executable file
39
model/gmodel/fsproducttemplatev2model.go
Executable file
@@ -0,0 +1,39 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsProductTemplateV2 struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
ModelId *int64 `gorm:"default:0" json:"model_id"` // 模型ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 模板(sku),预留字段
|
||||
Name *string `gorm:"default:''" json:"name"` // 名称
|
||||
CoverImg *string `gorm:"default:''" json:"cover_img"` // 模板背景图
|
||||
TemplateInfo *string `gorm:"default:''" json:"template_info"` // 模板详情
|
||||
MaterialImg *string `gorm:"default:''" json:"material_img"` // 合成好的贴图
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
LogoWidth *int64 `gorm:"default:0" json:"logo_width"` // logo图最大宽度
|
||||
LogoHeight *int64 `gorm:"default:0" json:"logo_height"` // logo图最大高度
|
||||
IsPublic *int64 `gorm:"default:0" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态1正常 2异常
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Tag *string `gorm:"default:''" json:"tag"` // 标签(用户自填)
|
||||
IsDel *int64 `gorm:"default:0" json:"is_del"` // 是否删除 1删除
|
||||
}
|
||||
type FsProductTemplateV2Model struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsProductTemplateV2Model(db *gorm.DB) *FsProductTemplateV2Model {
|
||||
return &FsProductTemplateV2Model{db}
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2Model{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
25
model/gmodel/fsqrcodesetmodel.go
Executable file
25
model/gmodel/fsqrcodesetmodel.go
Executable file
@@ -0,0 +1,25 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsQrcodeSet struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // id
|
||||
Name *string `gorm:"default:''" json:"name"` // 二维码组件名称
|
||||
Size *int64 `gorm:"default:0" json:"size"` // 二维码内容尺寸
|
||||
IndexX *int64 `gorm:"default:0" json:"index_x"` // x偏移量
|
||||
IndexY *int64 `gorm:"default:0" json:"index_y"` // y偏移量
|
||||
SvgWebsite *string `gorm:"default:''" json:"svg_website"` // website d数据
|
||||
SvgInstagram *string `gorm:"default:''" json:"svg_instagram"` // svg instagram d数据
|
||||
SvgFacebook *string `gorm:"default:''" json:"svg_facebook"` // svg facebook d数据
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1正常 1删除
|
||||
AdminId *int64 `gorm:"default:0" json:"admin_id"` // 操作人
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Utime *int64 `gorm:"default:0" json:"utime"` // 更新时间
|
||||
}
|
||||
type FsQrcodeSetModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsQrcodeSetModel(db *gorm.DB) *FsQrcodeSetModel {
|
||||
return &FsQrcodeSetModel{db}
|
||||
}
|
||||
18
model/gmodel/fsstandardlogomodel.go
Executable file
18
model/gmodel/fsstandardlogomodel.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package gmodel
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FsStandardLogo struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Name *string `gorm:"default:''" json:"name"` // logo名称
|
||||
Image *string `gorm:"default:''" json:"image"` // 图片地址
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1正常 0删除
|
||||
}
|
||||
type FsStandardLogoModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsStandardLogoModel(db *gorm.DB) *FsStandardLogoModel {
|
||||
return &FsStandardLogoModel{db}
|
||||
}
|
||||
49
model/gmodel/fstagsmodel.go
Executable file
49
model/gmodel/fstagsmodel.go
Executable file
@@ -0,0 +1,49 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsTags struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Level *int64 `gorm:"default:0" json:"level"` // 层级、分类 1 => 二维码分类
|
||||
ClickNum *int64 `gorm:"default:0" json:"click_num"` // 点击次数
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序(从大到小)
|
||||
CreateAt *int64 `gorm:"default:0" json:"create_at"` // 创建时间
|
||||
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"` // 推荐产品id例如: 1,3,4,5
|
||||
RecommendProductSort *string `gorm:"default:''" json:"recommend_product_sort"` // 推荐排序例如:1324
|
||||
}
|
||||
type FsTagsModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsTagsModel(db *gorm.DB) *FsTagsModel {
|
||||
return &FsTagsModel{db}
|
||||
}
|
||||
func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp FsTags, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsTagsModel{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsTags{}, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *FsTagsModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsTags, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsTagsModel{}).Where("`id` in(?) and `status` = ?", ids, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *FsTagsModel) GetAllByLevel(ctx context.Context, level int) (resp []FsTags, err error) {
|
||||
err = t.db.Model(&FsTagsModel{}).Where("`level` = ? and `status` = ?", level, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
51
model/gmodel/fsusermodel.go
Executable file
51
model/gmodel/fsusermodel.go
Executable file
@@ -0,0 +1,51 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FsUser struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
FaceId int64 `gorm:"default:0" json:"face_id"` // facebook的userid
|
||||
Sub int64 `gorm:"default:0" json:"sub"` // google的sub
|
||||
FirstName string `gorm:"default:''" json:"first_name"` // FirstName
|
||||
LastName string `gorm:"default:''" json:"last_name"` // LastName
|
||||
Username string `gorm:"default:''" json:"username"` // 用户名
|
||||
Company string `gorm:"default:''" json:"company"` // 公司名称
|
||||
Mobile string `gorm:"default:''" json:"mobile" ` // 手机号码
|
||||
AuthKey string `gorm:"default:''" json:"auth_key"`
|
||||
PasswordHash string `gorm:"default:''" json:"password_hash"`
|
||||
VerificationToken string `gorm:"default:''" json:"verification_token"`
|
||||
PasswordResetToken string `gorm:"default:''" json:"password_reset_token"`
|
||||
Email string `gorm:"default:''" json:"email"` // 邮箱
|
||||
Type int64 `gorm:"default:1" json:"type"` // 1普通餐厅 2连锁餐厅
|
||||
Status int64 `gorm:"default:1" json:"status"` // 1正常 0不正常
|
||||
IsDel int64 `gorm:"default:0" json:"is_del"` // 是否删除 1删除
|
||||
CreatedAt int64 `gorm:"default:0" json:"created_at"` // 添加时间
|
||||
UpdatedAt int64 `gorm:"default:0" json:"updated_at"` // 更新时间
|
||||
IsOrderStatusEmail int64 `gorm:"default:0" json:"is_order_status_email"` // 订单状态改变时是否接收邮件
|
||||
IsEmailAdvertisement int64 `gorm:"default:0" json:"is_email_advertisement"` // 是否接收邮件广告
|
||||
IsOrderStatusPhone int64 `gorm:"default:0" json:"is_order_status_phone"` // 订单状态改变是是否接收电话
|
||||
IsPhoneAdvertisement int64 `gorm:"default:0" json:"is_phone_advertisement"` // 是否接收短信广告
|
||||
IsOpenRender int64 `gorm:"default:0" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭)
|
||||
IsThousandFace int64 `gorm:"default:0" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在)
|
||||
IsLowRendering int64 `gorm:"default:0" json:"is_low_rendering"` // 是否开启低渲染模型渲染
|
||||
IsRemoveBg int64 `gorm:"default:1" json:"is_remove_bg"` // 用户上传logo是否去除背景
|
||||
}
|
||||
type FsUserModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsUserModel(db *gorm.DB) *FsUserModel {
|
||||
return &FsUserModel{db}
|
||||
}
|
||||
|
||||
func (u *FsUserModel) FindOne(ctx context.Context, id int64) (resp FsUser, err error) {
|
||||
err = u.db.WithContext(ctx).Model(&FsUserModel{}).Where("`id` = ? and is_del = ?", id, 0).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsUser{}, err
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user