parent
cadf5204fe
commit
82598c2bb5
@ -0,0 +1,16 @@ |
||||
import { TestBed } from '@angular/core/testing'; |
||||
|
||||
import { ForumService } from './forum.service'; |
||||
|
||||
describe('ForumService', () => { |
||||
let service: ForumService; |
||||
|
||||
beforeEach(() => { |
||||
TestBed.configureTestingModule({}); |
||||
service = TestBed.inject(ForumService); |
||||
}); |
||||
|
||||
it('should be created', () => { |
||||
expect(service).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,53 @@ |
||||
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>('审核帖子')) |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,66 @@ |
||||
// 帖子类型
|
||||
export enum ForumType { |
||||
active= 'active', |
||||
complaint= 'complaint' |
||||
} |
||||
|
||||
// 活动帖
|
||||
export interface Active { |
||||
// 活动帖
|
||||
// 帖子类型
|
||||
type: ForumType; |
||||
// 帖子ID
|
||||
id: number; |
||||
// 发帖人
|
||||
issuer: string; |
||||
// 头像
|
||||
headImg: string; |
||||
// 用户信用分
|
||||
userCreditScore: number; |
||||
// 帖子标题
|
||||
title: string; |
||||
// 帖子内容
|
||||
content: string; |
||||
// 活动开始时间
|
||||
startTime: number; |
||||
// 活动结束时间
|
||||
endTime: number; |
||||
// 活动奖励分
|
||||
activeCreditScore: number; |
||||
} |
||||
|
||||
// 投诉帖
|
||||
export interface Complaint { |
||||
// 帖子类型
|
||||
type: ForumType; |
||||
// 帖子ID
|
||||
id: number; |
||||
// 投诉人头像
|
||||
plaintiffHeadImg: string; |
||||
// 投诉人名称
|
||||
plaintiffName: string; |
||||
// 投诉人信用分
|
||||
plaintiffCreditScore: number; |
||||
// 被投诉人头像
|
||||
defendantHeadImg: string; |
||||
// 被投诉人名称
|
||||
defendantName: string; |
||||
// 被投诉人信用分
|
||||
defendantCreditScore: number; |
||||
// 投诉标题
|
||||
title: string; |
||||
// 投诉内容
|
||||
content: string; |
||||
// 投诉时间
|
||||
time: number; |
||||
} |
||||
|
||||
export interface Forum { |
||||
list: Array<Active|Complaint>; |
||||
page: { |
||||
count: number; |
||||
page: number; |
||||
currentPage: number; |
||||
}; |
||||
} |
||||
|
@ -0,0 +1,10 @@ |
||||
export interface Notice { |
||||
// 公告人
|
||||
managerName: string; |
||||
// 公告内容
|
||||
content: string; |
||||
// 公告标题
|
||||
title: string; |
||||
// 公告时间
|
||||
createTime: number; |
||||
} |
Loading…
Reference in new issue