diff --git a/index/src/app/class/Comment.ts b/index/src/app/class/Comment.ts
index 3637817..449e558 100644
--- a/index/src/app/class/Comment.ts
+++ b/index/src/app/class/Comment.ts
@@ -4,6 +4,7 @@ export class Comment {
authorAvatarImgUrl?: string;
content: string;
articleID: number;
+ articleTitle: string;
date?: string;
responseId: string;
pid: number;
@@ -29,4 +30,4 @@ export class CommentReq {
this.pid = -1;
this.id = null;
}
-}
\ No newline at end of file
+}
diff --git a/index/src/app/view/admin/admin-comment/admin-comment.component.html b/index/src/app/view/admin/admin-comment/admin-comment.component.html
index e4e9602..1cdd02d 100644
--- a/index/src/app/view/admin/admin-comment/admin-comment.component.html
+++ b/index/src/app/view/admin/admin-comment/admin-comment.component.html
@@ -1 +1,40 @@
-
admin-comment works!
+
+
diff --git a/index/src/app/view/admin/admin-comment/admin-comment.component.less b/index/src/app/view/admin/admin-comment/admin-comment.component.less
index e69de29..35aa4ab 100644
--- a/index/src/app/view/admin/admin-comment/admin-comment.component.less
+++ b/index/src/app/view/admin/admin-comment/admin-comment.component.less
@@ -0,0 +1,3 @@
+td {
+ max-width: 300px;
+}
diff --git a/index/src/app/view/admin/admin-comment/admin-comment.component.ts b/index/src/app/view/admin/admin-comment/admin-comment.component.ts
index 521c388..c7804f3 100644
--- a/index/src/app/view/admin/admin-comment/admin-comment.component.ts
+++ b/index/src/app/view/admin/admin-comment/admin-comment.component.ts
@@ -1,15 +1,77 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
+import {NzMessageService} from 'ng-zorro-antd';
+import {ApiService} from '../../../api/api.service';
+import {PageList} from '../../../class/HttpReqAndResp';
+import {Comment, CommentReq} from '../../../class/Comment';
@Component({
- selector: 'app-admin-comment',
- templateUrl: './admin-comment.component.html',
- styleUrls: ['./admin-comment.component.less']
+ selector: 'app-admin-comment',
+ templateUrl: './admin-comment.component.html',
+ styleUrls: ['./admin-comment.component.less']
})
export class AdminCommentComponent implements OnInit {
- constructor() { }
+ constructor(private apiService: ApiService, private messageService: NzMessageService) {
+ }
- ngOnInit(): void {
- }
+ loading: boolean = true;
+ pageIndex: number = 1;
+ pageSize: number = 10;
+ pageList: PageList = new PageList();
+ editInfo = {
+ id: null,
+ content: new CommentReq(true),
+ editFocus: false,
+ }
+ ngOnInit(): void {
+ this.getComment();
+ }
+
+ getComment = () => this.apiService.getCommentByTypeForAdmin(true, this.pageIndex, this.pageSize).subscribe({
+ next: data => this.pageList = data.result,
+ complete: () => this.loading = false,
+ error: err => this.loading = false
+ })
+
+ deleteComment(id: number) {
+ this.loading = true;
+ this.apiService.deleteComment(id).subscribe({
+ next: () => {
+ this.messageService.success('删除评论成功');
+ this.getComment();
+ },
+ error: err => {
+ this.loading = false;
+ this.messageService.success(err.msg);
+ },
+ complete: () => this.loading = false
+ })
+ }
+
+ edit() {
+ this.editInfo.editFocus = false;
+ this.loading = true;
+ this.apiService.updateComment(this.editInfo.content).subscribe({
+ next: data => {
+ this.messageService.success('更新评论成功');
+ this.getComment();
+ },
+ error: err => {
+ this.loading = false;
+ this.messageService.success(err.msg);
+ },
+ complete: () => this.loading = false
+ })
+ }
+
+ editFocus(data: Comment) {
+ this.editInfo.id = data.id;
+ this.editInfo.content.content = data.content;
+ this.editInfo.content.id = data.id;
+ this.editInfo.content.articleID = data.articleID;
+ this.editInfo.content.pid = data.pid;
+ this.editInfo.content.responseId = data.responseId;
+ this.editInfo.editFocus = true;
+ }
}
diff --git a/index/src/app/view/admin/admin-comment/admin-comment.module.ts b/index/src/app/view/admin/admin-comment/admin-comment.module.ts
index d65a619..b070182 100644
--- a/index/src/app/view/admin/admin-comment/admin-comment.module.ts
+++ b/index/src/app/view/admin/admin-comment/admin-comment.module.ts
@@ -2,6 +2,16 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule} from '@angular/router';
import {AdminCommentComponent} from './admin-comment.component';
+import {
+ NzButtonModule,
+ NzCardModule,
+ NzDividerModule, NzIconModule, NzInputModule,
+ NzPopconfirmModule,
+ NzTableModule,
+ NzToolTipModule,
+ NzTypographyModule
+} from 'ng-zorro-antd';
+import {FormsModule} from '@angular/forms';
@NgModule({
@@ -10,7 +20,17 @@ import {AdminCommentComponent} from './admin-comment.component';
],
imports: [
CommonModule,
- RouterModule.forChild([{path: '', component: AdminCommentComponent}])
+ RouterModule.forChild([{path: '', component: AdminCommentComponent}]),
+ NzCardModule,
+ NzTableModule,
+ NzDividerModule,
+ NzPopconfirmModule,
+ NzTypographyModule,
+ NzToolTipModule,
+ NzInputModule,
+ FormsModule,
+ NzIconModule,
+ NzButtonModule
]
})
export class AdminCommentModule {
diff --git a/index/src/app/view/admin/auth.guard.ts b/index/src/app/view/admin/auth.guard.ts
index fb7cd72..e0ec194 100644
--- a/index/src/app/view/admin/auth.guard.ts
+++ b/index/src/app/view/admin/auth.guard.ts
@@ -10,7 +10,7 @@ import {GlobalUserService} from '../../services/global-user.service';
export class AuthGuard implements CanActivate {
constructor(private userService: GlobalUserService, private router: Router) {
- this.userService.refreshUserInfo();
+ // this.userService.refreshUserInfo();
}
userInfo: User;