zhangbo1_wd

新增现网环境

@@ -7,9 +7,22 @@ import { DateTimeUtils, Logger } from 'wdKit' @@ -7,9 +7,22 @@ import { DateTimeUtils, Logger } from 'wdKit'
7 */ 7 */
8 export class HttpUrlUtils { 8 export class HttpUrlUtils {
9 /** 9 /**
10 - * 现网地址 10 + * uat环境url
11 */ 11 */
12 - static readonly HOST: string = "https://pd-apis-uat.pdnews.cn"; 12 + static readonly HOST_UAT: string = "https://pd-apis-uat.pdnews.cn";
  13 + /**
  14 + * 中文端sit环境
  15 + */
  16 + static readonly HOST_SIT: string = "https://pd-apis-sit.pdnews.cn";
  17 + /**
  18 + * 正式环境url
  19 + */
  20 + static readonly HOST_PRODUCT: string = "https://pdapis.pdnews.cn";
  21 + /**
  22 + * dev环境url
  23 + */
  24 + static readonly HOST_DEV: string = "https://pd-apis-dev.pdnews.cn";
  25 +
13 /** 26 /**
14 * 启动接口(底导接口) 27 * 启动接口(底导接口)
15 */ 28 */
@@ -22,14 +35,13 @@ export class HttpUrlUtils { @@ -22,14 +35,13 @@ export class HttpUrlUtils {
22 * 详情页面详情接口 35 * 详情页面详情接口
23 */ 36 */
24 static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; 37 static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
  38 + private static hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
25 39
26 static getCommonHeaders(): HashMap<string, string> { 40 static getCommonHeaders(): HashMap<string, string> {
27 let headers: HashMap<string, string> = new HashMap<string, string>() 41 let headers: HashMap<string, string> = new HashMap<string, string>()
28 headers.set('User-Agent', 'Dalvik/2.1.0 (Linux; U; Android 13; 22101317C Build/TKQ1.221013.002)') 42 headers.set('User-Agent', 'Dalvik/2.1.0 (Linux; U; Android 13; 22101317C Build/TKQ1.221013.002)')
29 headers.set('channel', this.getChannel()) 43 headers.set('channel', this.getChannel())
30 - headers.set('appCode', ConfigConstants.appCode)  
31 headers.set('plat', this.getPlat()) 44 headers.set('plat', this.getPlat())
32 - headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a')  
33 headers.set('Content-Type', 'application/json; charset=utf-8') 45 headers.set('Content-Type', 'application/json; charset=utf-8')
34 headers.set('timestamp', this.getTimestamp()) 46 headers.set('timestamp', this.getTimestamp())
35 headers.set('RMRB-X-TOKEN', this.getXToken()) 47 headers.set('RMRB-X-TOKEN', this.getXToken())
@@ -38,7 +50,6 @@ export class HttpUrlUtils { @@ -38,7 +50,6 @@ export class HttpUrlUtils {
38 headers.set('build_version', this.getVersion()) 50 headers.set('build_version', this.getVersion())
39 headers.set('adcode', this.getAdCode()) 51 headers.set('adcode', this.getAdCode())
40 headers.set('os_version', this.getOsVersion()) 52 headers.set('os_version', this.getOsVersion())
41 - headers.set('X-Ca-Stage', 'PRE')  
42 headers.set('versionCode', this.getVersionCode()) 53 headers.set('versionCode', this.getVersionCode())
43 headers.set('system', this.getTerminalId()) 54 headers.set('system', this.getTerminalId())
44 headers.set('version_name', 'debug') 55 headers.set('version_name', 'debug')
@@ -51,6 +62,7 @@ export class HttpUrlUtils { @@ -51,6 +62,7 @@ export class HttpUrlUtils {
51 headers.set('userId', this.getUserId()) 62 headers.set('userId', this.getUserId())
52 headers.set('userType', this.getUserType()) 63 headers.set('userType', this.getUserType())
53 64
  65 + HttpUrlUtils.addSpecialHeaders(headers);
54 // Logger.debug("TAG", '******************* commonHeaders headers start ******************************** '); 66 // Logger.debug("TAG", '******************* commonHeaders headers start ******************************** ');
55 // headers.forEach((v,k)=>{ 67 // headers.forEach((v,k)=>{
56 // Logger.debug("TAG", 'getCommonHeaders header: ' + k + ': ' + v); 68 // Logger.debug("TAG", 'getCommonHeaders header: ' + k + ': ' + v);
@@ -61,12 +73,12 @@ export class HttpUrlUtils { @@ -61,12 +73,12 @@ export class HttpUrlUtils {
61 73
62 static getBottomNavGroupUrl() { 74 static getBottomNavGroupUrl() {
63 // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup 75 // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
64 - return this.HOST + this.BOTTOM_NAV_PATH; 76 + return this.hostUrl + this.BOTTOM_NAV_PATH;
65 } 77 }
66 78
67 static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number 79 static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number
68 , pageSize: number) { 80 , pageSize: number) {
69 - let url = this.HOST + this.COMP_PATH; 81 + let url = this.hostUrl + this.COMP_PATH;
70 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? 82 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
71 url = url + "?channelStrategy=2&loadStrategy=first_load" 83 url = url + "?channelStrategy=2&loadStrategy=first_load"
72 + "&districtCode=" + this.getDistrictCode() 84 + "&districtCode=" + this.getDistrictCode()
@@ -83,7 +95,7 @@ export class HttpUrlUtils { @@ -83,7 +95,7 @@ export class HttpUrlUtils {
83 } 95 }
84 96
85 static getDetailInfoUrl(relId: string, contentId: string, relType: string) { 97 static getDetailInfoUrl(relId: string, contentId: string, relType: string) {
86 - let url = this.HOST + this.DETAIL_PATH; 98 + let url = this.hostUrl + this.DETAIL_PATH;
87 url = url + "?relId=" + relId 99 url = url + "?relId=" + relId
88 + "&contentId=" + contentId 100 + "&contentId=" + contentId
89 + "&relType=" + relType; 101 + "&relType=" + relType;
@@ -91,6 +103,34 @@ export class HttpUrlUtils { @@ -91,6 +103,34 @@ export class HttpUrlUtils {
91 return url; 103 return url;
92 } 104 }
93 105
  106 + static addSpecialHeaders(headers: HashMap<string, string>) {
  107 + switch (this.hostUrl) {
  108 + case this.HOST_UAT:
  109 + // TODO 待优化到常量类里
  110 + headers.set('X-Ca-Stage', 'PRE');
  111 + headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a');
  112 + headers.set('appCode', '83092caa603a421aa0222308b3f6b27a');
  113 + break
  114 + case this.HOST_SIT:
  115 + headers.set('X-Ca-Stage', 'TEST');
  116 + headers.set('Authorization', 'APPCODE 0af1f9085e484c97b2a44704bae72c07');
  117 + headers.set('appCode', '0af1f9085e484c97b2a44704bae72c07');
  118 + break
  119 + case this.HOST_PRODUCT:
  120 + headers.set('X-Ca-Stage', 'RELEASE');
  121 + headers.set('Authorization', 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6');
  122 + headers.set('appCode', '3d4181bceeb94d9780e10dbb6c67bbf6');
  123 + break
  124 + case this.HOST_DEV:
  125 + headers.set('X-Ca-Stage', 'TEST');
  126 + headers.set('Authorization', 'APPCODE ff33172859e14f9a8299e3bd769e79f9');
  127 + headers.set('appCode', 'ff33172859e14f9a8299e3bd769e79f9');
  128 + break
  129 + default:
  130 + break
  131 + }
  132 + }
  133 +
94 private static getCity() { 134 private static getCity() {
95 // TODO 对接定位 135 // TODO 对接定位
96 return '%E5%90%88%E8%82%A5%E5%B8%82'; 136 return '%E5%90%88%E8%82%A5%E5%B8%82';