import { Injectable } from '@angular/core'; import { PublicService } from '../PublicService'; import { map } from 'rxjs/operators'; import { HttpClient, HttpHeaders } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class MessageService { public constructor(private readonly publicService: PublicService, private readonly http: HttpClient) { } // 加载app端消息分类统计 public loadMsgTypeCount(){ return this.http .get(this.publicService.getApiUrl() + `/analysis/app/msg/loadMsgTypeCount`, {headers: new HttpHeaders({ Authorization: this.publicService.token }) }) .pipe(map(result => result as any)) .toPromise(); } // 获取类型下消息列表 public getMsgListFromType(type){ return this.http .get(this.publicService.getApiUrl() + `/analysis/app/msg/getMsgListFromType?type=` + type, {headers: new HttpHeaders({ Authorization: this.publicService.token }) }) .pipe(map(result => result as any)) .toPromise(); } // 单个消息标为已读 public changeMsgStatus(msgId){ return this.http .get(this.publicService.getApiUrl() + `/analysis/app/msg/changeMsgStatus?msgId=` + msgId, {headers: new HttpHeaders({ Authorization: this.publicService.token }) }) .pipe(map(result => result as any)) .toPromise(); } // 修改用户消息状态(某个类型下全部已读) public changeTypeMsgStatus(type){ return this.http .get(this.publicService.getApiUrl() + `/analysis/app/msg/changeTypeMsgStatus?msgTypeCode=` + type, {headers: new HttpHeaders({ Authorization: this.publicService.token }) }) .pipe(map(result => result as any)) .toPromise(); } }