favorite-brand-api.js 1.15 KB
/**
 * Created by TaoHuang on 2016/6/14.
 */

'use strict';

const ApiService = require('./favorite-api');
const _ = require('lodash');

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',
                method: 'app.favorite.queryFavoriteCountByBrandId',
            },
            url: '/favorite',
            api: global.yoho.SingleAPI
        });
    }


};