biz9-logic 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/biz9_config +1 -1
- package/index.js +5 -1
- package/main.js +85 -0
- package/package.json +3 -3
- package/test.js +32 -14
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Author: certifiedcoderz@gmail.com (Certified CoderZ)
|
|
|
4
4
|
License GNU General Public License v3.0
|
|
5
5
|
Description: BiZ9 Framework: Logic
|
|
6
6
|
*/
|
|
7
|
-
const { get_new_item_main,get_data_config_main,get_cloud_url_main } = require('./main.js');
|
|
7
|
+
const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main } = require('./main.js');
|
|
8
8
|
|
|
9
9
|
const get_new_item = (data_type,id) => {
|
|
10
10
|
return get_new_item_main(data_type,id);
|
|
@@ -15,9 +15,13 @@ const get_data_config = (biz9_config,params) => {
|
|
|
15
15
|
const get_cloud_url = (app_title_id,domain_url,action_url)=>{
|
|
16
16
|
return get_cloud_url_main(app_title_id,domain_url,action_url);
|
|
17
17
|
}
|
|
18
|
+
const get_biz_item = (biz9_config,item,options)=>{
|
|
19
|
+
return get_biz_item_main(biz9_config,item,options);
|
|
20
|
+
}
|
|
18
21
|
|
|
19
22
|
module.exports = {
|
|
20
23
|
get_data_config,
|
|
21
24
|
get_cloud_url,
|
|
22
25
|
get_new_item,
|
|
26
|
+
get_biz_item
|
|
23
27
|
};
|
package/main.js
CHANGED
|
@@ -5,6 +5,8 @@ License GNU General Public License v3.0
|
|
|
5
5
|
Description: BiZ9 Framework: Logic - Main
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
const moment = require('moment');
|
|
9
|
+
const { get_date_time_pretty,get_date_str,get_date_time_str,get_month_title_short,get_date_time_obj,get_time_str } = require('biz9-utility');
|
|
8
10
|
const get_new_item_main = (data_type,id) => {
|
|
9
11
|
if(!id){
|
|
10
12
|
id=0;
|
|
@@ -21,9 +23,92 @@ const get_data_config_main = (biz9_config,query) =>{
|
|
|
21
23
|
}
|
|
22
24
|
return biz9_config;
|
|
23
25
|
}
|
|
26
|
+
const get_biz_item_main=(biz9_config,item,options) =>{
|
|
27
|
+
/* option
|
|
28
|
+
* get_photo = true
|
|
29
|
+
* get_date = true
|
|
30
|
+
* get_count = true
|
|
31
|
+
* get_biz_map = true
|
|
32
|
+
*/
|
|
33
|
+
if(options.get_count){
|
|
34
|
+
if(!item.view_count){
|
|
35
|
+
item.view_count='0';
|
|
36
|
+
}
|
|
37
|
+
if(!item.like_count){
|
|
38
|
+
item.like_count='0';
|
|
39
|
+
}
|
|
40
|
+
if(!item.review_count){
|
|
41
|
+
item.review_count='0';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//photo setting - start
|
|
45
|
+
if(options.get_photo){
|
|
46
|
+
//photo
|
|
47
|
+
if(!item.photofilename){
|
|
48
|
+
item.photofilename=null;
|
|
49
|
+
}
|
|
50
|
+
let no_photo_str='/images/no_image.png';
|
|
51
|
+
let _photo_size_thumb='thumb_size_';
|
|
52
|
+
let _photo_size_mid='mid_size_';
|
|
53
|
+
let _photo_size_large='large_size_';
|
|
54
|
+
let _photo_size_square_thumb='square_thumb_size_';
|
|
55
|
+
let _photo_size_square_mid='square_mid_size_';
|
|
56
|
+
let _photo_size_square_large='square_large_size_';
|
|
57
|
+
item.photo_obj={
|
|
58
|
+
album_url : (item.photofilename) ? biz9_config.PHOTO_URL+item.photofilename : no_photo_str,
|
|
59
|
+
thumb_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_thumb+item.photofilename : no_photo_str,
|
|
60
|
+
mid_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_mid+item.photofilename : no_photo_str,
|
|
61
|
+
large_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_large+item.photofilename : no_photo_str,
|
|
62
|
+
thumb_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_thumb+item.photofilename : no_photo_str,
|
|
63
|
+
square_thumb_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_square_thumb+item.photofilename : no_photo_str,
|
|
64
|
+
square_mid_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_square_thumb+item.photofilename : no_photo_str,
|
|
65
|
+
square_large_url : (item.photofilename) ? biz9_config.PHOTO_URL+_photo_size_square_thumb+item.photofilename : no_photo_str,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//photo setting - end
|
|
69
|
+
//date setting - start
|
|
70
|
+
if(options.get_date){
|
|
71
|
+
no_date_str='';
|
|
72
|
+
if(!item.date_create){
|
|
73
|
+
item.date_create= new moment().toISOString();
|
|
74
|
+
item.date_save= new moment().toISOString();
|
|
75
|
+
}
|
|
76
|
+
item.date_obj={
|
|
77
|
+
pretty_create: (item.date_create) ? get_date_time_pretty(item.date_create) : no_date_str,
|
|
78
|
+
pretty_update: (item.date_create) ? get_date_time_pretty(item.date_save): no_date_str,
|
|
79
|
+
full_date_create: (item.date_create) ? get_date_str(item.date_create) : no_date_str,
|
|
80
|
+
full_date_update: (item.date_create) ? get_date_str(item.date_save) : no_date_str,
|
|
81
|
+
full_date_time_create: (item.date_create) ? get_date_time_str(item.date_create) : no_date_str,
|
|
82
|
+
full_date_time_update: (item.date_create) ? get_date_time_str(item.date_save) : no_date_str,
|
|
83
|
+
month_create: (item.date_create) ? get_month_title_short(1+get_date_time_obj(item.date_create).month()) : no_date_str,
|
|
84
|
+
month_update: (item.date_create) ? get_month_title_short(1+get_date_time_obj(item.date_save).month()) : no_date_str,
|
|
85
|
+
mo_create: (item.date_create) ? (1+get_date_time_obj(item.date_create).month()) : no_date_str,
|
|
86
|
+
mo_update: (item.date_create) ? (1+get_date_time_obj(item.date_save).month()) : no_date_str,
|
|
87
|
+
date_create: (item.date_create) ? get_date_time_obj(item.date_create).date() : no_date_str,
|
|
88
|
+
year_create: (item.date_create) ? get_date_time_obj(item.date_create).year() : no_date_str,
|
|
89
|
+
year_update: (item.date_create) ? get_date_time_obj(item.date_save).year() : no_date_str,
|
|
90
|
+
time_create: (item.date_create) ? get_time_str(item.date_create) : no_date_str,
|
|
91
|
+
time_update: (item.date_create) ? get_time_str(item.date_save) : no_date_str,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//date setting - end
|
|
95
|
+
//biz_map setting - start
|
|
96
|
+
if(options.get_biz_map){
|
|
97
|
+
for(a=0;a<20;a++){
|
|
98
|
+
if(item['field_'+a]){
|
|
99
|
+
item[item['field_'+a]]=item['value_'+a];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//biz_map setting - end
|
|
104
|
+
|
|
105
|
+
return item;
|
|
106
|
+
}
|
|
107
|
+
|
|
24
108
|
|
|
25
109
|
module.exports = {
|
|
26
110
|
get_data_config_main,
|
|
27
111
|
get_new_item_main,
|
|
28
112
|
get_cloud_url_main,
|
|
113
|
+
get_biz_item_main
|
|
29
114
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biz9-logic",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"async": "^3.2.6",
|
|
12
|
-
"biz9-scriptz": "^5.2.
|
|
12
|
+
"biz9-scriptz": "^5.2.34",
|
|
13
|
+
"biz9-utility": "^1.0.53"
|
|
13
14
|
},
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
@@ -19,6 +20,5 @@
|
|
|
19
20
|
"url": "https://github.com/biz9framework/biz9-logic/issues"
|
|
20
21
|
},
|
|
21
22
|
"homepage": "https://github.com/biz9framework/biz9-logic#readme",
|
|
22
|
-
"devDependencies": {},
|
|
23
23
|
"description": ""
|
|
24
24
|
}
|
package/test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const async = require('async');
|
|
2
|
-
const { get_data_config, get_new_item, get_cloud_url } = require('./');
|
|
2
|
+
const { get_data_config, get_new_item, get_cloud_url, get_biz_item } = require('./');
|
|
3
|
+
const { get_test_item,w } = require('biz9-utility');
|
|
3
4
|
/* --- TEST CONFIG START --- */
|
|
4
5
|
//const ID='0';
|
|
5
6
|
const ID='f23c2372-df8e-4c09-a919-677fe32ba0bb';
|
|
@@ -19,7 +20,8 @@ const biz9_config ={
|
|
|
19
20
|
MONGO_CONFIG_FILE_PATH:'/etc/mongod.conf',
|
|
20
21
|
SSH_KEY:"",
|
|
21
22
|
REDIS_URL:"0.0.0.0",
|
|
22
|
-
REDIS_PORT_ID:"27019"
|
|
23
|
+
REDIS_PORT_ID:"27019",
|
|
24
|
+
PHOTO_URL:"http://localhost:1901/"
|
|
23
25
|
};
|
|
24
26
|
/* --- TEST DATA CONFIG END --- */
|
|
25
27
|
|
|
@@ -27,36 +29,52 @@ describe("connect", () => {
|
|
|
27
29
|
it("_connect", () => {
|
|
28
30
|
async.series([
|
|
29
31
|
function(call) {
|
|
30
|
-
console.log('TEST-BIZ9-
|
|
32
|
+
console.log('TEST-BIZ9-LOGIC-CONNECT-START');
|
|
31
33
|
call();
|
|
32
34
|
},
|
|
33
35
|
function(call) {
|
|
34
|
-
console.log('TEST-BIZ9-
|
|
36
|
+
console.log('TEST-BIZ9-LOGIC-GET-NEW-ITEM-START');
|
|
35
37
|
var _new_item = get_new_item(DATA_TYPE,0);
|
|
36
38
|
console.log(_new_item);
|
|
37
|
-
console.log('TEST-BIZ9-
|
|
39
|
+
console.log('TEST-BIZ9-LOGIC-GET-NEW-ITEM-SUCCESS');
|
|
38
40
|
call();
|
|
39
41
|
},
|
|
40
42
|
function(call) {
|
|
41
|
-
console.log('TEST-BIZ9-
|
|
43
|
+
console.log('TEST-BIZ9-LOGIC-GET-DATA-CONFIG-START');
|
|
42
44
|
var _data_config = get_data_config(biz9_config,{app_title_id:'local_app_title_id'});
|
|
43
45
|
console.log(_data_config);
|
|
44
|
-
console.log('TEST-BIZ9-
|
|
46
|
+
console.log('TEST-BIZ9-LOGIC-GET-DATA-CONFIG-SUCCESS');
|
|
45
47
|
call();
|
|
46
48
|
},
|
|
47
49
|
function(call) {
|
|
48
|
-
console.log('TEST-BIZ9-
|
|
50
|
+
console.log('TEST-BIZ9-LOGIC-GET-CLOUD-URL-START');
|
|
49
51
|
var _cloud_url = get_cloud_url(biz9_config.APP_TITLE_ID,CLOUD_URL,'/get/test/');
|
|
50
52
|
console.log(_cloud_url);
|
|
51
|
-
console.log('TEST-BIZ9-
|
|
53
|
+
console.log('TEST-BIZ9-LOGIC-GET-CLOUD-URL-SUCCESS');
|
|
54
|
+
call();
|
|
55
|
+
},
|
|
56
|
+
function(call) {
|
|
57
|
+
console.log('TEST-BIZ9-LOGIC-SET-ITEM-BIZ-START');
|
|
58
|
+
let item_test = get_test_item();
|
|
59
|
+
item_test.photofilename='abc.png';
|
|
60
|
+
item_test.field_1 = 'my_field_1';
|
|
61
|
+
item_test.value_1 = 'my_value_1';
|
|
62
|
+
item_test.field_2 = 'my_field_2';
|
|
63
|
+
item_test.value_2 = 'my_value_2';
|
|
64
|
+
item_test.field_3 = 'my_field_3';
|
|
65
|
+
item_test.value_3 = 'my_value_3';
|
|
66
|
+
let item_biz = get_biz_item(biz9_config,item_test,{get_photo:true,get_date:true,get_count:true,get_biz_map:true});
|
|
67
|
+
//let item_biz = get_biz_item(biz9_config,item_test,{get_photo:false,get_date:false,get_count:false,get_biz_map:false});
|
|
68
|
+
console.log(item_biz);
|
|
69
|
+
console.log('TEST-BIZ9-LOGIC-SET-ITEM-BIZ-SUCCESS');
|
|
52
70
|
call();
|
|
53
71
|
},
|
|
54
72
|
], function(err, results) {
|
|
55
|
-
console.log('TEST-BIZ9-
|
|
56
|
-
console.log('TEST-BIZ9-
|
|
57
|
-
console.log('TEST-BIZ9-
|
|
58
|
-
console.log('TEST-BIZ9-
|
|
59
|
-
console.log('TEST-BIZ9-
|
|
73
|
+
console.log('TEST-BIZ9-LOGIC-CONNECT-SUCCESS');
|
|
74
|
+
console.log('TEST-BIZ9-LOGIC-GET-DATA-CONFIG-SUCCESS');
|
|
75
|
+
console.log('TEST-BIZ9-LOGIC-GET-NEW-ITEM-SUCCESS');
|
|
76
|
+
console.log('TEST-BIZ9-LOGIC-GET-CLOUD-URL-SUCCESS');
|
|
77
|
+
console.log('TEST-BIZ9-LOGIC-CONNECT-DONE');
|
|
60
78
|
});
|
|
61
79
|
});
|
|
62
80
|
});
|