fix
This commit is contained in:
24
model/fscartmodel.go
Executable file
24
model/fscartmodel.go
Executable file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsCartModel = (*customFsCartModel)(nil)
|
||||
|
||||
type (
|
||||
// FsCartModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsCartModel.
|
||||
FsCartModel interface {
|
||||
fsCartModel
|
||||
}
|
||||
|
||||
customFsCartModel struct {
|
||||
*defaultFsCartModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsCartModel returns a model for the database table.
|
||||
func NewFsCartModel(conn sqlx.SqlConn) FsCartModel {
|
||||
return &customFsCartModel{
|
||||
defaultFsCartModel: newFsCartModel(conn),
|
||||
}
|
||||
}
|
||||
99
model/fscartmodel_gen.go
Executable file
99
model/fscartmodel_gen.go
Executable file
@@ -0,0 +1,99 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
fsCartFieldNames = builder.RawFieldNames(&FsCart{})
|
||||
fsCartRows = strings.Join(fsCartFieldNames, ",")
|
||||
fsCartRowsExpectAutoSet = strings.Join(stringx.Remove(fsCartFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
fsCartRowsWithPlaceHolder = strings.Join(stringx.Remove(fsCartFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
fsCartModel interface {
|
||||
Insert(ctx context.Context, data *FsCart) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*FsCart, error)
|
||||
Update(ctx context.Context, data *FsCart) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultFsCartModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
FsCart struct {
|
||||
Id int64 `db:"id"` // id
|
||||
UserId sql.NullInt64 `db:"user_id"` // 用户ID
|
||||
ProductId int64 `db:"product_id"` // 产品ID
|
||||
TemplateId int64 `db:"template_id"` // 模板ID
|
||||
PriceId int64 `db:"price_id"` // 价格ID
|
||||
MaterialId int64 `db:"material_id"` // 材质ID
|
||||
SizeId int64 `db:"size_id"` // 尺寸ID
|
||||
BuyNum int64 `db:"buy_num"` // 购买数量
|
||||
Cover string `db:"cover"` // 截图
|
||||
DesignId int64 `db:"design_id"` // 设计ID
|
||||
Ctime sql.NullInt64 `db:"ctime"` // 添加时间
|
||||
Status int64 `db:"status"` // 状态位
|
||||
OptionalId int64 `db:"optional_id"` // 选项ID
|
||||
IsCheck int64 `db:"is_check"` // 是否选中状态(0:未选中,1:选中)
|
||||
TsTime time.Time `db:"ts_time"`
|
||||
IsEmail int64 `db:"is_email"` // 是否发送邮件
|
||||
}
|
||||
)
|
||||
|
||||
func newFsCartModel(conn sqlx.SqlConn) *defaultFsCartModel {
|
||||
return &defaultFsCartModel{
|
||||
conn: conn,
|
||||
table: "`fs_cart`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsCartModel) Delete(ctx context.Context, id int64) error {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultFsCartModel) FindOne(ctx context.Context, id int64) (*FsCart, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsCartRows, m.table)
|
||||
var resp FsCart
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsCartModel) Insert(ctx context.Context, data *FsCart) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsCartRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.UserId, data.ProductId, data.TemplateId, data.PriceId, data.MaterialId, data.SizeId, data.BuyNum, data.Cover, data.DesignId, data.Ctime, data.Status, data.OptionalId, data.IsCheck, data.TsTime, data.IsEmail)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultFsCartModel) Update(ctx context.Context, data *FsCart) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsCartRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.UserId, data.ProductId, data.TemplateId, data.PriceId, data.MaterialId, data.SizeId, data.BuyNum, data.Cover, data.DesignId, data.Ctime, data.Status, data.OptionalId, data.IsCheck, data.TsTime, data.IsEmail, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultFsCartModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
24
model/fsproductdesignmodel.go
Executable file
24
model/fsproductdesignmodel.go
Executable file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsProductDesignModel = (*customFsProductDesignModel)(nil)
|
||||
|
||||
type (
|
||||
// FsProductDesignModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsProductDesignModel.
|
||||
FsProductDesignModel interface {
|
||||
fsProductDesignModel
|
||||
}
|
||||
|
||||
customFsProductDesignModel struct {
|
||||
*defaultFsProductDesignModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsProductDesignModel returns a model for the database table.
|
||||
func NewFsProductDesignModel(conn sqlx.SqlConn) FsProductDesignModel {
|
||||
return &customFsProductDesignModel{
|
||||
defaultFsProductDesignModel: newFsProductDesignModel(conn),
|
||||
}
|
||||
}
|
||||
99
model/fsproductdesignmodel_gen.go
Executable file
99
model/fsproductdesignmodel_gen.go
Executable file
@@ -0,0 +1,99 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
fsProductDesignFieldNames = builder.RawFieldNames(&FsProductDesign{})
|
||||
fsProductDesignRows = strings.Join(fsProductDesignFieldNames, ",")
|
||||
fsProductDesignRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductDesignFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
fsProductDesignRowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductDesignFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
fsProductDesignModel interface {
|
||||
Insert(ctx context.Context, data *FsProductDesign) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*FsProductDesign, error)
|
||||
Update(ctx context.Context, data *FsProductDesign) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultFsProductDesignModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
FsProductDesign struct {
|
||||
Id int64 `db:"id"`
|
||||
Sn string `db:"sn"` // 唯一标识
|
||||
UserId int64 `db:"user_id"` // 用户ID
|
||||
ProductId int64 `db:"product_id"` // 产品ID
|
||||
TemplateId int64 `db:"template_id"` // 模型ID
|
||||
MaterialId int64 `db:"material_id"` // 材质ID
|
||||
SizeId int64 `db:"size_id"` // 尺寸ID
|
||||
OptionalId int64 `db:"optional_id"` // 选项ID
|
||||
Cover string `db:"cover"` // 封面图
|
||||
Info sql.NullString `db:"info"` // 保留的设计信息
|
||||
Utime time.Time `db:"utime"` // 更新时间
|
||||
Status int64 `db:"status"` // 状态
|
||||
IsDel int64 `db:"is_del"` // 是否删除 0未删除 1删除
|
||||
IsPay int64 `db:"is_pay"` // 是否已有支付 0 未 1 有
|
||||
LogoColor sql.NullString `db:"logo_color"` // logo图片备选项
|
||||
PageGuid string `db:"page_guid"` // 页面识别id
|
||||
}
|
||||
)
|
||||
|
||||
func newFsProductDesignModel(conn sqlx.SqlConn) *defaultFsProductDesignModel {
|
||||
return &defaultFsProductDesignModel{
|
||||
conn: conn,
|
||||
table: "`fs_product_design`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsProductDesignModel) Delete(ctx context.Context, id int64) error {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultFsProductDesignModel) FindOne(ctx context.Context, id int64) (*FsProductDesign, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductDesignRows, m.table)
|
||||
var resp FsProductDesign
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsProductDesignModel) Insert(ctx context.Context, data *FsProductDesign) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductDesignRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Sn, data.UserId, data.ProductId, data.TemplateId, data.MaterialId, data.SizeId, data.OptionalId, data.Cover, data.Info, data.Utime, data.Status, data.IsDel, data.IsPay, data.LogoColor, data.PageGuid)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultFsProductDesignModel) Update(ctx context.Context, data *FsProductDesign) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductDesignRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.Sn, data.UserId, data.ProductId, data.TemplateId, data.MaterialId, data.SizeId, data.OptionalId, data.Cover, data.Info, data.Utime, data.Status, data.IsDel, data.IsPay, data.LogoColor, data.PageGuid, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultFsProductDesignModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
@@ -35,6 +35,9 @@ func (c *FsCanteenProductModel) UpdateById(ctx context.Context, id int64, data *
|
||||
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 {
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` in (?) ", ids).Updates(&data).Error
|
||||
}
|
||||
func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProduct) error {
|
||||
|
||||
88
model/gmodel/fscartmodel.go
Executable file
88
model/gmodel/fscartmodel.go
Executable file
@@ -0,0 +1,88 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type FsCart struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // id
|
||||
UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
TemplateId *int64 `gorm:"default:0" json:"template_id"` // 模板ID
|
||||
PriceId *int64 `gorm:"default:0" json:"price_id"` // 价格ID
|
||||
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
|
||||
BuyNum *int64 `gorm:"default:0" json:"buy_num"` // 购买数量
|
||||
Cover *string `gorm:"default:''" json:"cover"` // 截图
|
||||
DesignId *int64 `gorm:"default:0" json:"design_id"` // 设计ID
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位
|
||||
OptionalId *int64 `gorm:"default:0" json:"optional_id"` // 选项ID
|
||||
IsCheck *int64 `gorm:"default:0" json:"is_check"` // 是否选中状态(0:未选中,1:选中)
|
||||
TsTime *time.Time `gorm:"" json:"ts_time"`
|
||||
IsEmail *int64 `gorm:"default:0" json:"is_email"` // 是否发送邮件
|
||||
}
|
||||
type FsCartModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFsCartModel(db *gorm.DB) *FsCartModel {
|
||||
return &FsCartModel{db}
|
||||
}
|
||||
|
||||
type FindOneCartByParamsReq struct {
|
||||
UserId *int64
|
||||
ProductId *int64
|
||||
TemplateId *int64
|
||||
PriceId *int64
|
||||
DesignId *int64
|
||||
MaterialId *int64
|
||||
Status *int64
|
||||
}
|
||||
|
||||
func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp FsCart, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCart{}, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp FsCart, err error) {
|
||||
db := c.db.WithContext(ctx).Model(&FsCart{})
|
||||
if req.UserId != nil {
|
||||
db = db.Where("`user_id` = ?", req.UserId)
|
||||
}
|
||||
if req.ProductId != nil {
|
||||
db = db.Where("`product_id` = ?", req.ProductId)
|
||||
}
|
||||
if req.TemplateId != nil {
|
||||
db = db.Where("`template_id` = ?", req.TemplateId)
|
||||
}
|
||||
if req.PriceId != nil {
|
||||
db = db.Where("`price_id` = ?", req.ProductId)
|
||||
}
|
||||
if req.DesignId != nil {
|
||||
db = db.Where("`design_id` = ?", req.DesignId)
|
||||
}
|
||||
if req.MaterialId != nil {
|
||||
db = db.Where("`material_id` = ?", req.MaterialId)
|
||||
}
|
||||
if req.Status != nil {
|
||||
db = db.Where("`status` = ?", req.Status)
|
||||
}
|
||||
if err = db.First(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCart{}, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (c *FsCartModel) Create(ctx context.Context, data FsCart) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCart{}).Create(data).Error
|
||||
}
|
||||
func (c *FsCartModel) Update(ctx context.Context, id int64, data FsCart) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).Updates(data).Error
|
||||
}
|
||||
42
model/gmodel/fsproductdesignmodel.go
Executable file
42
model/gmodel/fsproductdesignmodel.go
Executable file
@@ -0,0 +1,42 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type FsProductDesign struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Sn *string `gorm:"default:''" json:"sn"` // 唯一标识
|
||||
UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
TemplateId *int64 `gorm:"default:0" json:"template_id"` // 模型ID
|
||||
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
|
||||
OptionalId *int64 `gorm:"default:0" json:"optional_id"` // 选项ID
|
||||
Cover *string `gorm:"default:''" json:"cover"` // 封面图
|
||||
Info *string `gorm:"default:''" json:"info"` // 保留的设计信息
|
||||
Utime *time.Time `gorm:"" json:"utime"` // 更新时间
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态
|
||||
IsDel *int64 `gorm:"default:0" json:"is_del"` // 是否删除 0未删除 1删除
|
||||
IsPay *int64 `gorm:"default:0" json:"is_pay"` // 是否已有支付 0 未 1 有
|
||||
LogoColor *string `gorm:"default:''" json:"logo_color"` // logo图片备选项
|
||||
PageGuid *string `gorm:"default:''" json:"page_guid"` // 页面识别id
|
||||
}
|
||||
type FsProductDesignModel struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -45,6 +45,9 @@ func NewFsProductModel(db *gorm.DB) *FsProductModel {
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -60,6 +63,9 @@ func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []i
|
||||
}
|
||||
|
||||
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":
|
||||
|
||||
@@ -2,6 +2,7 @@ package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -45,9 +46,39 @@ func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, prod
|
||||
return
|
||||
}
|
||||
func (p *FsProductPriceModel) GetPriceListBySizeIds(ctx context.Context, sizeIds []int64) (resp []FsProductPrice, err error) {
|
||||
if len(sizeIds) == 0 {
|
||||
return
|
||||
}
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`size_id` in (?) and `status` = ? ", sizeIds, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type FindOneProductPriceByParamsReq struct {
|
||||
ProductId *int64
|
||||
MaterialId *int64
|
||||
SizeId *int64
|
||||
Status *int64
|
||||
}
|
||||
|
||||
func (p *FsProductPriceModel) FindOneProductPriceByParams(ctx context.Context, req FindOneProductPriceByParamsReq) (resp FsProductPrice, err error) {
|
||||
db := p.db.WithContext(ctx).Model(&FsProductPrice{})
|
||||
if req.ProductId != nil {
|
||||
db = db.Where("`product_id` = ?", *req.ProductId)
|
||||
}
|
||||
if req.MaterialId != nil {
|
||||
db = db.Where("`material_id` = ?", *req.MaterialId)
|
||||
}
|
||||
if req.SizeId != nil {
|
||||
db = db.Where("`size_id` = ?", *req.SizeId)
|
||||
}
|
||||
if req.Status != nil {
|
||||
db = db.Where("`status` = ?", *req.Status)
|
||||
}
|
||||
if err = db.First(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductPrice{}, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ func NewFsProductSizeModel(db *gorm.DB) *FsProductSizeModel {
|
||||
}
|
||||
|
||||
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
db := s.db.Model(&FsProductSize{}).Where("`id` in (?) and `status` = ?", ids, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
|
||||
@@ -31,6 +31,9 @@ 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
|
||||
|
||||
@@ -34,6 +34,9 @@ func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp FsTags, err e
|
||||
return
|
||||
}
|
||||
func (t *FsTagsModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsTags, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` in(?) and `status` = ?", ids, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user