fix
This commit is contained in:
parent
8ba0952cc5
commit
9a2f74fe64
@ -27,7 +27,6 @@ type (
|
|||||||
FindOne(ctx context.Context, id int64) (*FsFont, error)
|
FindOne(ctx context.Context, id int64) (*FsFont, error)
|
||||||
Update(ctx context.Context, data *FsFont) error
|
Update(ctx context.Context, data *FsFont) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
FindAllOrderSortByDesc(ctx context.Context) ([]*FsFont, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsFontModel struct {
|
defaultFsFontModel struct {
|
||||||
@ -71,8 +70,6 @@ func (m *defaultFsFontModel) FindOne(ctx context.Context, id int64) (*FsFont, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (m *defaultFsFontModel) Insert(ctx context.Context, data *FsFont) (sql.Result, error) {
|
func (m *defaultFsFontModel) Insert(ctx context.Context, data *FsFont) (sql.Result, error) {
|
||||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, fsFontRowsExpectAutoSet)
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, fsFontRowsExpectAutoSet)
|
||||||
ret, err := m.conn.ExecCtx(ctx, query, data.Title, data.LinuxFontname, data.FilePath, data.Sort)
|
ret, err := m.conn.ExecCtx(ctx, query, data.Title, data.LinuxFontname, data.FilePath, data.Sort)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductModel = (*customFsProductModel)(nil)
|
var _ FsProductModel = (*customFsProductModel)(nil)
|
||||||
|
|
||||||
@ -9,6 +13,8 @@ type (
|
|||||||
// and implement the added methods in customFsProductModel.
|
// and implement the added methods in customFsProductModel.
|
||||||
FsProductModel interface {
|
FsProductModel interface {
|
||||||
fsProductModel
|
fsProductModel
|
||||||
|
GetProductListByConditions(ctx context.Context, productType int, isDel int, isShelf int, sort string) ([]FsProduct, error)
|
||||||
|
GetAllProductList(ctx context.Context, isDel int, isShelf int, sort string) (resp []FsProduct, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFsProductModel struct {
|
customFsProductModel struct {
|
||||||
@ -22,3 +28,37 @@ func NewFsProductModel(conn sqlx.SqlConn) FsProductModel {
|
|||||||
defaultFsProductModel: newFsProductModel(conn),
|
defaultFsProductModel: newFsProductModel(conn),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (m *defaultFsProductModel) GetProductListByConditions(ctx context.Context, productType int, isDel int, isShelf int, sort string) (resp []FsProduct, err error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `type` = ? and `is_del` =? and `is_shelf` = ?",
|
||||||
|
fsProductRows, 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)
|
||||||
|
default:
|
||||||
|
query = fmt.Sprintf("%s order by sort DESC", query)
|
||||||
|
}
|
||||||
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, productType, isDel, isShelf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (m *defaultFsProductModel) GetAllProductList(ctx context.Context, isDel int, isShelf int, sort string) (resp []FsProduct, err error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `is_del` =? and `is_shelf` = ?",
|
||||||
|
fsProductRows, 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)
|
||||||
|
default:
|
||||||
|
query = fmt.Sprintf("%s order by sort DESC", query)
|
||||||
|
}
|
||||||
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, isDel, isShelf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductModel3dLightModel = (*customFsProductModel3dLightModel)(nil)
|
var _ FsProductModel3dLightModel = (*customFsProductModel3dLightModel)(nil)
|
||||||
|
|
||||||
@ -9,6 +14,7 @@ type (
|
|||||||
// and implement the added methods in customFsProductModel3dLightModel.
|
// and implement the added methods in customFsProductModel3dLightModel.
|
||||||
FsProductModel3dLightModel interface {
|
FsProductModel3dLightModel interface {
|
||||||
fsProductModel3dLightModel
|
fsProductModel3dLightModel
|
||||||
|
ListByIds(ctx context.Context, ids []string) (resp []FsProductModel3dLight, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFsProductModel3dLightModel struct {
|
customFsProductModel3dLightModel struct {
|
||||||
@ -22,3 +28,11 @@ func NewFsProductModel3dLightModel(conn sqlx.SqlConn) FsProductModel3dLightModel
|
|||||||
defaultFsProductModel3dLightModel: newFsProductModel3dLightModel(conn),
|
defaultFsProductModel3dLightModel: newFsProductModel3dLightModel(conn),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (m *defaultFsProductModel3dLightModel) ListByIds(ctx context.Context, ids []string) (resp []FsProductModel3dLight, err error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` in (?)", fsProductModel3dLightRows, m.table)
|
||||||
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(ids, ","))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -27,7 +27,6 @@ type (
|
|||||||
FindOne(ctx context.Context, id int64) (*FsProductModel3dLight, error)
|
FindOne(ctx context.Context, id int64) (*FsProductModel3dLight, error)
|
||||||
Update(ctx context.Context, data *FsProductModel3dLight) error
|
Update(ctx context.Context, data *FsProductModel3dLight) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
ListByIds(ctx context.Context, ids []string) (resp []FsProductModel3dLight, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductModel3dLightModel struct {
|
defaultFsProductModel3dLightModel struct {
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductModel3dModel = (*customFsProductModel3dModel)(nil)
|
var _ FsProductModel3dModel = (*customFsProductModel3dModel)(nil)
|
||||||
|
|
||||||
@ -9,6 +14,7 @@ type (
|
|||||||
// and implement the added methods in customFsProductModel3dModel.
|
// and implement the added methods in customFsProductModel3dModel.
|
||||||
FsProductModel3dModel interface {
|
FsProductModel3dModel interface {
|
||||||
fsProductModel3dModel
|
fsProductModel3dModel
|
||||||
|
ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFsProductModel3dModel struct {
|
customFsProductModel3dModel struct {
|
||||||
@ -22,3 +28,14 @@ func NewFsProductModel3dModel(conn sqlx.SqlConn) FsProductModel3dModel {
|
|||||||
defaultFsProductModel3dModel: newFsProductModel3dModel(conn),
|
defaultFsProductModel3dModel: newFsProductModel3dModel(conn),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (m *defaultFsProductModel3dModel) ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error) {
|
||||||
|
if len(sizeIds) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
query := fmt.Sprintf("select %s from %s where `size_id` in (?) and `tag` = ?", fsProductModel3dRows, m.table)
|
||||||
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(sizeIds, ","), tag)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -27,7 +27,6 @@ type (
|
|||||||
FindOne(ctx context.Context, id int64) (*FsProductModel3d, error)
|
FindOne(ctx context.Context, id int64) (*FsProductModel3d, error)
|
||||||
Update(ctx context.Context, data *FsProductModel3d) error
|
Update(ctx context.Context, data *FsProductModel3d) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductModel3dModel struct {
|
defaultFsProductModel3dModel struct {
|
||||||
|
@ -28,8 +28,6 @@ type (
|
|||||||
FindOneBySn(ctx context.Context, sn string) (*FsProduct, error)
|
FindOneBySn(ctx context.Context, sn string) (*FsProduct, error)
|
||||||
Update(ctx context.Context, data *FsProduct) error
|
Update(ctx context.Context, data *FsProduct) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
GetProductListByConditions(ctx context.Context, productType int, isDel int, isShelf int, sort string) ([]FsProduct, error)
|
|
||||||
GetAllProductList(ctx context.Context, isDel int, isShelf int, sort string) (resp []FsProduct, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductModel struct {
|
defaultFsProductModel struct {
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductPriceModel = (*customFsProductPriceModel)(nil)
|
var _ FsProductPriceModel = (*customFsProductPriceModel)(nil)
|
||||||
|
|
||||||
@ -9,6 +15,8 @@ type (
|
|||||||
// and implement the added methods in customFsProductPriceModel.
|
// and implement the added methods in customFsProductPriceModel.
|
||||||
FsProductPriceModel interface {
|
FsProductPriceModel interface {
|
||||||
fsProductPriceModel
|
fsProductPriceModel
|
||||||
|
GetPriceList(ctx context.Context, productIds []string) ([]GetPriceListRsp, error)
|
||||||
|
FindOneByProductIdMaterialIdSizeId(ctx context.Context, productId int64, materialId int64, sizeId int64) (*FsProductPrice, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFsProductPriceModel struct {
|
customFsProductPriceModel struct {
|
||||||
@ -22,3 +30,32 @@ func NewFsProductPriceModel(conn sqlx.SqlConn) FsProductPriceModel {
|
|||||||
defaultFsProductPriceModel: newFsProductPriceModel(conn),
|
defaultFsProductPriceModel: newFsProductPriceModel(conn),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetPriceListRsp struct {
|
||||||
|
ProductId int64 `json:"product_id"`
|
||||||
|
Price string `json:"price"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultFsProductPriceModel) GetPriceList(ctx context.Context, productIds []string) (resp []GetPriceListRsp, err error) {
|
||||||
|
if len(productIds) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
query := fmt.Sprintf("select %s from %s where `product_id` in (?) and `status` = ? group by product_id", "product_id,group_concat(step_price) as price ", m.table)
|
||||||
|
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(productIds, ","), 1); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (m *defaultFsProductPriceModel) FindOneByProductIdMaterialIdSizeId(ctx context.Context, productId int64, materialId int64, sizeId int64) (*FsProductPrice, error) {
|
||||||
|
var resp FsProductPrice
|
||||||
|
query := fmt.Sprintf("select %s from %s where `product_id` = ? and `material_id` = ? and `size_id` = ? limit 1", fsProductPriceRows, m.table)
|
||||||
|
err := m.conn.QueryRowCtx(ctx, &resp, query, productId, materialId, sizeId)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,10 +25,8 @@ type (
|
|||||||
fsProductPriceModel interface {
|
fsProductPriceModel interface {
|
||||||
Insert(ctx context.Context, data *FsProductPrice) (sql.Result, error)
|
Insert(ctx context.Context, data *FsProductPrice) (sql.Result, error)
|
||||||
FindOne(ctx context.Context, id int64) (*FsProductPrice, error)
|
FindOne(ctx context.Context, id int64) (*FsProductPrice, error)
|
||||||
FindOneByProductIdMaterialIdSizeId(ctx context.Context, productId int64, materialId int64, sizeId int64) (*FsProductPrice, error)
|
|
||||||
Update(ctx context.Context, data *FsProductPrice) error
|
Update(ctx context.Context, data *FsProductPrice) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
GetPriceList(ctx context.Context, productIds []string) ([]GetPriceListRsp, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductPriceModel struct {
|
defaultFsProductPriceModel struct {
|
||||||
@ -80,20 +78,6 @@ func (m *defaultFsProductPriceModel) FindOne(ctx context.Context, id int64) (*Fs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultFsProductPriceModel) FindOneByProductIdMaterialIdSizeId(ctx context.Context, productId int64, materialId int64, sizeId int64) (*FsProductPrice, error) {
|
|
||||||
var resp FsProductPrice
|
|
||||||
query := fmt.Sprintf("select %s from %s where `product_id` = ? and `material_id` = ? and `size_id` = ? limit 1", fsProductPriceRows, m.table)
|
|
||||||
err := m.conn.QueryRowCtx(ctx, &resp, query, productId, materialId, sizeId)
|
|
||||||
switch err {
|
|
||||||
case nil:
|
|
||||||
return &resp, nil
|
|
||||||
case sqlc.ErrNotFound:
|
|
||||||
return nil, ErrNotFound
|
|
||||||
default:
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultFsProductPriceModel) Insert(ctx context.Context, data *FsProductPrice) (sql.Result, error) {
|
func (m *defaultFsProductPriceModel) Insert(ctx context.Context, data *FsProductPrice) (sql.Result, error) {
|
||||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductPriceRowsExpectAutoSet)
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductPriceRowsExpectAutoSet)
|
||||||
ret, err := m.conn.ExecCtx(ctx, query, data.Sn, data.Title, data.ProductId, data.MaterialId, data.SizeId, data.EachBoxNum, data.EachBoxWeight, data.MinBuyNum, data.StepNum, data.StepPrice, data.Status, data.IsDefault)
|
ret, err := m.conn.ExecCtx(ctx, query, data.Sn, data.Title, data.ProductId, data.MaterialId, data.SizeId, data.EachBoxNum, data.EachBoxWeight, data.MinBuyNum, data.StepNum, data.StepPrice, data.Status, data.IsDefault)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductSizeModel = (*customFsProductSizeModel)(nil)
|
var _ FsProductSizeModel = (*customFsProductSizeModel)(nil)
|
||||||
|
|
||||||
@ -9,6 +13,8 @@ type (
|
|||||||
// and implement the added methods in customFsProductSizeModel.
|
// and implement the added methods in customFsProductSizeModel.
|
||||||
FsProductSizeModel interface {
|
FsProductSizeModel interface {
|
||||||
fsProductSizeModel
|
fsProductSizeModel
|
||||||
|
CountByStatus(ctx context.Context, status int) (total int, err error)
|
||||||
|
FindAllByStatus(ctx context.Context, status int, sort int) ([]FsProductSize, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFsProductSizeModel struct {
|
customFsProductSizeModel struct {
|
||||||
@ -22,3 +28,25 @@ func NewFsProductSizeModel(conn sqlx.SqlConn) FsProductSizeModel {
|
|||||||
defaultFsProductSizeModel: newFsProductSizeModel(conn),
|
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) FindAllByStatus(ctx context.Context, status int, sort int) (resp []FsProductSize, err error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `status` = ? ", fsProductSizeRows, 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)
|
||||||
|
}
|
||||||
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, status)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -27,8 +27,6 @@ type (
|
|||||||
FindOne(ctx context.Context, id int64) (*FsProductSize, error)
|
FindOne(ctx context.Context, id int64) (*FsProductSize, error)
|
||||||
Update(ctx context.Context, data *FsProductSize) error
|
Update(ctx context.Context, data *FsProductSize) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
CountByStatus(ctx context.Context, status int) (total int, err error)
|
|
||||||
FindAllByStatus(ctx context.Context, status int, sort int) ([]FsProductSize, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductSizeModel struct {
|
defaultFsProductSizeModel struct {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductTemplateTagsModel = (*customFsProductTemplateTagsModel)(nil)
|
var _ FsProductTemplateTagsModel = (*customFsProductTemplateTagsModel)(nil)
|
||||||
|
|
||||||
@ -9,6 +13,7 @@ type (
|
|||||||
// and implement the added methods in customFsProductTemplateTagsModel.
|
// and implement the added methods in customFsProductTemplateTagsModel.
|
||||||
FsProductTemplateTagsModel interface {
|
FsProductTemplateTagsModel interface {
|
||||||
fsProductTemplateTagsModel
|
fsProductTemplateTagsModel
|
||||||
|
ListByIds(ctx context.Context, ids []string) (resp []FsProductTemplateTags, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
customFsProductTemplateTagsModel struct {
|
customFsProductTemplateTagsModel struct {
|
||||||
@ -22,3 +27,14 @@ func NewFsProductTemplateTagsModel(conn sqlx.SqlConn) FsProductTemplateTagsModel
|
|||||||
defaultFsProductTemplateTagsModel: newFsProductTemplateTagsModel(conn),
|
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
|
||||||
|
}
|
||||||
|
@ -27,7 +27,6 @@ type (
|
|||||||
FindOne(ctx context.Context, id int64) (*FsProductTemplateTags, error)
|
FindOne(ctx context.Context, id int64) (*FsProductTemplateTags, error)
|
||||||
Update(ctx context.Context, data *FsProductTemplateTags) error
|
Update(ctx context.Context, data *FsProductTemplateTags) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
ListByIds(ctx context.Context, ids []string) (resp []FsProductTemplateTags, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductTemplateTagsModel struct {
|
defaultFsProductTemplateTagsModel struct {
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
var _ FsProductTemplateV2Model = (*customFsProductTemplateV2Model)(nil)
|
var _ FsProductTemplateV2Model = (*customFsProductTemplateV2Model)(nil)
|
||||||
|
|
||||||
@ -9,6 +14,9 @@ type (
|
|||||||
// and implement the added methods in customFsProductTemplateV2Model.
|
// and implement the added methods in customFsProductTemplateV2Model.
|
||||||
FsProductTemplateV2Model interface {
|
FsProductTemplateV2Model interface {
|
||||||
fsProductTemplateV2Model
|
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 {
|
customFsProductTemplateV2Model struct {
|
||||||
@ -22,3 +30,43 @@ func NewFsProductTemplateV2Model(conn sqlx.SqlConn) FsProductTemplateV2Model {
|
|||||||
defaultFsProductTemplateV2Model: newFsProductTemplateV2Model(conn),
|
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
|
||||||
|
}
|
||||||
|
@ -27,9 +27,6 @@ type (
|
|||||||
FindOne(ctx context.Context, id int64) (*FsProductTemplateV2, error)
|
FindOne(ctx context.Context, id int64) (*FsProductTemplateV2, error)
|
||||||
Update(ctx context.Context, data *FsProductTemplateV2) error
|
Update(ctx context.Context, data *FsProductTemplateV2) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductTemplateV2Model struct {
|
defaultFsProductTemplateV2Model struct {
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (m *defaultFsProductModel) GetProductListByConditions(ctx context.Context, productType int, isDel int, isShelf int, sort string) (resp []FsProduct, err error) {
|
|
||||||
query := fmt.Sprintf("select %s from %s where `type` = ? and `is_del` =? and `is_shelf` = ?",
|
|
||||||
fsProductRows, 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)
|
|
||||||
default:
|
|
||||||
query = fmt.Sprintf("%s order by sort DESC", query)
|
|
||||||
}
|
|
||||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, productType, isDel, isShelf)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (m *defaultFsProductModel) GetAllProductList(ctx context.Context, isDel int, isShelf int, sort string) (resp []FsProduct, err error) {
|
|
||||||
query := fmt.Sprintf("select %s from %s where `is_del` =? and `is_shelf` = ?",
|
|
||||||
fsProductRows, 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)
|
|
||||||
default:
|
|
||||||
query = fmt.Sprintf("%s order by sort DESC", query)
|
|
||||||
}
|
|
||||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, isDel, isShelf)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (m *defaultFsProductModel3dLightModel) ListByIds(ctx context.Context, ids []string) (resp []FsProductModel3dLight, err error) {
|
|
||||||
query := fmt.Sprintf("select %s from %s where `id` in (?)", fsProductModel3dLightRows, m.table)
|
|
||||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(ids, ","))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (m *defaultFsProductModel3dModel) ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error) {
|
|
||||||
if len(sizeIds) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
query := fmt.Sprintf("select %s from %s where `size_id` in (?) and `tag` = ?", fsProductModel3dRows, m.table)
|
|
||||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(sizeIds, ","), tag)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetPriceListRsp struct {
|
|
||||||
ProductId int64 `json:"product_id"`
|
|
||||||
Price string `json:"price"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultFsProductPriceModel) GetPriceList(ctx context.Context, productIds []string) (resp []GetPriceListRsp, err error) {
|
|
||||||
if len(productIds) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
query := fmt.Sprintf("select %s from %s where `product_id` in (?) and `status` = ? group by product_id", "product_id,group_concat(step_price) as price ", m.table)
|
|
||||||
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(productIds, ","), 1); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
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) FindAllByStatus(ctx context.Context, status int, sort int) (resp []FsProductSize, err error) {
|
|
||||||
query := fmt.Sprintf("select %s from %s where `status` = ? ", fsProductSizeRows, 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)
|
|
||||||
}
|
|
||||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, status)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user