调整接口

调整接口
This commit is contained in:
禾几海
2020-05-27 18:31:02 +08:00
committed by GitHub
31 changed files with 197 additions and 161 deletions

View File

@@ -111,7 +111,7 @@ export class ApiService extends HttpService {
} }
categories() { categories() {
return super.Service<Category[]>({ return super.Service<PageList<Category>>({
path: '/categories', path: '/categories',
method: 'GET' method: 'GET'
}); });
@@ -183,10 +183,9 @@ export class ApiService extends HttpService {
}); });
} }
getCommentByTypeForAdmin(pagePath: string, pageNumber: number = 1, pageSize: number = 10) {
getCommentByPid(pid: number, pageNumber: number = 1, pageSize: number = 10) { return super.Service<PageList<Comment>>({
return super.Service<Comment[]>({ path: `/admin/comment/pagePath/${pagePath}`,
path: `/comment/pid/${pid}`,
method: 'GET', method: 'GET',
queryParam: { queryParam: {
page: pageNumber, page: pageNumber,
@@ -195,20 +194,9 @@ export class ApiService extends HttpService {
}); });
} }
getCommentByTypeForAdmin(isComment: boolean, pageNumber: number = 1, pageSize: number = 10) { getCommentByTypeForUser(pagePath: string, pageNumber: number = 1, pageSize: number = 10) {
return super.Service<PageList<Comment>>({ return super.Service<PageList<Comment>>({
path: `/admin/comment/type/${isComment ? 1 : 0}`, path: `/user/comment/pagePath/${pagePath}`,
method: 'GET',
queryParam: {
page: pageNumber,
count: pageSize
}
});
}
getCommentByTypeForUser(isComment: boolean, pageNumber: number = 1, pageSize: number = 10) {
return super.Service<PageList<Comment>>({
path: `/user/comment/type/${isComment ? 1 : 0}`,
method: 'GET', method: 'GET',
queryParam: { queryParam: {
page: pageNumber, page: pageNumber,
@@ -234,21 +222,9 @@ export class ApiService extends HttpService {
}); });
} }
comments(articleID: number, pageSize: number = 10, pageNumber: number = 1) { comments(pagePath: string, pageSize: number = 10, pageNumber: number = 1) {
return super.Service<PageList<Comment>>({ return super.Service<PageList<Comment>>({
path: '/comments', path: `/comment/pagePath/${pagePath}`,
method: 'GET',
queryParam: {
articleId: articleID,
count: pageSize,
page: pageNumber
}
});
}
leaveMsg(pageSize: number = 10, pageNumber: number = 1) {
return super.Service<PageList<Comment>>({
path: '/leaveMsg',
method: 'GET', method: 'GET',
queryParam: { queryParam: {
count: pageSize, count: pageSize,
@@ -272,7 +248,6 @@ export class ApiService extends HttpService {
articleCount: number, articleCount: number,
visitorCount: number, visitorCount: number,
categoryCount: number, categoryCount: number,
leaveMsgCount: number,
tagCount: number, tagCount: number,
commentCount: number commentCount: number
}>({ }>({

View File

@@ -1,3 +1,6 @@
import {Tag} from './Tag';
import {User} from './User';
export class Article { export class Article {
id: number; id: number;
title: string; title: string;
@@ -5,16 +8,16 @@ export class Article {
mdContent?: string; mdContent?: string;
original?: boolean; original?: boolean;
url?: string; url?: string;
publishDateFormat?: string; publishDateFormat: string;
updateDateFormat?: string; updateDateFormat?: string;
category?: string; category?: string;
tags?: string[]; tags?: Tag[];
authorName?: string; author: User;
preArticleId?: number; preArticle?: Article;
nextArticleId?: number; nextArticle?: Article;
preArticleTitle?: string; readingNumber: number;
nextArticleTitle?: string; likeCount: number;
readingNumber?: number; dislikeCount: number;
open?: string; open?: string;
} }
@@ -24,7 +27,7 @@ export class ArticleReq {
id?: number; id?: number;
mdContent: string; mdContent: string;
open: boolean; open: boolean;
tags: string; tags: string[];
title: string; title: string;
type: boolean; type: boolean;
url?: string; url?: string;

View File

@@ -1,33 +1,26 @@
import {User} from './User';
export class Comment { export class Comment {
id?: number; id?: number;
authorName?: string; fromUser: User;
authorAvatarImgUrl?: string; toUser?: User;
content: string; content: string;
articleID: number; pagePath: string;
articleTitle: string;
date?: string; date?: string;
responseId: string;
pid: number; pid: number;
comment: boolean;
respComment: Comment[]; respComment: Comment[];
status: number;
} }
export class CommentReq { export class CommentReq {
id?: number; id?: number;
comment: boolean;
content: string; content: string;
pid: number; pid: number = -1;
articleID: number; toUserId: number;
responseId: string; pagePath: string;
constructor(comment: boolean) { constructor(pagePath: string) {
this.comment = comment; this.pagePath = pagePath;
this.responseId = '';
if (!comment) {
this.articleID = -1;
}
this.pid = -1;
this.id = null;
} }
} }

View File

@@ -15,7 +15,6 @@ export class Response<T> {
code: number; code: number;
msg: string; msg: string;
result: T; result: T;
date: number;
constructor(t: T) { constructor(t: T) {
this.code = 0; this.code = 0;
@@ -28,18 +27,4 @@ export class PageList<T> {
list: T[]; list: T[];
pageNum: number; pageNum: number;
pageSize: number; pageSize: number;
size: number;
startRow: number;
endRow: number;
pages: number;
prePage: number;
nextPage: number;
isFirstPage: boolean;
isLastPage: boolean;
hasPreviousPage: boolean;
hasNextPage: boolean;
navigatePages: number;
navigatepageNums: number[];
navigateFirstPage: number;
navigateLastPage: number;
} }

View File

@@ -3,4 +3,6 @@ export class Link {
name: string; name: string;
url: string; url: string;
open?: boolean; open?: boolean;
iconPath: string;
desc: string;
} }

View File

@@ -1,12 +1,14 @@
import {Article} from './Article';
export class Category { export class Category {
id: number; id: number;
name: string; name: string;
articles?: number[]; articles?: Article[];
} }
export class Tag { export class Tag {
id: number; id: number;
name: string; name: string;
articles?: number[]; articles?: Article[];
} }

View File

@@ -2,10 +2,10 @@ export class User {
id: number; id: number;
email: string; email: string;
displayName: string; displayName: string;
emailStatus: boolean; emailStatus?: boolean;
avatarImgUrl?: string; avatarImgUrl: string;
desc: string; desc: string;
role: string; role?: string;
token?: string; token?: string;
pwd?: string; pwd?: string;
recentlyLandedDate?: string recentlyLandedDate?: string

View File

@@ -1,14 +1,22 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="文章管理" nzSize="small"> <nz-card nzTitle="文章管理" nzSize="small" [nzExtra]="reload">
<nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="page" <nz-table #table [nzData]="pageList.list"
[nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'1100px'}" [nzTotal]="pageList.total"
(nzPageIndexChange)="getArticle()" nzFrontPagination="false"> [(nzPageIndex)]="page"
[nzPageSize]="pageSize"
[nzLoading]="loading"
[nzScroll]="{x:'1100px'}"
(nzPageIndexChange)="getArticle()"
nzFrontPagination="false"
nzTableLayout="fixed">
<thead> <thead>
<th>标题</th> <th>标题</th>
<th>发布日期</th> <th>发布日期</th>
<th>更新日期</th> <th>更新日期</th>
<th>文章类型</th> <th>文章类型</th>
<th>阅读量</th> <th>阅读量</th>
<th>👍赞</th>
<th>👎踩</th>
<th>是否可见</th> <th>是否可见</th>
<th>操作</th> <th>操作</th>
</thead> </thead>
@@ -25,6 +33,12 @@
<td> <td>
<nz-tag [nzColor]="'purple'">{{data.readingNumber}}</nz-tag> <nz-tag [nzColor]="'purple'">{{data.readingNumber}}</nz-tag>
</td> </td>
<td>
<nz-tag [nzColor]="'blue'">{{data.likeCount}}</nz-tag>
</td>
<td>
<nz-tag [nzColor]="'magenta'">{{data.dislikeCount}}</nz-tag>
</td>
<td><input type="checkbox" [checked]="data.open" disabled></td> <td><input type="checkbox" [checked]="data.open" disabled></td>
<td> <td>
<a routerLink="/write" [queryParams]="{id:data.id}" class="edit-opr">编辑</a> <a routerLink="/write" [queryParams]="{id:data.id}" class="edit-opr">编辑</a>
@@ -36,6 +50,10 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
<ng-template #reload>
<a (click)="getArticle()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>
</nz-table> </nz-table>
</nz-card> </nz-card>
</div> </div>

View File

@@ -4,7 +4,7 @@ import {RouterModule} from '@angular/router';
import {AdminArticleComponent} from './admin-article.component'; import {AdminArticleComponent} from './admin-article.component';
import { import {
NzCardModule, NzCardModule,
NzDividerModule, NzDividerModule, NzIconModule,
NzPopconfirmModule, NzPopconfirmModule,
NzTableModule, NzTagModule, NzTableModule, NzTagModule,
NzToolTipModule, NzToolTipModule,
@@ -25,6 +25,7 @@ import {
NzDividerModule, NzDividerModule,
NzPopconfirmModule, NzPopconfirmModule,
NzTagModule, NzTagModule,
NzIconModule,
] ]
}) })
export class AdminArticleModule { export class AdminArticleModule {

View File

@@ -1,20 +1,25 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="评论管理" nzSize="small"> <nz-card nzTitle="评论管理" nzSize="small" [nzExtra]="reload">
<nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex" <nz-table #table [nzData]="pageList.list"
[nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}" [nzTotal]="pageList.total"
(nzPageIndexChange)="getComment()" nzFrontPagination="false"> [(nzPageIndex)]="pageIndex"
[nzPageSize]="pageSize"
[nzLoading]="loading"
[nzScroll]="{x:'800px'}"
(nzPageIndexChange)="getComment()"
nzFrontPagination="false"
nzTableLayout="fixed">
<thead> <thead>
<th>文章标题</th> <th nzAlign="center">评论页面</th>
<th>评论内容</th> <th nzAlign="center">评论内容</th>
<th>评论</th> <th nzAlign="center">评论日期</th>
<th>评论日期</th> <th nzAlign="center">操作</th>
<th>操作</th>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of table.data"> <tr *ngFor="let data of table.data">
<td nz-typography nzEllipsis="true" [nzTooltipTitle]="data.articleTitle" nzTooltipPlacement="right" <td nzAlign="center"><a [href]="data.pagePath">{{data.pagePath}}</a></td>
nz-tooltip>{{data.articleTitle}}</td> <td nzAlign="center" nzEllipsis="true" [nzTooltipTitle]="data.content"
<td nz-typography nzEllipsis="true" [nzTooltipTitle]="data.content" nzTooltipPlacement="right" nzTooltipPlacement="right"
nz-tooltip style="min-width: 100px;max-width: 400px"> nz-tooltip style="min-width: 100px;max-width: 400px">
<span *ngIf="!editInfo.editFocus||data.id!==editInfo.id">{{data.content}}</span> <span *ngIf="!editInfo.editFocus||data.id!==editInfo.id">{{data.content}}</span>
<nz-input-group *ngIf="editInfo.editFocus&&data.id===editInfo.id" <nz-input-group *ngIf="editInfo.editFocus&&data.id===editInfo.id"
@@ -26,9 +31,8 @@
<button nz-button (click)="editInfo.editFocus=false" nzSize="small">取消</button> <button nz-button (click)="editInfo.editFocus=false" nzSize="small">取消</button>
</nz-input-group> </nz-input-group>
</td> </td>
<td>{{data.authorName}}</td> <td nzAlign="center">{{data.date}}</td>
<td>{{data.date}}</td> <td nzAlign="center">
<td>
<a (click)="editFocus(data)" class="edit-opr">编辑</a> <a (click)="editFocus(data)" class="edit-opr">编辑</a>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<a nz-popconfirm nzPopconfirmTitle="确定要删除这篇文章吗?" nzOkText="删除" nzCancelText="点错了" <a nz-popconfirm nzPopconfirmTitle="确定要删除这篇文章吗?" nzOkText="删除" nzCancelText="点错了"
@@ -40,3 +44,6 @@
</nz-card> </nz-card>
</div> </div>
<ng-template #tagIcon><i nz-icon nzType="message" nzTheme="outline"></i></ng-template> <ng-template #tagIcon><i nz-icon nzType="message" nzTheme="outline"></i></ng-template>
<ng-template #reload>
<a (click)="getComment()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>

View File

@@ -27,7 +27,9 @@ export class AdminCommentComponent implements OnInit {
} else { } else {
this.getComment = this.getCommentForUser; this.getComment = this.getCommentForUser;
} }
if (this.requested) return;
this.getComment() this.getComment()
this.requested = true
}, },
error: null, error: null,
complete: null complete: null
@@ -40,23 +42,25 @@ export class AdminCommentComponent implements OnInit {
pageList: PageList<Comment> = new PageList<Comment>(); pageList: PageList<Comment> = new PageList<Comment>();
editInfo = { editInfo = {
id: null, id: null,
content: new CommentReq(true), content: new CommentReq(null),
editFocus: false, editFocus: false,
} }
getComment: any;// 存放获取评论的方法 getComment: any;// 存放获取评论的方法
private requested: boolean = false;
ngOnInit(): void { ngOnInit(): void {
} }
getCommentForAdmin = () => this.apiService.getCommentByTypeForAdmin(true, this.pageIndex, this.pageSize).subscribe({ // TODO:: pagePath
getCommentForAdmin = () => this.apiService.getCommentByTypeForAdmin('*', this.pageIndex, this.pageSize).subscribe({
next: data => this.pageList = data.result, next: data => this.pageList = data.result,
complete: () => this.loading = false, complete: () => this.loading = false,
error: err => this.loading = false error: err => this.loading = false
}) })
getCommentForUser = () => this.apiService.getCommentByTypeForUser(true, this.pageIndex, this.pageSize).subscribe({ getCommentForUser = () => this.apiService.getCommentByTypeForUser('*', this.pageIndex, this.pageSize).subscribe({
next: data => this.pageList = data.result, next: data => this.pageList = data.result,
complete: () => this.loading = false, complete: () => this.loading = false,
error: err => this.loading = false error: err => this.loading = false
@@ -97,9 +101,9 @@ export class AdminCommentComponent implements OnInit {
this.editInfo.id = data.id; this.editInfo.id = data.id;
this.editInfo.content.content = data.content; this.editInfo.content.content = data.content;
this.editInfo.content.id = data.id; this.editInfo.content.id = data.id;
this.editInfo.content.articleID = data.articleID; // this.editInfo.content.articleID = data.articleID;
this.editInfo.content.pid = data.pid; this.editInfo.content.pid = data.pid;
this.editInfo.content.responseId = data.responseId; // this.editInfo.content.responseId = data.responseId;
this.editInfo.editFocus = true; this.editInfo.editFocus = true;
} }
} }

View File

@@ -23,10 +23,9 @@ export class AdminDashboardComponent implements OnInit {
articleCount: number, articleCount: number,
visitorCount: number, visitorCount: number,
categoryCount: number, categoryCount: number,
leaveMsgCount: number,
tagCount: number, tagCount: number,
commentCount: number commentCount: number
} = {articleCount: 0, visitorCount: 0, categoryCount: 0, tagCount: 0, commentCount: 0, leaveMsgCount: 0} } = {articleCount: 0, visitorCount: 0, categoryCount: 0, tagCount: 0, commentCount: 0}
dayVisitCount: number = 0; dayVisitCount: number = 0;
userInfo: User = new User(); userInfo: User = new User();

View File

@@ -1,5 +1,5 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="友链管理" nzSize="small"> <nz-card nzTitle="友链管理" nzSize="small" [nzExtra]="reload">
<button nz-button (click)="addLink()" style="margin-bottom: 15px">新增</button> <button nz-button (click)="addLink()" style="margin-bottom: 15px">新增</button>
<nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex" <nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex"
[nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'1200px'}" [nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'1200px'}"
@@ -29,6 +29,10 @@
</nz-card> </nz-card>
</div> </div>
<ng-template #reload>
<a (click)="getLinks()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>
<nz-modal [(nzVisible)]="modalVisible" [nzTitle]="modalTitle" (nzOnOk)="modalConfirm()" <nz-modal [(nzVisible)]="modalVisible" [nzTitle]="modalTitle" (nzOnOk)="modalConfirm()"
(nzOnCancel)="modalVisible = false" [nzClosable]="true" [nzOkDisabled]="!formGroup.valid"> (nzOnCancel)="modalVisible = false" [nzClosable]="true" [nzOkDisabled]="!formGroup.valid">
<form nz-form [formGroup]="formGroup"> <form nz-form [formGroup]="formGroup">

View File

@@ -6,7 +6,7 @@ import {
NzButtonModule, NzButtonModule,
NzCardModule, NzCardModule,
NzDividerModule, NzDividerModule,
NzFormModule, NzInputModule, NzFormModule, NzIconModule, NzInputModule,
NzModalModule, NzModalModule,
NzPopconfirmModule, NzSelectModule, NzPopconfirmModule, NzSelectModule,
NzTableModule NzTableModule
@@ -30,7 +30,8 @@ import {ReactiveFormsModule} from '@angular/forms';
ReactiveFormsModule, ReactiveFormsModule,
NzInputModule, NzInputModule,
NzSelectModule, NzSelectModule,
NzButtonModule NzButtonModule,
NzIconModule
] ]
}) })
export class AdminLinkModule { export class AdminLinkModule {

View File

@@ -1,7 +1,7 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="" nzSize="small"> <nz-card nzTitle="" nzSize="small">
<nz-tabset> <nz-tabset [nzTabBarExtraContent]="reload">
<nz-tab nzTitle="分类管理" (nzClick)="editInfo.editFocus=false"> <nz-tab nzTitle="分类管理" (nzClick)="tabChanged('tag')">
<div style="margin-bottom: 15px;"> <div style="margin-bottom: 15px;">
<nz-input-group *ngIf="editInfo.editFocus&&editInfo.isAdd" [nzPrefix]="tagIcon" <nz-input-group *ngIf="editInfo.editFocus&&editInfo.isAdd" [nzPrefix]="tagIcon"
style="width: 200px"> style="width: 200px">
@@ -49,7 +49,7 @@
</tbody> </tbody>
</nz-table> </nz-table>
</nz-tab> </nz-tab>
<nz-tab nzTitle="标签管理" (nzClick)="editInfo.editFocus=false"> <nz-tab nzTitle="标签管理" (nzClick)="tabChanged('category')">
<nz-table #tagTable [nzData]="tagPageList.list" [nzTotal]="tagPageList.total" <nz-table #tagTable [nzData]="tagPageList.list" [nzTotal]="tagPageList.total"
[(nzPageIndex)]="pageIndex" [nzScroll]="{x:'800px'}" [(nzPageIndex)]="pageIndex" [nzScroll]="{x:'800px'}"
[nzPageSize]="pageSize" (nzPageIndexChange)="getTag()" nzFrontPagination="false"> [nzPageSize]="pageSize" (nzPageIndexChange)="getTag()" nzFrontPagination="false">
@@ -90,3 +90,8 @@
</nz-card> </nz-card>
</div> </div>
<ng-template #tagIcon><i nz-icon nzType="tag" nzTheme="outline"></i></ng-template> <ng-template #tagIcon><i nz-icon nzType="tag" nzTheme="outline"></i></ng-template>
<ng-template #reload>
<a (click)="getData()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>

View File

@@ -29,15 +29,17 @@ export class AdminTagComponent implements OnInit {
pageIndex: number = 1; pageIndex: number = 1;
pageSize: number = 10; pageSize: number = 10;
getData: any;
ngOnInit(): void { ngOnInit(): void {
this.title.setTitle('小海博客 | 标签分类管理') this.title.setTitle('小海博客 | 标签分类管理')
this.getCategory(); this.getCategory();
this.getTag(); this.getTag();
this.getData = this.getTag;
} }
getCategory = () => this.apiService.categories().subscribe({ getCategory = () => this.apiService.categories().subscribe({
next: data => this.categoryList = data.result, next: data => this.categoryList = data.result.list,
complete: () => this.loading = false, complete: () => this.loading = false,
error: err => this.loading = false error: err => this.loading = false
}) })
@@ -138,4 +140,12 @@ export class AdminTagComponent implements OnInit {
this.editInfo.isAdd = false this.editInfo.isAdd = false
this.editInfo.name = null this.editInfo.name = null
} }
tabChanged(mode: 'tag' | 'category') {
this.editInfo.editFocus = false
if (mode === 'tag')
this.getData = this.getTag;
else
this.getData = this.getCategory;
}
} }

View File

@@ -1,5 +1,5 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="更新内容管理" nzSize="small"> <nz-card nzTitle="更新内容管理" nzSize="small" [nzExtra]="reload">
<button nz-button (click)="showModal()" style="margin-bottom: 15px;">新增</button> <button nz-button (click)="showModal()" style="margin-bottom: 15px;">新增</button>
<nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex" <nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex"
[nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}" [nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}"
@@ -30,3 +30,6 @@
(nzOnOk)="confirm()" [nzTitle]="modalData.title"> (nzOnOk)="confirm()" [nzTitle]="modalData.title">
<textarea nz-input [(ngModel)]="modalData.content" [nzAutosize]="{ minRows: 2, maxRows: 8 }"></textarea> <textarea nz-input [(ngModel)]="modalData.content" [nzAutosize]="{ minRows: 2, maxRows: 8 }"></textarea>
</nz-modal> </nz-modal>
<ng-template #reload>
<a (click)="getUpdateInfo()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>

View File

@@ -5,7 +5,7 @@ import {AdminUpdateComponent} from './admin-update.component';
import { import {
NzButtonModule, NzButtonModule,
NzCardModule, NzCardModule,
NzDividerModule, NzInputModule, NzModalModule, NzDividerModule, NzIconModule, NzInputModule, NzModalModule,
NzPopconfirmModule, NzPopconfirmModule,
NzTableModule, NzTableModule,
NzToolTipModule, NzToolTipModule,
@@ -30,7 +30,8 @@ import {FormsModule} from '@angular/forms';
NzModalModule, NzModalModule,
FormsModule, FormsModule,
NzButtonModule, NzButtonModule,
NzInputModule NzInputModule,
NzIconModule
] ]
}) })
export class AdminUpdateModule { export class AdminUpdateModule {

View File

@@ -1,5 +1,5 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="用户管理" nzSize="small"> <nz-card nzTitle="用户管理" nzSize="small" [nzExtra]="reload">
<nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex" <nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex"
[nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}" [nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}"
(nzPageIndexChange)="getUser()" nzFrontPagination="false"> (nzPageIndexChange)="getUser()" nzFrontPagination="false">
@@ -115,3 +115,8 @@
</ng-template> </ng-template>
</nz-modal> </nz-modal>
<ng-template #reload>
<a (click)="getUser()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>

View File

@@ -1,5 +1,5 @@
<div class="inner-content"> <div class="inner-content">
<nz-card nzTitle="访客信息管理" nzSize="small"> <nz-card nzTitle="访客信息管理" nzSize="small" [nzExtra]="reload">
<nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex" <nz-table #table [nzData]="pageList.list" [nzTotal]="pageList.total" [(nzPageIndex)]="pageIndex"
[nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}" [nzPageSize]="pageSize" [nzLoading]="loading" [nzScroll]="{x:'800px'}"
(nzPageIndexChange)="getVisitors()" nzFrontPagination="false"> (nzPageIndexChange)="getVisitors()" nzFrontPagination="false">
@@ -22,3 +22,6 @@
</nz-table> </nz-table>
</nz-card> </nz-card>
</div> </div>
<ng-template #reload>
<a (click)="getVisitors()" title="刷新"><i nz-icon nzType="reload" nzTheme="outline"></i></a>
</ng-template>

View File

@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {AdminVisitorComponent} from './admin-visitor.component'; import {AdminVisitorComponent} from './admin-visitor.component';
import {NzButtonModule, NzCardModule, NzDividerModule, NzTableModule} from 'ng-zorro-antd'; import {NzButtonModule, NzCardModule, NzDividerModule, NzIconModule, NzTableModule} from 'ng-zorro-antd';
@NgModule({ @NgModule({
@@ -15,7 +15,8 @@ import {NzButtonModule, NzCardModule, NzDividerModule, NzTableModule} from 'ng-z
NzCardModule, NzCardModule,
NzTableModule, NzTableModule,
NzButtonModule, NzButtonModule,
NzDividerModule NzDividerModule,
NzIconModule
] ]
}) })
export class AdminVisitorModule { export class AdminVisitorModule {

View File

@@ -24,7 +24,6 @@ export class AdminComponent implements OnInit {
next: data => { next: data => {
console.log('更新user') console.log('更新user')
this.user = data.result this.user = data.result
this.user.avatarImgUrl += '?t=' + Date.now();
if (data.result) this.initHelloWords() if (data.result) this.initHelloWords()
} }
} }

View File

@@ -6,7 +6,7 @@
<!-- 文章版权 --> <!-- 文章版权 -->
<div id="copyright"> <div id="copyright">
<p>本文作者:{{article.authorName}} </p> <p>本文作者:{{article.author.displayName}} </p>
<p>{{article.original ? "本文" : "原文"}}链接:{{article.original ? copyRightUrl : article.url}}</p> <p>{{article.original ? "本文" : "原文"}}链接:{{article.original ? copyRightUrl : article.url}}</p>
<p>版权声明:转载请注明出处</p> <p>版权声明:转载请注明出处</p>
</div> </div>
@@ -16,17 +16,19 @@
<!-- TODO --> <!-- TODO -->
<span *ngFor="let item of (article.tags||'')" class="tag"> <span *ngFor="let item of (article.tags||'')" class="tag">
<i nz-icon nzType="tag" nzTheme="fill"></i> <i nz-icon nzType="tag" nzTheme="fill"></i>
<a class="tag" [routerLink]="['/tags']" [queryParams]="{name:item}">{{item}}</a> <a class="tag" [routerLink]="['/tags/'+item.name]">{{item.name}}</a>
</span> </span>
</div> </div>
<div class="article-bAnda"> <div class="article-bAnda">
<a (click)="toArticle(article.nextArticleId)" [class.disabled]="article.nextArticleId==-1"> <a (click)="toArticle(article.nextArticle.id)" [class.disabled]="!article.nextArticle">
<i nz-icon nzType="left" nzTheme="outline"></i> {{article.nextArticleTitle}} <i nz-icon nzType="left" nzTheme="outline"></i>
{{(article.nextArticle && article.nextArticle.title) || '无'}}
</a> </a>
<a (click)="toArticle(article.preArticleId)" [class.disabled]="article.preArticleId==-1" <a (click)="toArticle(article.preArticle.id)" [class.disabled]="!article.preArticle"
style="float: right" id="pre"> style="float: right" id="pre">
{{article.preArticleTitle}} <i nz-icon nzType="right" nzTheme="outline"></i> {{(article.preArticle && article.preArticle.title) || '无'}}
<i nz-icon nzType="right" nzTheme="outline"></i>
</a> </a>
</div> </div>
@@ -58,19 +60,30 @@
<nz-list [nzLoading]="!commentPage"> <nz-list [nzLoading]="!commentPage">
<nz-list-item *ngFor="let comment of commentPage.list"> <nz-list-item *ngFor="let comment of commentPage.list">
<nz-comment [nzAuthor]="comment.authorName" [nzDatetime]="comment.date" style="width: 100%"> <nz-comment [nzAuthor]="comment.fromUser.displayName" [nzDatetime]="comment.date" style="width: 100%">
<nz-avatar nz-comment-avatar nzIcon="user" [nzSrc]="comment.authorAvatarImgUrl"></nz-avatar> <nz-avatar nz-comment-avatar nzIcon="user" [nzSrc]="comment.fromUser.avatarImgUrl"
*ngIf="comment.fromUser.avatarImgUrl">
</nz-avatar>
<nz-avatar nz-comment-avatar nzIcon="user" [nzText]="comment.fromUser.displayName"
*ngIf="!comment.fromUser.avatarImgUrl">
</nz-avatar>
<nz-comment-content> <nz-comment-content>
<p style="font-size: larger">{{ comment.content }}</p> <p style="font-size: larger">{{ comment.content }}</p>
</nz-comment-content> </nz-comment-content>
<nz-comment-action> <nz-comment-action>
<i nz-icon nzType="message" nzTheme="outline"></i> <i nz-icon nzType="message" nzTheme="outline"></i>
<button nz-button nzType="link" (click)="resp(comment.id,comment.authorName)">回复</button> <button nz-button nzType="link" (click)="resp(comment.id,comment.fromUser.displayName)">回复
</button>
</nz-comment-action> </nz-comment-action>
<nz-list-item *ngFor="let com of comment.respComment"> <nz-list-item *ngFor="let com of comment.respComment">
<nz-comment [nzAuthor]="com.authorName" [nzDatetime]="com.date"> <nz-comment [nzAuthor]="com.fromUser.displayName" [nzDatetime]="com.date">
<nz-avatar nz-comment-avatar nzIcon="user" [nzSrc]="com.authorAvatarImgUrl"></nz-avatar> <nz-avatar nz-comment-avatar nzIcon="user" [nzSrc]="com.fromUser.avatarImgUrl"
*ngIf="com.fromUser.avatarImgUrl">
</nz-avatar>
<nz-avatar nz-comment-avatar nzIcon="user" [nzText]="com.fromUser.displayName"
*ngIf="!com.fromUser.avatarImgUrl">
</nz-avatar>
<nz-comment-content> <nz-comment-content>
<p style="font-size: larger">{{ com.content }}</p> <p style="font-size: larger">{{ com.content }}</p>
</nz-comment-content> </nz-comment-content>

View File

@@ -51,7 +51,7 @@ export class ArticleComponent implements OnInit {
if (data.result) this.avatarImgUrl = data.result.avatarImgUrl; if (data.result) this.avatarImgUrl = data.result.avatarImgUrl;
} }
}); });
this.comment = new CommentReq(true); this.comment = new CommentReq(`article/${this.articleId}`);
} }
parseMd(md: string) { parseMd(md: string) {
@@ -73,7 +73,7 @@ export class ArticleComponent implements OnInit {
this.router.navigateByUrl('/article/' + id); this.router.navigateByUrl('/article/' + id);
this.apiService.getArticle(id).subscribe({ this.apiService.getArticle(id).subscribe({
next: data => { next: data => {
this.apiService.comments(id).subscribe(commData => { this.apiService.comments(`article+${id}`).subscribe(commData => {
this.commentPage = commData.result; this.commentPage = commData.result;
}); });
document.getElementById('article-content').innerHTML = ''; document.getElementById('article-content').innerHTML = '';
@@ -89,7 +89,6 @@ export class ArticleComponent implements OnInit {
// true ==> 一级评论 false ==>二级评论 // true ==> 一级评论 false ==>二级评论
submitComment(bool: boolean) { submitComment(bool: boolean) {
this.submitting = true; this.submitting = true;
this.comment.articleID = this.articleId;
if (!bool) { if (!bool) {
this.comment.content = this.content; this.comment.content = this.content;
this.comment.pid = this.pid; this.comment.pid = this.pid;

View File

@@ -38,8 +38,8 @@ export class CategoryComponent implements OnInit {
getCategories(needGetArticle: boolean) { getCategories(needGetArticle: boolean) {
this.apiService.categories().subscribe(data => { this.apiService.categories().subscribe(data => {
this.categoryList = data.result; this.categoryList = data.result.list;
this.category = data.result[0]; this.category = this.categoryList[0];
if (needGetArticle) { if (needGetArticle) {
this.getArticles(this.category.name); this.getArticles(this.category.name);
this.name = this.category.name; this.name = this.category.name;

View File

@@ -10,7 +10,7 @@
</span> </span>
<span *ngIf="showMediaArea" class="badge"> <span *ngIf="showMediaArea" class="badge">
<i nz-icon nzType="user" nzTheme="outline"></i> <i nz-icon nzType="user" nzTheme="outline"></i>
<span>{{data.authorName}}</span> <span>{{data.author.displayName}}</span>
</span> </span>
<span *ngIf="showMediaArea" class="badge"> <span *ngIf="showMediaArea" class="badge">
<i nz-icon nzType="file" nzTheme="outline"></i> <i nz-icon nzType="file" nzTheme="outline"></i>
@@ -28,7 +28,7 @@
<div> <div>
<span *ngFor="let tag of data.tags"> <span *ngFor="let tag of data.tags">
<i nz-icon nzType="tag" nzTheme="outline"></i> <i nz-icon nzType="tag" nzTheme="outline"></i>
<a [routerLink]="'/tags/'+tag">{{tag}}</a> <a [routerLink]="'/tags/'+tag.name">{{tag.name}}</a>
</span> </span>
</div> </div>
</ng-template> </ng-template>

View File

@@ -22,7 +22,7 @@ export class ArticleDetailCardComponent implements OnInit {
} }
if (this.showMediaArea == null) { if (this.showMediaArea == null) {
// 如果作者名不为空 则显示 // 如果作者名不为空 则显示
this.showMediaArea = this.data.authorName != null; this.showMediaArea = this.data.author.displayName != null;
} }
if (this.showTagArea == null) { if (this.showTagArea == null) {
this.showTagArea = this.data.tags != null; this.showTagArea = this.data.tags != null;

View File

@@ -7,7 +7,7 @@ import {PageList} from '../../class/HttpReqAndResp';
import {ErrDispatch} from '../../class/ErrDispatch'; import {ErrDispatch} from '../../class/ErrDispatch';
import {RequestObj} from '../../class/HttpReqAndResp'; import {RequestObj} from '../../class/HttpReqAndResp';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {Tag} from '../../class/Tag'; import {Category, Tag} from '../../class/Tag';
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
@Component({ @Component({
@@ -36,12 +36,11 @@ export class IndexComponent implements OnInit, ErrDispatch {
desc: string; desc: string;
articles: PageList<Article>; articles: PageList<Article>;
tagNameAndNumber: { name: string, size: number }[]; tagNameAndNumber: { name: string, size: number }[];
categoryList: Tag[]; categoryList: Category[];
counts: { counts: {
articleCount: number, articleCount: number,
visitorCount: number, visitorCount: number,
categoryCount: number, categoryCount: number,
leaveMsgCount: number,
tagCount: number, tagCount: number,
commentCount: number commentCount: number
}; };
@@ -75,7 +74,7 @@ export class IndexComponent implements OnInit, ErrDispatch {
} }
}); });
this.apiService.categories().subscribe({ this.apiService.categories().subscribe({
next: data => this.categoryList = data.result, next: data => this.categoryList = data.result.list,
error: err => { error: err => {
} }
}); });

View File

@@ -29,7 +29,7 @@ export class UpdateComponent implements OnInit {
this.lastUpdate = data.result; this.lastUpdate = data.result;
}); });
this.apiService.webUpdate().subscribe(data => { this.apiService.webUpdate().subscribe(data => {
this.webUpdate = data.result.reverse(); this.webUpdate = data.result;
}); });
} }

View File

@@ -1,6 +1,6 @@
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {Tag} from '../../../../class/Tag'; import {Category, Tag} from '../../../../class/Tag';
@Component({ @Component({
selector: 'c-publish-form', selector: 'c-publish-form',
@@ -15,9 +15,9 @@ export class PublishFormComponent implements OnInit {
@ViewChild('inputElement', {static: false}) tagInputElement: ElementRef; @ViewChild('inputElement', {static: false}) tagInputElement: ElementRef;
@Input() tagNacList: { name: string, size: number }[]; @Input() tagNacList: { name: string, size: number }[];
@Input() categoryList: Tag[]; @Input() categoryList: Category[];
@Input() primaryData: { id: number, type: boolean, tags: string, category: string, url?: string }; @Input() primaryData: { id: number, type: boolean, tags: string[], category: string, url?: string };
@Output() submitEvent = new EventEmitter<{ id: number, type: boolean, tags: string, category: string, url?: string }>(); @Output() submitEvent = new EventEmitter<{ id: number, type: boolean, tags: string[], category: string, url?: string }>();
formGroup: FormGroup; formGroup: FormGroup;
tagTmpList: string[] = []; tagTmpList: string[] = [];
@@ -36,8 +36,8 @@ export class PublishFormComponent implements OnInit {
if (this.primaryData) { if (this.primaryData) {
this.formGroup.get('type').setValue(this.primaryData.type); this.formGroup.get('type').setValue(this.primaryData.type);
const tags = this.primaryData.tags; const tags = this.primaryData.tags;
this.formGroup.get('tagList').setValue(tags ? this.primaryData.tags.split(',') : tags); this.formGroup.get('tagList').setValue(tags);
this.tagTmpList = tags ? this.primaryData.tags.split(',') : [...tags]; this.tagTmpList = tags;
this.formGroup.get('category').setValue(this.primaryData.category); this.formGroup.get('category').setValue(this.primaryData.category);
this.formGroup.get('url').setValue(this.primaryData.url); this.formGroup.get('url').setValue(this.primaryData.url);
} }
@@ -47,7 +47,7 @@ export class PublishFormComponent implements OnInit {
const formData = { const formData = {
id: this.formGroup.value.isUpdate ? this.primaryData.id : null, id: this.formGroup.value.isUpdate ? this.primaryData.id : null,
type: this.formGroup.value.type, type: this.formGroup.value.type,
tags: this.formGroup.value.tagList.toString(), tags: this.formGroup.value.tagList,
category: this.formGroup.value.category, category: this.formGroup.value.category,
url: this.formGroup.value.type ? null : this.formGroup.value.url url: this.formGroup.value.type ? null : this.formGroup.value.url
}; };

View File

@@ -81,7 +81,7 @@ export class WriteComponent implements OnInit {
}); });
this.apiService.categories().subscribe({ this.apiService.categories().subscribe({
next: data => { next: data => {
this.categoryList = data.result; this.categoryList = data.result.list;
}, },
error: err => { error: err => {
this.message.error('获取分类信息失败'); this.message.error('获取分类信息失败');
@@ -109,17 +109,19 @@ export class WriteComponent implements OnInit {
/** /**
* 文章数据提交 * 文章数据提交
*/ */
publishArticle(e: { id: number, type: boolean, tags: string, category: string, url?: string }) { publishArticle(e: { id: number, type: boolean, tags: string[], category: string, url?: string }) {
this.article.type = e.type; this.article.type = e.type;
this.article.tags = e.tags; this.article.tags = e.tags;
this.article.category = e.category; this.article.category = e.category;
this.article.url = e.url; this.article.url = e.url;
this.article.id = e.id; this.article.id = e.id;
if (!this.article.id && this.title === this.article.title) { this.modalVisible = false;
this.message.error('文章标题未经更改,请修改后再发布');
return; // if (!this.article.id && this.title === this.article.title) {
} // this.message.error('文章标题未经更改,请修改后再发布');
// return;
// }
// 文章 暂存 // 文章 暂存
localStorage.setItem('tmpArticle', JSON.stringify(this.article)); localStorage.setItem('tmpArticle', JSON.stringify(this.article));
@@ -182,7 +184,9 @@ export class WriteComponent implements OnInit {
next: data => { next: data => {
this.article.category = data.result.category; this.article.category = data.result.category;
this.article.mdContent = data.result.mdContent; this.article.mdContent = data.result.mdContent;
this.article.tags = String(data.result.tags); const tags = []
data.result.tags.forEach(t => tags.push(t.name))
this.article.tags = tags;
this.article.type = data.result.original; this.article.type = data.result.original;
this.article.url = data.result.url; this.article.url = data.result.url;
this.article.title = data.result.title; this.article.title = data.result.title;