This commit is contained in:
laodaming 2023-06-12 14:35:36 +08:00
parent 53a3490837
commit 9d7022ec11
8 changed files with 111 additions and 340 deletions

View File

@ -1,17 +1,17 @@
package 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"` // 是否默认
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"` // 是否默认
}

View File

@ -1,69 +1,14 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"strings"
)
var _ FsProductSizeModel = (*customFsProductSizeModel)(nil)
type (
// FsProductSizeModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsProductSizeModel.
FsProductSizeModel interface {
fsProductSizeModel
CountByStatus(ctx context.Context, status int) (total int, err error)
GetAllByProductIds(ctx context.Context, productIds []string, sort string) (resp []FsProductSize, err error)
GetAllByIds(ctx context.Context, ids []string, sort string) (resp []FsProductSize, err error)
}
customFsProductSizeModel struct {
*defaultFsProductSizeModel
}
)
// NewFsProductSizeModel returns a model for the database table.
func NewFsProductSizeModel(conn sqlx.SqlConn) FsProductSizeModel {
return &customFsProductSizeModel{
defaultFsProductSizeModel: newFsProductSizeModel(conn),
}
}
func (m *defaultFsProductSizeModel) CountByStatus(ctx context.Context, status int) (total int, err error) {
query := fmt.Sprintf("select %s from %s where `status` = ? limit 1", "count(*) as num", m.table)
err = m.conn.QueryRowCtx(ctx, &total, query, status)
if err != nil {
return 0, err
}
return
}
func (m *defaultFsProductSizeModel) GetAllByProductIds(ctx context.Context, productIds []string, sort string) (resp []FsProductSize, err error) {
query := fmt.Sprintf("select %s from %s where `product_id` in(?) and `status` = ? ", fsProductSizeRows, m.table)
switch sort {
case "sort-asc":
query = fmt.Sprintf("%s order by `sort` ASC", query)
case "sort-desc":
query = fmt.Sprintf("%s order by `sort` DESC", query)
}
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(productIds, ","), 1)
if err != nil {
return nil, err
}
return
}
func (m *defaultFsProductSizeModel) GetAllByIds(ctx context.Context, ids []string, sort string) (resp []FsProductSize, err error) {
query := fmt.Sprintf("select %s from %s where `id` in (?) and `status` = ? ", fsProductSizeRows, m.table)
switch sort {
case "sort-asc":
query = fmt.Sprintf("%s order by `sort` ASC", query)
case "sort-desc":
query = fmt.Sprintf("%s order by `sort` DESC", query)
}
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(ids, ","), 1)
if err != nil {
return nil, err
}
return
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否
}

View File

@ -1,40 +1,8 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ FsProductTemplateTagsModel = (*customFsProductTemplateTagsModel)(nil)
type (
// FsProductTemplateTagsModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsProductTemplateTagsModel.
FsProductTemplateTagsModel interface {
fsProductTemplateTagsModel
ListByIds(ctx context.Context, ids []string) (resp []FsProductTemplateTags, err error)
}
customFsProductTemplateTagsModel struct {
*defaultFsProductTemplateTagsModel
}
)
// NewFsProductTemplateTagsModel returns a model for the database table.
func NewFsProductTemplateTagsModel(conn sqlx.SqlConn) FsProductTemplateTagsModel {
return &customFsProductTemplateTagsModel{
defaultFsProductTemplateTagsModel: newFsProductTemplateTagsModel(conn),
}
}
func (m *defaultFsProductTemplateTagsModel) ListByIds(ctx context.Context, ids []string) (resp []FsProductTemplateTags, err error) {
if len(ids) == 0 {
return nil, nil
}
query := fmt.Sprintf("select %s from %s where `id` in (?) ", fsProductTemplateTagsRows, m.table)
err = m.conn.QueryRowsCtx(ctx, &resp, query, ids)
if err != nil {
return nil, err
}
return
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"` // 创建时间
}

View File

@ -1,72 +1,20 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"strings"
)
var _ FsProductTemplateV2Model = (*customFsProductTemplateV2Model)(nil)
type (
// FsProductTemplateV2Model is an interface to be customized, add more methods here,
// and implement the added methods in customFsProductTemplateV2Model.
FsProductTemplateV2Model interface {
fsProductTemplateV2Model
FindAllByCondition(ctx context.Context, productIds []string) (resp []FsProductTemplateV2, err error)
FindAllByModelIdsProduct(ctx context.Context, modelIds []string, productId int64, sort int) (resp []FsProductTemplateV2, err error)
FindAllByModelIds(ctx context.Context, modelIds []string, sort int) (resp []FsProductTemplateV2, err error)
}
customFsProductTemplateV2Model struct {
*defaultFsProductTemplateV2Model
}
)
// NewFsProductTemplateV2Model returns a model for the database table.
func NewFsProductTemplateV2Model(conn sqlx.SqlConn) FsProductTemplateV2Model {
return &customFsProductTemplateV2Model{
defaultFsProductTemplateV2Model: newFsProductTemplateV2Model(conn),
}
}
func (m *defaultFsProductTemplateV2Model) FindAllByCondition(ctx context.Context, productIds []string) (resp []FsProductTemplateV2, err error) {
query := fmt.Sprintf("select %s from %s where `id` in (?) and `is_del` = ? and `status` = ?", fsProductTemplateV2Rows, m.table)
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(productIds, ","), 0, 1); err != nil {
return nil, err
}
return
}
func (m *defaultFsProductTemplateV2Model) FindAllByModelIdsProduct(ctx context.Context, modelIds []string, productId int64, sort int) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {
return
}
query := fmt.Sprintf("select %s from %s where `model_id` in (?) and `product_id` = ? and `is_del` = ? and `status` = ?", fsProductTemplateV2Rows, m.table)
switch sort {
case 1:
query = fmt.Sprintf("%s order by `sort` ASC", query)
case 2:
query = fmt.Sprintf("%s order by `sort` DESC", query)
}
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(modelIds, ","), productId, 0, 1); err != nil {
return nil, err
}
return
}
func (m *defaultFsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelIds []string, sort int) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {
return
}
query := fmt.Sprintf("select %s from %s where `model_id` in (?) and `is_del` = ? and `status` = ?", fsProductTemplateV2Rows, m.table)
switch sort {
case 1:
query = fmt.Sprintf("%s order by `sort` ASC", query)
case 2:
query = fmt.Sprintf("%s order by `sort` DESC", query)
}
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(modelIds, ","), 0, 1); err != nil {
return nil, err
}
return
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删除
}

View File

@ -1,38 +1,16 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ FsQrcodeSetModel = (*customFsQrcodeSetModel)(nil)
type (
// FsQrcodeSetModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsQrcodeSetModel.
FsQrcodeSetModel interface {
fsQrcodeSetModel
GetAll(ctx context.Context) (resp []FsQrcodeSet, err error)
}
customFsQrcodeSetModel struct {
*defaultFsQrcodeSetModel
}
)
// NewFsQrcodeSetModel returns a model for the database table.
func NewFsQrcodeSetModel(conn sqlx.SqlConn) FsQrcodeSetModel {
return &customFsQrcodeSetModel{
defaultFsQrcodeSetModel: newFsQrcodeSetModel(conn),
}
}
func (m *defaultFsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
query := fmt.Sprintf("select %s from %s where `status` = ?", fsQrcodeSetRows, m.table)
err = m.conn.QueryRowsCtx(ctx, &resp, query, 1)
if err != nil {
return nil, err
}
return
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"` // 更新时间
}

View File

@ -1,38 +1,9 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ FsStandardLogoModel = (*customFsStandardLogoModel)(nil)
type (
// FsStandardLogoModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsStandardLogoModel.
FsStandardLogoModel interface {
fsStandardLogoModel
GetAll(ctx context.Context) (resp []FsStandardLogo, err error)
}
customFsStandardLogoModel struct {
*defaultFsStandardLogoModel
}
)
// NewFsStandardLogoModel returns a model for the database table.
func NewFsStandardLogoModel(conn sqlx.SqlConn) FsStandardLogoModel {
return &customFsStandardLogoModel{
defaultFsStandardLogoModel: newFsStandardLogoModel(conn),
}
}
func (m *defaultFsStandardLogoModel) GetAll(ctx context.Context) (resp []FsStandardLogo, err error) {
query := fmt.Sprintf("select %s from %s where `status` = ? ", fsStandardLogoRows, m.table)
err = m.conn.QueryRowsCtx(ctx, &resp, query, 1)
if err != nil {
return nil, err
}
return
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删除
}

View File

@ -1,48 +1,15 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"strings"
)
var _ FsTagsModel = (*customFsTagsModel)(nil)
type (
// FsTagsModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsTagsModel.
FsTagsModel interface {
fsTagsModel
GetAllByLevel(ctx context.Context, level int) (resp []FsTags, err error)
GetAllByIds(ctx context.Context, ids []string) (resp []FsTags, err error)
}
customFsTagsModel struct {
*defaultFsTagsModel
}
)
// NewFsTagsModel returns a model for the database table.
func NewFsTagsModel(conn sqlx.SqlConn) FsTagsModel {
return &customFsTagsModel{
defaultFsTagsModel: newFsTagsModel(conn),
}
}
func (m *defaultFsTagsModel) GetAllByLevel(ctx context.Context, level int) (resp []FsTags, err error) {
query := fmt.Sprintf("select %s from %s where `level` = ? and `status` = ?", fsTagsRows, m.table)
err = m.conn.QueryRowsCtx(ctx, &resp, query, level, 1)
if err != nil {
return nil, err
}
return
}
func (m *defaultFsTagsModel) GetAllByIds(ctx context.Context, ids []string) (resp []FsTags, err error) {
query := fmt.Sprintf("select %s from %s where `id` in (?) and `status` = ?", fsTagsRows, m.table)
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(ids, ","), 1)
if err != nil {
return nil, err
}
return
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
}

View File

@ -1,36 +1,30 @@
package model
package gorm
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ FsUserModel = (*customFsUserModel)(nil)
type (
// FsUserModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsUserModel.
FsUserModel interface {
fsUserModel
UpdateVerificationToken(ctx context.Context, userid int64, token string) error
}
customFsUserModel struct {
*defaultFsUserModel
}
)
// NewFsUserModel returns a model for the database table.
func NewFsUserModel(conn sqlx.SqlConn) FsUserModel {
return &customFsUserModel{
defaultFsUserModel: newFsUserModel(conn),
}
}
func (m *defaultFsUserModel) UpdateVerificationToken(ctx context.Context, userid int64, verificationToken string) error {
query := fmt.Sprintf("update %s set `verification_token` = ? where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, verificationToken, userid)
return err
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是否去除背景
}