fix
This commit is contained in:
parent
68c431bda2
commit
47bf9580da
|
@ -1,7 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,11 +37,3 @@ type FsOrderDetailModel struct {
|
||||||
func NewFsOrderDetailModel(db *gorm.DB) *FsOrderDetailModel {
|
func NewFsOrderDetailModel(db *gorm.DB) *FsOrderDetailModel {
|
||||||
return &FsOrderDetailModel{db}
|
return &FsOrderDetailModel{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) {
|
|
||||||
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
13
model/gmodel/fs_order_detail_logic.go
Executable file
13
model/gmodel/fs_order_detail_logic.go
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) {
|
||||||
|
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,14 +24,3 @@ type FsOrderDetailTemplateModel struct {
|
||||||
func NewFsOrderDetailTemplateModel(db *gorm.DB) *FsOrderDetailTemplateModel {
|
func NewFsOrderDetailTemplateModel(db *gorm.DB) *FsOrderDetailTemplateModel {
|
||||||
return &FsOrderDetailTemplateModel{db}
|
return &FsOrderDetailTemplateModel{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dt *FsOrderDetailTemplateModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsOrderDetailTemplate, err error) {
|
|
||||||
if len(ids) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` in (?)", ids).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
16
model/gmodel/fs_order_detail_template_logic.go
Executable file
16
model/gmodel/fs_order_detail_template_logic.go
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (dt *FsOrderDetailTemplateModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsOrderDetailTemplate, err error) {
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` in (?)", ids).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -53,14 +51,3 @@ type FsOrderModel struct {
|
||||||
func NewFsOrderModel(db *gorm.DB) *FsOrderModel {
|
func NewFsOrderModel(db *gorm.DB) *FsOrderModel {
|
||||||
return &FsOrderModel{db}
|
return &FsOrderModel{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp FsOrder, err error) {
|
|
||||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).First(&resp).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return FsOrder{}, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
func (o *FsOrderModel) Update(ctx context.Context, id int64, data FsOrder) error {
|
|
||||||
return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", id).Updates(data).Error
|
|
||||||
}
|
|
18
model/gmodel/fs_order_logic.go
Executable file
18
model/gmodel/fs_order_logic.go
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp FsOrder, err error) {
|
||||||
|
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).First(&resp).Error
|
||||||
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return FsOrder{}, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
func (o *FsOrderModel) Update(ctx context.Context, id int64, data FsOrder) error {
|
||||||
|
return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", id).Updates(data).Error
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -33,21 +31,3 @@ type FsProductDesignModel struct {
|
||||||
func NewFsProductDesignModel(db *gorm.DB) *FsProductDesignModel {
|
func NewFsProductDesignModel(db *gorm.DB) *FsProductDesignModel {
|
||||||
return &FsProductDesignModel{db}
|
return &FsProductDesignModel{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string) (resp FsProductDesign, err error) {
|
|
||||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `status` = ?", sn, 1).First(&resp).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return FsProductDesign{}, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
|
|
||||||
if len(ids) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
25
model/gmodel/fs_product_design_logic.go
Executable file
25
model/gmodel/fs_product_design_logic.go
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string) (resp FsProductDesign, err error) {
|
||||||
|
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `status` = ?", sn, 1).First(&resp).Error
|
||||||
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return FsProductDesign{}, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -43,47 +42,3 @@ type FsProductModel struct {
|
||||||
func NewFsProductModel(db *gorm.DB) *FsProductModel {
|
func NewFsProductModel(db *gorm.DB) *FsProductModel {
|
||||||
return &FsProductModel{db}
|
return &FsProductModel{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
|
||||||
if len(productIds) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
if len(productTypes) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
db := p.db.WithContext(ctx).Model(&FsProduct{}).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(&FsProduct{}).
|
|
||||||
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
47
model/gmodel/fs_product_logic.go
Executable file
47
model/gmodel/fs_product_logic.go
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
||||||
|
if len(productIds) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
if len(productTypes) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db := p.db.WithContext(ctx).Model(&FsProduct{}).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(&FsProduct{}).
|
||||||
|
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,23 +31,3 @@ type FsProductModel3dModel struct {
|
||||||
func NewFsProductModel3dModel(db *gorm.DB) *FsProductModel3dModel {
|
func NewFsProductModel3dModel(db *gorm.DB) *FsProductModel3dModel {
|
||||||
return &FsProductModel3dModel{db}
|
return &FsProductModel3dModel{db}
|
||||||
}
|
}
|
||||||
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
|
||||||
if len(ids) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) {
|
|
||||||
if len(ids) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
1
model/gmodel/fs_product_model3d_light_logic.go
Executable file
1
model/gmodel/fs_product_model3d_light_logic.go
Executable file
|
@ -0,0 +1 @@
|
||||||
|
package gmodel
|
26
model/gmodel/fs_product_model3d_logic.go
Executable file
26
model/gmodel/fs_product_model3d_logic.go
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) {
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
28
model/gmodel/fs_product_price_gen.go
Executable file
28
model/gmodel/fs_product_price_gen.go
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"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}
|
||||||
|
}
|
|
@ -6,29 +6,6 @@ import (
|
||||||
"gorm.io/gorm"
|
"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 {
|
type GetPriceListByProductIdsRsp struct {
|
||||||
ProductId int64 `json:"product_id"`
|
ProductId int64 `json:"product_id"`
|
||||||
Price string `json:"price"`
|
Price string `json:"price"`
|
25
model/gmodel/fs_product_size_gen.go
Executable file
25
model/gmodel/fs_product_size_gen.go
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"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}
|
||||||
|
}
|
|
@ -2,29 +2,8 @@ package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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) {
|
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
|
||||||
if len(ids) == 0 {
|
if len(ids) == 0 {
|
||||||
return
|
return
|
|
@ -1,7 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,14 +17,3 @@ type FsProductTemplateTagsModel struct {
|
||||||
func NewFsProductTemplateTagsModel(db *gorm.DB) *FsProductTemplateTagsModel {
|
func NewFsProductTemplateTagsModel(db *gorm.DB) *FsProductTemplateTagsModel {
|
||||||
return &FsProductTemplateTagsModel{db}
|
return &FsProductTemplateTagsModel{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt *FsProductTemplateTagsModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateTags, err error) {
|
|
||||||
if len(ids) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`id` in (?)", ids).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
16
model/gmodel/fs_product_template_tags_logic.go
Executable file
16
model/gmodel/fs_product_template_tags_logic.go
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (pt *FsProductTemplateTagsModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateTags, err error) {
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`id` in (?)", ids).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,13 +29,3 @@ type FsProductTemplateV2Model struct {
|
||||||
func NewFsProductTemplateV2Model(db *gorm.DB) *FsProductTemplateV2Model {
|
func NewFsProductTemplateV2Model(db *gorm.DB) *FsProductTemplateV2Model {
|
||||||
return &FsProductTemplateV2Model{db}
|
return &FsProductTemplateV2Model{db}
|
||||||
}
|
}
|
||||||
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
|
|
||||||
if len(productIds) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
16
model/gmodel/fs_product_template_v2_logic.go
Executable file
16
model/gmodel/fs_product_template_v2_logic.go
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
|
||||||
|
if len(productIds) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,17 +25,3 @@ type FsQrcodeSetModel struct {
|
||||||
func NewFsQrcodeSetModel(db *gorm.DB) *FsQrcodeSetModel {
|
func NewFsQrcodeSetModel(db *gorm.DB) *FsQrcodeSetModel {
|
||||||
return &FsQrcodeSetModel{db}
|
return &FsQrcodeSetModel{db}
|
||||||
}
|
}
|
||||||
func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
|
|
||||||
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`status` = ?", 1).Find(&resp).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp FsQrcodeSet, err error) {
|
|
||||||
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`id` = ?", id).First(&resp).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return FsQrcodeSet{}, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
22
model/gmodel/fs_qrcode_set_logic.go
Executable file
22
model/gmodel/fs_qrcode_set_logic.go
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
|
||||||
|
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`status` = ?", 1).Find(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp FsQrcodeSet, err error) {
|
||||||
|
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`id` = ?", id).First(&resp).Error
|
||||||
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return FsQrcodeSet{}, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user