Authored by htoooth

fix

... ... @@ -4,8 +4,7 @@
'use strict';
const mRoot = '../models';
const service = require(`${mRoot}/coupon-service`);
const service = require('../models/coupon-service');
const acquire = (req, res, next) => {
let uid = req.user.uid;
... ... @@ -18,7 +17,7 @@ const acquire = (req, res, next) => {
});
}
service.acquireAsync(cid, uid).then((result) => {
req.ctx(service).acquireAsync(cid, uid).then((result) => {
return res.json(result);
}).catch(next);
};
... ...
... ... @@ -43,7 +43,6 @@ const showMain = (req, res, next) => {
page: 'detail'
}, result.seo, result));
}).catch(()=> next());
};
const showMainBack = (req, res) => {
... ... @@ -62,7 +61,6 @@ const showMainBack = (req, res) => {
res.end();
}).catch();
};
/**
... ...
... ... @@ -18,7 +18,7 @@ const changeFavoriteBrand = (req, res, next) => {
let type = req.body.type || '';
if (uid && brandId) {
brandService.changeAsync(type, uid, brandId).then(result => {
req.ctx(brandService).changeAsync(type, uid, brandId).then(result => {
return res.json(result);
}).catch(next);
} else if (!uid) {
... ... @@ -42,7 +42,7 @@ const isFavoriteBrand = (req, res, next) => {
let brandId = req.query.brandId;
if (uid && brandId) {
brandService.isFavoriteAsync(uid, brandId).then(result => {
req.ctx(brandService).isFavoriteAsync(uid, brandId).then(result => {
return res.json(result);
}).catch(next);
} else {
... ... @@ -61,7 +61,7 @@ const collectProduct = (req, res, next) => {
if (uid && pid) {
switch (type) {
case 'add':
productService.createAsync(uid, pid)
req.ctx(productService).createAsync(uid, pid)
.then(result => {
if (result.code === 413) {
result.message = '该商品已经收藏';
... ... @@ -72,7 +72,7 @@ const collectProduct = (req, res, next) => {
.catch(next);
break;
case 'cancel':
productService.deleteAsync(uid, pid)
req.ctx(productService).deleteAsync(uid, pid)
.then(result => res.json(result))
.catch(next);
break;
... ... @@ -120,7 +120,7 @@ const collectShop = (req, res, next) => {
message: '收藏失败'
});
} else {
fav.toggleFavShop(shopId, uid, isadd).then(result => {
req.ctx(fav).toggleFavShop(shopId, uid, isadd).then(result => {
res.json(result);
}).catch(next);
}
... ... @@ -137,7 +137,7 @@ const isFavShop = (req, res, next) => {
});
}
fav.getFavStatus(uid, shopId, 'shop').then(result => {
req.ctx(fav).getFavStatus(uid, shopId, 'shop').then(result => {
return res.json(result);
}).catch(next);
};
... ... @@ -147,13 +147,13 @@ const num = (req, res, next) => {
let sid = _.parseInt(`0${req.query.sid}`) || 0;
if (sid) {
return brandService.getShopFavNumAsync(sid).then((result) => {
return req.ctx(brandService).getShopFavNumAsync(sid).then((result) => {
res.json(result);
}).catch(next);
}
if (bid) {
return brandService.getBrandFavNumAsync(bid).then((result) => {
return req.ctx(brandService).getBrandFavNumAsync(bid).then((result) => {
res.json(result);
}).catch(next);
}
... ...
/**
* Created by TaoHuang on 2016/6/28.
*/
'use strict';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
shopBannerAsync(shopId) {
return this.get({data: {
method: 'app.shop.banner',
shop_id: shopId
}});
}
queryShopsByBrandId(sid, bid) {
return this.get({data: {
method: 'app.product.queryShopsInfoById',
brand_id: bid,
shop_id: sid
}});
}
};
... ...
/**
* Created by TaoHuang on 2016/6/28.
*/
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const Api = require('./ctx-shop-api');
const DEFAULT_IMG = '01091c21f2317a64f123f1649fbbccf7ba';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new Api(ctx);
}
getShopBannerAsync(shopId) {
return this.api.shopBannerAsync(shopId).then((result) => {
if (result.code === 200) {
return _.includes(result.data.banner, DEFAULT_IMG) ? '' : result.data.banner;
} else {
return null;
}
});
}
queryShopByBrandIdAsync(sid, bid) {
return co(function * () {
let result = yield this.api.queryShopsByBrandId(sid, bid);
if (_.get(result, 'code') !== 200) {
return false;
}
return _.get(result, 'data[0]', {});
}).bind(this)();
}
};
... ...
... ... @@ -146,12 +146,12 @@ module.exports = class extends global.yoho.BaseModel {
* 店铺推荐
*/
getShopRecommendAsync(skn, page, limit) {
return this.get({
return this.get({data: {
method: 'web.product.shopRecommend',
product_skn: skn,
page: page || 1,
limit: limit || 20
});
}});
}
/**
... ...
... ... @@ -22,10 +22,9 @@ const ConsultServiceModel = require('./detail-consult-service');
const CommentServiceModel = require('./detail-comment-service');
const HotAreaServiceModel = require('./detail-hotarea-service');
const CouponServiceModel = require('./coupon-service');
const ShopServiceModel = require('./shop-service');
const ShopServiceModel = require('./ctx-shop-service');
const BrandServiceModel = require('./brand-service');
const favoriteProductService = require('./favorite-product-service');
const FavoriteProductServiceModel = require('./favorite-product-service');
const homeService = require('./home-service');
const HeaderModel = require('../../../doraemon/models/header');
... ... @@ -85,7 +84,7 @@ function _getProductFavoriteDataAsync(uid, pid) {
let requestApi = {};
if (pid) {
requestApi.product = favoriteProductService.isFavoriteAsync(uid, pid);
requestApi.product = this.favoriteProductService.isFavoriteAsync(uid, pid);
}
let requestData = yield Promise.props(requestApi);
... ... @@ -1107,17 +1106,21 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) {
let coupon = requestData.coupon;
let limitedInfo = requestData.limited;
let bundle = requestData.bundle;
let recommendKeywords = requestData.recommendKeywords ? JSON.parse(requestData.recommendKeywords) : [];
let recommendKeywords = JSON.parse(requestData.recommendAsync || '[]');
let shopRecommend = requestData.shopRecommend;
let alike = requestData.alike;
// 处理相似商品
result.alike = productProcess.processProductList(_.get(requestData, 'alike.data.product_list', ''));
result.alike = productProcess.processProductList(
_.get(alike, 'data.product_list', '')
);
// 推荐关键词页面
result.recommendKeywords = getKeywordsInfo(recommendKeywords);
// 处理店铺推荐
result.shopRecommend = productProcess.processProductList(
_.get(requestData, 'shopRecommend.data.product_list', '')
_.get(shopRecommend, 'data.product_list', '')
);
// 商品标签
... ... @@ -1479,11 +1482,7 @@ function saleReturn(skn) {
* 第一次把售价隐藏,防爬虫的需要
*/
function _removeSalePrice(productInfo) {
delete productInfo.goodsInfo.salePrice;
delete productInfo.goodsInfo.hasOtherPrice;
delete productInfo.goodsInfo.promotion;
return productInfo;
return _.omit(productInfo, ['goodsInfo.salePrice', 'goodsInfo.hasOtherPrice', 'goodsInfo.promotion']);
}
/**
... ... @@ -1710,6 +1709,7 @@ module.exports = class extends global.yoho.BaseModel {
this.couponService = new CouponServiceModel(ctx);
this.shopService = new ShopServiceModel(ctx);
this.brandService = new BrandServiceModel(ctx);
this.favoriteProductService = new FavoriteProductServiceModel(ctx);
// 获取评论列表
this.getShareOrderListAsync = this.commentService.getShareOrderListAsync.bind(this.commentService);
... ...
... ... @@ -4,63 +4,61 @@
* @date: 2016/7/17
*/
'use strict';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
const api = global.yoho.API;
/**
* 是否收藏API
* @function cancelFavAsync
* @param { number } uid 用户uid
* @param { number } id 收藏id
* @param { string } type 类型 product--商品 brand--品牌 shop--店铺
* @return { Object } 收藏状态
*/
isFavAsync(uid, id, type) {
return this.get({ data: {
method: 'app.favorite.isFavorite',
id: id,
uid: uid,
type: type
}});
}
/**
* 是否收藏API
* @function cancelFavAsync
* @param { number } uid 用户uid
* @param { number } id 收藏id
* @param { string } type 类型 product--商品 brand--品牌 shop--店铺
* @return { Object } 收藏状态
*/
const isFavAsync = (uid, id, type) => {
return api.get('', {
method: 'app.favorite.isFavorite',
id: id,
uid: uid,
type: type
});
};
/**
* 收藏API
* @function addFavAsync
* @param { number } uid 用户uid
* @param { number } id 收藏id
* @param { string } type 收藏类型 product--商品 brand--品牌 shop--店铺
* @return { Object } 收藏结果
*/
addFavAsync(uid, id, type) {
return this.get({ data: {
method: 'app.favorite.add',
id: id,
uid: uid,
type: type
}});
}
/**
* 收藏API
* @function addFavAsync
* @param { number } uid 用户uid
* @param { number } id 收藏id
* @param { string } type 收藏类型 product--商品 brand--品牌 shop--店铺
* @return { Object } 收藏结果
*/
const addFavAsync = (uid, id, type) => {
return api.get('', {
method: 'app.favorite.add',
id: id,
uid: uid,
type: type
});
/**
* 取消收藏API
* @function cancelFavAsync
* @param { number } uid 用户uid
* @param { number } id 收藏id
* @param { string } type 收藏类型 product--商品 brand--品牌 shop--店铺
* @return { Object } 取消收藏结果
*/
cancelFavAsync(uid, id, type) {
return this.get({ data: {
method: 'app.favorite.cancel',
fav_id: id,
uid: uid,
type: type
}});
}
};
/**
* 取消收藏API
* @function cancelFavAsync
* @param { number } uid 用户uid
* @param { number } id 收藏id
* @param { string } type 收藏类型 product--商品 brand--品牌 shop--店铺
* @return { Object } 取消收藏结果
*/
const cancelFavAsync = (uid, id, type) => {
return api.get('', {
method: 'app.favorite.cancel',
fav_id: id,
uid: uid,
type: type
});
};
module.exports = {
isFavAsync, // 是否收藏
addFavAsync, // 收藏
cancelFavAsync // 取消收藏
};
... ...
... ... @@ -4,37 +4,42 @@
'use strict';
const api = require('./favorite-api');
const serviceApi = global.yoho.SingleAPI;
const ApiService = require('./favorite-api');
const _ = require('lodash');
const isFavoriteAsync = _.partial(api.isFavAsync, _, _, 'brand');
const addFavAsync = _.partial(api.addFavAsync, _, _, 'brand');
const cancelFavAsync = _.partial(api.cancelFavAsync, _, _, 'brand');
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
});
}
const getShopFavNumAsync = (sid) => {
return serviceApi.post('/favorite', {
favIds: sid,
type: 'shop',
method: 'app.favorite.queryFavoriteCountByShopIds'
});
};
const getBrandIdNumAsync = (bid) => {
return serviceApi.post('/favorite', {
brandId: bid,
type: 'brand',
method: 'app.favorite.queryFavoriteCountByBrandId'
});
};
module.exports = {
isFavoriteAsync,
addFavAsync,
cancelFavAsync,
getShopFavNumAsync,
getBrandIdNumAsync
};
... ...
... ... @@ -4,62 +4,63 @@
'use strict';
const api = require('./favorite-brand-api');
const ApiModel = require('./favorite-brand-api');
const _ = require('lodash');
const changeAsync = (type, uid, brandId) => {
switch (type) {
case 'add':
return api.addFavAsync(uid, brandId);
case 'cancel' :
return api.cancelFavAsync(uid, brandId);
default:
return Promise.reject('favorite brand error');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new ApiModel(ctx);
this.isFavoriteAsync = this.api.isFavoriteAsync.bind(this.api);
}
};
const getShopFavNumAsync = (sid) => {
return api.getShopFavNumAsync(sid).then((result) => {
if (result.code === 200) {
return {
code: 200,
data: {
count: _.get(result, 'data[0].count')
}
};
} else {
return {
code: 500,
message: '服务器错误'
};
changeAsync(type, uid, brandId) {
switch (type) {
case 'add':
return this.api.addFavAsync(uid, brandId);
case 'cancel' :
return this.api.cancelFavAsync(uid, brandId);
default:
return Promise.reject('favorite brand error');
}
});
};
};
const getBrandFavNumAsync = (bid) => {
return api.getBrandIdNumAsync(bid).then((result) => {
if (result.code === 200) {
return {
code: 200,
data: {
count: _.get(result, 'data.count')
}
};
} else {
return {
code: 500,
message: '服务器错误'
};
}
});
};
getShopFavNumAsync(sid) {
return this.api.getShopFavNumAsync(sid).then((result) => {
if (result.code === 200) {
return {
code: 200,
data: {
count: _.get(result, 'data[0].count')
}
};
} else {
return {
code: 500,
message: '服务器错误'
};
}
});
};
const isFavoriteAsync = api.isFavoriteAsync;
getBrandFavNumAsync(bid) {
return this.api.getBrandIdNumAsync(bid).then((result) => {
if (result.code === 200) {
return {
code: 200,
data: {
count: _.get(result, 'data.count')
}
};
} else {
return {
code: 500,
message: '服务器错误'
};
}
});
};
module.exports = {
changeAsync,
isFavoriteAsync,
getShopFavNumAsync,
getBrandFavNumAsync
};
};
... ...
... ... @@ -4,38 +4,40 @@
'use strict';
const api = global.yoho.API;
const favApi = global.yoho.FavAPI;
const _ = require('lodash');
const FavoriteApiModel = require('./favorite-api');
const favoriteApi = require('./favorite-api');
const isFavoriteAsync = (uid, pid) => {
let onNewApi = false;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.favoriteApi = new FavoriteApiModel(ctx);
if (onNewApi) {
return favApi.get('', {
method: 'app.favorite.isFavoriteNew',
id: pid,
uid: uid,
type: 'product'
});
} else {
return api.get('', {
method: 'app.favorite.isFavorite',
id: pid,
uid: uid,
type: 'product'
});
this.createAsync = _.partial(this.favoriteApi.addFavAsync.bind(this.favoriteApi), _, _, 'product');
this.deleteAsync = _.partial(this.favoriteApi.cancelFavAsync.bind(this.favoriteApi), _, _, 'product');
}
};
const createAsync = _.partial(favoriteApi.addFavAsync, _, _, 'product');
const deleteAsync = _.partial(favoriteApi.cancelFavAsync, _, _, 'product');
module.exports = {
isFavoriteAsync,
createAsync,
deleteAsync
isFavoriteAsync(uid, pid) {
let onNewApi = false;
if (onNewApi) {
return this.get({
data: {
method: 'app.favorite.isFavoriteNew',
id: pid,
uid: uid,
type: 'product'
},
api: global.yoho.FavAPI
});
} else {
return this.get({
data: {
method: 'app.favorite.isFavorite',
id: pid,
uid: uid,
type: 'product'
}
});
}
}
};
... ...
... ... @@ -4,6 +4,6 @@
'use strict';
const favoriteProductAPI = require('./favorite-product-api');
const FavoriteProductAPI = require('./favorite-product-api');
module.exports = favoriteProductAPI;
module.exports = FavoriteProductAPI;
... ...
... ... @@ -6,63 +6,65 @@
'use strict';
const favAPI = require('./favorite-api');
const FavAPI = require('./favorite-api');
/**
* 收藏商品
* @function toggleFavProduct
* @param { number } productId 商品id
* @param { number } uid 用户uid
* @param { string } isadd 是否收藏 true--添加收藏 false--取消收藏
* @return { Object } 收藏结果
*/
const toggleFavProduct = (productId, uid, isadd) => {
if (isadd) {
return favAPI.addFavAsync(uid, productId, 'product');
} else {
return favAPI.cancelFavAsync(uid, productId, 'product');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.favAPI = new FavAPI(ctx);
}
};
/**
* 收藏品牌
* @function toggleFavBrand
* @param { number } brandId 品牌id
* @param { number } uid 用户uid
* @param { string } isadd 是否收藏 true--添加收藏 false--取消收藏
* @return { Object } 收藏结果
*/
const toggleFavBrand = (brandId, uid, isadd) => {
if (isadd) {
return favAPI.addFavAsync(uid, brandId, 'brand');
} else {
return favAPI.cancelFavAsync(uid, brandId, 'brand');
/**
* 收藏商品
* @function toggleFavProduct
* @param { number } productId 商品id
* @param { number } uid 用户uid
* @param { string } isadd 是否收藏 true--添加收藏 false--取消收藏
* @return { Object } 收藏结果
*/
toggleFavProduct(productId, uid, isadd) {
if (isadd) {
return this.favAPI.addFavAsync(uid, productId, 'product');
} else {
return this.favAPI.cancelFavAsync(uid, productId, 'product');
}
}
};
/**
* 收藏店铺
* @function toggleFavShop
* @param { number } shopId 店铺id
* @param { number } uid 用户uid
* @param { string } isadd 是否收藏 true--添加收藏 false--取消收藏
* @return { Object } 收藏结果
*/
const toggleFavShop = (shopId, uid, isadd) => {
if (isadd) {
return favAPI.addFavAsync(uid, shopId, 'shop');
} else {
return favAPI.cancelFavAsync(uid, shopId, 'shop');
/**
* 收藏品牌
* @function toggleFavBrand
* @param { number } brandId 品牌id
* @param { number } uid 用户uid
* @param { string } isadd 是否收藏 true--添加收藏 false--取消收藏
* @return { Object } 收藏结果
*/
toggleFavBrand(brandId, uid, isadd) {
if (isadd) {
return this.favAPI.addFavAsync(uid, brandId, 'brand');
} else {
return this.favAPI.cancelFavAsync(uid, brandId, 'brand');
}
}
};
const getFavStatus = (uid, id, type) => {
return favAPI.isFavAsync(uid, id, type);
};
/**
* 收藏店铺
* @function toggleFavShop
* @param { number } shopId 店铺id
* @param { number } uid 用户uid
* @param { string } isadd 是否收藏 true--添加收藏 false--取消收藏
* @return { Object } 收藏结果
*/
toggleFavShop(shopId, uid, isadd) {
if (isadd) {
return this.favAPI.addFavAsync(uid, shopId, 'shop');
} else {
return this.favAPI.cancelFavAsync(uid, shopId, 'shop');
}
}
getFavStatus(uid, id, type) {
return this.favAPI.isFavAsync(uid, id, type);
}
module.exports = {
getFavStatus, // 收藏状态
toggleFavProduct, // 收藏商品
toggleFavBrand, // 收藏品牌
toggleFavShop // 收藏店铺
};
... ...
... ... @@ -3,23 +3,49 @@
*/
'use strict';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
const api = global.yoho.API;
const config = global.yoho.config;
shopBannerAsync(shopId) {
return this.get({data: {
method: 'app.shop.banner',
shop_id: shopId
}});
}
/**
* 获取店铺装修的所有资源接口
*/
exports.shopsDecoratorListAsync = shopId => {
return api.get('', {
method: 'app.shopsdecorator.getList',
shop_id: shopId
}, config.apiCache);
};
queryShopsByBrandId(sid, bid) {
return this.get({data: {
method: 'app.product.queryShopsInfoById',
brand_id: bid,
shop_id: sid
}});
/**
* 获取店铺优惠券接口
*/
exports.shopCouponListAsync = (shopId, uid) => {
let extra = {
code: 200
};
if (!uid) {
extra.cache = true;
}
return api.get('', {
method: 'shop.coupons.list',
shop_id: shopId,
uid: uid
}, extra);
};
exports.shopBannerAsync = (shopId) => {
return api.get('', {
method: 'app.shop.banner',
shop_id: shopId
});
};
exports.queryShopsByBrandId = (sid, bid) => {
return api.get('', {
method: 'app.product.queryShopsInfoById',
brand_id: bid,
shop_id: sid
});
};
... ...
... ... @@ -6,35 +6,112 @@
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const Api = require('./shop-api');
const api = require('./shop-api');
const DEFAULT_IMG = '01091c21f2317a64f123f1649fbbccf7ba';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new Api(ctx);
/**
* 生成缩略图
*/
const _imageView2 = (url, width, height) => {
url += url.includes('?') ? '&' : '?';
return `${url}imageView2/1/w${width}/h/${height}`;
};
/**
* 解析 resource_data 参数
*/
const _getResourceData = list => {
list.resource_data = JSON.parse(list.resource_data || '[]');
return list;
};
/**
* 店铺Banner 资源位
*/
const _shopTopBanner = data => {
let result = {
banner: '',
isShowShopName: false,
bannerHeight: 150
};
let resource = _.head(data.resource_data);
if (resource.shopSrc) {
result.banner = _imageView2(resource.shopSrc, 1150, 150);
}
getShopBannerAsync(shopId) {
return this.api.shopBannerAsync(shopId).then((result) => {
if (result.code === 200) {
return _.includes(result.data.banner, DEFAULT_IMG) ? '' : result.data.banner;
} else {
return null;
}
});
if (resource.detailSrc) {
result.detailSrc = _imageView2(resource.detailSrc, 1150, 150);
}
queryShopByBrandIdAsync(sid, bid) {
return co(function * () {
let result = yield this.api.queryShopsByBrandId(sid, bid);
if (resource.isShowShopName) {
result.isShowShopName = resource.isShowShopName === 'Y';
}
return result;
};
const _shopTopBannerBase = _shopTopBanner;
if (_.get(result, 'code') !== 200) {
return false;
/**
* 基础模板
*/
exports.basisTemplateAsync = shopId => {
return co(function * () {
let data = { shopTopBanner_base: {}};
const ResourceHandler = {
shopTopBanner_base: _shopTopBannerBase
};
let shops = yield api.shopsDecoratorListAsync(shopId);
if (!shops.code || shops.code !== 200 || _.isEmpty(shops.data.list)) {
return data;
}
shops.data.list.forEach(shop => {
let resourceHandlerName = shop.resource_name;
if (!ResourceHandler[resourceHandlerName]) {
return;
}
return _.get(result, 'data[0]', {});
}).bind(this)();
}
let resourceData = ResourceHandler[resourceHandlerName](_getResourceData(shop));
switch (resourceHandlerName) {
case 'shopTopBanner_base':
{
data[resourceHandlerName] = resourceData;
break;
}
default:
break;
}
});
return data;
})();
};
exports.getShopBannerAsync = (shopId) => {
return api.shopBannerAsync(shopId).then((result) => {
if (result.code === 200) {
return _.includes(result.data.banner, DEFAULT_IMG) ? '' : result.data.banner;
} else {
return null;
}
});
};
exports.queryShopByBrandIdAsync = (sid, bid) => {
return co(function * () {
let result = yield api.queryShopsByBrandId(sid, bid);
if (_.get(result, 'code') !== 200) {
return false;
}
return _.get(result, 'data[0]', {});
})();
};
... ...