zhangbo1_wd

新增现网环境,合入4.0

@@ -71,6 +71,10 @@ export class HttpUrlUtils { @@ -71,6 +71,10 @@ export class HttpUrlUtils {
71 return headers; 71 return headers;
72 } 72 }
73 73
  74 + static getHost() {
  75 + return this.hostUrl;
  76 + }
  77 +
74 static getBottomNavGroupUrl() { 78 static getBottomNavGroupUrl() {
75 // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup 79 // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
76 return this.hostUrl + this.BOTTOM_NAV_PATH; 80 return this.hostUrl + this.BOTTOM_NAV_PATH;
@@ -6,11 +6,11 @@ import { ContentDetailDTO, NavigationBodyDTO, PageDTO } from 'wdBean'; @@ -6,11 +6,11 @@ import { ContentDetailDTO, NavigationBodyDTO, PageDTO } from 'wdBean';
6 export class PageRepository { 6 export class PageRepository {
7 static getBottomNavGroupUrl() { 7 static getBottomNavGroupUrl() {
8 // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup 8 // https: //pd-apis-uat.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup
9 - return HttpUrlUtils.HOST + HttpUrlUtils.BOTTOM_NAV_PATH; 9 + return HttpUrlUtils.getHost() + HttpUrlUtils.BOTTOM_NAV_PATH;
10 } 10 }
11 11
12 static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) { 12 static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
13 - let url = HttpUrlUtils.HOST + HttpUrlUtils.COMP_PATH; 13 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH;
14 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? 14 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
15 url = url + "?channelStrategy=2&loadStrategy=first_load" 15 url = url + "?channelStrategy=2&loadStrategy=first_load"
16 + "&districtCode=" + HttpUrlUtils.getDistrictCode() 16 + "&districtCode=" + HttpUrlUtils.getDistrictCode()
@@ -27,7 +27,7 @@ export class PageRepository { @@ -27,7 +27,7 @@ export class PageRepository {
27 } 27 }
28 28
29 static getDetailInfoUrl(relId: string, contentId: string, relType: string) { 29 static getDetailInfoUrl(relId: string, contentId: string, relType: string) {
30 - let url = HttpUrlUtils.HOST + HttpUrlUtils.DETAIL_PATH; 30 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH;
31 url = url + "?relId=" + relId 31 url = url + "?relId=" + relId
32 + "&contentId=" + contentId 32 + "&contentId=" + contentId
33 + "&relType=" + relType; 33 + "&relType=" + relType;
@@ -7,9 +7,21 @@ import { DateTimeUtils, Logger } from 'wdKit' @@ -7,9 +7,21 @@ 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";
13 /** 25 /**
14 * 启动接口(底导接口) 26 * 启动接口(底导接口)
15 */ 27 */
@@ -23,13 +35,15 @@ export class HttpUrlUtils { @@ -23,13 +35,15 @@ export class HttpUrlUtils {
23 */ 35 */
24 static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; 36 static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
25 37
  38 + private static hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
  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', HttpUrlUtils.getChannel()) 43 headers.set('channel', HttpUrlUtils.getChannel())
30 - headers.set('appCode', ConfigConstants.appCode) 44 + //headers.set('appCode', ConfigConstants.appCode)
31 headers.set('plat', HttpUrlUtils.getPlat()) 45 headers.set('plat', HttpUrlUtils.getPlat())
32 - headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a') 46 + //headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a')
33 headers.set('Content-Type', 'application/json; charset=utf-8') 47 headers.set('Content-Type', 'application/json; charset=utf-8')
34 headers.set('timestamp', HttpUrlUtils.getTimestamp()) 48 headers.set('timestamp', HttpUrlUtils.getTimestamp())
35 headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken()) 49 headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken())
@@ -38,7 +52,7 @@ export class HttpUrlUtils { @@ -38,7 +52,7 @@ export class HttpUrlUtils {
38 headers.set('build_version', HttpUrlUtils.getVersion()) 52 headers.set('build_version', HttpUrlUtils.getVersion())
39 headers.set('adcode', HttpUrlUtils.getAdCode()) 53 headers.set('adcode', HttpUrlUtils.getAdCode())
40 headers.set('os_version', HttpUrlUtils.getOsVersion()) 54 headers.set('os_version', HttpUrlUtils.getOsVersion())
41 - headers.set('X-Ca-Stage', 'PRE') 55 + //headers.set('X-Ca-Stage', 'PRE')
42 headers.set('versionCode', HttpUrlUtils.getVersionCode()) 56 headers.set('versionCode', HttpUrlUtils.getVersionCode())
43 headers.set('system', HttpUrlUtils.getTerminalId()) 57 headers.set('system', HttpUrlUtils.getTerminalId())
44 headers.set('version_name', 'debug') 58 headers.set('version_name', 'debug')
@@ -50,7 +64,7 @@ export class HttpUrlUtils { @@ -50,7 +64,7 @@ export class HttpUrlUtils {
50 // TODO 判断是否登录 64 // TODO 判断是否登录
51 headers.set('userId', HttpUrlUtils.getUserId()) 65 headers.set('userId', HttpUrlUtils.getUserId())
52 headers.set('userType', HttpUrlUtils.getUserType()) 66 headers.set('userType', HttpUrlUtils.getUserType())
53 - 67 + HttpUrlUtils.addSpecialHeaders(headers);
54 // Logger.debug("TAG", '******************* commonHeaders headers start ******************************** '); 68 // Logger.debug("TAG", '******************* commonHeaders headers start ******************************** ');
55 // headers.forEach((v,k)=>{ 69 // headers.forEach((v,k)=>{
56 // Logger.debug("TAG", 'getCommonHeaders header: ' + k + ': ' + v); 70 // Logger.debug("TAG", 'getCommonHeaders header: ' + k + ': ' + v);
@@ -59,6 +73,37 @@ export class HttpUrlUtils { @@ -59,6 +73,37 @@ export class HttpUrlUtils {
59 return headers; 73 return headers;
60 } 74 }
61 75
  76 + static addSpecialHeaders(headers: HashMap<string, string>) {
  77 + switch (this.hostUrl) {
  78 + case this.HOST_UAT:
  79 + // TODO 待优化到常量类里
  80 + headers.set('X-Ca-Stage', 'PRE');
  81 + headers.set('Authorization', 'APPCODE 83092caa603a421aa0222308b3f6b27a');
  82 + headers.set('appCode', '83092caa603a421aa0222308b3f6b27a');
  83 + break
  84 + case this.HOST_SIT:
  85 + headers.set('X-Ca-Stage', 'TEST');
  86 + headers.set('Authorization', 'APPCODE 0af1f9085e484c97b2a44704bae72c07');
  87 + headers.set('appCode', '0af1f9085e484c97b2a44704bae72c07');
  88 + break
  89 + case this.HOST_PRODUCT:
  90 + headers.set('X-Ca-Stage', 'RELEASE');
  91 + headers.set('Authorization', 'APPCODE 3d4181bceeb94d9780e10dbb6c67bbf6');
  92 + headers.set('appCode', '3d4181bceeb94d9780e10dbb6c67bbf6');
  93 + break
  94 + case this.HOST_DEV:
  95 + headers.set('X-Ca-Stage', 'TEST');
  96 + headers.set('Authorization', 'APPCODE ff33172859e14f9a8299e3bd769e79f9');
  97 + headers.set('appCode', 'ff33172859e14f9a8299e3bd769e79f9');
  98 + break
  99 + default:
  100 + break
  101 + }
  102 + }
  103 +
  104 + static getHost() {
  105 + return this.hostUrl;
  106 + }
62 107
63 private static getCity() { 108 private static getCity() {
64 // TODO 对接定位 109 // TODO 对接定位