private cloud update 2020-06-14

1. completed i18n for private cloud (foreground and background)
2. fixed issues
This commit is contained in:
strawmanbobi
2020-06-14 11:56:18 +08:00
parent 7fc902a540
commit f94a89faef
28 changed files with 899 additions and 1227 deletions

View File

@@ -5,31 +5,31 @@
// global inclusion
require('../mini_poem/configuration/constants');
var logger = require('../mini_poem/logging/logger4js').helper;
let logger = require('../mini_poem/logging/logger4js').helper;
// local inclusion
var Category = require('../model/category_dao.js');
var Brand = require('../model/brand_dao.js');
var City = require('../model/city_dao.js');
var RemoteIndex = require('../model/remote_index_dao.js');
let Category = require('../model/category_dao.js');
let Brand = require('../model/brand_dao.js');
let City = require('../model/city_dao.js');
let RemoteIndex = require('../model/remote_index_dao.js');
var Enums = require('../constants/enums.js');
var ErrorCode = require('../constants/error_code.js');
let Enums = require('../constants/enums.js');
let ErrorCode = require('../constants/error_code.js');
var enums = new Enums();
var errorCode = new ErrorCode();
let enums = new Enums();
let errorCode = new ErrorCode();
var async = require('async');
let async = require('async');
exports.countRemoteWorkUnit = function(callback) {
var conditions = {
let conditions = {
status: enums.ITEM_VALID
};
Category.countCategories(conditions, function(countCategoriesErr, categoriesCount) {
Brand.countBrands(conditions, function(countBrandsErr, brandsCount) {
RemoteIndex.countRemoteIndexes(conditions, function(countRemoteIndexesErr, remoteIndexesCount) {
var statInfo = new Object();
let statInfo = {};
statInfo.categories_count = categoriesCount;
statInfo.brands_count = brandsCount;
statInfo.remote_indexes_count = remoteIndexesCount;
@@ -40,29 +40,29 @@ exports.countRemoteWorkUnit = function(callback) {
};
exports.statCategoriesWorkUnit = function(callback) {
var conditions = {
let conditions = {
status: enums.ITEM_VALID
};
var retCategoriesCount = [];
let retCategoriesCount = [];
Category.listCategories(conditions, 0, 200, "id", function(findCategoriesErr, categories) {
if (errorCode.FAILED.code == findCategoriesErr.code) {
if (errorCode.FAILED.code === findCategoriesErr.code) {
logger.error("failed to find categories");
callback(findCategoriesErr, null);
} else {
async.eachSeries(categories, function (category, innerCallback) {
var categoryName = category.name;
var categoryID = category.id;
if (enums.CATEGORY_STB != categoryID) {
var countConditions = {
let categoryName = category.name;
let categoryID = category.id;
if (enums.CATEGORY_STB !== categoryID) {
let countConditions = {
category_id: categoryID,
status: enums.ITEM_VALID
};
Brand.countBrands(countConditions,
function(countBrandsErr, brandsCount) {
if (errorCode.SUCCESS.code == countBrandsErr.code) {
var categoryStat = new Object();
if (errorCode.SUCCESS.code === countBrandsErr.code) {
let categoryStat = {};
categoryStat.id = categoryID;
categoryStat.name = categoryName;
categoryStat.brands_count = brandsCount;
@@ -73,11 +73,11 @@ exports.statCategoriesWorkUnit = function(callback) {
innerCallback();
});
} else {
var countConditions = "code LIKE '__0000';";
let countConditions = "code LIKE '__0000';";
City.countCities(countConditions,
function(countCitiesErr, citiesCount) {
if (errorCode.SUCCESS.code == countCitiesErr.code) {
var categoryStat = new Object();
if (errorCode.SUCCESS.code === countCitiesErr.code) {
let categoryStat = {};
categoryStat.id = categoryID;
categoryStat.name = categoryName;
categoryStat.brands_count = citiesCount[0].number;
@@ -97,31 +97,31 @@ exports.statCategoriesWorkUnit = function(callback) {
};
exports.statBrandsWorkUnit = function (categoryID, callback) {
var conditions = {
let conditions = {
category_id: categoryID,
status: enums.ITEM_VALID
};
var retBrandsCount = [];
let retBrandsCount = [];
Brand.listBrands(conditions, 0, 200, "priority", function(findBrandsErr, brands) {
if (errorCode.FAILED.code == findBrandsErr.code) {
if (errorCode.FAILED.code === findBrandsErr.code) {
logger.error("failed to find brands");
callback(findBrandsErr, null);
} else {
async.eachSeries(brands, function (brand, innerCallback) {
var brandName = brand.name;
var brandID = brand.id;
let brandName = brand.name;
let brandID = brand.id;
if (enums.CATEGORY_STB != categoryID) {
var countConditions = {
if (enums.CATEGORY_STB !== categoryID) {
let countConditions = {
brand_id: brandID,
status: enums.ITEM_VALID
};
RemoteIndex.countRemoteIndexes(countConditions,
function(countRemoteIndexesErr, remoteIndexesCount) {
if (errorCode.SUCCESS.code == countRemoteIndexesErr.code) {
var brandStat = new Object();
if (errorCode.SUCCESS.code === countRemoteIndexesErr.code) {
let brandStat = {};
brandStat.id = brandID;
brandStat.name = brandName;
brandStat.remote_indexes_count = remoteIndexesCount;
@@ -140,22 +140,22 @@ exports.statBrandsWorkUnit = function (categoryID, callback) {
};
exports.statCitiesWorkUnit = function (callback) {
var retCitiesCount = [];
let retCitiesCount = [];
City.listProvinces(function(listProvincesErr, provinces) {
if (errorCode.FAILED.code == listProvincesErr.code) {
if (errorCode.FAILED.code === listProvincesErr.code) {
logger.error("failed to find brands");
callback(listProvincesErr, null);
} else {
async.eachSeries(provinces, function (province, innerCallback) {
var provinceName = province.name;
var provinceCode = province.code;
var provincePrefix = provinceCode.substring(0, 2);
var countConditions = "code LIKE '" + provincePrefix + "__00' AND code <> '" + provincePrefix + "0000';";
let provinceName = province.name;
let provinceCode = province.code;
let provincePrefix = provinceCode.substring(0, 2);
let countConditions = "code LIKE '" + provincePrefix + "__00' AND code <> '" + provincePrefix + "0000';";
City.countCities(countConditions,
function(countCitiesErr, citiesCount) {
if (errorCode.SUCCESS.code == countCitiesErr.code) {
var cityStat = new Object();
if (errorCode.SUCCESS.code === countCitiesErr.code) {
let cityStat = {};
cityStat.name = provinceName;
cityStat.city_count = citiesCount[0].number;
retCitiesCount.push(cityStat);