You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
pocketcommunityweb/src/app/forum/forum.service.ts

52 lines
1.3 KiB

import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {JSONResponse} from '../interface/JSONResponse';
import {HttpInterface} from '../interface/HttpInterface';
import {JSONRequest} from '../interface/JSONRequest';
import {Observable} from 'rxjs';
import {catchError} from 'rxjs/operators';
import {ForumNewResponse} from '../interface/Response';
import {ForumStatus} from '../interface/ForumType';
/**
* 论坛服务
*/
@Injectable({
providedIn: 'root'
})
export class ForumService extends JSONRequest {
constructor(
private http: HttpClient
) {
super();
}
/**
* 获取所有帖子
*/
getAllPosts(page): Observable<ForumNewResponse> {
return this.http.get<ForumNewResponse>(HttpInterface.getAllPosts, Object.assign(this.httpOptions, {
params: {
currentPage: page,
status: ForumStatus.uncheck
}
}))
.pipe(
catchError(this.handleError<any>('获取帖子'))
);
}
/**
* 审核帖子
*/
checkPost($id, $status): Observable<JSONResponse<any>> {
return this.http.post<JSONResponse<any>>(HttpInterface.checkPost, {
id: $id,
status: $status
}, this.httpOptions)
.pipe(
catchError(this.handleError<any>('审核帖子'))
);
}
}