This commit is contained in:
laodaming
2023-06-06 17:18:01 +08:00
parent 29f6e2ddbf
commit 8ba0952cc5
4 changed files with 80 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ type (
Update(ctx context.Context, data *FsProduct) 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 {

View File

@@ -24,3 +24,20 @@ func (m *defaultFsProductModel) GetProductListByConditions(ctx context.Context,
}
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
}