diff --git a/model/gmodel/fsorderdetailmodel.go b/model/gmodel/fs_order_detail_gen.go similarity index 90% rename from model/gmodel/fsorderdetailmodel.go rename to model/gmodel/fs_order_detail_gen.go index ad245e18..27a2e5ac 100755 --- a/model/gmodel/fsorderdetailmodel.go +++ b/model/gmodel/fs_order_detail_gen.go @@ -1,7 +1,6 @@ package gmodel import ( - "context" "gorm.io/gorm" ) @@ -38,11 +37,3 @@ type FsOrderDetailModel struct { func NewFsOrderDetailModel(db *gorm.DB) *FsOrderDetailModel { 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 -} diff --git a/model/gmodel/fs_order_detail_logic.go b/model/gmodel/fs_order_detail_logic.go new file mode 100755 index 00000000..e16fe337 --- /dev/null +++ b/model/gmodel/fs_order_detail_logic.go @@ -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 +} diff --git a/model/gmodel/fsorderdetailtemplatemodel.go b/model/gmodel/fs_order_detail_template_gen.go similarity index 78% rename from model/gmodel/fsorderdetailtemplatemodel.go rename to model/gmodel/fs_order_detail_template_gen.go index 02c72e23..c2548be5 100755 --- a/model/gmodel/fsorderdetailtemplatemodel.go +++ b/model/gmodel/fs_order_detail_template_gen.go @@ -1,7 +1,6 @@ package gmodel import ( - "context" "gorm.io/gorm" ) @@ -25,14 +24,3 @@ type FsOrderDetailTemplateModel struct { func NewFsOrderDetailTemplateModel(db *gorm.DB) *FsOrderDetailTemplateModel { 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 -} diff --git a/model/gmodel/fs_order_detail_template_logic.go b/model/gmodel/fs_order_detail_template_logic.go new file mode 100755 index 00000000..571cec9e --- /dev/null +++ b/model/gmodel/fs_order_detail_template_logic.go @@ -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 +} diff --git a/model/gmodel/fsordermodel.go b/model/gmodel/fs_order_gen.go similarity index 89% rename from model/gmodel/fsordermodel.go rename to model/gmodel/fs_order_gen.go index c92f7be1..aa59e60f 100755 --- a/model/gmodel/fsordermodel.go +++ b/model/gmodel/fs_order_gen.go @@ -1,8 +1,6 @@ package gmodel import ( - "context" - "errors" "time" "gorm.io/gorm" @@ -53,14 +51,3 @@ type FsOrderModel struct { func NewFsOrderModel(db *gorm.DB) *FsOrderModel { 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 -} diff --git a/model/gmodel/fs_order_logic.go b/model/gmodel/fs_order_logic.go new file mode 100755 index 00000000..967dc122 --- /dev/null +++ b/model/gmodel/fs_order_logic.go @@ -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 +} diff --git a/model/gmodel/fsproductdesignmodel.go b/model/gmodel/fs_product_design_gen.go similarity index 68% rename from model/gmodel/fsproductdesignmodel.go rename to model/gmodel/fs_product_design_gen.go index 4af18324..e2e83fcc 100755 --- a/model/gmodel/fsproductdesignmodel.go +++ b/model/gmodel/fs_product_design_gen.go @@ -1,8 +1,6 @@ package gmodel import ( - "context" - "errors" "time" "gorm.io/gorm" @@ -33,21 +31,3 @@ type FsProductDesignModel struct { func NewFsProductDesignModel(db *gorm.DB) *FsProductDesignModel { 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 -} diff --git a/model/gmodel/fs_product_design_logic.go b/model/gmodel/fs_product_design_logic.go new file mode 100755 index 00000000..819c0074 --- /dev/null +++ b/model/gmodel/fs_product_design_logic.go @@ -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 +} diff --git a/model/gmodel/fsproductmodel.go b/model/gmodel/fs_product_gen.go similarity index 69% rename from model/gmodel/fsproductmodel.go rename to model/gmodel/fs_product_gen.go index 1df06768..a9ad0dd2 100755 --- a/model/gmodel/fsproductmodel.go +++ b/model/gmodel/fs_product_gen.go @@ -1,7 +1,6 @@ package gmodel import ( - "context" "gorm.io/gorm" ) @@ -43,47 +42,3 @@ type FsProductModel struct { func NewFsProductModel(db *gorm.DB) *FsProductModel { 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 -} diff --git a/model/gmodel/fs_product_logic.go b/model/gmodel/fs_product_logic.go new file mode 100755 index 00000000..5d5a9ed1 --- /dev/null +++ b/model/gmodel/fs_product_logic.go @@ -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 +} diff --git a/model/gmodel/fsproductmodel3dmodel.go b/model/gmodel/fs_product_model3d_gen.go similarity index 72% rename from model/gmodel/fsproductmodel3dmodel.go rename to model/gmodel/fs_product_model3d_gen.go index b2a3b3f9..0e6f670e 100755 --- a/model/gmodel/fsproductmodel3dmodel.go +++ b/model/gmodel/fs_product_model3d_gen.go @@ -1,7 +1,6 @@ package gmodel import ( - "context" "gorm.io/gorm" ) @@ -32,23 +31,3 @@ type FsProductModel3dModel struct { func NewFsProductModel3dModel(db *gorm.DB) *FsProductModel3dModel { 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 -} diff --git a/model/gmodel/fsproductmodel3dlightmodel.go b/model/gmodel/fs_product_model3d_light_gen.go similarity index 100% rename from model/gmodel/fsproductmodel3dlightmodel.go rename to model/gmodel/fs_product_model3d_light_gen.go diff --git a/model/gmodel/fs_product_model3d_light_logic.go b/model/gmodel/fs_product_model3d_light_logic.go new file mode 100755 index 00000000..f35dfc56 --- /dev/null +++ b/model/gmodel/fs_product_model3d_light_logic.go @@ -0,0 +1 @@ +package gmodel diff --git a/model/gmodel/fs_product_model3d_logic.go b/model/gmodel/fs_product_model3d_logic.go new file mode 100755 index 00000000..9e3e604b --- /dev/null +++ b/model/gmodel/fs_product_model3d_logic.go @@ -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 +} diff --git a/model/gmodel/fs_product_price_gen.go b/model/gmodel/fs_product_price_gen.go new file mode 100755 index 00000000..d62fab72 --- /dev/null +++ b/model/gmodel/fs_product_price_gen.go @@ -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} +} diff --git a/model/gmodel/fsproductpricemodel.go b/model/gmodel/fs_product_price_logic.go similarity index 63% rename from model/gmodel/fsproductpricemodel.go rename to model/gmodel/fs_product_price_logic.go index 0e988b6c..b36a7790 100755 --- a/model/gmodel/fsproductpricemodel.go +++ b/model/gmodel/fs_product_price_logic.go @@ -6,29 +6,6 @@ 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} -} - type GetPriceListByProductIdsRsp struct { ProductId int64 `json:"product_id"` Price string `json:"price"` diff --git a/model/gmodel/fs_product_size_gen.go b/model/gmodel/fs_product_size_gen.go new file mode 100755 index 00000000..c6e9f217 --- /dev/null +++ b/model/gmodel/fs_product_size_gen.go @@ -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} +} diff --git a/model/gmodel/fsproductsizemodel.go b/model/gmodel/fs_product_size_logic.go similarity index 52% rename from model/gmodel/fsproductsizemodel.go rename to model/gmodel/fs_product_size_logic.go index 1b8a186a..a48d46bf 100755 --- a/model/gmodel/fsproductsizemodel.go +++ b/model/gmodel/fs_product_size_logic.go @@ -2,29 +2,8 @@ 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) { if len(ids) == 0 { return diff --git a/model/gmodel/fsproducttemplatetagsmodel.go b/model/gmodel/fs_product_template_tags_gen.go similarity index 62% rename from model/gmodel/fsproducttemplatetagsmodel.go rename to model/gmodel/fs_product_template_tags_gen.go index 81bc121e..7a371b50 100755 --- a/model/gmodel/fsproducttemplatetagsmodel.go +++ b/model/gmodel/fs_product_template_tags_gen.go @@ -1,7 +1,6 @@ package gmodel import ( - "context" "gorm.io/gorm" ) @@ -18,14 +17,3 @@ type FsProductTemplateTagsModel struct { func NewFsProductTemplateTagsModel(db *gorm.DB) *FsProductTemplateTagsModel { 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 -} diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go new file mode 100755 index 00000000..68fc2b2e --- /dev/null +++ b/model/gmodel/fs_product_template_tags_logic.go @@ -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 +} diff --git a/model/gmodel/fsproducttemplatev2model.go b/model/gmodel/fs_product_template_v2_gen.go similarity index 80% rename from model/gmodel/fsproducttemplatev2model.go rename to model/gmodel/fs_product_template_v2_gen.go index e97fc6e3..4e26f4db 100755 --- a/model/gmodel/fsproducttemplatev2model.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -1,7 +1,6 @@ package gmodel import ( - "context" "gorm.io/gorm" ) @@ -30,13 +29,3 @@ type FsProductTemplateV2Model struct { func NewFsProductTemplateV2Model(db *gorm.DB) *FsProductTemplateV2Model { 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 -} diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go new file mode 100755 index 00000000..e31f35fe --- /dev/null +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -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 +} diff --git a/model/gmodel/fsqrcodesetmodel.go b/model/gmodel/fs_qrcode_set_gen.go similarity index 68% rename from model/gmodel/fsqrcodesetmodel.go rename to model/gmodel/fs_qrcode_set_gen.go index 9519388e..4ead2640 100755 --- a/model/gmodel/fsqrcodesetmodel.go +++ b/model/gmodel/fs_qrcode_set_gen.go @@ -1,8 +1,6 @@ package gmodel import ( - "context" - "errors" "gorm.io/gorm" ) @@ -27,17 +25,3 @@ type FsQrcodeSetModel struct { func NewFsQrcodeSetModel(db *gorm.DB) *FsQrcodeSetModel { 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 -} diff --git a/model/gmodel/fs_qrcode_set_logic.go b/model/gmodel/fs_qrcode_set_logic.go new file mode 100755 index 00000000..efad4008 --- /dev/null +++ b/model/gmodel/fs_qrcode_set_logic.go @@ -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 +}