合并为一个项目 #14

Merged
xiaohai2271 merged 56 commits from issue11 into master 2020-05-16 22:35:08 +08:00
5 changed files with 286 additions and 7 deletions
Showing only changes of commit c40837b1b2 - Show all commits

View File

@@ -6,7 +6,7 @@ import {HttpService} from './http/http.service';
import {PageList} from '../class/HttpReqAndResp'; import {PageList} from '../class/HttpReqAndResp';
import {ErrDispatch} from '../class/ErrDispatch'; import {ErrDispatch} from '../class/ErrDispatch';
import {ArticleReq} from '../class/Article'; import {ArticleReq} from '../class/Article';
import {Tag} from '../class/Tag'; import {Category, Tag} from '../class/Tag';
import {Comment} from '../class/Comment'; import {Comment} from '../class/Comment';
import {CommentReq} from '../class/Comment'; import {CommentReq} from '../class/Comment';
import {Link} from '../class/Link'; import {Link} from '../class/Link';
@@ -14,6 +14,8 @@ import {User} from '../class/User';
import {LoginReq} from '../class/User'; import {LoginReq} from '../class/User';
import {LocalStorageService} from '../services/local-storage.service'; import {LocalStorageService} from '../services/local-storage.service';
import {Visitor} from '../class/Visitor';
import {UpdateInfo} from '../class/UpdateInfo';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -39,6 +41,14 @@ export class ApiService extends HttpService {
}); });
} }
deleteArticle(id: number) {
return super.Service<boolean>({
path: '/admin/article/del',
method: 'DELETE',
queryParam: {articleID: id}
})
}
articles(pageNumber: number = 1, pageSize: number = 5) { articles(pageNumber: number = 1, pageSize: number = 5) {
return super.Service<PageList<Article>>({ return super.Service<PageList<Article>>({
path: '/articles', path: '/articles',
@@ -50,6 +60,17 @@ export class ApiService extends HttpService {
}); });
} }
adminArticles(pageNumber: number = 1, pageSize: number = 10) {
return super.Service<PageList<Article>>({
path: '/admin/articles',
method: 'GET',
queryParam: {
page: pageNumber,
count: pageSize
}
});
}
updateArticle(article: ArticleReq) { updateArticle(article: ArticleReq) {
return super.Service<Article>({ return super.Service<Article>({
path: '/admin/article/update', path: '/admin/article/update',
@@ -96,6 +117,30 @@ export class ApiService extends HttpService {
}); });
} }
createCategory(nameStr: string) {
return super.Service<Category>({
path: '/admin/category/create',
method: 'POST',
queryParam: {name: nameStr}
});
}
deleteCategory(categoryId: number) {
return super.Service<boolean>({
path: '/admin/category/del',
method: 'DELETE',
queryParam: {id: categoryId}
});
}
updateCategory(categoryId: number, nameStr: string) {
return super.Service<Category>({
path: '/admin/category/update',
method: 'PUT',
queryParam: {id: categoryId, name: nameStr}
});
}
tags(pageNumber: number = 1, pageSize: number = 10) { tags(pageNumber: number = 1, pageSize: number = 10) {
return super.Service<Tag[]>({ return super.Service<Tag[]>({
path: '/tags', path: '/tags',
@@ -114,8 +159,33 @@ export class ApiService extends HttpService {
}); });
} }
createTag(nameStr: string) {
return super.Service<Tag>({
path: '/admin/tag/create',
method: 'POST',
queryParam: {name: nameStr}
});
}
deleteTag(TagId: number) {
return super.Service<boolean>({
path: '/admin/tag/del',
method: 'DELETE',
queryParam: {id: TagId}
});
}
updateTag(TagId: number, nameStr: string) {
return super.Service<Tag>({
path: '/admin/tag/update',
method: 'PUT',
queryParam: {id: TagId, name: nameStr}
});
}
getCommentByPid(pid: number, 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: `/comment/pid/${pid}`, path: `/comment/pid/${pid}`,
method: 'GET', method: 'GET',
queryParam: { queryParam: {
@@ -125,6 +195,45 @@ export class ApiService extends HttpService {
}); });
} }
getCommentByTypeForAdmin(isComment: boolean, pageNumber: number = 1, pageSize: number = 10) {
return super.Service<PageList<Comment>>({
path: `/admin/comment/type/${isComment ? 1 : 0}`,
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',
queryParam: {
page: pageNumber,
count: pageSize
}
});
}
deleteComment(idNumer: number) {
return super.Service<boolean>({
path: `/user/comment/del`,
method: 'DELETE',
queryParam: {id: idNumer}
});
}
updateComment(commentReq: CommentReq) {
return super.Service<Comment>({
path: `/user/comment/update`,
method: 'PUT',
data: commentReq,
contentType: 'application/json'
});
}
comments(articleID: number, pageSize: number = 10, pageNumber: number = 1) { comments(articleID: number, pageSize: number = 10, pageNumber: number = 1) {
return super.Service<PageList<Comment>>({ return super.Service<PageList<Comment>>({
path: '/comments', path: '/comments',
@@ -172,6 +281,42 @@ export class ApiService extends HttpService {
}); });
} }
adminLinks(pageSize: number = 10, pageNumber: number = 1) {
return super.Service<PageList<Link>>({
path: '/admin/links',
method: 'GET',
queryParam: {
count: pageSize,
page: pageNumber
}
});
}
createLink(linkReq: Link) {
return super.Service<Link>({
path: '/admin/links/create',
method: 'POST',
data: linkReq,
contentType: 'application/json'
});
}
deleteLink(idNumber: number) {
return super.Service<boolean>({
path: `/admin/links/del/${idNumber}`,
method: 'DELETE',
});
}
updateLink(linkReq: Link) {
return super.Service<Link>({
path: '/admin/links/update',
method: 'PUT',
data: linkReq,
contentType: 'application/json'
});
}
applyLink(link: Link) { applyLink(link: Link) {
return super.Service<string>({ return super.Service<string>({
path: '/apply', path: '/apply',
@@ -273,10 +418,105 @@ export class ApiService extends HttpService {
}); });
} }
visit() { adminUpdateUser(user: User) {
return super.Service<User>({ return super.Service<User>({
path: '/admin/user',
method: 'PUT',
data: user,
contentType: 'application/json'
})
}
deleteUser(id: number) {
return super.Service<boolean>({
path: `/admin/user/del/${id}`,
method: 'DELETE',
});
}
multipleDeleteUser(idArray: number[]) {
return super.Service<{ id: number; msg: string; status: boolean }[]>({
path: `/admin/user/delete`,
method: 'DELETE',
data: idArray,
contentType: 'application/json'
});
}
// 获取邮件是否已注册
emailStatus(email: string) {
return super.Service<boolean>({
path: `/emailStatus/${email}`,
method: 'GET'
})
}
updateUserInfo(descStr: string, disPlayNameStr: string) {
return super.Service<User>({
path: '/user/userInfo/update',
method: 'PUT',
queryParam: {
desc: descStr,
displayName: disPlayNameStr
}
});
}
adminUsers(pageSize: number = 10, pageNumber: number = 1) {
return super.Service<PageList<User>>({
path: '/admin/users',
method: 'GET',
queryParam: {
count: pageSize,
page: pageNumber
}
});
}
visit() {
return super.Service<Visitor>({
path: '/visit', path: '/visit',
method: 'POST', method: 'POST'
});
}
adminVisitors(location: boolean = false, pageSize: number = 10, pageNumber: number = 1) {
return super.Service<PageList<Visitor>>({
path: '/admin/visitor/page',
method: 'GET',
queryParam: {
count: pageSize,
page: pageNumber,
showLocation: location
}
});
}
dayVisitCount() {
return super.Service<number>({
path: '/dayVisitCount',
method: 'GET',
});
}
getLocalIp() {
return super.Service<string>({
path: '/ip',
method: 'GET',
});
}
getIpLocation(ip: string) {
return super.Service<string>({
path: `/ip/${ip}`,
method: 'GET',
});
}
visitorCount() {
return super.Service<number>({
path: `/visitor/count`,
method: 'GET',
}); });
} }
@@ -301,6 +541,29 @@ export class ApiService extends HttpService {
}); });
} }
createWebUpdateInfo(infoStr: string) {
return super.Service<UpdateInfo>({
path: '/admin/webUpdate/create',
method: 'POST',
queryParam: {info: infoStr}
});
}
deleteWebUpdateInfo(idNumber: number) {
return super.Service<boolean>({
path: `/admin/webUpdate/del/${idNumber}`,
method: 'DELETE',
});
}
updateWebUpdateInfo(idNumber: number, infoStr: string) {
return super.Service<UpdateInfo>({
path: '/admin/webUpdate/update',
method: 'PUT',
queryParam: {id: idNumber, info: infoStr}
});
}
bingPic() { bingPic() {
return super.Service<string>({ return super.Service<string>({
path: '/bingPic', path: '/bingPic',

View File

@@ -2,4 +2,5 @@ export class Link {
id?: number; id?: number;
name: string; name: string;
url: string; url: string;
open?: boolean;
} }

View File

@@ -0,0 +1,5 @@
export class UpdateInfo {
id: number;
info: string;
time: string;
}

View File

@@ -3,10 +3,11 @@ export class User {
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;
} }
export class LoginReq { export class LoginReq {

View File

@@ -0,0 +1,9 @@
export class Visitor {
id: number;
ip: string;
date: string;
browserName: string;
browserVersion: string;
osname: string;
location: string;
}