Blame view

apps/product/models/favorite-brand-api.js 1.15 KB
htoooth authored
1 2 3
/**
 * Created by TaoHuang on 2016/6/14.
 */
htoooth authored
4
htoooth authored
5
'use strict';
htoooth authored
6
htoooth authored
7
const ApiService = require('./favorite-api');
htoooth authored
8
const _ = require('lodash');
yoho authored
9
htoooth authored
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
        this.api = new ApiService(ctx);

        this.isFavoriteAsync = _.partial(this.api.isFavAsync.bind(this.api), _, _, 'brand');
        this.addFavAsync = _.partial(this.api.addFavAsync.bind(this.api), _, _, 'brand');
        this.cancelFavAsync = _.partial(this.api.cancelFavAsync.bind(this.api), _, _, 'brand');
    }

    getShopFavNumAsync(sid) {
        return this.post({
            data: {
                favIds: sid,
                type: 'shop',
                method: 'app.favorite.queryFavoriteCountByShopIds'
            },
            url: '/favorite',
            api: global.yoho.SingleAPI
        });
    }

    getBrandIdNumAsync(bid) {
        return this.post({
            data: {
                brandId: bid,
                type: 'brand',
htoooth authored
37
                method: 'app.favorite.queryFavoriteCountByBrandId'
htoooth authored
38 39 40 41 42
            },
            url: '/favorite',
            api: global.yoho.SingleAPI
        });
    }
htoooth authored
43
htoooth authored
44
htoooth authored
45
};