@@ -186,8 +186,8 @@ var JSONResponse = {
186186 KEY_THROW : 'throw' ,
187187 CODE_SUCCESS : 200 ,
188188 IGNORE_KEYS : [ 'traceId' , 'trace:stack' , 'debug:info|help' ] ,
189- UPGRADE_KEYS : [ 'price' , 'amount' , 'money' , 'cash' , 'spend' , 'cost' , 'income' , 'outgoing' , 'borrow' , 'lend' , 'gold' , 'coin' , 'diamond' , 'credit' , 'budget' , 'quantity' , 'balance' ] ,
190- DOWNGRADE_KEYS : [ 'traceId' , 'trace_id' , 'date' , 'time' , 'datetime' , 'date_time' , 'dateTime' , 'timestamp' , 'create_time' , 'update_time' , 'created_at' , 'updated_at' , 'createTime' , 'updateTime' , 'createdAt' , 'updatedAt' ] ,
189+ UPGRADE_KEYS : [ 'price' , 'amount' , 'money' , 'cash' , 'spend' , 'cost' , 'income' , 'outgoing' , 'borrow' , 'lend' , 'gold' , 'coin' , 'diamond' , 'credit' , 'budget' , 'quantity' , 'balance' , 'type' , 'status' , 'state' , 'stage' , 'mode' , 'currency' , 'percent' , 'percentage' , 'rate' , 'ratio' , 'cent' , 'vip' , 'tax' , 'change' , 'exchange' , 'role' , 'permission' , 'access' , 'wealth' , 'fee' , 'pay' , 'sku' , 'spu' , 'level' , 'reward' , 'award' , 'bonus' , 'consume' , 'produce' , 'gift' , 'order' , 'buy' , 'purchase' , 'salary' , 'earn' , 'coupon' , 'discount' ] ,
190+ DOWNGRADE_KEYS : [ 'traceId' , 'trace_id' , 'date' , 'time' , 'datetime' , 'date_time' , 'dateTime' , 'timestamp' , 'create_time' , 'update_time' , 'created_at' , 'updated_at' , 'createTime' , 'updateTime' , 'createdAt' , 'updatedAt' , 'delete_time' , 'deleteTime' , 'deleted_at' , 'cur_time' , 'curTime' , 'cur_timestamp' , 'curTimestamp' , 'cur_time_stamp' , 'current_time' , 'current_time_stamp' , 'currentTime' , 'currentTimestamp' , 'server_time' , 'serverTime' , 'start_time' , 'started_at' , 'startTime' , 'startedAt' , 'begin_time' , 'begun_at' , 'beginTime' , 'begunAt' , 'end_time' , 'ended_at' , 'endTime' , 'endedAt' , 'title' , 'subtitle' , 'content' , 'comment' , 'emoji' , 'name' , 'nickname' , 'detail' , 'desc' , 'describe' , 'description' ] ,
191191
192192 /**是否成功
193193 * @param code
@@ -525,6 +525,56 @@ var JSONResponse = {
525525 return it ;
526526 } ,
527527
528+ isUpgradeCompare : function ( key , folder ) {
529+ if ( StringUtil . isEmpty ( key ) ) {
530+ return false ;
531+ }
532+
533+ var keys = JSONResponse . UPGRADE_KEYS || [ ] ;
534+ if ( keys . includes ( key ) || keys . includes ( JSONResponse . getAbstractPath ( folder , key ) ) ) {
535+ return true ;
536+ }
537+
538+ for ( var i = 0 ; i < keys . length ; i ++ ) {
539+ var k = keys [ i ] ;
540+ if ( StringUtil . isNotEmpty ( k ) && StringUtil . isKeyOfCategory ( key , StringUtil . firstCase ( k , true ) ) ) {
541+ return true ;
542+ }
543+ }
544+
545+ return StringUtil . isMoneyKey ( key ) || StringUtil . isBalanceKey ( key ) || StringUtil . isAmountKey ( key ) || StringUtil . isLoanKey ( key )
546+ || StringUtil . isPriceKey ( key ) || StringUtil . isPercentKey ( key ) || StringUtil . isRevenueKey ( key ) || StringUtil . isProfitKey ( key )
547+ || StringUtil . isCashKey ( key ) || StringUtil . isDiscountKey ( key ) || StringUtil . isGradeKey ( key ) || StringUtil . isLevelKey ( key )
548+ || StringUtil . isRankKey ( key ) || StringUtil . isScoreKey ( key ) || StringUtil . isSexKey ( key ) || StringUtil . isGenderKey ( key ) ;
549+ // || StringUtil.isIncomeKey(key) || StringUtil.isOutgoingKey(key) || StringUtil.isGoldKey(key) || StringUtil.isCoinKey(key)
550+ // || StringUtil.isBuyKey(key) || StringUtil.isPurchaseKey(key) || StringUtil.isPayKey(key) || StringUtil.isEarnKey(key)
551+ // || StringUtil.isSalaryKey(key) || StringUtil.isCostKey(key) || StringUtil.isConsumeKey(key) || StringUtil.isProduceKey(key)
552+ // || StringUtil.isFeeKey(key) || StringUtil.isWealthKey(key) || StringUtil.isRewardKey(key) || StringUtil.isAwardKey(key)
553+ // || StringUtil.isVipKey(key) || StringUtil.isDiamondKey(key) || StringUtil.isTaxKey(key) || StringUtil.isCurrencyKey(key)
554+ // || StringUtil.isChangeKey(key) || StringUtil.isExchangeKey(key) || StringUtil.isBorrowKey(key) || StringUtil.isLendKey(key);
555+ } ,
556+ isDowngradeCompare : function ( key , folder ) {
557+ if ( StringUtil . isEmpty ( key ) ) {
558+ return false ;
559+ }
560+
561+ var keys = JSONResponse . DOWNGRADE_KEYS || [ ] ;
562+ if ( keys . includes ( key ) || keys . includes ( JSONResponse . getAbstractPath ( folder , key ) ) ) {
563+ return true ;
564+ }
565+
566+ for ( var i = 0 ; i < keys . length ; i ++ ) {
567+ var k = keys [ i ] ;
568+ if ( StringUtil . isNotEmpty ( k ) && StringUtil . isKeyOfCategory ( key , StringUtil . firstCase ( k , true ) ) ) {
569+ return true ;
570+ }
571+ }
572+
573+ return StringUtil . isDateKey ( key ) || StringUtil . isTimeKey ( key ) || StringUtil . isNameKey ( key ) || StringUtil . isDetailKey ( key )
574+ || StringUtil . isTitleKey ( key ) || StringUtil . isTextKey ( key ) || StringUtil . isCommentKey ( key ) || StringUtil . isContentKey ( key )
575+ || StringUtil . isDescribeKey ( key ) || StringUtil . isMessageKey ( key ) ;
576+ } ,
577+
528578 /**测试compare: 对比 新的请求与上次请求的结果
529579 0-相同,无颜色;
530580 1-对象新增字段或数组新增值,绿色;
@@ -1088,25 +1138,27 @@ var JSONResponse = {
10881138 ? 0 : JSONResponse . compareValue ( valueLevel , values , real , target . trend , target . repeat ) ;
10891139
10901140 if ( valueCompare > 0 ) {
1091- if ( isNum && isFolderMeaningful ) {
1141+ var cmp = valueCompare ;
1142+ if ( isNum && isFolderMeaningful && cmp > JSONResponse . COMPARE_VALUE_MORE && cmp < JSONResponse . COMPARE_VALUE_EMPTY ) {
10921143 if ( JSONResponse . UPGRADE_KEYS . includes ( folder ) ) {
1093- valueCompare ++ ;
1144+ cmp = JSONResponse . COMPARE_VALUE_EMPTY ;
10941145 } else if ( JSONResponse . DOWNGRADE_KEYS . includes ( folder ) ) {
1095- valueCompare -- ;
1146+ cmp = JSONResponse . COMPARE_VALUE_MORE ;
10961147 } else if ( folder . includes ( '/' ) ) {
10971148 var keys = StringUtil . splitPath ( folder ) ;
10981149 var key = keys == null || keys . length <= 0 ? null : keys [ keys . length - 1 ] ;
10991150 if ( StringUtil . isNotEmpty ( key ) && ! StringUtil . isNumber ( key ) ) {
1100- if ( JSONResponse . UPGRADE_KEYS . includes ( key ) ) {
1101- valueCompare ++ ;
1102- } else if ( JSONResponse . DOWNGRADE_KEYS . includes ( key ) ) {
1103- valueCompare -- ;
1151+ var fd = keys . slice ( 0 , keys . length - 1 ) . join ( '/' ) ;
1152+ if ( JSONResponse . isUpgradeCompare ( key , fd ) ) {
1153+ cmp = JSONResponse . COMPARE_VALUE_EMPTY ;
1154+ } else if ( JSONResponse . isDowngradeCompare ( key , fd ) ) {
1155+ cmp = JSONResponse . COMPARE_VALUE_MORE ;
11041156 }
11051157 }
11061158 }
11071159 }
11081160
1109- max . code = valueCompare ;
1161+ max . code = cmp ;
11101162 max . path = folder ;
11111163 max . value = real ;
11121164
@@ -1536,7 +1588,6 @@ var JSONResponse = {
15361588 log ( 'updateStandard lengthLevel = target.lengthLevel = ' + lengthLevel + ' >>' ) ;
15371589 log ( 'updateStandard lengths = target.lengths = ' + lengths + ' >>' ) ;
15381590
1539-
15401591 var valueLevel = target . valueLevel ;
15411592 var values = target . values ;
15421593 log ( 'updateStandard valueLevel = target.valueLevel = ' + valueLevel + ' >>' ) ;
@@ -1547,7 +1598,6 @@ var JSONResponse = {
15471598 valueLevel = target . valueLevel = 0 ;
15481599 }
15491600
1550-
15511601 if ( type == 'array' ) {
15521602 log ( 'updateStandard type == array >> ' ) ;
15531603
0 commit comments