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

var UserCategoryUtil = (function () {
    var f = {
        hasChildren: function (parentId) {
            var searchArgs = {
                parent_id: parentId
            }

            var searchResult = owl_mall_u_categoryService.search('0', searchArgs, null, 0, 1, null);
            if (searchResult.state === 'ok') {
                if (searchResult.list.length > 0) {
                    return true;
                }
            }
            return false;
        },
        getCategoryPathName: function (jCategory, spex) {
            var parentPathNames = jCategory.parentPathNames;

            var namePath = "";
            if (parentPathNames) {
                if(parentPathNames.length > 1) {
                    for (var i = parentPathNames.length - 2; i >= 0; i--) {
                        var rid = parentPathNames[i];
                        if (!rid) {
                            continue;
                        }

                        if (namePath != "") {
                            namePath += spex;
                        }
                        namePath += parentPathNames[i];
                    }
                }
            }
            if (namePath != "") {
                namePath += spex;
            }
            namePath += jCategory.name;

            return namePath;
        }
    };
    return f;
})();