biz9-logic 4.8.145 → 4.8.147

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 CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='6.2.5'
1
+ VERSION='6.2.7'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -34,6 +34,20 @@ class Item_Logic {
34
34
  }
35
35
  return item;
36
36
  }
37
+ static get_not_found = (data_type,id,option) =>{
38
+ if(!id){
39
+ id=0;
40
+ }
41
+ let item = Item_Logic.get_test("",data_type,id,{get_blank:true})
42
+ item.id = 0;
43
+ item.id_key = id;
44
+ item.title = "Item Not Found";
45
+ item.title_url = Str.get_title_url(item.title);
46
+ if(option.app_id){
47
+ item.app_id = option.app_id;
48
+ }
49
+ return item;
50
+ };
37
51
  static get_test_list = (data_type,option) =>{
38
52
  option = Field_Logic.get_option(data_type,option?option:{});
39
53
  let item_list = [];
@@ -218,8 +232,14 @@ class Page_Logic {
218
232
  class Cart_Logic {
219
233
  static get_cart_number = () => {
220
234
  return FieldType.CART_NUMBER + Number.get_id(99999);
221
- }
222
- static get_test_cart_item = (cart_item_id,cart_number,user_id,parent_data_type,parent_id,option) =>{
235
+ };
236
+ static get_cart = (user_id) => {
237
+ return DataItem.get_new(DataType.CART,0,{user_id:user_id,cart_number:Cart_Logic.get_cart_number(),quanity:1,grand_total:0,cart_item_list:[]});
238
+ };
239
+ static get_cart_item = (parent_data_type,parent_id,cart_number,user_id,quanity) =>{
240
+ return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,user_id:user_id,quanity:quanity,sub_total:0,cart_sub_item_list:[]});
241
+ };
242
+ static get_test_item = (cart_item_id,cart_number,user_id,parent_data_type,parent_id,option) =>{
223
243
  option = Field_Logic.get_option(DataType.CART_ITEM,option?option:{generate_id:Str.check_is_null(cart_item_id)? true : false });
224
244
  let cart_item = DataItem.get_new(DataType.CART_ITEM,Number.get_guid(),Field_Logic.get_test("Cart Item "+Number.get_id(),option));
225
245
  cart_item.cart_item_id = cart_item_id;
@@ -230,13 +250,13 @@ class Cart_Logic {
230
250
  if(option.get_cart_sub_item){
231
251
  cart_item.cart_sub_item_list = [];
232
252
  for(let a = 0;a<option.cart_sub_item_count;a++){
233
- let cart_sub_item = Cart_Logic.get_test_cart_sub_item(cart_number,user_id,cart_item.id,parent_data_type,parent_id,{get_value:true,get_cart_sub_item:option.get_cart_sub_item,cart_sub_item_count:option.cart_sub_item_count});
253
+ let cart_sub_item = Cart_Logic.get_test_sub_item(cart_number,user_id,cart_item.id,parent_data_type,parent_id,{get_value:true,get_cart_sub_item:option.get_cart_sub_item,cart_sub_item_count:option.cart_sub_item_count});
234
254
  cart_item.cart_sub_item_list.push(cart_sub_item);
235
255
  }
236
256
  }
237
257
  return cart_item;
238
258
  };
239
- static get_test_cart_sub_item = (cart_number,user_id,cart_item_id,parent_data_type,parent_id,option) =>{
259
+ static get_test_sub_item = (cart_number,user_id,cart_item_id,parent_data_type,parent_id,option) =>{
240
260
  option = Field_Logic.get_option(DataType.CART_SUB_ITEM,option?option:{});
241
261
  let item_blank = Item_Logic.get_test('Sub Item '+Number.get_id(),DataType.ITEM,0,{generate_id:true});
242
262
  let cart_sub_item = DataItem.get_new(DataType.CART_SUB_ITEM,Number.get_guid(),Field_Logic.get_test("Cart Sub Item "+Number.get_id(),option));
@@ -311,7 +331,7 @@ class Product_Logic {
311
331
  let product_list = Product_Logic.get_test_list(product_option);
312
332
  cart.cart_item_list = [];
313
333
  for(let a = 0;a<product_list.length;a++){
314
- let product_cart_item =Cart_Logic.get_test_cart_item(cart_number,cart.id,user_id,product_list[a].data_type,product_list[a].id,{get_value:false,get_cart_sub_item:option.get_cart_sub_item,cart_sub_item_count:option.cart_sub_item_count,generate_id:true});
334
+ let product_cart_item =Cart_Logic.get_test_item(cart_number,cart.id,user_id,product_list[a].data_type,product_list[a].id,{get_value:false,get_cart_sub_item:option.get_cart_sub_item,cart_sub_item_count:option.cart_sub_item_count,generate_id:true});
315
335
  product_cart_item.parent_item = product_list[a];
316
336
  cart.cart_item_list.push(product_cart_item);
317
337
  }
@@ -775,6 +795,7 @@ class FieldType {
775
795
  static KEY_ADMIN="key_admin";
776
796
  static KEY_APP_ID="key_app_id";
777
797
  static KEY_BUSINESS="key_business";
798
+ static KEY_TEMPLATE="key_template";
778
799
  static KEY_CART="key_cart";
779
800
  static KEY_GUEST="key_guest";
780
801
  static KEY_ORDER="key_order";
@@ -1029,16 +1050,16 @@ class Favorite_Logic {
1029
1050
  static get_user_search_filter = (parent_data_type,user_id) =>{
1030
1051
  return {
1031
1052
  $and: [
1032
- { parent_data_type: { $regex:parent_data_type, $options: "i" } },
1033
- { user_id: { $regex:user_id, $options: "i" } }
1053
+ { parent_data_type: { $regex:String(parent_data_type), $options: "i" } },
1054
+ { user_id: { $regex:String(user_id), $options: "i" } }
1034
1055
  ] };
1035
1056
  }
1036
1057
  static get_search_filter = (parent_data_type,parent_id,user_id) =>{
1037
1058
  return {
1038
1059
  $and: [
1039
- { parent_data_type: { $regex:parent_data_type, $options: "i" } },
1040
- { parent_id: { $regex:parent_id, $options: "i" } },
1041
- { user_id: { $regex:user_id, $options: "i" } }
1060
+ { parent_data_type: { $regex:String(parent_data_type), $options: "i" } },
1061
+ { parent_id: { $regex:String(parent_id), $options: "i" } },
1062
+ { user_id: { $regex:String(user_id), $options: "i" } }
1042
1063
  ] };
1043
1064
  }
1044
1065
  }
@@ -1057,8 +1078,8 @@ class Review_Logic {
1057
1078
  static get_search_filter = (parent_data_type,parent_id) =>{
1058
1079
  return {
1059
1080
  $and: [
1060
- { parent_data_type: { $regex:parent_data_type, $options: "i" } },
1061
- { parent_id: { $regex:parent_id, $options: "i" } },
1081
+ { parent_data_type: { $regex:String(parent_data_type), $options: "i" } },
1082
+ { parent_id: { $regex:String(parent_id), $options: "i" } },
1062
1083
  ] };
1063
1084
  }
1064
1085
  static get_test = (parent_data_type,parent_id,user_id,option) =>{
@@ -1884,20 +1905,32 @@ class User_Logic {
1884
1905
  static get_guest(){
1885
1906
  return DataItem.get_new(DataType.USER,Number.get_id(999),{is_guest:true,title:"Guest",country:"United States"});
1886
1907
  }
1887
- static get_user(req){
1908
+ static get_request_user(req){
1888
1909
  if(!req || !req.session.user){
1889
1910
  let user=DataItem.get_new(DataType.USER,Number.get_id(9999999),{is_guest:true});
1890
1911
  req.session.user=user;
1891
1912
  }
1892
1913
  return req.session.user;
1893
1914
  }
1894
- static set_user(req){
1915
+ static set_request_user(req){
1895
1916
  req.session.user=user;
1896
1917
  }
1897
- static del_user(req){
1918
+ static del_request_user(req){
1898
1919
  req.session.user=null;
1899
1920
  delete req.session.user;
1900
1921
  }
1922
+ static get_not_found = (user_id) =>{
1923
+ if(!user_id){
1924
+ user_id=0;
1925
+ }
1926
+ let user = User_Logic.get_test("",{get_blank:true})
1927
+ user.id = 0;
1928
+ user.id_key = user_id;
1929
+ user.title = "User Not Found";
1930
+ user.first_name = "User Not Found";
1931
+ user.title_url = Str.get_title_url(user.title);
1932
+ return user;
1933
+ };
1901
1934
  static get_test = (title,option) =>{
1902
1935
  [title,option] = Field_Logic.get_option_title(title,option);
1903
1936
  option = Field_Logic.get_option(DataType.USER,option?option:{});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.8.145",
3
+ "version": "4.8.147",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/test.js CHANGED
@@ -103,7 +103,7 @@ describe("connect", () => {
103
103
  //let user_list = User_Logic.get_test_list();
104
104
  //Log.w('user',user);
105
105
  //Log.w('user_list',user_list);
106
- Log.w('guest',User_Logic.get_guest());
106
+ //Log.w('guest',User_Logic.get_guest());
107
107
  /* --USER--END */
108
108
 
109
109
  /* --SEARCH--START */
@@ -153,6 +153,8 @@ describe("connect", () => {
153
153
 
154
154
 
155
155
  /* --CONTENT--START */
156
+ let item_list = Content_Logic.get_test_list({content_count:6,get_item:false,get_value:false,get_blank:true});
157
+ Log.w('content_list',item_list);
156
158
  //let content = Content_Logic.get_test("cool 1");
157
159
  //let content = Content_Logic.get_test("Content 1",{get_value:true,get_item:true})
158
160
  //Log.w("content",content);