调整class文件,合并部分class到一个文件中
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable, Observer, of} from 'rxjs';
|
||||
|
||||
import {Article} from '../class/Article';
|
||||
import {HttpService} from './http/http.service';
|
||||
import {PageList} from '../class/pageList';
|
||||
import {PageList} from '../class/HttpReqAndResp';
|
||||
import {ErrDispatch} from '../class/ErrDispatch';
|
||||
import {ArticleReq} from '../class/ArticleReq';
|
||||
import {Category} from '../class/Category';
|
||||
import {ArticleReq} from '../class/Article';
|
||||
import {Tag} from '../class/Tag';
|
||||
import {Comment} from '../class/Comment';
|
||||
import {CommentReq} from '../class/CommentReq';
|
||||
import {CommentReq} from '../class/Comment';
|
||||
import {Link} from '../class/Link';
|
||||
import {User} from '../class/User';
|
||||
import {LoginReq} from '../class/LoginReq';
|
||||
import {Observable, Observer, of} from 'rxjs';
|
||||
import {Response} from '../class/Response';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {LocalStorageService} from '../utils/local-storage.service';
|
||||
import {LoginReq} from '../class/User';
|
||||
import {Response} from '../class/HttpReqAndResp';
|
||||
|
||||
import {LocalStorageService} from '../services/local-storage.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -90,14 +92,14 @@ export class ApiService extends HttpService {
|
||||
}
|
||||
|
||||
categories() {
|
||||
return super.Service<Category[]>({
|
||||
return super.Service<Tag[]>({
|
||||
path: '/categories',
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
tags(pageNumber: number = 1, pageSize: number = 10) {
|
||||
return super.Service<Category[]>({
|
||||
return super.Service<Tag[]>({
|
||||
path: '/tags',
|
||||
method: 'GET',
|
||||
queryParam: {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {RequestObj} from '../../class/Request';
|
||||
import {RequestObj} from '../../class/HttpReqAndResp';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {LocalStorageService} from '../../utils/local-storage.service';
|
||||
import {Response} from '../../class/Response';
|
||||
import {LocalStorageService} from '../../services/local-storage.service';
|
||||
import {Response} from '../../class/HttpReqAndResp';
|
||||
import {Observable, Observer, Subject} from 'rxjs';
|
||||
import {ErrDispatch} from '../../class/ErrDispatch';
|
||||
import {multicast} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component, ElementRef, OnInit, TemplateRef, ViewChild} from '@angular/core';
|
||||
import {LoginReq} from './class/LoginReq';
|
||||
import {LoginReq} from './class/User';
|
||||
import {HeaderComponent} from './components/header/header.component';
|
||||
|
||||
@Component({
|
||||
@@ -14,14 +14,14 @@ export class AppComponent {
|
||||
|
||||
registration() {
|
||||
// todo :: 登录
|
||||
console.log('registration');
|
||||
// console.log('registration');
|
||||
this.regModal = true;
|
||||
|
||||
}
|
||||
|
||||
login() {
|
||||
// TODO :: 注册
|
||||
console.log('login');
|
||||
// console.log('login');
|
||||
this.loginModal = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,3 +17,19 @@ export class Article {
|
||||
readingNumber?: number;
|
||||
open?: string;
|
||||
}
|
||||
|
||||
|
||||
export class ArticleReq {
|
||||
category: string;
|
||||
id?: number;
|
||||
mdContent: string;
|
||||
open: boolean;
|
||||
tags: string;
|
||||
title: string;
|
||||
type: boolean;
|
||||
url?: string;
|
||||
|
||||
constructor() {
|
||||
this.type = true;
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,23 @@ export class Comment {
|
||||
comment: boolean;
|
||||
respComment: Comment[];
|
||||
}
|
||||
|
||||
|
||||
export class CommentReq {
|
||||
id?: number;
|
||||
comment: boolean;
|
||||
content: string;
|
||||
pid: number;
|
||||
articleID: number;
|
||||
responseId: string;
|
||||
|
||||
constructor(comment: boolean) {
|
||||
this.comment = comment;
|
||||
this.responseId = '';
|
||||
if (!comment) {
|
||||
this.articleID = -1;
|
||||
}
|
||||
this.pid = -1;
|
||||
this.id = null;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {RequestObj} from './Request';
|
||||
import {RequestObj} from './HttpReqAndResp';
|
||||
|
||||
export interface ErrDispatch {
|
||||
errHandler(code: number, msg: string, request?: RequestObj): void;
|
||||
|
||||
45
index/src/app/class/HttpReqAndResp.ts
Normal file
45
index/src/app/class/HttpReqAndResp.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {HttpHeaders} from '@angular/common/http';
|
||||
|
||||
export class RequestObj {
|
||||
path: string;
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
data?: {};
|
||||
contentType?: 'application/json' | 'application/x-www-form-urlencoded';
|
||||
queryParam?: {};
|
||||
header?: HttpHeaders | {
|
||||
[header: string]: string | string[];
|
||||
};
|
||||
}
|
||||
|
||||
export class Response<T> {
|
||||
code: number;
|
||||
msg: string;
|
||||
result: T;
|
||||
date: number;
|
||||
|
||||
constructor(t: T) {
|
||||
this.code = 0;
|
||||
this.result = t;
|
||||
}
|
||||
}
|
||||
|
||||
export class PageList<T> {
|
||||
total: number;
|
||||
list: T[];
|
||||
pageNum: 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;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import {HttpHeaders} from '@angular/common/http';
|
||||
|
||||
export class RequestObj {
|
||||
path: string;
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
data?: {};
|
||||
contentType?: 'application/json' | 'application/x-www-form-urlencoded';
|
||||
queryParam?: {};
|
||||
header?: HttpHeaders | {
|
||||
[header: string]: string | string[];
|
||||
};
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
export class Response<T> {
|
||||
code: number;
|
||||
msg: string;
|
||||
result: T;
|
||||
date: number;
|
||||
|
||||
constructor(t: T) {
|
||||
this.code = 0;
|
||||
this.result = t;
|
||||
}
|
||||
}
|
||||
@@ -3,3 +3,10 @@ export class Category {
|
||||
name: string;
|
||||
articles?: number[];
|
||||
}
|
||||
|
||||
|
||||
export class Tag {
|
||||
id: number;
|
||||
name: string;
|
||||
articles?: number[];
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
export class User {
|
||||
id: number;
|
||||
email: string;
|
||||
displayName: string;
|
||||
emailStatus: boolean;
|
||||
avatarImgUrl: string;
|
||||
desc: string;
|
||||
role: string;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export class LoginReq {
|
||||
email: string;
|
||||
isRememberMe: boolean;
|
||||
@@ -1,14 +0,0 @@
|
||||
export class ArticleReq {
|
||||
category: string;
|
||||
id?: number;
|
||||
mdContent: string;
|
||||
open: boolean;
|
||||
tags: string;
|
||||
title: string;
|
||||
type: boolean;
|
||||
url?: string;
|
||||
|
||||
constructor() {
|
||||
this.type = true;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
export class CommentReq {
|
||||
id?: number;
|
||||
comment: boolean;
|
||||
content: string;
|
||||
pid: number;
|
||||
articleID: number;
|
||||
responseId: string;
|
||||
|
||||
constructor(comment: boolean) {
|
||||
this.comment = comment;
|
||||
this.responseId = '';
|
||||
if (!comment) {
|
||||
this.articleID = -1;
|
||||
}
|
||||
this.pid = -1;
|
||||
this.id = null;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
export class PageList<T> {
|
||||
total: number;
|
||||
list: T[];
|
||||
pageNum: 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;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export class Tag {
|
||||
id: number;
|
||||
name: string;
|
||||
articles?: number[];
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
export class User {
|
||||
id: number;
|
||||
email: string;
|
||||
displayName: string;
|
||||
emailStatus: boolean;
|
||||
avatarImgUrl: string;
|
||||
desc: string;
|
||||
role: string;
|
||||
token?: string;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import {NavigationEnd, Router, RouterEvent} from '@angular/router';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {ApiService} from '../../api/api.service';
|
||||
import {User} from '../../class/User';
|
||||
import {LocalStorageService} from '../../utils/local-storage.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
|
||||
@@ -4,8 +4,8 @@ import {ApiService} from '../../api/api.service';
|
||||
import {Article} from '../../class/Article';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {User} from '../../class/User';
|
||||
import {CommentReq} from '../../class/CommentReq';
|
||||
import {PageList} from '../../class/pageList';
|
||||
import {CommentReq} from '../../class/Comment';
|
||||
import {PageList} from '../../class/HttpReqAndResp';
|
||||
import {Comment} from '../../class/Comment';
|
||||
|
||||
declare var editormd;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ApiService} from '../../api/api.service';
|
||||
import {Category} from '../../class/Category';
|
||||
import {Tag} from '../../class/Tag';
|
||||
import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {PageList} from '../../class/pageList';
|
||||
import {PageList} from '../../class/HttpReqAndResp';
|
||||
import {Article} from '../../class/Article';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
@@ -22,8 +22,8 @@ export class CategoryComponent implements OnInit {
|
||||
private title: Title) {
|
||||
}
|
||||
|
||||
categoryList: Category[] = [];
|
||||
private category: Category;
|
||||
categoryList: Tag[] = [];
|
||||
private category: Tag;
|
||||
articleList: PageList<Article>;
|
||||
|
||||
name: string;
|
||||
@@ -58,7 +58,7 @@ export class CategoryComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
changeCategory(category: Category) {
|
||||
changeCategory(category: Tag) {
|
||||
if (this.name === category.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ import {ApiService} from '../../api/api.service';
|
||||
import {Article} from '../../class/Article';
|
||||
import {NzIconService, NzMessageService} from 'ng-zorro-antd';
|
||||
import {SvgIconUtil} from '../../utils/svgIconUtil';
|
||||
import {PageList} from '../../class/pageList';
|
||||
import {PageList} from '../../class/HttpReqAndResp';
|
||||
import {ErrDispatch} from '../../class/ErrDispatch';
|
||||
import {RequestObj} from '../../class/Request';
|
||||
import {RequestObj} from '../../class/HttpReqAndResp';
|
||||
import {Router} from '@angular/router';
|
||||
import {Category} from '../../class/Category';
|
||||
import {Tag} from '../../class/Tag';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
@@ -36,7 +36,7 @@ export class IndexComponent implements OnInit, ErrDispatch {
|
||||
desc: string;
|
||||
articles: PageList<Article>;
|
||||
tagNameAndNumber: { name: string, size: number }[];
|
||||
categoryList: Category[];
|
||||
categoryList: Tag[];
|
||||
counts: {
|
||||
articleCount: number,
|
||||
visitorCount: number,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {ApiService} from '../../../../api/api.service';
|
||||
import {LoginReq} from '../../../../class/LoginReq';
|
||||
import {LocalStorageService} from '../../../../utils/local-storage.service';
|
||||
import {LoginReq} from '../../../../class/User';
|
||||
import {LocalStorageService} from '../../../../services/local-storage.service';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {LoginRegistrationService} from '../../service/login-registration.service';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
|
||||
@@ -4,8 +4,8 @@ import {ApiService} from '../../../../api/api.service';
|
||||
import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {Router} from '@angular/router';
|
||||
import {ErrDispatch} from '../../../../class/ErrDispatch';
|
||||
import {RequestObj} from '../../../../class/Request';
|
||||
import {LoginReq} from '../../../../class/LoginReq';
|
||||
import {RequestObj} from '../../../../class/HttpReqAndResp';
|
||||
import {LoginReq} from '../../../../class/User';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Category} from '../../class/Category';
|
||||
import {PageList} from '../../class/pageList';
|
||||
import {PageList} from '../../class/HttpReqAndResp';
|
||||
import {Article} from '../../class/Article';
|
||||
import {Tag} from '../../class/Tag';
|
||||
import {ApiService} from '../../api/api.service';
|
||||
import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {Location} from '@angular/common';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
import {ApiService} from '../../../../api/api.service';
|
||||
import {Category} from '../../../../class/Category';
|
||||
import {Tag} from '../../../../class/Tag';
|
||||
|
||||
@Component({
|
||||
selector: 'c-publish-form',
|
||||
@@ -16,7 +15,7 @@ export class PublishFormComponent implements OnInit {
|
||||
@ViewChild('inputElement', {static: false}) tagInputElement: ElementRef;
|
||||
|
||||
@Input() tagNacList: { name: string, size: number }[];
|
||||
@Input() categoryList: Category[];
|
||||
@Input() categoryList: Tag[];
|
||||
@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 }>();
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import {ArticleReq} from '../../class/ArticleReq';
|
||||
import {ArticleReq} from '../../class/Article';
|
||||
import {EditorConfig} from '../../class/EditorConfig';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ApiService} from '../../api/api.service';
|
||||
import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {User} from '../../class/User';
|
||||
import {Category} from '../../class/Category';
|
||||
import {Tag} from '../../class/Tag';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
@@ -31,7 +31,7 @@ export class WriteComponent implements OnInit {
|
||||
public article: ArticleReq = new ArticleReq();
|
||||
|
||||
userInfo: User;
|
||||
categoryList: Category[];
|
||||
categoryList: Tag[];
|
||||
tagNacList: { name: string, size: number }[];
|
||||
primaryData = {};
|
||||
// 发布新文章时,文章相同会被拦回 此处判断一下
|
||||
|
||||
Reference in New Issue
Block a user