biz9-logic 3.5.12 → 3.5.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 +19 -3
- package/main.js +35 -6
- package/package.json +2 -2
- package/test.js +42 -17
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -47,6 +47,13 @@ class DataItem {
|
|
|
47
47
|
static get_biz = (biz9_config,item,options)=>{
|
|
48
48
|
return get_biz_item_main(biz9_config,item,options);
|
|
49
49
|
}
|
|
50
|
+
static get_biz_by_list = (biz9_config,list,options)=>{
|
|
51
|
+
let r_list = [];
|
|
52
|
+
for(let a=0;a<list.length;a++){
|
|
53
|
+
r_list.push(get_biz_item_main(biz9_config,list[a],options));
|
|
54
|
+
}
|
|
55
|
+
return r_list;
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
class BiZ_Url {
|
|
52
59
|
static get_item=(biz9_config,data_type,id)=>{
|
|
@@ -113,7 +120,7 @@ class Obj {
|
|
|
113
120
|
}
|
|
114
121
|
};
|
|
115
122
|
class Cat {
|
|
116
|
-
static
|
|
123
|
+
static get_category_drop_down_list_by_list = (cat_list) => {
|
|
117
124
|
let category_list = [];
|
|
118
125
|
for(let a=0;a<cat_list.length;a++){
|
|
119
126
|
category_list.push({value:cat_list[a].title,label:cat_list[a].title});
|
|
@@ -168,8 +175,9 @@ class CMS {
|
|
|
168
175
|
static Tab_Edit_Title_List = 'list';
|
|
169
176
|
static Tab_Edit_Title_Value = 'value';
|
|
170
177
|
static Tab_Edit_Title_Setting = 'setting';
|
|
178
|
+
static Tab_Edit_Title_Audio = 'audio';
|
|
179
|
+
static Tab_Edit_Title_Video = 'video';
|
|
171
180
|
static Tab_Edit_Title_Note = 'note';
|
|
172
|
-
|
|
173
181
|
static get_new_query_item_by_item = (item) => {
|
|
174
182
|
return {
|
|
175
183
|
id: item.id ? item.id : 0,
|
|
@@ -228,10 +236,19 @@ class CMS {
|
|
|
228
236
|
break;
|
|
229
237
|
case CMS.Tab_Edit_Title_Setting:
|
|
230
238
|
return 'Settings';
|
|
239
|
+
break;
|
|
231
240
|
case CMS.Tab_Edit_Title_Note:
|
|
232
241
|
return 'Note';
|
|
242
|
+
break;
|
|
243
|
+
case CMS.Tab_Edit_Title_Audio:
|
|
244
|
+
return 'Audio';
|
|
245
|
+
break;
|
|
246
|
+
case CMS.Tab_Edit_Title_Video:
|
|
247
|
+
return 'Video';
|
|
248
|
+
break;
|
|
233
249
|
default:
|
|
234
250
|
return 'N/A';
|
|
251
|
+
break;
|
|
235
252
|
}
|
|
236
253
|
}
|
|
237
254
|
static get_page_url = (url,tab_title,item,parent_item,top_item,parms) => {
|
|
@@ -253,7 +270,6 @@ class CMS {
|
|
|
253
270
|
return url+r_url;
|
|
254
271
|
}
|
|
255
272
|
}
|
|
256
|
-
|
|
257
273
|
module.exports = {
|
|
258
274
|
DataType,
|
|
259
275
|
DataItem,
|
package/main.js
CHANGED
|
@@ -5,7 +5,7 @@ License GNU General Public License v3.0
|
|
|
5
5
|
Description: BiZ9 Framework: Logic - Main
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const { DateTime } = require('biz9-utility');
|
|
8
|
+
const { DateTime,Number } = require('biz9-utility');
|
|
9
9
|
const biz9_config_local=__dirname+"/../../"+"biz9_config";
|
|
10
10
|
|
|
11
11
|
const get_cloud_filter_obj_main = (data_type,filter,sort_by,page_current,page_size) => {
|
|
@@ -25,9 +25,38 @@ const get_cloud_url_main = (app_title_id,domain_url,action_url,params) =>{
|
|
|
25
25
|
return domain_url+"/"+action_url+app_title_id_url + params;
|
|
26
26
|
}
|
|
27
27
|
const get_biz_item_main=(biz9_config,item,options) =>{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/*
|
|
29
|
+
-options {
|
|
30
|
+
get_count: true/false, false=default --
|
|
31
|
+
get_date: true/false, false=default --
|
|
32
|
+
get_biz_map: true/false, false=default --
|
|
33
|
+
get_money: true/false, false=default --
|
|
34
|
+
}
|
|
35
|
+
*/
|
|
36
|
+
//money setting - start
|
|
37
|
+
if(options.get_money){
|
|
38
|
+
if(isNaN(item.cost)){
|
|
39
|
+
item.cost=parseFloat(0.00);
|
|
40
|
+
}
|
|
41
|
+
if(isNaN(item.old_cost)){
|
|
42
|
+
item.old_cost=parseFloat(0.00);
|
|
43
|
+
}
|
|
44
|
+
if(isNaN(item.discount)){
|
|
45
|
+
item.discount=parseFloat(0.00);
|
|
46
|
+
}
|
|
47
|
+
discount = item.old_cost - item.cost;
|
|
48
|
+
item.discount= parseInt(((discount / item.old_cost) * 100));
|
|
49
|
+
if(isNaN(item.discount)){
|
|
50
|
+
item.discount="0%";
|
|
51
|
+
}else{
|
|
52
|
+
item.discount=item.discount+"%";
|
|
53
|
+
}
|
|
54
|
+
item.cost = Number.get_money(item.cost);
|
|
55
|
+
item.old_cost = Number.get_money(item.old_cost);
|
|
56
|
+
}
|
|
57
|
+
//money setting - end
|
|
58
|
+
|
|
59
|
+
//count setting - start
|
|
31
60
|
if(options.get_count){
|
|
32
61
|
if(!item.view_count){
|
|
33
62
|
item.view_count='0';
|
|
@@ -39,6 +68,7 @@ const get_biz_item_main=(biz9_config,item,options) =>{
|
|
|
39
68
|
item.review_count='0';
|
|
40
69
|
}
|
|
41
70
|
}
|
|
71
|
+
//count setting - end
|
|
42
72
|
//date setting - start
|
|
43
73
|
if(options.get_date){
|
|
44
74
|
let no_date_str='';
|
|
@@ -46,7 +76,7 @@ const get_biz_item_main=(biz9_config,item,options) =>{
|
|
|
46
76
|
item.date_create = DateTime.get_new_date();
|
|
47
77
|
item.date_save = DateTime.get_new_date();
|
|
48
78
|
}
|
|
49
|
-
item
|
|
79
|
+
item={
|
|
50
80
|
pretty_create: (item.date_create) ? DateTime.get_pretty(item.date_create) : no_date_str,
|
|
51
81
|
pretty_update: (item.date_create) ? DateTime.get_pretty(item.date_save): no_date_str,
|
|
52
82
|
full_date_create: (item.date_create) ? DateTime.get_date_str(item.date_create) : no_date_str,
|
|
@@ -74,7 +104,6 @@ const get_biz_item_main=(biz9_config,item,options) =>{
|
|
|
74
104
|
}
|
|
75
105
|
}
|
|
76
106
|
//biz_map setting - end
|
|
77
|
-
|
|
78
107
|
return item;
|
|
79
108
|
}
|
|
80
109
|
const get_title_url_main = (title) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biz9-logic",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.15",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"async-series": "^0.0.1",
|
|
12
12
|
"biz9-scriptz": "^5.5.4",
|
|
13
|
-
"biz9-utility": "^2.
|
|
13
|
+
"biz9-utility": "^3.2.5",
|
|
14
14
|
"jest": "^29.7.0"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
package/test.js
CHANGED
|
@@ -28,6 +28,47 @@ const biz9_config ={
|
|
|
28
28
|
describe("connect", () => {
|
|
29
29
|
it("_connect", () => {
|
|
30
30
|
series([
|
|
31
|
+
function(call) {
|
|
32
|
+
console.log('SET-ITEM-BIZ-BY-LIST-START');
|
|
33
|
+
let item_test_list = [];
|
|
34
|
+
let item_test = Test.get_item('dt_blank',0);
|
|
35
|
+
item_test.cost = String(Number.get_id())+'.55';
|
|
36
|
+
item_test.old_cost = String(Number.get_id())+'.20';
|
|
37
|
+
item_test.title ='_title_'+Number.get_id();
|
|
38
|
+
|
|
39
|
+
item_test_list.push(item_test);
|
|
40
|
+
|
|
41
|
+
let item_test_1 = Test.get_item('dt_blank',0);
|
|
42
|
+
item_test_1.cost = '5.55';
|
|
43
|
+
item_test_1.old_cost = '9.55';
|
|
44
|
+
item_test_1.title ='_title_'+Number.get_id();
|
|
45
|
+
|
|
46
|
+
item_test_list.push(item_test_1);
|
|
47
|
+
|
|
48
|
+
let item_list_biz = DataItem.get_biz_by_list(biz9_config,item_test_list,{get_date:false,get_count:false,get_biz_map:false,get_money:true});
|
|
49
|
+
console.log(item_list_biz);
|
|
50
|
+
console.log('SET-ITEM-BIZ-BY-LIST-SUCCESS');
|
|
51
|
+
//call();
|
|
52
|
+
},
|
|
53
|
+
function(call) {
|
|
54
|
+
console.log('SET-ITEM-BIZ-START');
|
|
55
|
+
let item_test = Test.get_item('dt_blank',0);
|
|
56
|
+
item_test.photofilename='abc.png';
|
|
57
|
+
item_test.cost = '5.55';
|
|
58
|
+
item_test.old_cost = '9.55';
|
|
59
|
+
item_test.field_1 = 'my_field_1';
|
|
60
|
+
item_test.value_1 = 'my_value_1';
|
|
61
|
+
item_test.field_2 = 'my_field_2';
|
|
62
|
+
item_test.value_2 = 'my_value_2';
|
|
63
|
+
item_test.field_3 = 'my_field_3';
|
|
64
|
+
item_test.value_3 = 'my_value_3';
|
|
65
|
+
let item_biz = DataItem.get_biz(biz9_config,item_test,{get_date:false,get_count:false,get_biz_map:false,get_money:true});
|
|
66
|
+
console.log(item_biz);
|
|
67
|
+
console.log('SET-ITEM-BIZ-SUCCESS');
|
|
68
|
+
call();
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/*
|
|
31
72
|
function(call) {
|
|
32
73
|
console.log('SET_CATEGORY_DROP_DOWN_LIST-START');
|
|
33
74
|
let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
|
|
@@ -42,7 +83,6 @@ describe("connect", () => {
|
|
|
42
83
|
//call()
|
|
43
84
|
},
|
|
44
85
|
|
|
45
|
-
/*
|
|
46
86
|
|
|
47
87
|
function(call) {
|
|
48
88
|
console.log('GET-BiZ-Url-Item-Get-Item-START');
|
|
@@ -203,22 +243,7 @@ describe("connect", () => {
|
|
|
203
243
|
console.log('GET-NEW-ITEM-SUCCESS');
|
|
204
244
|
call()
|
|
205
245
|
},
|
|
206
|
-
|
|
207
|
-
console.log('SET-ITEM-BIZ-START');
|
|
208
|
-
let item_test = Test.get_item('dt_blank',0);
|
|
209
|
-
item_test.photofilename='abc.png';
|
|
210
|
-
item_test.field_1 = 'my_field_1';
|
|
211
|
-
item_test.value_1 = 'my_value_1';
|
|
212
|
-
item_test.field_2 = 'my_field_2';
|
|
213
|
-
item_test.value_2 = 'my_value_2';
|
|
214
|
-
item_test.field_3 = 'my_field_3';
|
|
215
|
-
item_test.value_3 = 'my_value_3';
|
|
216
|
-
let item_biz = DataItem.get_biz(biz9_config,item_test,{get_date:true,get_count:true,get_biz_map:true});
|
|
217
|
-
console.log(item_biz);
|
|
218
|
-
console.log('SET-ITEM-BIZ-SUCCESS');
|
|
219
|
-
call();
|
|
220
|
-
},
|
|
221
|
-
function(call) {
|
|
246
|
+
function(call) {
|
|
222
247
|
console.log('GET_URL-BIZ-ITEM-START');
|
|
223
248
|
let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
|
|
224
249
|
let data_type = 'dt_blank';
|