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

53 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';
/**
* 论坛服务
*/
@Injectable({
providedIn: 'root'
})
export class ForumService extends JSONRequest {
constructor(
private http: HttpClient
) {
super();
}
/**
* 获取公告信息
*/
getAllNotices(): Observable<JSONResponse<any>> {
return this.http.get<JSONResponse<any>>(HttpInterface.getAllNotices, this.httpOptions)
.pipe(
catchError(this.handleError<any>('获取公告信息'))
);
}
/**
* 获取所有帖子
*/
getAllPosts(page): Observable<JSONResponse<any>> {
return this.http.get<JSONResponse<any>>(HttpInterface.getAllPosts + '/' + page, this.httpOptions)
.pipe(
catchError(this.handleError<any>('获取帖子'))
);
}
/**
* 审核帖子
*/
checkPost(id, s): Observable<JSONResponse<any>> {
return this.http.patch<JSONResponse<any>>(HttpInterface.checkPost + '/' + id, { status : s}, this.httpOptions)
.pipe(
catchError(this.handleError<any>('审核帖子'))
);
}
}