Browse Source

api exclude 0 number goods

Ark 4 years ago
parent
commit
2b7174e484
1 changed files with 8 additions and 2 deletions
  1. 8 2
      src/api/controller/index.js

+ 8 - 2
src/api/controller/index.js

@@ -4,8 +4,14 @@ module.exports = class extends Base {
   async indexAction() {
   async indexAction() {
     const banner = await this.model('ad').where({ad_position_id: 1}).select();
     const banner = await this.model('ad').where({ad_position_id: 1}).select();
     const channel = await this.model('channel').order({sort_order: 'asc'}).select();
     const channel = await this.model('channel').order({sort_order: 'asc'}).select();
-    const newGoods = await this.model('goods').field(['id', 'name', 'list_pic_url', 'retail_price']).where({is_new: 1}).select();
-    const hotGoods = await this.model('goods').field(['id', 'name', 'list_pic_url', 'retail_price', 'goods_brief']).where({is_hot: 1}).select();
+    const newGoods = await this.model('goods').field(['id', 'name', 'list_pic_url', 'retail_price']).where({
+      is_new: 1,
+      goods_number: ['>', 0]
+    }).select();
+    const hotGoods = await this.model('goods').field(['id', 'name', 'list_pic_url', 'retail_price', 'goods_brief']).where({
+      is_hot: 1,
+      goods_number: ['>', 0]
+    }).select();
     const brandList = await this.model('brand').where({is_new: 1}).order({new_sort_order: 'asc'}).limit(4).select();
     const brandList = await this.model('brand').where({is_new: 1}).order({new_sort_order: 'asc'}).limit(4).select();
     const topicList = await this.model('topic').limit(3).select();
     const topicList = await this.model('topic').limit(3).select();