fix
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user