delete service files
This commit is contained in:
@@ -1,48 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {PageList} from "../../../../class/HttpReqAndResp";
|
|
||||||
import {Article} from "../../../../class/Article";
|
|
||||||
import {exist} from "../../../../utils/dataUtil";
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class ArticleService {
|
|
||||||
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// 存储所有已经请求过的数据<首页数据>
|
|
||||||
pageList: PageList<Article>[] = [];
|
|
||||||
|
|
||||||
currentPage: PageList<Article>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文章
|
|
||||||
* @param pageNum 页码数
|
|
||||||
* @param pageSize 单页数据量
|
|
||||||
*/
|
|
||||||
getArticle(pageNum: number, pageSize: number) {
|
|
||||||
const articlePage = exist<Article>(pageNum, pageSize, this.pageList);
|
|
||||||
if (articlePage) {
|
|
||||||
articlePage.subscribe(data => {
|
|
||||||
this.currentPage = data;
|
|
||||||
});
|
|
||||||
return articlePage;
|
|
||||||
}
|
|
||||||
const observable = this.http.get('/admin/articles?page=' + pageNum + '&count=' + pageSize);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.currentPage = data.result;
|
|
||||||
this.pageList.push(data.result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteArticle(id) {
|
|
||||||
return this.http.delete('/admin/article/del?articleID=' + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {Category} from '../../classes/category';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class CategoryService {
|
|
||||||
|
|
||||||
// FIXME : !!!!!!!!!!!!!!!!!!数据处理全部放到一个模块中!!!!!!!!!!!!!!!!!!
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
categories: Category[];
|
|
||||||
|
|
||||||
getAllCategory() {
|
|
||||||
const observable = this.http.get('/categories');
|
|
||||||
observable.subscribe((data) => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.categories = data.result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
update(submitBody: { id: number, name: string }) {
|
|
||||||
return this.http.put('/admin/category/update', submitBody, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
create(nameStr: string) {
|
|
||||||
const observable = this.http.post('/admin/category/create', {name: nameStr}, false);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.categories.push(data.result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number) {
|
|
||||||
const observable = this.http.delete(`/admin/category/del?id=${id}`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
// tslint:disable-next-line:prefer-for-of
|
|
||||||
for (let i = 0; i < this.categories.length; i++) {
|
|
||||||
if (this.categories[i].id === id) {
|
|
||||||
this.categories.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {Page} from '../../classes/page';
|
|
||||||
import {Comment} from '../../classes/comment';
|
|
||||||
import {exist} from '../../utils/dataUtil';
|
|
||||||
import {CommentReq} from "../../classes/commentReq";
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class CommentService {
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// 存放
|
|
||||||
leaveMsgPage: Page<Comment>[] = [];
|
|
||||||
|
|
||||||
commentPage: Page<Comment>[] = [];
|
|
||||||
|
|
||||||
currentComment: Page<Comment>;
|
|
||||||
|
|
||||||
currentLeaveMsg: Page<Comment>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 评论
|
|
||||||
* @param pageNum 页码
|
|
||||||
* @param pageSize 单页数据数量
|
|
||||||
* @param isAdmin 是否是管理员
|
|
||||||
*/
|
|
||||||
getComments(pageNum: number, pageSize: number, isAdmin: boolean) {
|
|
||||||
const exist1 = exist<Comment>(pageNum, pageSize, this.commentPage);
|
|
||||||
if (exist1) {
|
|
||||||
exist1.subscribe(data => {
|
|
||||||
this.currentComment = data;
|
|
||||||
});
|
|
||||||
return exist1;
|
|
||||||
}
|
|
||||||
const observable = this.http.get(`/${isAdmin ? 'admin' : 'user'}/comment/type/1?count=${pageSize}&page=${pageNum}`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.commentPage.unshift(data.result);
|
|
||||||
this.currentComment = data.result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 留言
|
|
||||||
* @param pageNum 页码
|
|
||||||
* @param pageSize 单页数据数量
|
|
||||||
* @param isAdmin 是否是管理员
|
|
||||||
*/
|
|
||||||
getLeaveMsg(pageNum: number, pageSize: number, isAdmin: boolean) {
|
|
||||||
const exist1 = exist<Comment>(pageNum, pageSize, this.leaveMsgPage);
|
|
||||||
if (exist1) {
|
|
||||||
exist1.subscribe(data => {
|
|
||||||
this.currentLeaveMsg = data;
|
|
||||||
});
|
|
||||||
return exist1;
|
|
||||||
}
|
|
||||||
const observable = this.http.get(`/${isAdmin ? 'admin' : 'user'}/comment/type/0?count=${pageSize}&page=${pageNum}`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.leaveMsgPage.unshift(data.result);
|
|
||||||
this.currentLeaveMsg = data.result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 回复评论/留言
|
|
||||||
* @param responseComment 请求体
|
|
||||||
*/
|
|
||||||
rely(responseComment: CommentReq) {
|
|
||||||
return this.http.post('/user/comment/create', responseComment, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过父评论 获取回复
|
|
||||||
* @param pid 父评论id
|
|
||||||
*/
|
|
||||||
getByPid(pid: number) {
|
|
||||||
return this.http.get('/comment/pid/' + pid + '?count=5&page=1');
|
|
||||||
}
|
|
||||||
|
|
||||||
update(subComment) {
|
|
||||||
return this.http.put('/user/comment/update', subComment);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number) {
|
|
||||||
return this.http.delete('/user/comment/del?id=' + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {Link} from '../../classes/link';
|
|
||||||
import {Page} from '../../classes/page';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class LinkService {
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// 不采取存储page[] :: 数据量较少
|
|
||||||
public currentPage: Page<Link>;
|
|
||||||
|
|
||||||
getLinks(pageNum: number, pageSize: number) {
|
|
||||||
const observable = this.http.get(`/admin/links?page=${pageNum}&count=${pageSize}`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.currentPage = data.result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
update(submitBody: Link) {
|
|
||||||
return this.http.put('/admin/links/update', submitBody, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
create(submitBody: Link) {
|
|
||||||
submitBody.id = null;
|
|
||||||
return this.http.post('/admin/links/create', submitBody, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id) {
|
|
||||||
return this.http.delete(`/admin/links/del/${id}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class LogService {
|
|
||||||
|
|
||||||
constructor(private http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
logText: string;
|
|
||||||
|
|
||||||
getLog() {
|
|
||||||
// @ts-ignore
|
|
||||||
const observable = this.http.httpClient.get<string>('https://api.celess.cn/blog.log', {responseType: 'text'});
|
|
||||||
observable.subscribe(data => {
|
|
||||||
this.logText = data;
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {Tag} from '../../classes/tag';
|
|
||||||
import {Page} from '../../classes/page';
|
|
||||||
import {exist} from '../../utils/dataUtil';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class TagService {
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
tagPages: Page<Tag>[] = [];
|
|
||||||
currentTagPage: Page<Tag>;
|
|
||||||
|
|
||||||
getTags(pageNum: number, pageSize: number) {
|
|
||||||
const exist1 = exist<Tag>(pageNum, pageSize, this.tagPages);
|
|
||||||
if (exist1) {
|
|
||||||
exist1.subscribe(data => {
|
|
||||||
this.currentTagPage = data;
|
|
||||||
});
|
|
||||||
return exist1;
|
|
||||||
}
|
|
||||||
const observable = this.http.get(`/tags?count=${pageSize}&page=${pageNum}`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.currentTagPage = data.result;
|
|
||||||
this.tagPages.unshift(data.result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
update(id: number, name: string) {
|
|
||||||
return this.http.put(`/admin/tag/update?id=${id}&name=${name}`, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number) {
|
|
||||||
return this.http.delete(`/admin/tag/del?id=${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {UpdateInfo} from '../../classes/updateInfo';
|
|
||||||
import {Page} from '../../classes/page';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class WebUpdateService {
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public updateInfoList: Page<UpdateInfo>;
|
|
||||||
|
|
||||||
public lastestUpdateTime: string;
|
|
||||||
|
|
||||||
getUpdateInfo(pageNum: number, pageSize: number) {
|
|
||||||
const observable = this.http.get(`/webUpdate/pages?page=${pageNum}&count=${pageSize}`);
|
|
||||||
observable.subscribe((data: any) => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.updateInfoList = data.result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLastestUpdateTime() {
|
|
||||||
this.http.get('/lastestUpdateTime').subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.lastestUpdateTime = data.result;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update(submitBody: { id: number, info: string }) {
|
|
||||||
return this.http.put('/admin/webUpdate/update', submitBody, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
create(infoStr: string) {
|
|
||||||
return this.http.post('/admin/webUpdate/create', {info: infoStr}, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number) {
|
|
||||||
return this.http.delete(`/admin/webUpdate/del/${id}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {User} from '../../classes/user';
|
|
||||||
import {Page} from '../../classes/page';
|
|
||||||
import {exist} from '../../utils/dataUtil';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class UserService {
|
|
||||||
|
|
||||||
userInfo: User;
|
|
||||||
|
|
||||||
avatarHost: string = 'http://cdn.celess.cn';
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
userPage: Page<User>[] = [];
|
|
||||||
currentUserPage: Page<User>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户信息
|
|
||||||
*/
|
|
||||||
getUserInfo() {
|
|
||||||
return this.http.get('/user/userInfo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注销登录
|
|
||||||
*/
|
|
||||||
logout() {
|
|
||||||
this.http.get('/logout').subscribe((data: any) => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.userInfo = null;
|
|
||||||
this.http.removeToken();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updateInfo(submitBody: { desc: string, displayName: string }) {
|
|
||||||
const observable = this.http.put('/user/userInfo/update', submitBody, false);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.userInfo.desc = submitBody.desc;
|
|
||||||
this.userInfo.displayName = submitBody.displayName;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sendEmail() {
|
|
||||||
return this.http.post('/sendVerifyEmail', {email: this.userInfo.email}, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取分页数据
|
|
||||||
* @param pageNum 页码
|
|
||||||
* @param pageSize 单页数据量
|
|
||||||
* @param refresh 是否强制刷新
|
|
||||||
*/
|
|
||||||
getPageUser(pageNum: number, pageSize: number, refresh: boolean = false) {
|
|
||||||
const existData = exist<User>(pageNum, pageSize, this.userPage);
|
|
||||||
if (existData && !refresh) {
|
|
||||||
existData.subscribe(data => {
|
|
||||||
this.currentUserPage = data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.http.get(`/admin/users?page=${pageNum}&count=${pageSize}`).subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.currentUserPage = data.result;
|
|
||||||
this.userPage.unshift(data.result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number) {
|
|
||||||
return this.http.delete(`/admin/user/delete/${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
update(user: User) {
|
|
||||||
return this.http.put('/admin/user', user, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
getExistOfEmail(email: string) {
|
|
||||||
return this.http.get(`/emailStatus/${email}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
import {HttpService} from '../http.service';
|
|
||||||
import {Page} from '../../classes/page';
|
|
||||||
import {Visitor} from '../../classes/visitor';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class VisitorService {
|
|
||||||
|
|
||||||
constructor(public http: HttpService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public pageList: Page<Visitor>[] = [];
|
|
||||||
public currentPage: Page<Visitor>;
|
|
||||||
|
|
||||||
public dayVisit: number;
|
|
||||||
public totalVisitCount: number;
|
|
||||||
|
|
||||||
private ipLocationList: { ip: string, location: string }[] = [];
|
|
||||||
|
|
||||||
getVisitor(pageNum: number, pageSize: number) {
|
|
||||||
const observable = this.http.get(`/admin/visitor/page?count=${pageSize}&page=${pageNum}&showLocation=false`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.pageList.unshift(data.result);
|
|
||||||
this.currentPage = data.result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getDayVisitor() {
|
|
||||||
this.http.get('/dayVisitCount').subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.dayVisit = data.result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getTotalVisitorCount() {
|
|
||||||
this.http.get('/visitor/count').subscribe(data => {
|
|
||||||
this.totalVisitCount = data.result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
getIp(ip: string) {
|
|
||||||
const location = this.exist(ip);
|
|
||||||
if (location) {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
const observable = this.http.get(`/ip/${ip}`);
|
|
||||||
observable.subscribe(data => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.ipLocationList.unshift(data.result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return observable;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLocalIp() {
|
|
||||||
return this.http.get('/ip');
|
|
||||||
}
|
|
||||||
|
|
||||||
private exist(ip): string {
|
|
||||||
if (this.ipLocationList.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// tslint:disable-next-line:prefer-for-of
|
|
||||||
for (let i = 0; i < this.ipLocationList.length; i++) {
|
|
||||||
if (this.ipLocationList[i].ip === ip) {
|
|
||||||
return this.ipLocationList[i].location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user