removed Ali-OSS and essential info from project

This commit is contained in:
strawmanbobi
2016-12-04 20:41:57 +08:00
parent f8f9592cae
commit 0c4a3dda6a
14 changed files with 297 additions and 543 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -29,13 +29,6 @@ global.MONGO_DB_NAME = "default_db";
global.MONGO_DB_USER = null; global.MONGO_DB_USER = null;
global.MONGO_DB_PASSWORD = null; global.MONGO_DB_PASSWORD = null;
// data_set : Aliyun-OSS
global.OSS_HOST = "oss-cn-hangzhou.aliyuncs.com";
global.OSS_PORT = "80";
global.OSS_APP_ID = "T82nbipHSESmHzd8";
global.OSS_APP_SECRET = "SOweQ8UVwCwPr2NC8EC89EOeKJc5Um";
global.BUCKET_NAME = "strawmanbobi-beats";
// cache : memcached // cache : memcached
global.MEMCACHED_HOST = ""; global.MEMCACHED_HOST = "";
global.MEMCACHED_PORT = ""; global.MEMCACHED_PORT = "";

View File

@@ -26,7 +26,8 @@ var Brand = dbOrm.define('brand',
update_time: String, update_time: String,
priority: Number, priority: Number,
name_en: String, name_en: String,
name_tw: String name_tw: String,
contributor: String
}, },
{ {
cache: false cache: false
@@ -43,7 +44,8 @@ Brand.createBrand = function(brand, callback) {
update_time: date, update_time: date,
priority: brand.priority, priority: brand.priority,
name_en: brand.name_en, name_en: brand.name_en,
name_tw: brand.name_tw name_tw: brand.name_tw,
contributor: brand.contributor
}); });
newBrand.save(function(error, createdBrand) { newBrand.save(function(error, createdBrand) {
if(error) { if(error) {
@@ -122,6 +124,7 @@ Brand.updateBrandByID = function(brandID, newBrand, callback) {
brand.priority = newBrand.priority; brand.priority = newBrand.priority;
brand.name_en = newBrand.name_en; brand.name_en = newBrand.name_en;
brand.name_tw = newBrand.name_tw; brand.name_tw = newBrand.name_tw;
brand.contributor = newBrand.contributor;
brand.save(function(error, createdBrand) { brand.save(function(error, createdBrand) {
if(error) { if(error) {
logger.error('failed to create brand in update brand : ' + error); logger.error('failed to create brand in update brand : ' + error);

View File

@@ -20,7 +20,8 @@ var Category = dbOrm.define('category',
status: Number, status: Number,
update_time: String, update_time: String,
name_en: String, name_en: String,
name_tw: String name_tw: String,
contributor: String
}, },
{ {
cache: false cache: false
@@ -34,7 +35,8 @@ Category.createCategory = function (category, callback) {
status: 1, status: 1,
update_time: date, update_time: date,
name_en: category.name_en, name_en: category.name_en,
name_tw: category.name_tw name_tw: category.name_tw,
contributor: category.contributor
}); });
newCategory.save(function (error, createdCategory) { newCategory.save(function (error, createdCategory) {
if (error) { if (error) {

View File

@@ -22,7 +22,8 @@ var IRProtocol = dbOrm.define('ir_protocol',
name: String, name: String,
type: Number, type: Number,
status: Number, status: Number,
update_time: String update_time: String,
contributor: String
}, },
{ {
cache: false cache: false
@@ -35,7 +36,8 @@ IRProtocol.createIRProtocol = function(protocol, callback) {
name: protocol.name, name: protocol.name,
status: protocol.status, status: protocol.status,
type: protocol.type, type: protocol.type,
update_time: date update_time: date,
contributor: protocol.contributor
}); });
newProtocol.save(function(error, createdProtocol) { newProtocol.save(function(error, createdProtocol) {
if(error) { if(error) {

View File

@@ -39,7 +39,7 @@ var RemoteIndex = dbOrm.define('remote_index',
brand_name_tw: String, brand_name_tw: String,
city_name_tw: String, city_name_tw: String,
binary_md5: String, binary_md5: String,
input_source: String, contributor: String,
update_time: String update_time: String
}, },
{ {
@@ -72,7 +72,7 @@ RemoteIndex.createRemoteIndex = function(remoteIndex, callback) {
brand_name_tw: remoteIndex.brand_name_tw, brand_name_tw: remoteIndex.brand_name_tw,
city_name_tw: remoteIndex.city_name_tw, city_name_tw: remoteIndex.city_name_tw,
binary_md5: remoteIndex.binary_md5, binary_md5: remoteIndex.binary_md5,
input_source: remoteIndex.input_source, contributor: remoteIndex.contributor,
update_time: date update_time: date
}); });
newRemoteIndex.save(function(error, createdRemoteIndex) { newRemoteIndex.save(function(error, createdRemoteIndex) {
@@ -185,7 +185,7 @@ RemoteIndex.updateRemoteIndex = function(remoteIndexID, newRemoteIndex, callback
remoteIndex.brand_name_tw = newRemoteIndex.brand_name_tw; remoteIndex.brand_name_tw = newRemoteIndex.brand_name_tw;
remoteIndex.city_name_tw = newRemoteIndex.city_name_tw; remoteIndex.city_name_tw = newRemoteIndex.city_name_tw;
remoteIndex.binary_md5 = newRemoteIndex.binary_md5; remoteIndex.binary_md5 = newRemoteIndex.binary_md5;
remoteIndex.input_source = newRemoteIndex.input_source; remoteIndex.contributor = newRemoteIndex.contributor;
remoteIndex.update_time = newRemoteIndex.update_time; remoteIndex.update_time = newRemoteIndex.update_time;
remoteIndex.save(function(error, updatedRemoteIndex) { remoteIndex.save(function(error, updatedRemoteIndex) {

View File

@@ -23,6 +23,12 @@ npm install log4js
echo "npm install formidable" echo "npm install formidable"
npm install formidable npm install formidable
echo "npm install mysql"
npm install mysql
echo "npm install redis"
npm install redis
echo "npm install orm" echo "npm install orm"
npm install orm npm install orm
@@ -38,18 +44,9 @@ npm install form-data
echo "npm install async" echo "npm install async"
npm install async npm install async
echo "npm install aliyun-sdk"
npm install aliyun-sdk
echo "npm install nodemailer" echo "npm install nodemailer"
npm install nodemailer@0.7 npm install nodemailer@0.7
echo "npm install node-mysql"
npm install mysql
echo "npm install redis"
npm install redis
echo "npm install done" echo "npm install done"
echo "create logging directory" echo "create logging directory"

View File

@@ -269,7 +269,6 @@ exports.createRemoteIndex = function (req, res) {
var contentType; var contentType;
var adminID = req.query.id; var adminID = req.query.id;
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
form.on('file', function(field, file) { form.on('file', function(field, file) {
// rename the incoming file to the file's name // rename the incoming file to the file's name
@@ -296,7 +295,7 @@ exports.createRemoteIndex = function (req, res) {
// set MIME to octet-stream as there might not be any contentType passed from the front-end form // set MIME to octet-stream as there might not be any contentType passed from the front-end form
contentType = files.type || "application/octet-stream"; contentType = files.type || "application/octet-stream";
logger.info("remoteIndex.kk_remote_number = " + remoteIndex.kk_remote_number); logger.info("remoteIndex.kk_remote_number = " + remoteIndex.kk_remote_number);
internalLogic.createRemoteIndexWorkUnit(remoteIndex, filePath, contentType, ip, adminID, internalLogic.createRemoteIndexWorkUnit(remoteIndex, filePath, contentType, adminID,
function (createRemoteIndexErr) { function (createRemoteIndexErr) {
if(errorCode.SUCCESS.code == createRemoteIndexErr.code) { if(errorCode.SUCCESS.code == createRemoteIndexErr.code) {
res.send("<html>" + res.send("<html>" +
@@ -399,10 +398,8 @@ exports.createBrand = function (req, res) {
var brand = req.body; var brand = req.body;
var adminID = req.query.id; var adminID = req.query.id;
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var serviceResponse = new ServiceResponse(); var serviceResponse = new ServiceResponse();
internalLogic.createBrandWorkUnit(brand, ip, adminID, function (createBrandErr) { internalLogic.createBrandWorkUnit(brand, adminID, function (createBrandErr) {
serviceResponse.status = createBrandErr; serviceResponse.status = createBrandErr;
res.send(serviceResponse); res.send(serviceResponse);
res.end(); res.end();

View File

@@ -240,12 +240,6 @@
<input type="text" class="form-control" placeholder="eg. upd6121g_box_041 or new_ac_11737" id="remote_map"> <input type="text" class="form-control" placeholder="eg. upd6121g_box_041 or new_ac_11737" id="remote_map">
</div> </div>
<br> <br>
<!--
<div class="input-group" style="max-height: 25px;">
<span class="input-group-addon">编码来源</span>
<input type="text" class="form-control" placeholder="eg. strawmanbobi@irext.net" id="input_source">
</div>
-->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-danger" onclick="searchRemote();">确定</button> <button type="button" class="btn btn-danger" onclick="searchRemote();">确定</button>

View File

@@ -208,7 +208,7 @@ function loadRemoteList(isSearch, remoteMap) {
sortable: true, sortable: true,
clickToSelect: true clickToSelect: true
}, { }, {
field: 'input_source', field: 'contributor',
title: '来源', title: '来源',
align: 'left', align: 'left',
valign: 'middle', valign: 'middle',

View File

@@ -192,7 +192,7 @@ exports.listIRProtocolsWorkUnit = function (from, count, callback) {
}); });
}; };
exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType, ip, adminID, callback) { exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType, adminID, callback) {
////////////////////////////////////// //////////////////////////////////////
// step 1, rename input remote xml file // step 1, rename input remote xml file
var find = '\\\\'; var find = '\\\\';
@@ -211,7 +211,7 @@ exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType,
var newRemoteIndex; var newRemoteIndex;
var newACRemoteNumber; var newACRemoteNumber;
var tagType; var tagType;
var inputSource = ""; var contributor = "";
var protocolFileName = ""; var protocolFileName = "";
var localProtocolFileName = ""; var localProtocolFileName = "";
@@ -222,7 +222,7 @@ exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType,
// verify admin // verify admin
Admin.getAdminByID(adminID, function(getAdminErr, admin) { Admin.getAdminByID(adminID, function(getAdminErr, admin) {
if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) { if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) {
inputSource = admin.user_name + "-" + ip; contributor = admin.user_name;
// begin creating remote index // begin creating remote index
switch(parseInt(categoryID)) { switch(parseInt(categoryID)) {
@@ -322,7 +322,7 @@ exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType,
category_name_tw: remoteIndex.category_name_tw, category_name_tw: remoteIndex.category_name_tw,
brand_name_tw: remoteIndex.brand_name_tw, brand_name_tw: remoteIndex.brand_name_tw,
binary_md5: fileHash, binary_md5: fileHash,
input_source: inputSource contributor: contributor
}; };
// see if this remote index is already in database // see if this remote index is already in database
@@ -468,7 +468,7 @@ exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType,
city_name_tw: remoteIndex.city_name_tw, city_name_tw: remoteIndex.city_name_tw,
operator_name_tw: remoteIndex.operator_name_tw, operator_name_tw: remoteIndex.operator_name_tw,
binary_md5: fileHash, binary_md5: fileHash,
input_source: inputSource contributor: contributor
} }
} else { } else {
newRemoteIndex = { newRemoteIndex = {
@@ -486,7 +486,7 @@ exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType,
category_name_tw: remoteIndex.category_name_tw, category_name_tw: remoteIndex.category_name_tw,
brand_name_tw: remoteIndex.brand_name_tw, brand_name_tw: remoteIndex.brand_name_tw,
binary_md5: fileHash, binary_md5: fileHash,
input_source: inputSource contributor: contributor
} }
} }
@@ -546,7 +546,7 @@ exports.deleteRemoteIndexWorkUnit = function (remoteIndex, adminID, callback) {
Admin.getAdminByID(adminID, function(getAdminErr, admin) { Admin.getAdminByID(adminID, function(getAdminErr, admin) {
if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) { if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) {
if (admin.admin_type == enums.ADMIN_TYPE_EXTERNAL) { if (admin.admin_type == enums.ADMIN_TYPE_EXTERNAL) {
if(remoteIndex.input_source.indexOf(admin.user_name) == -1) { if(remoteIndex.contributor.indexOf(admin.user_name) == -1) {
logger.info("this admin " + admin.user_name + " could not change this remote index"); logger.info("this admin " + admin.user_name + " could not change this remote index");
callback(errorCode.FAILED); callback(errorCode.FAILED);
return; return;
@@ -586,7 +586,7 @@ exports.verifyRemoteIndexWorkUnit = function (remoteIndex, pass, adminID, callba
Admin.getAdminByID(adminID, function(getAdminErr, admin) { Admin.getAdminByID(adminID, function(getAdminErr, admin) {
if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) { if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) {
if (admin.admin_type == enums.ADMIN_TYPE_EXTERNAL) { if (admin.admin_type == enums.ADMIN_TYPE_EXTERNAL) {
if (remoteIndex.input_source.indexOf(admin.user_name) == -1) { if (remoteIndex.contributor.indexOf(admin.user_name) == -1) {
logger.info("this admin " + admin.user_name + " could not change this remote index"); logger.info("this admin " + admin.user_name + " could not change this remote index");
callback(errorCode.FAILED); callback(errorCode.FAILED);
return; return;
@@ -607,7 +607,7 @@ exports.fallbackRemoteIndexWorkUnit = function (remoteIndex, adminID, callback)
Admin.getAdminByID(adminID, function(getAdminErr, admin) { Admin.getAdminByID(adminID, function(getAdminErr, admin) {
if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) { if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) {
if (admin.admin_type == enums.ADMIN_TYPE_EXTERNAL) { if (admin.admin_type == enums.ADMIN_TYPE_EXTERNAL) {
if (remoteIndex.input_source.indexOf(admin.user_name) == -1) { if (remoteIndex.contributor.indexOf(admin.user_name) == -1) {
logger.info("this admin " + admin.user_name + " could not change this remote index"); logger.info("this admin " + admin.user_name + " could not change this remote index");
callback(errorCode.FAILED); callback(errorCode.FAILED);
return; return;
@@ -751,7 +751,7 @@ exports.publishRemoteIndexWorkUnit = function (callback) {
}); });
}; };
exports.createBrandWorkUnit = function (brand, ip, adminID, callback) { exports.createBrandWorkUnit = function (brand, adminID, callback) {
var conditions = { var conditions = {
category_id: brand.category_id, category_id: brand.category_id,
name: brand.name, name: brand.name,
@@ -766,7 +766,7 @@ exports.createBrandWorkUnit = function (brand, ip, adminID, callback) {
return; return;
} }
brand.input_source = admin.user_name + "-" + ip; brand.contributor = admin.user_name;
Brand.findBrandByConditions(conditions, function(findBrandErr, brands) { Brand.findBrandByConditions(conditions, function(findBrandErr, brands) {
if(errorCode.SUCCESS.code == findBrandErr.code && null != brands && brands.length > 0) { if(errorCode.SUCCESS.code == findBrandErr.code && null != brands && brands.length > 0) {
logger.info("brand already exists"); logger.info("brand already exists");
@@ -833,13 +833,13 @@ exports.createProtocolWorkUnit = function(protocol, filePath, contentType, admin
var unixFilePath = filePath.replace(re, '/'); var unixFilePath = filePath.replace(re, '/');
var lios = unixFilePath.lastIndexOf('/'); var lios = unixFilePath.lastIndexOf('/');
var fileDir = unixFilePath.substring(0, lios); var fileDir = unixFilePath.substring(0, lios);
var contributor;
var protocolName = protocol.protocol_name_b; var protocolName = protocol.protocol_name_b;
var srcFile = fileDir + "/" + protocolName + ".xml"; var srcFile = fileDir + "/" + protocolName + ".xml";
var destFile = fileDir + "/" + protocolName + ".bin"; var destFile = fileDir + "/" + protocolName + ".bin";
var protocolType = protocol.protocol_type; var protocolType = protocol.protocol_type;
var localProtocolFile = ""; var localProtocolFile = "";
var remoteProtocolFile = "";
var pythonRuntimeDir = fileDir, var pythonRuntimeDir = fileDir,
pythonFile = "irda_tv_protocol.py", pythonFile = "irda_tv_protocol.py",
@@ -853,6 +853,7 @@ exports.createProtocolWorkUnit = function(protocol, filePath, contentType, admin
Admin.getAdminByID(adminID, function(getAdminErr, admin) { Admin.getAdminByID(adminID, function(getAdminErr, admin) {
if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) { if (errorCode.SUCCESS.code == getAdminErr.code && null != admin) {
contributor = admin.user_name;
logger.info("get admin error code = " + JSON.stringify(getAdminErr) + ", admin = " + JSON.stringify(admin)); logger.info("get admin error code = " + JSON.stringify(getAdminErr) + ", admin = " + JSON.stringify(admin));
@@ -890,7 +891,8 @@ exports.createProtocolWorkUnit = function(protocol, filePath, contentType, admin
var newProtocol = { var newProtocol = {
name: protocolName, name: protocolName,
status: enums.ITEM_VALID, status: enums.ITEM_VALID,
type: protocolType type: protocolType,
contributor: contributor
}; };
var conditions = { var conditions = {
@@ -898,14 +900,17 @@ exports.createProtocolWorkUnit = function(protocol, filePath, contentType, admin
}; };
logger.info("irda_tv_protocol.py called successfully, create protocol in DB"); logger.info("irda_tv_protocol.py called successfully, create protocol in DB");
IRProtocol.findIRProtocolByConditions(conditions, function(findIRProtocolErr, IRProtocols) { IRProtocol.findIRProtocolByConditions(conditions,
function(findIRProtocolErr, IRProtocols) {
if(errorCode.SUCCESS.code == findIRProtocolErr.code && if(errorCode.SUCCESS.code == findIRProtocolErr.code &&
null != IRProtocols && null != IRProtocols &&
IRProtocols.length > 0) { IRProtocols.length > 0) {
logger.info("protocol " + protocolName + " already exists, nothing to be updated"); logger.info("protocol " + protocolName + " already exists, " +
"nothing to be updated");
callback(errorCode.SUCCESS); callback(errorCode.SUCCESS);
} else { } else {
IRProtocol.createIRProtocol(newProtocol, function(createIRProtocolErr, createdIRProtocol) { IRProtocol.createIRProtocol(newProtocol,
function(createIRProtocolErr, createdIRProtocol) {
callback(createIRProtocolErr); callback(createIRProtocolErr);
}); });
} }