王士厅

多图(图集)详情页评论、点赞调接口中

@@ -23,7 +23,18 @@ export { Pic } from './src/main/ets/bean/content/Pic' @@ -23,7 +23,18 @@ export { Pic } from './src/main/ets/bean/content/Pic'
23 23
24 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; 24 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO';
25 25
26 -export { InteractDataStatusBean, PhotoListBean, InputMethodProperty } from './src/main/ets/bean/detail/MultiPictureDetailPageDTO'; 26 +export {
  27 + PhotoListBean,
  28 + InputMethodProperty,
  29 + batchLikeAndCollectParams,
  30 + postBatchAttentionStatusParams,
  31 + postInteractBrowsOperateParams,
  32 + postBatchAttentionStatusResult,
  33 + batchLikeAndCollectResult,
  34 + postExecuteLikeParams,
  35 + postExecuteCollectRecordParams,
  36 + contentListParams
  37 +} from './src/main/ets/bean/detail/MultiPictureDetailPageDTO';
27 38
28 export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam'; 39 export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
29 40
1 /* 1 /*
2 * 多图(图集)详情 2 * 多图(图集)详情
3 * */ 3 * */
4 -// 批量查询内容当前用户点赞、收藏状态  
5 -export interface InteractDataStatusBean {  
6 - contentId: string;  
7 - contentType: number;  
8 - contentRelId: string;  
9 - relType: number;  
10 - likeStatus: number;  
11 - collectStatus: number;  
12 -}  
13 4
14 // 【图文、图集稿件正文图片】图片信息数组 5 // 【图文、图集稿件正文图片】图片信息数组
15 export interface PhotoListBean { 6 export interface PhotoListBean {
@@ -98,3 +89,82 @@ export interface InputMethodProperty { @@ -98,3 +89,82 @@ export interface InputMethodProperty {
98 */ 89 */
99 extra?: object; 90 extra?: object;
100 } 91 }
  92 +
  93 +export interface IStatusContentList {
  94 + contentId: string;
  95 +
  96 + // relType: string;
  97 + contentType: string;
  98 + // contentRelId: string;
  99 +}
  100 +export interface batchLikeAndCollectParams {
  101 + // userType: number;
  102 + // userId: string;
  103 + contentList: IStatusContentList[]
  104 +}
  105 +
  106 +export interface postBatchAttentionStatusParamsItem {
  107 + creatorId: string;
  108 +}
  109 +
  110 +export interface postBatchAttentionStatusParams {
  111 + creatorIds: postBatchAttentionStatusParamsItem[]
  112 +}
  113 +
  114 +export interface postInteractBrowsOperateParamsContent {
  115 + browseTime: string;
  116 + contentId: string;
  117 + contentType: number;
  118 +}
  119 +
  120 +export interface postInteractBrowsOperateParams {
  121 + delStatus: number;
  122 + contentList: postInteractBrowsOperateParamsContent[]
  123 +}
  124 +
  125 +export interface postBatchAttentionStatusResult {
  126 + creatorId: string;
  127 + status: string;
  128 + userId: string;
  129 +}
  130 +
  131 +export interface batchLikeAndCollectResult {
  132 + collectStatus: number;
  133 + contentType: string;
  134 + likeStatus: string;
  135 + relType: string;
  136 + contentId: string;
  137 + contentRelId: string;
  138 +}
  139 +
  140 +export interface postExecuteLikeParams {
  141 + status: string;
  142 + contentId: string;
  143 + contentType: string;
  144 + relType?: string;
  145 + userName?: string;
  146 + title?: string;
  147 + contentRelId?: string;
  148 + userHeaderUrl?: string;
  149 + channelId?: string;
  150 +}
  151 +export interface postExecuteCollectRecordParamsItem {
  152 + contentId: string;
  153 + contentType: string;
  154 + relType?: string;
  155 + contentRelId?: string;
  156 +}
  157 +
  158 +export interface postExecuteCollectRecordParams {
  159 + status: string;
  160 + contentList: postExecuteCollectRecordParamsItem[]
  161 +}
  162 +
  163 +interface contentListItem {
  164 + contentId: string;
  165 + contentType: number;
  166 +}
  167 +
  168 +export interface contentListParams {
  169 + contentList: contentListItem[];
  170 +}
1 import { Logger } from 'wdKit'; 1 import { Logger } from 'wdKit';
2 -import { ContentDetailDTO, PhotoListBean } from 'wdBean'; 2 +import { ContentDetailDTO, PhotoListBean, postInteractBrowsOperateParams, postBatchAttentionStatusParams } from 'wdBean';
3 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 3 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
4 import display from '@ohos.display'; 4 import display from '@ohos.display';
5 import font from '@ohos.font'; 5 import font from '@ohos.font';
6 import { OperRowListView } from './view/OperRowListView'; 6 import { OperRowListView } from './view/OperRowListView';
7 import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent'; 7 import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent';
  8 +import { DateTimeUtils } from 'wdKit/Index';
  9 +import { HttpUrlUtils } from 'wdNetwork/Index';
8 10
9 const TAG = 'MultiPictureDetailPageComponent'; 11 const TAG = 'MultiPictureDetailPageComponent';
10 12
@@ -21,6 +23,7 @@ export struct MultiPictureDetailPageComponent { @@ -21,6 +23,7 @@ export struct MultiPictureDetailPageComponent {
21 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01' 23 @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
22 private swiperController: SwiperController = new SwiperController() 24 private swiperController: SwiperController = new SwiperController()
23 @State swiperIndex: number = 0; 25 @State swiperIndex: number = 0;
  26 + @Provide followStatus: string = '0' // 关注状态
24 27
25 //watch监听页码回调 28 //watch监听页码回调
26 onCurrentPageNumUpdated(): void { 29 onCurrentPageNumUpdated(): void {
@@ -43,6 +46,10 @@ export struct MultiPictureDetailPageComponent { @@ -43,6 +46,10 @@ export struct MultiPictureDetailPageComponent {
43 familySrc: $rawfile('font/BebasNeue_Regular.otf') 46 familySrc: $rawfile('font/BebasNeue_Regular.otf')
44 }) 47 })
45 this.getContentDetailData() 48 this.getContentDetailData()
  49 + if (HttpUrlUtils.getUserId()) {
  50 + this.getInteractBrowsOperate()
  51 + this.getBatchAttentionStatus()
  52 + }
46 } 53 }
47 54
48 aboutToDisappear() { 55 aboutToDisappear() {
@@ -74,7 +81,9 @@ export struct MultiPictureDetailPageComponent { @@ -74,7 +81,9 @@ export struct MultiPictureDetailPageComponent {
74 this.swiperIndex = index 81 this.swiperIndex = index
75 }) 82 })
76 } 83 }
77 - OperRowListView() 84 + OperRowListView({
  85 + contentDetailData: this.contentDetailData?.[0],
  86 + })
78 .alignRules({ 87 .alignRules({
79 bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, 88 bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
80 middle: { anchor: "__container__", align: HorizontalAlign.Center } 89 middle: { anchor: "__container__", align: HorizontalAlign.Center }
@@ -98,4 +107,37 @@ export struct MultiPictureDetailPageComponent { @@ -98,4 +107,37 @@ export struct MultiPictureDetailPageComponent {
98 107
99 } 108 }
100 } 109 }
  110 +
  111 + // 记录浏览历史
  112 + private getInteractBrowsOperate() {
  113 + try {
  114 + const params: postInteractBrowsOperateParams = {
  115 + delStatus: 0,
  116 + contentList: [{
  117 + browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN),
  118 + contentId: this.contentDetailData?.[0].newsId + '',
  119 + contentType: this.contentDetailData?.[0].newsType || 0,
  120 + }]
  121 + }
  122 + MultiPictureDetailViewModel.getInteractBrowsOperate(params).then(res => {
  123 + console.log('记录浏览历史==', JSON.stringify(res.data))
  124 + })
  125 + } catch (exception) {
  126 +
  127 + }
  128 + }
  129 +
  130 + // 已登录->批量查作品是否被号主关注
  131 + private async getBatchAttentionStatus() {
  132 + try {
  133 + const params: postBatchAttentionStatusParams = {
  134 + creatorIds: [{ creatorId: this.contentDetailData?.[0]?.rmhInfo?.rmhId ?? '' }]
  135 + }
  136 + let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
  137 + this.followStatus = data[0]?.status;
  138 + Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
  139 + } catch (exception) {
  140 +
  141 + }
  142 + }
101 } 143 }
1 import { ToastUtils, Logger } from 'wdKit'; 1 import { ToastUtils, Logger } from 'wdKit';
2 -import { InputMethodProperty } from 'wdBean'; 2 +import {
  3 + InputMethodProperty,
  4 + batchLikeAndCollectResult,
  5 + batchLikeAndCollectParams,
  6 + ContentDetailDTO,
  7 + postExecuteLikeParams,
  8 + contentListParams,
  9 + InteractDataDTO,
  10 + postExecuteCollectRecordParams
  11 +} from 'wdBean';
3 import router from '@ohos.router'; 12 import router from '@ohos.router';
4 import inputMethod from '@ohos.inputMethod'; 13 import inputMethod from '@ohos.inputMethod';
  14 +import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
  15 +import { HttpUrlUtils } from 'wdNetwork/Index';
  16 +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
  17 +import { PageRepository } from '../../repository/PageRepository';
5 18
6 export interface OperationItem { 19 export interface OperationItem {
7 icon: Resource; 20 icon: Resource;
  21 + icon_check?: Resource;
8 text: string | Resource; 22 text: string | Resource;
9 num?: number; // 个数 23 num?: number; // 个数
10 } 24 }
@@ -14,19 +28,23 @@ const TAG = 'OperRowListView'; @@ -14,19 +28,23 @@ const TAG = 'OperRowListView';
14 @Preview 28 @Preview
15 @Component 29 @Component
16 export struct OperRowListView { 30 export struct OperRowListView {
  31 + private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
  32 + private interactData: InteractDataDTO | undefined = undefined
  33 + @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
  34 +
17 @State operationList: OperationItem[] = [ 35 @State operationList: OperationItem[] = [
18 { 36 {
19 icon: $r('app.media.ic_comment'), 37 icon: $r('app.media.ic_comment'),
20 text: "评论", 38 text: "评论",
21 - num: 500,  
22 }, 39 },
23 { 40 {
24 icon: $r('app.media.ic_like_uncheck'), 41 icon: $r('app.media.ic_like_uncheck'),
  42 + icon_check: $r('app.media.ic_like_check'),
25 text: "点赞", 43 text: "点赞",
26 - num: 6622  
27 }, 44 },
28 { 45 {
29 icon: $r('app.media.ic_collect_uncheck'), 46 icon: $r('app.media.ic_collect_uncheck'),
  47 + icon_check: $r('app.media.ic_collect_check'),
30 text: "收藏", 48 text: "收藏",
31 }, 49 },
32 { 50 {
@@ -36,6 +54,10 @@ export struct OperRowListView { @@ -36,6 +54,10 @@ export struct OperRowListView {
36 ] 54 ]
37 55
38 aboutToAppear() { 56 aboutToAppear() {
  57 + if (HttpUrlUtils.getUserId()) {
  58 + this.getInteractDataStatus()
  59 + }
  60 + this.queryContentInteractCount()
39 } 61 }
40 62
41 build() { 63 build() {
@@ -100,6 +122,97 @@ export struct OperRowListView { @@ -100,6 +122,97 @@ export struct OperRowListView {
100 @Builder 122 @Builder
101 buildOperationItem(item: OperationItem, index: number) { 123 buildOperationItem(item: OperationItem, index: number) {
102 Column() { 124 Column() {
  125 + if (item.text === '点赞') {
  126 + RelativeContainer() {
  127 + Row() {
  128 + Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon)
  129 + .width(24)
  130 + .height(24)
  131 + .aspectRatio(1)
  132 + .interpolation(ImageInterpolation.High)
  133 + .onClick(() => {
  134 + this.toggleLikeStatus()
  135 + })
  136 + }
  137 + .alignRules({
  138 + center: { anchor: '__container__', align: VerticalAlign.Center },
  139 + middle: { anchor: '__container__', align: HorizontalAlign.Center }
  140 + })
  141 + .id(`e_row1_${index}`)
  142 + if(this.interactData?.likeNum) {
  143 + Row() {
  144 + Image($r('app.media.corner_mark'))
  145 + .width(25)
  146 + .height(12)
  147 + .interpolation(ImageInterpolation.High)
  148 + }
  149 + .alignRules({
  150 + top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top },
  151 + left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center }
  152 + })
  153 + .id(`e_row2_${index}`)
  154 +
  155 + Row() {
  156 + Text(`${this.interactData?.likeNum}`)
  157 + .fontSize(8)
  158 + .textAlign(TextAlign.Center)
  159 + .fontColor(Color.White)
  160 + .lineHeight(12)
  161 + }
  162 + .alignRules({
  163 + top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top },
  164 + middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center }
  165 + })
  166 + .id(`e_row3_${index}`)
  167 + }
  168 + }
  169 + .id(`e_icon_${index}`)
  170 + } else if (item.text === '收藏') {
  171 + RelativeContainer() {
  172 + Row() {
  173 + Image(this.newsStatusOfUser?.collectStatus == 1 ? item.icon_check : item.icon)
  174 + .width(24)
  175 + .height(24)
  176 + .aspectRatio(1)
  177 + .interpolation(ImageInterpolation.High)
  178 + .onClick(() => {
  179 + this.toggleCollectStatus()
  180 + })
  181 + }
  182 + .alignRules({
  183 + center: { anchor: '__container__', align: VerticalAlign.Center },
  184 + middle: { anchor: '__container__', align: HorizontalAlign.Center }
  185 + })
  186 + .id(`e_row1_${index}`)
  187 + if(this.interactData?.collectNum) {
  188 + Row() {
  189 + Image($r('app.media.corner_mark'))
  190 + .width(25)
  191 + .height(12)
  192 + .interpolation(ImageInterpolation.High)
  193 + }
  194 + .alignRules({
  195 + top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top },
  196 + left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center }
  197 + })
  198 + .id(`e_row2_${index}`)
  199 +
  200 + Row() {
  201 + Text(`${this.interactData?.collectNum}`)
  202 + .fontSize(8)
  203 + .textAlign(TextAlign.Center)
  204 + .fontColor(Color.White)
  205 + .lineHeight(12)
  206 + }
  207 + .alignRules({
  208 + top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top },
  209 + middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center }
  210 + })
  211 + .id(`e_row3_${index}`)
  212 + }
  213 + }
  214 + .id(`e_icon_${index}`)
  215 + } else if (item.text === '评论') {
103 RelativeContainer() { 216 RelativeContainer() {
104 Row() { 217 Row() {
105 Image(item.icon) 218 Image(item.icon)
@@ -107,13 +220,16 @@ export struct OperRowListView { @@ -107,13 +220,16 @@ export struct OperRowListView {
107 .height(24) 220 .height(24)
108 .aspectRatio(1) 221 .aspectRatio(1)
109 .interpolation(ImageInterpolation.High) 222 .interpolation(ImageInterpolation.High)
  223 + .onClick((event: ClickEvent) => {
  224 + ToastUtils.showToast('评论为公共方法,待开发', 1000);
  225 + })
110 } 226 }
111 .alignRules({ 227 .alignRules({
112 center: { anchor: '__container__', align: VerticalAlign.Center }, 228 center: { anchor: '__container__', align: VerticalAlign.Center },
113 middle: { anchor: '__container__', align: HorizontalAlign.Center } 229 middle: { anchor: '__container__', align: HorizontalAlign.Center }
114 }) 230 })
115 .id(`e_row1_${index}`) 231 .id(`e_row1_${index}`)
116 - if(item.num) { 232 + if(this.interactData?.commentNum) {
117 Row() { 233 Row() {
118 Image($r('app.media.corner_mark')) 234 Image($r('app.media.corner_mark'))
119 .width(25) 235 .width(25)
@@ -127,7 +243,7 @@ export struct OperRowListView { @@ -127,7 +243,7 @@ export struct OperRowListView {
127 .id(`e_row2_${index}`) 243 .id(`e_row2_${index}`)
128 244
129 Row() { 245 Row() {
130 - Text('99+') 246 + Text(`${this.interactData?.commentNum}`)
131 .fontSize(8) 247 .fontSize(8)
132 .textAlign(TextAlign.Center) 248 .textAlign(TextAlign.Center)
133 .fontColor(Color.White) 249 .fontColor(Color.White)
@@ -141,14 +257,31 @@ export struct OperRowListView { @@ -141,14 +257,31 @@ export struct OperRowListView {
141 } 257 }
142 } 258 }
143 .id(`e_icon_${index}`) 259 .id(`e_icon_${index}`)
  260 + } else {
  261 + RelativeContainer() {
  262 + Row() {
  263 + Image(item.icon)
  264 + .width(24)
  265 + .height(24)
  266 + .aspectRatio(1)
  267 + .interpolation(ImageInterpolation.High)
  268 + .onClick((event: ClickEvent) => {
  269 + ToastUtils.showToast('分享为公共方法,待开发', 1000);
  270 + })
  271 + }
  272 + .alignRules({
  273 + center: { anchor: '__container__', align: VerticalAlign.Center },
  274 + middle: { anchor: '__container__', align: HorizontalAlign.Center }
  275 + })
  276 + .id(`e_row1_${index}`)
  277 + }
  278 + .id(`e_icon_${index}`)
  279 + }
  280 +
144 } 281 }
145 .margin(5) 282 .margin(5)
146 .alignItems(HorizontalAlign.Center) 283 .alignItems(HorizontalAlign.Center)
147 .hoverEffect(HoverEffect.Scale) 284 .hoverEffect(HoverEffect.Scale)
148 - .onClick(() => {  
149 - Logger.info(TAG, `buildOperationItem onClick event index: ${index}`);  
150 - ToastUtils.showToast('体验版,本功能暂未开发', 1000);  
151 - })  
152 } 285 }
153 286
154 /** 287 /**
@@ -180,4 +313,94 @@ export struct OperRowListView { @@ -180,4 +313,94 @@ export struct OperRowListView {
180 console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); 313 console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
181 } 314 }
182 } 315 }
  316 +
  317 + // 已登录->查询用户对作品点赞、收藏状态
  318 + private async getInteractDataStatus() {
  319 + try {
  320 + const params: batchLikeAndCollectParams = {
  321 + contentList: [
  322 + {
  323 + contentId: this.contentDetailData?.newsId + '',
  324 + contentType: this.contentDetailData?.newsType + '',
  325 + }
  326 + ]
  327 + }
  328 + let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
  329 + console.error(TAG, JSON.stringify(data))
  330 + this.newsStatusOfUser = data[0];
  331 + Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
  332 + } catch (exception) {
  333 +
  334 + }
  335 + }
  336 +
  337 + /**
  338 + * 点赞、取消点赞
  339 + */
  340 + toggleLikeStatus() {
  341 + // 未登录,跳转登录
  342 + if (!HttpUrlUtils.getUserId()) {
  343 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  344 + return
  345 + }
  346 + const params: postExecuteLikeParams = {
  347 + status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
  348 + contentId: this.contentDetailData?.newsId + '',
  349 + contentType: this.contentDetailData?.newsType + '',
  350 + }
  351 + PageRepository.postExecuteLike(params).then(res => {
  352 + console.log('toggleLikeStatus==',)
  353 + if (this.newsStatusOfUser) {
  354 + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
  355 + this.queryContentInteractCount()
  356 + }
  357 +
  358 + })
  359 + }
  360 + /**
  361 + * 收藏、取消收藏
  362 + */
  363 + toggleCollectStatus() {
  364 + // 未登录,跳转登录
  365 + if (!HttpUrlUtils.getUserId()) {
  366 + WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
  367 + return
  368 + }
  369 + const params: postExecuteCollectRecordParams = {
  370 + status: this.newsStatusOfUser?.collectStatus === 1 ? '0' : '1',
  371 + contentList: [{
  372 + contentId: this.contentDetailData?.newsId + '',
  373 + contentType: this.contentDetailData?.newsType + '',
  374 + }],
  375 +
  376 + }
  377 + PageRepository.postExecuteCollectRecord(params).then(res => {
  378 + console.log('toggleLikeStatus==',)
  379 + if (this.newsStatusOfUser) {
  380 + this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
  381 + this.queryContentInteractCount()
  382 + }
  383 + })
  384 +
  385 + }
  386 +
  387 + /**
  388 + * 查询点赞、收藏数量
  389 + */
  390 + queryContentInteractCount() {
  391 + const params: contentListParams = {
  392 + contentList: [{
  393 + contentId: this.contentDetailData?.newsId + '',
  394 + contentType: this.contentDetailData?.newsType,
  395 + }]
  396 + }
  397 + PageRepository.getContentInteract(params).then(res => {
  398 + if (res.data && this.interactData) {
  399 + this.interactData.likeNum = res.data[0]?.likeNum
  400 + this.interactData.collectNum = res.data[0]?.collectNum
  401 + this.interactData.commentNum = res.data[0]?.commentNum
  402 + }
  403 + console.log('获取互动点赞等数据===', JSON.stringify(res))
  404 + })
  405 + }
183 } 406 }
@@ -5,13 +5,18 @@ import { @@ -5,13 +5,18 @@ import {
5 CompInfoBean, 5 CompInfoBean,
6 ContentDetailDTO, 6 ContentDetailDTO,
7 InteractDataDTO, 7 InteractDataDTO,
8 - InteractDataStatusBean, 8 + batchLikeAndCollectResult,
9 MorningEveningPaperDTO, 9 MorningEveningPaperDTO,
10 NavigationBodyDTO, 10 NavigationBodyDTO,
11 NewspaperListBean, 11 NewspaperListBean,
12 NewspaperTimeInfoBean, 12 NewspaperTimeInfoBean,
13 PageDTO, 13 PageDTO,
14 - PageInfoBean 14 + PageInfoBean,
  15 + postBatchAttentionStatusParams,
  16 + postBatchAttentionStatusResult,
  17 + postExecuteLikeParams,
  18 + postExecuteCollectRecordParams,
  19 + contentListParams
15 } from 'wdBean'; 20 } from 'wdBean';
16 21
17 const TAG = 'HttpRequest'; 22 const TAG = 'HttpRequest';
@@ -174,9 +179,41 @@ export class PageRepository { @@ -174,9 +179,41 @@ export class PageRepository {
174 static fetchInteractDataStatus(param: object) { 179 static fetchInteractDataStatus(param: object) {
175 let url = PageRepository.getInteractDataStatusUrl() 180 let url = PageRepository.getInteractDataStatusUrl()
176 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 181 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
177 - return WDHttp.post<ResponseDTO<InteractDataStatusBean[]>>(url, param, headers) 182 + return WDHttp.post<ResponseDTO<batchLikeAndCollectResult[]>>(url, param, headers)
178 }; 183 };
179 184
  185 + /**
  186 + * 用户点赞、取消点赞
  187 + * @param params
  188 + * @returns
  189 + */
  190 + static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> {
  191 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE
  192 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  193 + return WDHttp.post0(url, params, headers)
  194 + }
  195 +
  196 + /**
  197 + * 用户收藏、取消收藏
  198 + * @param params
  199 + * @returns
  200 + */
  201 + static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
  202 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
  203 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  204 + return WDHttp.post0(url, params, headers)
  205 + }
  206 +
  207 + /**
  208 + *
  209 + * @returns
  210 + */
  211 + static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
  212 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
  213 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  214 + return WDHttp.post0(url, params, headers)
  215 + }
  216 +
180 // 浏览历史新增、删除接口 217 // 浏览历史新增、删除接口
181 static fetchInteractBrowsOperate(param: object) { 218 static fetchInteractBrowsOperate(param: object) {
182 let url = PageRepository.getInteractBrowsOperateUrl() 219 let url = PageRepository.getInteractBrowsOperateUrl()
@@ -184,6 +221,16 @@ export class PageRepository { @@ -184,6 +221,16 @@ export class PageRepository {
184 return WDHttp.post<ResponseDTO<null>>(url, param, headers) 221 return WDHttp.post<ResponseDTO<null>>(url, param, headers)
185 }; 222 };
186 223
  224 + /**
  225 + * 批量查号主是否为用户关注
  226 + * @returns
  227 + */
  228 + static fetchBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> {
  229 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
  230 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  231 + return WDHttp.post0(url, params, headers)
  232 + }
  233 +
187 static fetchNewspaperInfo(date: string) { 234 static fetchNewspaperInfo(date: string) {
188 let url = PageRepository.getNewspaperInfoUrl(date) 235 let url = PageRepository.getNewspaperInfoUrl(date)
189 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 236 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
1 import { Logger } from 'wdKit'; 1 import { Logger } from 'wdKit';
2 import { ResponseDTO } from 'wdNetwork'; 2 import { ResponseDTO } from 'wdNetwork';
3 -import { ContentDetailDTO } from 'wdBean'; 3 +import { ContentDetailDTO,
  4 + batchLikeAndCollectParams,
  5 + batchLikeAndCollectResult,
  6 + postBatchAttentionStatusParams,
  7 + postBatchAttentionStatusResult,
  8 + postInteractBrowsOperateParams
  9 +} from 'wdBean';
4 import { PageRepository } from '../repository/PageRepository'; 10 import { PageRepository } from '../repository/PageRepository';
5 11
6 const TAG = 'MultiPictureDetailViewModel'; 12 const TAG = 'MultiPictureDetailViewModel';
7 13
8 export class MultiPictureDetailViewModel { 14 export class MultiPictureDetailViewModel {
9 15
10 - /*fetchDetailData  
11 - fetchInteractData  
12 - fetchInteractDataStatus  
13 - fetchInteractBrowsOperate*/  
14 -  
15 static async getDetailData(relId: string, contentId: string, relType: string): Promise<ContentDetailDTO[]> { 16 static async getDetailData(relId: string, contentId: string, relType: string): Promise<ContentDetailDTO[]> {
16 return new Promise<ContentDetailDTO[]>((success, error) => { 17 return new Promise<ContentDetailDTO[]>((success, error) => {
17 Logger.info(TAG, `fetchDetailData start`); 18 Logger.info(TAG, `fetchDetailData start`);
@@ -34,4 +35,75 @@ export class MultiPictureDetailViewModel { @@ -34,4 +35,75 @@ export class MultiPictureDetailViewModel {
34 }) 35 })
35 }) 36 })
36 } 37 }
  38 +
  39 + /**
  40 + * 批量查询作品查询点赞、收藏状态
  41 + * @returns
  42 + */
  43 + static async getInteractDataStatus(params:batchLikeAndCollectParams): Promise<batchLikeAndCollectResult[]> {
  44 + return new Promise<batchLikeAndCollectResult[]>((success, error) => {
  45 + Logger.info(TAG, `fetchInteractDataStatus start`);
  46 + PageRepository.fetchInteractDataStatus(params).then((resDTO: ResponseDTO<batchLikeAndCollectResult[]>) => {
  47 + if (!resDTO || !resDTO.data) {
  48 + Logger.error(TAG, 'fetchInteractDataStatus is empty');
  49 + error('resDTO is empty');
  50 + return
  51 + }
  52 + if (resDTO.code != 0) {
  53 + Logger.error(TAG, `fetchInteractDataStatus then code:${resDTO.code}, message:${resDTO.message}`);
  54 + error('resDTO Response Code is failure');
  55 + return
  56 + }
  57 + Logger.info(TAG, "fetchInteractDataStatus then,navResDTO.timestamp:" + resDTO.timestamp);
  58 + success(resDTO.data);
  59 + }).catch((err: Error) => {
  60 + Logger.error(TAG, `fetchInteractDataStatus catch, error.name : ${err.name}, error.message:${err.message}`);
  61 + error(err);
  62 + })
  63 + })
  64 + }
  65 +
  66 + // 已登录->批量查作品是否被号主关注
  67 + static async getBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<postBatchAttentionStatusResult[]> {
  68 + return new Promise<postBatchAttentionStatusResult[]>((success, error) => {
  69 + Logger.info(TAG, `fetchBatchAttentionStatus start`);
  70 + PageRepository.fetchBatchAttentionStatus(params).then((resDTO: ResponseDTO<postBatchAttentionStatusResult[]>) => {
  71 + if (!resDTO || !resDTO.data) {
  72 + Logger.error(TAG, 'fetchBatchAttentionStatus is empty');
  73 + error('resDTO is empty');
  74 + return
  75 + }
  76 + if (resDTO.code != 0) {
  77 + Logger.error(TAG, `fetchBatchAttentionStatus then code:${resDTO.code}, message:${resDTO.message}`);
  78 + error('resDTO Response Code is failure');
  79 + return
  80 + }
  81 + Logger.info(TAG, "fetchBatchAttentionStatus then,navResDTO.timestamp:" + resDTO.timestamp);
  82 + success(resDTO.data);
  83 + }).catch((err: Error) => {
  84 + Logger.error(TAG, `fetchBatchAttentionStatus catch, error.name : ${err.name}, error.message:${err.message}`);
  85 + error(err);
  86 + })
  87 + })
  88 + }
  89 +
  90 + // 记录浏览历史
  91 + static async getInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO<null>> {
  92 + return new Promise<ResponseDTO<null>>((success, error) => {
  93 + Logger.info(TAG, `fetchInteractBrowsOperate start`);
  94 + PageRepository.fetchInteractBrowsOperate(params).then((resDTO: ResponseDTO<null>) => {
  95 + if (resDTO.code != 0) {
  96 + Logger.error(TAG, `fetchInteractBrowsOperate then code:${resDTO.code}, message:${resDTO.message}`);
  97 + error('resDTO Response Code is failure');
  98 + return
  99 + }
  100 + Logger.info(TAG, "fetchInteractBrowsOperate then,navResDTO.timestamp:" + resDTO.timestamp);
  101 + success(resDTO);
  102 + }).catch((err: Error) => {
  103 + Logger.error(TAG, `fetchInteractBrowsOperate catch, error.name : ${err.name}, error.message:${err.message}`);
  104 + error(err);
  105 + })
  106 + })
  107 + }
  108 +
37 } 109 }