biz9-logic 4.8.130 → 4.8.134

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.
Files changed (4) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +126 -28
  3. package/package.json +1 -1
  4. package/test.js +11 -4
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='6.1.0'
1
+ VERSION='6.1.4'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -4,8 +4,7 @@ Author: certifiedcoderz@gmail.com (Certified CoderZ)
4
4
  License GNU General Public License v3.0
5
5
  Description: BiZ9 Framework: Logic-JS
6
6
  */
7
- const moment = require('moment');
8
- const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main,get_cloud_filter_obj_main,get_new_full_item_main } = require('./main');
7
+ const moment = require('moment'); const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main,get_cloud_filter_obj_main,get_new_full_item_main } = require('./main');
9
8
  const { Log,Str,DateTime,Number,Obj } = require('/home/think2/www/doqbox/biz9-framework/biz9-utility/code');
10
9
  class Message {
11
10
  static SUCCESS="Update Success";
@@ -46,6 +45,9 @@ class Item_Logic {
46
45
  static get_search = (data_type,filter,sort_by,page_current,page_size) => {
47
46
  return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
48
47
  }
48
+ static get_note = () => {
49
+ return "Note "+String(Number.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
50
+ }
49
51
  static get_search_query(search){
50
52
  let url = "";
51
53
  if(search.data_type){
@@ -95,6 +97,24 @@ class Item_Logic {
95
97
  return Item_Logic.get_search(query.data_type,filter,sort_by,query.page_current,query.page_size);
96
98
  }
97
99
  }
100
+ class Stat_Logic {
101
+ /*
102
+ static STAT_VIEW_ADD_ID='1';
103
+ static STAT_LIKE_ADD_ID='2';
104
+ static STAT_FAVORITE_ADD_ID='3';
105
+ static STAT_CART_ADD_ID='4';
106
+ static STAT_ORDER_ADD_ID='5';
107
+ static STAT_REVIEW_ADD_ID='6';
108
+ */
109
+ static get_new = (parent_data_type,user_id,stat_type_id,item_list,option)=>{
110
+ return {
111
+ parent_data_type:parent_data_type,
112
+ user_id:user_id,
113
+ stat_type_id:stat_type_id,
114
+ item_list:item_list,
115
+ }
116
+ }
117
+ }
98
118
  class Template_Logic {
99
119
  static get_test = (title,option) =>{
100
120
  if(!Str.check_is_null(title) && Obj.check_is_empty(option)){
@@ -580,8 +600,7 @@ class Field_Logic {
580
600
  static get_test = (title,option) =>{
581
601
  option = !Obj.check_is_empty(option) ? option : {};
582
602
  let sub_note = "Sub Note "+String(Number.get_id());
583
- let note = "Note "+String(Number.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
584
- if(option.get_blank == true){
603
+ if(option.get_blank == true){
585
604
  date_create:"";
586
605
  date_save:"";
587
606
  title = "";
@@ -594,7 +613,7 @@ class Field_Logic {
594
613
  setting_visible:"1",
595
614
  title_url:Str.get_title_url(title),
596
615
  sub_note:sub_note,
597
- note:note,
616
+ note:Item_Logic.get_note(),
598
617
  view_count:0,
599
618
  id:0,
600
619
  date_create:new moment().toISOString(),
@@ -772,6 +791,9 @@ class Field_Logic {
772
791
  option.category_event_count = req.query.category_event_count ? req.query.category_event_count : 9;
773
792
  option.event_count = req.query.event_count ? req.query.event_count : 9;
774
793
 
794
+ option.get_product_review = req.query.get_product_review ? req.query.get_product_review : false;
795
+ option.product_review_count = req.query.product_review_count ? req.query.product_review_count : 19;
796
+
775
797
  option.user_count = req.query.user_count ? req.query.user_count : 9;
776
798
  option.get_admin = req.query.get_admin ? req.query.get_admin : false;
777
799
  option.get_business = req.query.get_business ? req.query.get_business : false;
@@ -780,6 +802,7 @@ class Field_Logic {
780
802
  option.get_page = req.query.get_page ? req.query.get_page : false;
781
803
  option.get_team = req.query.get_team ? req.query.get_team : false;
782
804
 
805
+
783
806
  return option;
784
807
  }
785
808
 
@@ -1056,33 +1079,87 @@ class Faq_Logic {
1056
1079
  return item_list;
1057
1080
  }
1058
1081
  }
1082
+ class Favorite_Logic {
1083
+ static get_new = (parent_data_type,parent_id,user_id,option) =>{
1084
+ option = Field_Logic.get_option(DataType.FAVORITE,option?option:{});
1085
+ let favorite = DataItem.get_new(DataType.FAVORITE,0,{
1086
+ parent_data_type:parent_data_type,
1087
+ parent_id:parent_id,
1088
+ user_id:user_id,
1089
+ });
1090
+ return favorite;
1091
+ }
1092
+ static get_user_search_filter = (parent_data_type,user_id) =>{
1093
+ return {
1094
+ $and: [
1095
+ { parent_data_type: { $regex:parent_data_type, $options: "i" } },
1096
+ { user_id: { $regex:user_id, $options: "i" } }
1097
+ ] };
1098
+ }
1099
+ static get_search_filter = (parent_data_type,parent_id,user_id) =>{
1100
+ return {
1101
+ $and: [
1102
+ { parent_data_type: { $regex:parent_data_type, $options: "i" } },
1103
+ { parent_id: { $regex:parent_id, $options: "i" } },
1104
+ { user_id: { $regex:user_id, $options: "i" } }
1105
+ ] };
1106
+ }
1107
+ }
1059
1108
  class Review_Logic {
1060
- static get_test = () =>{
1061
- let city_list = ["Miami","Atlanta","Chicago","Seattle","New York City"];
1062
- let state_list = ["Georgia","New York","Illinois","Washington","Flordia"];
1063
- let review = DataItem.get_new_full_item(
1064
- DataItem.get_new(DataType.REVIEW,Number.get_id()),
1065
- DataItem.get_new(DataType.REVIEW,0),
1066
- DataItem.get_new(DataType.REVIEW,0),
1067
- Field_Logic.get_test("Review "+Number.get_id(),{get_value:false}));
1109
+ static get_new = (parent_data_type,parent_id,user_id,review) =>{
1110
+ if(!review){
1111
+ review = {};
1112
+ }
1113
+ return DataItem.get_new(DataType.REVIEW,0,{
1114
+ parent_data_type:parent_data_type,
1115
+ parent_id:parent_id,
1116
+ user_id:user_id,
1117
+ comment:review.comment ? review.comment : "",
1118
+ email:review.email ? review.email : "",
1119
+ first_name:review.first_name ? review.first_name : "",
1120
+ last_name:review.last_name ? review.last_name : "",
1121
+ title:review.title ? review.title : "",
1122
+ hometown:review.hometown ? review.hometown : "",
1123
+ position:review.position ? review.position : "",
1124
+ rating:review.rating ? review.rating : ""
1125
+ });
1126
+ }
1127
+ static get_search_filter = (parent_data_type,parent_id) =>{
1128
+ return {
1129
+ $and: [
1130
+ { parent_data_type: { $regex:parent_data_type, $options: "i" } },
1131
+ { parent_id: { $regex:parent_id, $options: "i" } },
1132
+ ] };
1133
+ }
1134
+ static get_test = (parent_data_type,parent_id,user_id,option) =>{
1135
+ option = Field_Logic.get_option(DataType.REVIEW,option?option:{});
1136
+ let review = DataItem.get_new(DataType.REVIEW,0);
1137
+ if(option.generate_id){
1138
+ review.id = Number.get_id();
1139
+ }
1068
1140
  review.email="ceo@biz"+String(Number.get_id())+".com";
1141
+ review.title="Review " + Number.get_id()+ Number.get_id();
1069
1142
  review.first_name="First Name "+ Number.get_id();
1070
1143
  review.last_name="Last Name "+ Number.get_id();
1071
1144
  review.hometown="Hometown "+ Number.get_id();
1072
1145
  review.position="Position "+ Number.get_id();
1073
- review.rating=parseInt(Number.get_id(6)+1);
1074
- review.comment="My comment "+ Number.get_id() + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
1146
+ review.rating=Number.get_id(6);
1147
+ review.user_id=user_id;
1148
+ review.parent_data_type=parent_data_type;
1149
+ review.parent_id=parent_id;
1150
+ review.comment="My comment "+ Item_Logic.get_note();
1075
1151
  return review;
1076
1152
  };
1077
1153
  static get_test_list=(option)=>{
1078
1154
  option = !Obj.check_is_empty(option) ? option : {review_count:19};
1079
1155
  let item_list = [];
1080
1156
  for(let a=0;a<option.review_count;a++){
1081
- item_list.push(Review_Logic.get_test());
1157
+ item_list.push(Review_Logic.get_test(option));
1082
1158
  }
1083
1159
  return item_list;
1084
1160
  };
1085
1161
  }
1162
+
1086
1163
  class Admin_Logic {
1087
1164
  static get_new = (title,option) =>{
1088
1165
  [title,option] = Field_Logic.get_option_title(title,option);
@@ -1243,6 +1320,24 @@ class FAQ_Url {
1243
1320
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1244
1321
  };
1245
1322
  }
1323
+ class Cart_Url {
1324
+ static update = (biz9_config,parent_data_type,user_id,params) => {
1325
+ let action_url="cart/update/"+parent_data_type+"/"+user_id;
1326
+ return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1327
+ };
1328
+ static get = (biz9_config,parent_data_type,cart_number,params) => {
1329
+ let action_url="cart/get/"+parent_data_type+"/"+cart_number;
1330
+ return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1331
+ };
1332
+ static delete = (biz9_config,id,params) => {
1333
+ let action_url="cart/delete/"+id;
1334
+ return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1335
+ };
1336
+ static search = (biz9_config,params) => {
1337
+ let action_url="cart/search";
1338
+ return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1339
+ };
1340
+ }
1246
1341
  class Order_Url {
1247
1342
  static stripe_checkout = (biz9_config,cart_number,params) => {
1248
1343
  let action_url="order/stripe-checkout/"+cart_number;
@@ -1285,6 +1380,7 @@ class Order_Url {
1285
1380
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1286
1381
  };
1287
1382
  }
1383
+
1288
1384
  class Product_Url {
1289
1385
  static get = (biz9_config,key,params) => {
1290
1386
  let action_url="product/get/"+key;
@@ -1305,11 +1401,7 @@ class Product_Url {
1305
1401
  }
1306
1402
  class Review_Url {
1307
1403
  static update = (biz9_config,parent_data_type,parent_id,user_id,params) => {
1308
- let action_url="review/"+parent_data_type+"/"+parent_id+"/"+user_id;
1309
- return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1310
- };
1311
- static search = (biz9_config,parent_data_type,parent_id,params) => {
1312
- let action_url="review/"+parent_data_type+"/"+parent_id;
1404
+ let action_url="review/update/"+parent_data_type+"/"+parent_id+"/"+user_id;
1313
1405
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1314
1406
  };
1315
1407
  }
@@ -1386,16 +1478,18 @@ class Gallery_Url {
1386
1478
  };
1387
1479
  }
1388
1480
  class User_Url {
1389
- static favorite = (biz9_config,user_id,params) => {
1390
- let action_url="user/favorite/"+user_id;
1481
+ static search = (biz9_config,params) => {
1482
+ let action_url="user/search";
1391
1483
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1392
1484
  };
1393
- static favorite_update = (biz9_config,parent_data_type,parent_id,user_id,params) => {
1394
- let action_url="user/favorite/"+parent_data_type+"/"+parent_id +"/"+user_id;
1485
+ }
1486
+ class Favorite_Url {
1487
+ static get = (biz9_config,parent_data_type,user_id,page_current,page_size,params) => {
1488
+ let action_url="favorite/get/"+parent_data_type+"/"+user_id+"/"+page_current+"/"+page_size;
1395
1489
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1396
1490
  };
1397
- static search = (biz9_config,params) => {
1398
- let action_url="user/search";
1491
+ static update = (biz9_config,parent_data_type,parent_id,user_id,params) => {
1492
+ let action_url="favorite/update/"+parent_data_type+"/"+parent_id +"/"+user_id;
1399
1493
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
1400
1494
  };
1401
1495
  }
@@ -1898,7 +1992,7 @@ class Sub_Item_Logic {
1898
1992
  title:item_title,
1899
1993
  title_url:Str.get_title_url(item_title),
1900
1994
  sub_note:"Sub Note "+String(Number.get_id()),
1901
- note:"Note "+String(Number.get_id()),
1995
+ note:Item_Logic.get_note()
1902
1996
  }
1903
1997
  );
1904
1998
  if(option.get_value){
@@ -1949,6 +2043,7 @@ module.exports = {
1949
2043
  Blog_Post_Logic,
1950
2044
  Blog_Post_Url,
1951
2045
  Cart_Logic,
2046
+ Cart_Url,
1952
2047
  Category_Logic,
1953
2048
  Category_Url,
1954
2049
  Content_Url,
@@ -1961,6 +2056,8 @@ module.exports = {
1961
2056
  Field_Logic,
1962
2057
  FieldType,
1963
2058
  Faq_Logic,
2059
+ Favorite_Logic,
2060
+ Favorite_Url,
1964
2061
  Gallery_Url,
1965
2062
  Item_Logic,
1966
2063
  Event_Logic,
@@ -1978,6 +2075,7 @@ module.exports = {
1978
2075
  Service_Url,
1979
2076
  Social,
1980
2077
  Sub_Item_Logic,
2078
+ Stat_Logic,
1981
2079
  Storage,
1982
2080
  Schedule,
1983
2081
  Stock,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.8.130",
3
+ "version": "4.8.134",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/test.js CHANGED
@@ -205,6 +205,7 @@ describe("connect", () => {
205
205
  /* --SERVICE--END */
206
206
 
207
207
 
208
+ /*
208
209
  console.log('PRODUCT-START');
209
210
 
210
211
  console.log('PRODUCT-CART-START');
@@ -231,7 +232,8 @@ describe("connect", () => {
231
232
  //Log.w('product_cart_item_list',product_order.order_item_list.length);
232
233
  //Log.w('product_cart_item_list_len',product_order.order_item_list[0].order_sub_item_list.length);
233
234
  //Log.w('product_order',product_order.order_item_list[0].order_sub_item_list.length);
234
- console.log('PRODUCT-CART-END');
235
+ //console.log('PRODUCT-CART-END');
236
+ */
235
237
 
236
238
  /*
237
239
  console.log('PRODUCT-ORDER-START');
@@ -358,15 +360,20 @@ describe("connect", () => {
358
360
 
359
361
 
360
362
  /* --REVIEW--START */
361
- //Log.w("Review",Review.get_test());
362
- //Log.w("Review List",Review_Logic.get_test_list());
363
+ //console.log('REVIEW-START');
364
+ //let parent_data_type = DataType.PRODUCT;
365
+ //let parent_id = Number.get_id();
366
+ //let user_id = Number.get_id();
367
+ //Log.w("Review",Review_Logic.get_new(parent_data_type,parent_id,user_id));
368
+ //Log.w("Review",Review_Logic.get_test({generate_id:true}));
369
+ //Log.w("Review List",Review_Logic.get_test_list({generate_id:true,review_count:3}));
363
370
  /*
364
371
  let review_list = Review.get_test_list({review_count:3,get_item:true})
365
372
  Log.w("Review List",review_list);
366
373
  */
374
+ //console.log('REVIEW-END');
367
375
  /* --REVIEW--END */
368
376
 
369
-
370
377
  /* --BUSINESS--START */
371
378
  //Log.w("Business",Business_Logic.get_test("Business " + Number.get_id()));
372
379
  //Log.w("Business",Business_Logic.get_test());