//#import $owl_mall_category:services/modelService.jsx

var ProductCategoryUtil = (function () {
    var f = {
        getCategoryList: function (parentId) {
            var searchArgs = {
                parent_id: parentId
            }

            var searchResult = owl_mall_categoryService.search('0', searchArgs, null, 0, 1000, [{"ext_info.pos.keyword": {order: "asc"}}]);
            if (searchResult.state === 'ok') {
                return searchResult.list;
            }
            return [];
        },
        getCategoryNamePaths: function (categoryId, spex) {
            var result = "";
            if (categoryId) {
                var jCategory = owl_mall_categoryService.get(categoryId);
                if (jCategory) {
                    var parentPathNames = jCategory.parentPathNames;
                    if (parentPathNames && parentPathNames.length > 0) {
                        for (var i = parentPathNames.length - 1; i >= 0; i--) {
                            if (result == "") {
                                result = parentPathNames[i];
                            } else {
                                result += spex + parentPathNames[i];
                            }
                        }
                    }
                }
            }
            return result;
        }
    };
    return f;
})();