完善api列表
This commit is contained in:
@@ -6,7 +6,7 @@ import {HttpService} from './http/http.service';
|
||||
import {PageList} from '../class/HttpReqAndResp';
|
||||
import {ErrDispatch} from '../class/ErrDispatch';
|
||||
import {ArticleReq} from '../class/Article';
|
||||
import {Tag} from '../class/Tag';
|
||||
import {Category, Tag} from '../class/Tag';
|
||||
import {Comment} from '../class/Comment';
|
||||
import {CommentReq} from '../class/Comment';
|
||||
import {Link} from '../class/Link';
|
||||
@@ -14,6 +14,8 @@ import {User} from '../class/User';
|
||||
import {LoginReq} from '../class/User';
|
||||
|
||||
import {LocalStorageService} from '../services/local-storage.service';
|
||||
import {Visitor} from '../class/Visitor';
|
||||
import {UpdateInfo} from '../class/UpdateInfo';
|
||||
|
||||
@Injectable({
|
||||
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) {
|
||||
return super.Service<PageList<Article>>({
|
||||
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) {
|
||||
return super.Service<Article>({
|
||||
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) {
|
||||
return super.Service<Tag[]>({
|
||||
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) {
|
||||
return super.Service<PageList<Comment>[]>({
|
||||
return super.Service<Comment[]>({
|
||||
path: `/comment/pid/${pid}`,
|
||||
method: 'GET',
|
||||
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) {
|
||||
return super.Service<PageList<Comment>>({
|
||||
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) {
|
||||
return super.Service<string>({
|
||||
path: '/apply',
|
||||
@@ -273,10 +418,105 @@ export class ApiService extends HttpService {
|
||||
});
|
||||
}
|
||||
|
||||
visit() {
|
||||
adminUpdateUser(user: 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',
|
||||
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() {
|
||||
return super.Service<string>({
|
||||
path: '/bingPic',
|
||||
|
||||
@@ -2,4 +2,5 @@ export class Link {
|
||||
id?: number;
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
open?: boolean;
|
||||
}
|
||||
|
||||
5
index/src/app/class/UpdateInfo.ts
Normal file
5
index/src/app/class/UpdateInfo.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class UpdateInfo {
|
||||
id: number;
|
||||
info: string;
|
||||
time: string;
|
||||
}
|
||||
@@ -3,10 +3,11 @@ export class User {
|
||||
email: string;
|
||||
displayName: string;
|
||||
emailStatus: boolean;
|
||||
avatarImgUrl: string;
|
||||
avatarImgUrl?: string;
|
||||
desc: string;
|
||||
role: string;
|
||||
token?: string;
|
||||
pwd?: string;
|
||||
}
|
||||
|
||||
export class LoginReq {
|
||||
@@ -19,4 +20,4 @@ export class LoginReq {
|
||||
this.isRememberMe = isRememberMe;
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
index/src/app/class/Visitor.ts
Normal file
9
index/src/app/class/Visitor.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class Visitor {
|
||||
id: number;
|
||||
ip: string;
|
||||
date: string;
|
||||
browserName: string;
|
||||
browserVersion: string;
|
||||
osname: string;
|
||||
location: string;
|
||||
}
|
||||
Reference in New Issue
Block a user