mirror of https://github.com/fantasticit/think.git
refactor: add api definition in domain
This commit is contained in:
parent
a3cce12243
commit
55f227fae0
|
@ -0,0 +1,49 @@
|
|||
import { IDocument, IWiki, CollectType } from '../models';
|
||||
export declare type CollectorApiTypeDefinition = {
|
||||
toggle: {
|
||||
request: {
|
||||
targetId: IDocument['id'] | IWiki['id'];
|
||||
type: CollectType;
|
||||
};
|
||||
};
|
||||
check: {
|
||||
request: {
|
||||
targetId: IDocument['id'] | IWiki['id'];
|
||||
type: CollectType;
|
||||
};
|
||||
};
|
||||
};
|
||||
export declare const CollectorApiDefinition: {
|
||||
/**
|
||||
* 收藏(或取消收藏)
|
||||
*/
|
||||
toggle: {
|
||||
method: "Post";
|
||||
server: "toggle";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 检测是否收藏
|
||||
*/
|
||||
check: {
|
||||
method: "Post";
|
||||
server: "check";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取收藏的知识库
|
||||
*/
|
||||
wikis: {
|
||||
method: "Post";
|
||||
server: "wikis";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取收藏的文档
|
||||
*/
|
||||
documents: {
|
||||
method: "Post";
|
||||
server: "documents";
|
||||
client: () => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.CollectorApiDefinition = void 0;
|
||||
exports.CollectorApiDefinition = {
|
||||
/**
|
||||
* 收藏(或取消收藏)
|
||||
*/
|
||||
toggle: {
|
||||
method: 'Post',
|
||||
server: 'toggle',
|
||||
client: function () { return '/collector/toggle'; }
|
||||
},
|
||||
/**
|
||||
* 检测是否收藏
|
||||
*/
|
||||
check: {
|
||||
method: 'Post',
|
||||
server: 'check',
|
||||
client: function () { return '/collector/check'; }
|
||||
},
|
||||
/**
|
||||
* 获取收藏的知识库
|
||||
*/
|
||||
wikis: {
|
||||
method: 'Post',
|
||||
server: 'wikis',
|
||||
client: function () { return '/collector/wikis'; }
|
||||
},
|
||||
/**
|
||||
* 获取收藏的文档
|
||||
*/
|
||||
documents: {
|
||||
method: 'Post',
|
||||
server: 'documents',
|
||||
client: function () { return '/collector/documents'; }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
import { IComment, IDocument } from '../models';
|
||||
export declare const CommentApiDefinition: {
|
||||
/**
|
||||
* 新建评论
|
||||
*/
|
||||
add: {
|
||||
method: "Post";
|
||||
server: "add";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 更新评论
|
||||
*/
|
||||
update: {
|
||||
method: "Patch";
|
||||
server: "update";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
delete: {
|
||||
method: "Delete";
|
||||
server: "delete/:id";
|
||||
client: (id: IComment['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取指定文档评论
|
||||
*/
|
||||
documents: {
|
||||
method: "Get";
|
||||
server: "document/:documentId";
|
||||
client: (documentId: IDocument['id']) => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.CommentApiDefinition = void 0;
|
||||
exports.CommentApiDefinition = {
|
||||
/**
|
||||
* 新建评论
|
||||
*/
|
||||
add: {
|
||||
method: 'Post',
|
||||
server: 'add',
|
||||
client: function () { return '/comment/add'; }
|
||||
},
|
||||
/**
|
||||
* 更新评论
|
||||
*/
|
||||
update: {
|
||||
method: 'Patch',
|
||||
server: 'update',
|
||||
client: function () { return '/comment/update'; }
|
||||
},
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
"delete": {
|
||||
method: 'Delete',
|
||||
server: 'delete/:id',
|
||||
client: function (id) { return "/comment/delete/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取指定文档评论
|
||||
*/
|
||||
documents: {
|
||||
method: 'Get',
|
||||
server: 'document/:documentId',
|
||||
client: function (documentId) { return "/comment/document/".concat(documentId); }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,123 @@
|
|||
import { IDocument } from '../models';
|
||||
export declare const DocumentApiDefinition: {
|
||||
/**
|
||||
* 搜索文档
|
||||
*/
|
||||
search: {
|
||||
method: "Get";
|
||||
server: "search";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取用户最近访问的文档
|
||||
*/
|
||||
recent: {
|
||||
method: "Get";
|
||||
server: "recent";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 新建文档
|
||||
*/
|
||||
create: {
|
||||
method: "Post";
|
||||
server: "create";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取文档详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: "Get";
|
||||
server: "detail/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 更新文档
|
||||
*/
|
||||
updateById: {
|
||||
method: "Patch";
|
||||
server: "update/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取文档版本记录
|
||||
*/
|
||||
getVersionById: {
|
||||
method: "Get";
|
||||
server: "version/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取文档成员
|
||||
*/
|
||||
getMemberById: {
|
||||
method: "Get";
|
||||
server: "member/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 添加文档成员
|
||||
*/
|
||||
addMemberById: {
|
||||
method: "Post";
|
||||
server: "member/:id/add";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 更新文档成员
|
||||
*/
|
||||
updateMemberById: {
|
||||
method: "Patch";
|
||||
server: "member/:id/update";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 删除文档成员
|
||||
*/
|
||||
deleteMemberById: {
|
||||
method: "Post";
|
||||
server: "member/:id/delete";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取子文档
|
||||
*/
|
||||
getChildren: {
|
||||
method: "Get";
|
||||
server: "children";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 删除文档
|
||||
*/
|
||||
deleteById: {
|
||||
method: "Delete";
|
||||
server: "delete/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 分享文档
|
||||
*/
|
||||
shareById: {
|
||||
method: "Post";
|
||||
server: "share/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取公开文档详情
|
||||
*/
|
||||
getPublicDetailById: {
|
||||
method: "Get";
|
||||
server: "public/detail/:id";
|
||||
client: (id: IDocument['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取公开文档的子文档
|
||||
*/
|
||||
getPublicChildren: {
|
||||
method: "Get";
|
||||
server: "public/children";
|
||||
client: () => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,125 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.DocumentApiDefinition = void 0;
|
||||
exports.DocumentApiDefinition = {
|
||||
/**
|
||||
* 搜索文档
|
||||
*/
|
||||
search: {
|
||||
method: 'Get',
|
||||
server: 'search',
|
||||
client: function () { return '/document/search'; }
|
||||
},
|
||||
/**
|
||||
* 获取用户最近访问的文档
|
||||
*/
|
||||
recent: {
|
||||
method: 'Get',
|
||||
server: 'recent',
|
||||
client: function () { return '/document/recent'; }
|
||||
},
|
||||
/**
|
||||
* 新建文档
|
||||
*/
|
||||
create: {
|
||||
method: 'Post',
|
||||
server: 'create',
|
||||
client: function () { return '/document/create'; }
|
||||
},
|
||||
/**
|
||||
* 获取文档详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: 'Get',
|
||||
server: 'detail/:id',
|
||||
client: function (id) { return "/document/detail/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 更新文档
|
||||
*/
|
||||
updateById: {
|
||||
method: 'Patch',
|
||||
server: 'update/:id',
|
||||
client: function (id) { return "/document/update/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取文档版本记录
|
||||
*/
|
||||
getVersionById: {
|
||||
method: 'Get',
|
||||
server: 'version/:id',
|
||||
client: function (id) { return "/document/version/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取文档成员
|
||||
*/
|
||||
getMemberById: {
|
||||
method: 'Get',
|
||||
server: 'member/:id',
|
||||
client: function (id) { return "/document/member/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 添加文档成员
|
||||
*/
|
||||
addMemberById: {
|
||||
method: 'Post',
|
||||
server: 'member/:id/add',
|
||||
client: function (id) { return "/document/member/".concat(id, "/add"); }
|
||||
},
|
||||
/**
|
||||
* 更新文档成员
|
||||
*/
|
||||
updateMemberById: {
|
||||
method: 'Patch',
|
||||
server: 'member/:id/update',
|
||||
client: function (id) { return "/document/member/".concat(id, "/update"); }
|
||||
},
|
||||
/**
|
||||
* 删除文档成员
|
||||
*/
|
||||
deleteMemberById: {
|
||||
method: 'Post',
|
||||
server: 'member/:id/delete',
|
||||
client: function (id) { return "/document/member/".concat(id, "/delete"); }
|
||||
},
|
||||
/**
|
||||
* 获取子文档
|
||||
*/
|
||||
getChildren: {
|
||||
method: 'Get',
|
||||
server: 'children',
|
||||
client: function () { return "/document/children"; }
|
||||
},
|
||||
/**
|
||||
* 删除文档
|
||||
*/
|
||||
deleteById: {
|
||||
method: 'Delete',
|
||||
server: 'delete/:id',
|
||||
client: function (id) { return "/document/delete/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 分享文档
|
||||
*/
|
||||
shareById: {
|
||||
method: 'Post',
|
||||
server: 'share/:id',
|
||||
client: function (id) { return "/document/share/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取公开文档详情
|
||||
*/
|
||||
getPublicDetailById: {
|
||||
method: 'Get',
|
||||
server: 'public/detail/:id',
|
||||
client: function (id) { return "/document/public/detail/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取公开文档的子文档
|
||||
*/
|
||||
getPublicChildren: {
|
||||
method: 'Get',
|
||||
server: 'public/children',
|
||||
client: function () { return "/document/public/children"; }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
export declare const FileApiDefinition: {
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
upload: {
|
||||
method: "Post";
|
||||
server: "upload";
|
||||
client: () => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.FileApiDefinition = void 0;
|
||||
exports.FileApiDefinition = {
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
upload: {
|
||||
method: 'Post',
|
||||
server: 'upload',
|
||||
client: function () { return '/file/upload'; }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
export * from './user';
|
||||
export * from './wiki';
|
||||
export * from './document';
|
||||
export * from './file';
|
||||
export * from './message';
|
||||
export * from './template';
|
||||
export * from './comment';
|
||||
export * from './collector';
|
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
exports.__esModule = true;
|
||||
__exportStar(require("./user"), exports);
|
||||
__exportStar(require("./wiki"), exports);
|
||||
__exportStar(require("./document"), exports);
|
||||
__exportStar(require("./file"), exports);
|
||||
__exportStar(require("./message"), exports);
|
||||
__exportStar(require("./template"), exports);
|
||||
__exportStar(require("./comment"), exports);
|
||||
__exportStar(require("./collector"), exports);
|
|
@ -0,0 +1,35 @@
|
|||
import { IMessage } from '../models';
|
||||
export declare const MessageApiDefinition: {
|
||||
/**
|
||||
* 获取未读消息
|
||||
*/
|
||||
getUnread: {
|
||||
method: "Get";
|
||||
server: "unread";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取已读消息
|
||||
*/
|
||||
getRead: {
|
||||
method: "Get";
|
||||
server: "read";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取所有消息
|
||||
*/
|
||||
getAll: {
|
||||
method: "Get";
|
||||
server: "all";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 将消息标记为已读
|
||||
*/
|
||||
readMessage: {
|
||||
method: "Post";
|
||||
server: "read/:id";
|
||||
client: (id: IMessage['id']) => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.MessageApiDefinition = void 0;
|
||||
exports.MessageApiDefinition = {
|
||||
/**
|
||||
* 获取未读消息
|
||||
*/
|
||||
getUnread: {
|
||||
method: 'Get',
|
||||
server: 'unread',
|
||||
client: function () { return '/message/unread'; }
|
||||
},
|
||||
/**
|
||||
* 获取已读消息
|
||||
*/
|
||||
getRead: {
|
||||
method: 'Get',
|
||||
server: 'read',
|
||||
client: function () { return '/message/read'; }
|
||||
},
|
||||
/**
|
||||
* 获取所有消息
|
||||
*/
|
||||
getAll: {
|
||||
method: 'Get',
|
||||
server: 'all',
|
||||
client: function () { return '/message/all'; }
|
||||
},
|
||||
/**
|
||||
* 将消息标记为已读
|
||||
*/
|
||||
readMessage: {
|
||||
method: 'Post',
|
||||
server: 'read/:id',
|
||||
client: function (id) { return "/message/read/".concat(id); }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
import { ITemplate } from '../models';
|
||||
export declare const TemplateApiDefinition: {
|
||||
/**
|
||||
* 获取公开模板
|
||||
*/
|
||||
public: {
|
||||
method: "Get";
|
||||
server: "public";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取个人创建模板
|
||||
*/
|
||||
own: {
|
||||
method: "Get";
|
||||
server: "own";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 新建模板
|
||||
*/
|
||||
add: {
|
||||
method: "Post";
|
||||
server: "add";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 更新模板
|
||||
*/
|
||||
updateById: {
|
||||
method: "Patch";
|
||||
server: "update/:id";
|
||||
client: (id: ITemplate['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取模板详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: "Get";
|
||||
server: "detail/:id";
|
||||
client: (id: ITemplate['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 删除模板
|
||||
*/
|
||||
deleteById: {
|
||||
method: "Delete";
|
||||
server: "delete/:id";
|
||||
client: (id: ITemplate['id']) => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.TemplateApiDefinition = void 0;
|
||||
exports.TemplateApiDefinition = {
|
||||
/**
|
||||
* 获取公开模板
|
||||
*/
|
||||
public: {
|
||||
method: 'Get',
|
||||
server: 'public',
|
||||
client: function () { return '/template/public'; }
|
||||
},
|
||||
/**
|
||||
* 获取个人创建模板
|
||||
*/
|
||||
own: {
|
||||
method: 'Get',
|
||||
server: 'own',
|
||||
client: function () { return '/template/own'; }
|
||||
},
|
||||
/**
|
||||
* 新建模板
|
||||
*/
|
||||
add: {
|
||||
method: 'Post',
|
||||
server: 'add',
|
||||
client: function () { return '/template/add'; }
|
||||
},
|
||||
/**
|
||||
* 更新模板
|
||||
*/
|
||||
updateById: {
|
||||
method: 'Patch',
|
||||
server: 'update/:id',
|
||||
client: function (id) { return "/template/update/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取模板详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: 'Get',
|
||||
server: 'detail/:id',
|
||||
client: function (id) { return "/template/detail/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 删除模板
|
||||
*/
|
||||
deleteById: {
|
||||
method: 'Delete',
|
||||
server: 'delete/:id',
|
||||
client: function (id) { return "/template/delete/".concat(id); }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,42 @@
|
|||
export declare const UserApiDefinition: {
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
getAllUsers: {
|
||||
method: "Get";
|
||||
server: "/";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
register: {
|
||||
method: "Post";
|
||||
server: "register";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
login: {
|
||||
method: "Post";
|
||||
server: "login";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
logout: {
|
||||
method: "Post";
|
||||
server: "logout";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
update: {
|
||||
method: "Patch";
|
||||
server: "update";
|
||||
client: () => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.UserApiDefinition = void 0;
|
||||
exports.UserApiDefinition = {
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
getAllUsers: {
|
||||
method: 'Get',
|
||||
server: '/',
|
||||
client: function () { return '/user'; }
|
||||
},
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
register: {
|
||||
method: 'Post',
|
||||
server: 'register',
|
||||
client: function () { return '/user/register'; }
|
||||
},
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
login: {
|
||||
method: 'Post',
|
||||
server: 'login',
|
||||
client: function () { return '/user/login'; }
|
||||
},
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
logout: {
|
||||
method: 'Post',
|
||||
server: 'logout',
|
||||
client: function () { return '/user/logout'; }
|
||||
},
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
update: {
|
||||
method: 'Patch',
|
||||
server: 'update',
|
||||
client: function () { return "/user/update"; }
|
||||
}
|
||||
};
|
|
@ -0,0 +1,163 @@
|
|||
import { IWiki } from '../models';
|
||||
export declare const WikiApiDefinition: {
|
||||
/**
|
||||
* 获取用户所有知识库(创建的、参与的)
|
||||
*/
|
||||
getAllWikis: {
|
||||
method: "Get";
|
||||
server: "list/all";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取用户创建的知识库
|
||||
*/
|
||||
getOwnWikis: {
|
||||
method: "Get";
|
||||
server: "list/own";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取用户参与的知识库
|
||||
*/
|
||||
getJoinWikis: {
|
||||
method: "Get";
|
||||
server: "list/join";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 新建知识库
|
||||
*/
|
||||
add: {
|
||||
method: "Post";
|
||||
server: "add";
|
||||
client: () => string;
|
||||
};
|
||||
/**
|
||||
* 获取知识库首页文档
|
||||
*/
|
||||
getHomeDocumentById: {
|
||||
method: "Get";
|
||||
server: "homedoc/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取知识库目录
|
||||
*/
|
||||
getTocsById: {
|
||||
method: "Get";
|
||||
server: "tocs/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 更新知识库目录
|
||||
*/
|
||||
updateTocsById: {
|
||||
method: "Patch";
|
||||
server: "tocs/:id/update";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取知识库所有文档
|
||||
*/
|
||||
getDocumentsById: {
|
||||
method: "Get";
|
||||
server: "documents/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取知识库详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: "Get";
|
||||
server: "detail/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 更新知识库
|
||||
*/
|
||||
updateById: {
|
||||
method: "Patch";
|
||||
server: "update/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 删除知识库
|
||||
*/
|
||||
deleteById: {
|
||||
method: "Delete";
|
||||
server: "delet/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取知识库成员
|
||||
*/
|
||||
getMemberById: {
|
||||
method: "Get";
|
||||
server: "member/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 添加知识库成员
|
||||
*/
|
||||
addMemberById: {
|
||||
method: "Post";
|
||||
server: "member/:id/add";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 更新知识库成员
|
||||
*/
|
||||
updateMemberById: {
|
||||
method: "Patch";
|
||||
server: "member/:id/update";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 删除知识库成员
|
||||
*/
|
||||
deleteMemberById: {
|
||||
method: "Delete";
|
||||
server: "member/:id/delete";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 分享知识库
|
||||
*/
|
||||
shareById: {
|
||||
method: "Post";
|
||||
server: "share/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取公开知识库首页文档
|
||||
*/
|
||||
getPublicHomeDocumentById: {
|
||||
method: "Get";
|
||||
server: "/public/homedoc/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取公开知识库目录
|
||||
*/
|
||||
getPublicTocsById: {
|
||||
method: "Get";
|
||||
server: "/public/tocs/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取知识库详情
|
||||
*/
|
||||
getPublicDetailById: {
|
||||
method: "Get";
|
||||
server: "/public/detail/:id";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
/**
|
||||
* 获取所有公开知识库
|
||||
*/
|
||||
getPublicWikis: {
|
||||
method: "Get";
|
||||
server: "/public/wikis";
|
||||
client: (id: IWiki['id']) => string;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,165 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.WikiApiDefinition = void 0;
|
||||
exports.WikiApiDefinition = {
|
||||
/**
|
||||
* 获取用户所有知识库(创建的、参与的)
|
||||
*/
|
||||
getAllWikis: {
|
||||
method: 'Get',
|
||||
server: 'list/all',
|
||||
client: function () { return '/wiki/list/all'; }
|
||||
},
|
||||
/**
|
||||
* 获取用户创建的知识库
|
||||
*/
|
||||
getOwnWikis: {
|
||||
method: 'Get',
|
||||
server: 'list/own',
|
||||
client: function () { return '/wiki/list/own'; }
|
||||
},
|
||||
/**
|
||||
* 获取用户参与的知识库
|
||||
*/
|
||||
getJoinWikis: {
|
||||
method: 'Get',
|
||||
server: 'list/join',
|
||||
client: function () { return '/wiki/list/join'; }
|
||||
},
|
||||
/**
|
||||
* 新建知识库
|
||||
*/
|
||||
add: {
|
||||
method: 'Post',
|
||||
server: 'add',
|
||||
client: function () { return '/wiki/add'; }
|
||||
},
|
||||
/**
|
||||
* 获取知识库首页文档
|
||||
*/
|
||||
getHomeDocumentById: {
|
||||
method: 'Get',
|
||||
server: 'homedoc/:id',
|
||||
client: function (id) { return "/wiki/homedoc/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取知识库目录
|
||||
*/
|
||||
getTocsById: {
|
||||
method: 'Get',
|
||||
server: 'tocs/:id',
|
||||
client: function (id) { return "/wiki/tocs/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 更新知识库目录
|
||||
*/
|
||||
updateTocsById: {
|
||||
method: 'Patch',
|
||||
server: 'tocs/:id/update',
|
||||
client: function (id) { return "/wiki/tocs/".concat(id, "/update"); }
|
||||
},
|
||||
/**
|
||||
* 获取知识库所有文档
|
||||
*/
|
||||
getDocumentsById: {
|
||||
method: 'Get',
|
||||
server: 'documents/:id',
|
||||
client: function (id) { return "/wiki/documents/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取知识库详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: 'Get',
|
||||
server: 'detail/:id',
|
||||
client: function (id) { return "/wiki/detail/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 更新知识库
|
||||
*/
|
||||
updateById: {
|
||||
method: 'Patch',
|
||||
server: 'update/:id',
|
||||
client: function (id) { return "/wiki/update/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 删除知识库
|
||||
*/
|
||||
deleteById: {
|
||||
method: 'Delete',
|
||||
server: 'delet/:id',
|
||||
client: function (id) { return "/wiki/delet/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取知识库成员
|
||||
*/
|
||||
getMemberById: {
|
||||
method: 'Get',
|
||||
server: 'member/:id',
|
||||
client: function (id) { return "/wiki/member/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 添加知识库成员
|
||||
*/
|
||||
addMemberById: {
|
||||
method: 'Post',
|
||||
server: 'member/:id/add',
|
||||
client: function (id) { return "/wiki/member/".concat(id, "/add"); }
|
||||
},
|
||||
/**
|
||||
* 更新知识库成员
|
||||
*/
|
||||
updateMemberById: {
|
||||
method: 'Patch',
|
||||
server: 'member/:id/update',
|
||||
client: function (id) { return "/wiki/member/".concat(id, "/update"); }
|
||||
},
|
||||
/**
|
||||
* 删除知识库成员
|
||||
*/
|
||||
deleteMemberById: {
|
||||
method: 'Delete',
|
||||
server: 'member/:id/delete',
|
||||
client: function (id) { return "/wiki/member/".concat(id, "/delete"); }
|
||||
},
|
||||
/**
|
||||
* 分享知识库
|
||||
*/
|
||||
shareById: {
|
||||
method: 'Post',
|
||||
server: 'share/:id',
|
||||
client: function (id) { return "/wiki/share/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取公开知识库首页文档
|
||||
*/
|
||||
getPublicHomeDocumentById: {
|
||||
method: 'Get',
|
||||
server: '/public/homedoc/:id',
|
||||
client: function (id) { return "/wiki/public/homedoc/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取公开知识库目录
|
||||
*/
|
||||
getPublicTocsById: {
|
||||
method: 'Get',
|
||||
server: '/public/tocs/:id',
|
||||
client: function (id) { return "/wiki/public/tocs/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取知识库详情
|
||||
*/
|
||||
getPublicDetailById: {
|
||||
method: 'Get',
|
||||
server: '/public/detail/:id',
|
||||
client: function (id) { return "/wiki/public/detail/".concat(id); }
|
||||
},
|
||||
/**
|
||||
* 获取所有公开知识库
|
||||
*/
|
||||
getPublicWikis: {
|
||||
method: 'Get',
|
||||
server: '/public/wikis',
|
||||
client: function (id) { return "/wiki/public/wikis"; }
|
||||
}
|
||||
};
|
|
@ -1,2 +1,3 @@
|
|||
export * from './models';
|
||||
export * from './util';
|
||||
export * from './api';
|
||||
|
|
|
@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|||
exports.__esModule = true;
|
||||
__exportStar(require("./models"), exports);
|
||||
__exportStar(require("./util"), exports);
|
||||
__exportStar(require("./api"), exports);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
import { IDocument, IWiki, CollectType } from '../models';
|
||||
|
||||
export type CollectorApiTypeDefinition = {
|
||||
toggle: {
|
||||
request: {
|
||||
targetId: IDocument['id'] | IWiki['id'];
|
||||
type: CollectType;
|
||||
};
|
||||
};
|
||||
check: {
|
||||
request: {
|
||||
targetId: IDocument['id'] | IWiki['id'];
|
||||
type: CollectType;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const CollectorApiDefinition = {
|
||||
/**
|
||||
* 收藏(或取消收藏)
|
||||
*/
|
||||
toggle: {
|
||||
method: 'Post' as const,
|
||||
server: 'toggle' as const,
|
||||
client: () => '/collector/toggle',
|
||||
},
|
||||
|
||||
/**
|
||||
* 检测是否收藏
|
||||
*/
|
||||
check: {
|
||||
method: 'Post' as const,
|
||||
server: 'check' as const,
|
||||
client: () => '/collector/check',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取收藏的知识库
|
||||
*/
|
||||
wikis: {
|
||||
method: 'Post' as const,
|
||||
server: 'wikis' as const,
|
||||
client: () => '/collector/wikis',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取收藏的文档
|
||||
*/
|
||||
documents: {
|
||||
method: 'Post' as const,
|
||||
server: 'documents' as const,
|
||||
client: () => '/collector/documents',
|
||||
},
|
||||
};
|
|
@ -0,0 +1,39 @@
|
|||
import { IComment, IDocument } from '../models';
|
||||
|
||||
export const CommentApiDefinition = {
|
||||
/**
|
||||
* 新建评论
|
||||
*/
|
||||
add: {
|
||||
method: 'Post' as const,
|
||||
server: 'add' as const,
|
||||
client: () => '/comment/add',
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新评论
|
||||
*/
|
||||
update: {
|
||||
method: 'Patch' as const,
|
||||
server: 'update' as const,
|
||||
client: () => '/comment/update',
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
delete: {
|
||||
method: 'Delete' as const,
|
||||
server: 'delete/:id' as const,
|
||||
client: (id: IComment['id']) => `/comment/delete/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取指定文档评论
|
||||
*/
|
||||
documents: {
|
||||
method: 'Get' as const,
|
||||
server: 'document/:documentId' as const,
|
||||
client: (documentId: IDocument['id']) => `/comment/document/${documentId}`,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,138 @@
|
|||
import { IDocument } from '../models';
|
||||
|
||||
export const DocumentApiDefinition = {
|
||||
/**
|
||||
* 搜索文档
|
||||
*/
|
||||
search: {
|
||||
method: 'Get' as const,
|
||||
server: 'search' as const,
|
||||
client: () => '/document/search',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户最近访问的文档
|
||||
*/
|
||||
recent: {
|
||||
method: 'Get' as const,
|
||||
server: 'recent' as const,
|
||||
client: () => '/document/recent',
|
||||
},
|
||||
|
||||
/**
|
||||
* 新建文档
|
||||
*/
|
||||
create: {
|
||||
method: 'Post' as const,
|
||||
server: 'create' as const,
|
||||
client: () => '/document/create',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取文档详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: 'Get' as const,
|
||||
server: 'detail/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/detail/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新文档
|
||||
*/
|
||||
updateById: {
|
||||
method: 'Patch' as const,
|
||||
server: 'update/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/update/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取文档版本记录
|
||||
*/
|
||||
getVersionById: {
|
||||
method: 'Get' as const,
|
||||
server: 'version/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/version/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取文档成员
|
||||
*/
|
||||
getMemberById: {
|
||||
method: 'Get' as const,
|
||||
server: 'member/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/member/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 添加文档成员
|
||||
*/
|
||||
addMemberById: {
|
||||
method: 'Post' as const,
|
||||
server: 'member/:id/add' as const,
|
||||
client: (id: IDocument['id']) => `/document/member/${id}/add`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新文档成员
|
||||
*/
|
||||
updateMemberById: {
|
||||
method: 'Patch' as const,
|
||||
server: 'member/:id/update' as const,
|
||||
client: (id: IDocument['id']) => `/document/member/${id}/update`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除文档成员
|
||||
*/
|
||||
deleteMemberById: {
|
||||
method: 'Post' as const,
|
||||
server: 'member/:id/delete' as const,
|
||||
client: (id: IDocument['id']) => `/document/member/${id}/delete`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取子文档
|
||||
*/
|
||||
getChildren: {
|
||||
method: 'Get' as const,
|
||||
server: 'children' as const,
|
||||
client: () => `/document/children`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除文档
|
||||
*/
|
||||
deleteById: {
|
||||
method: 'Delete' as const,
|
||||
server: 'delete/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/delete/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享文档
|
||||
*/
|
||||
shareById: {
|
||||
method: 'Post' as const,
|
||||
server: 'share/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/share/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取公开文档详情
|
||||
*/
|
||||
getPublicDetailById: {
|
||||
method: 'Get' as const,
|
||||
server: 'public/detail/:id' as const,
|
||||
client: (id: IDocument['id']) => `/document/public/detail/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取公开文档的子文档
|
||||
*/
|
||||
getPublicChildren: {
|
||||
method: 'Get' as const,
|
||||
server: 'public/children' as const,
|
||||
client: () => `/document/public/children`,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
export const FileApiDefinition = {
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
upload: {
|
||||
method: 'Post' as const,
|
||||
server: 'upload' as const,
|
||||
client: () => '/file/upload',
|
||||
},
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
export * from './user';
|
||||
export * from './wiki';
|
||||
export * from './document';
|
||||
export * from './file';
|
||||
export * from './message';
|
||||
export * from './template';
|
||||
export * from './comment';
|
||||
export * from './collector';
|
|
@ -0,0 +1,39 @@
|
|||
import { IMessage } from '../models';
|
||||
|
||||
export const MessageApiDefinition = {
|
||||
/**
|
||||
* 获取未读消息
|
||||
*/
|
||||
getUnread: {
|
||||
method: 'Get' as const,
|
||||
server: 'unread' as const,
|
||||
client: () => '/message/unread',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取已读消息
|
||||
*/
|
||||
getRead: {
|
||||
method: 'Get' as const,
|
||||
server: 'read' as const,
|
||||
client: () => '/message/read',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取所有消息
|
||||
*/
|
||||
getAll: {
|
||||
method: 'Get' as const,
|
||||
server: 'all' as const,
|
||||
client: () => '/message/all',
|
||||
},
|
||||
|
||||
/**
|
||||
* 将消息标记为已读
|
||||
*/
|
||||
readMessage: {
|
||||
method: 'Post' as const,
|
||||
server: 'read/:id' as const,
|
||||
client: (id: IMessage['id']) => `/message/read/${id}`,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,57 @@
|
|||
import { ITemplate } from '../models';
|
||||
|
||||
export const TemplateApiDefinition = {
|
||||
/**
|
||||
* 获取公开模板
|
||||
*/
|
||||
public: {
|
||||
method: 'Get' as const,
|
||||
server: 'public' as const,
|
||||
client: () => '/template/public',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取个人创建模板
|
||||
*/
|
||||
own: {
|
||||
method: 'Get' as const,
|
||||
server: 'own' as const,
|
||||
client: () => '/template/own',
|
||||
},
|
||||
|
||||
/**
|
||||
* 新建模板
|
||||
*/
|
||||
add: {
|
||||
method: 'Post' as const,
|
||||
server: 'add' as const,
|
||||
client: () => '/template/add',
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新模板
|
||||
*/
|
||||
updateById: {
|
||||
method: 'Patch' as const,
|
||||
server: 'update/:id' as const,
|
||||
client: (id: ITemplate['id']) => `/template/update/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取模板详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: 'Get' as const,
|
||||
server: 'detail/:id' as const,
|
||||
client: (id: ITemplate['id']) => `/template/detail/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除模板
|
||||
*/
|
||||
deleteById: {
|
||||
method: 'Delete' as const,
|
||||
server: 'delete/:id' as const,
|
||||
client: (id: ITemplate['id']) => `/template/delete/${id}`,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,48 @@
|
|||
import { IUser } from '../models';
|
||||
|
||||
export const UserApiDefinition = {
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
getAllUsers: {
|
||||
method: 'Get' as const,
|
||||
server: '/' as const,
|
||||
client: () => '/user',
|
||||
},
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
register: {
|
||||
method: 'Post' as const,
|
||||
server: 'register' as const,
|
||||
client: () => '/user/register',
|
||||
},
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
login: {
|
||||
method: 'Post' as const,
|
||||
server: 'login' as const,
|
||||
client: () => '/user/login',
|
||||
},
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
logout: {
|
||||
method: 'Post' as const,
|
||||
server: 'logout' as const,
|
||||
client: () => '/user/logout',
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
update: {
|
||||
method: 'Patch' as const,
|
||||
server: 'update' as const,
|
||||
client: () => `/user/update`,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,183 @@
|
|||
import { IWiki } from '../models';
|
||||
|
||||
export const WikiApiDefinition = {
|
||||
/**
|
||||
* 获取用户所有知识库(创建的、参与的)
|
||||
*/
|
||||
getAllWikis: {
|
||||
method: 'Get' as const,
|
||||
server: 'list/all' as const,
|
||||
client: () => '/wiki/list/all',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户创建的知识库
|
||||
*/
|
||||
getOwnWikis: {
|
||||
method: 'Get' as const,
|
||||
server: 'list/own' as const,
|
||||
client: () => '/wiki/list/own',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取用户参与的知识库
|
||||
*/
|
||||
getJoinWikis: {
|
||||
method: 'Get' as const,
|
||||
server: 'list/join' as const,
|
||||
client: () => '/wiki/list/join',
|
||||
},
|
||||
|
||||
/**
|
||||
* 新建知识库
|
||||
*/
|
||||
add: {
|
||||
method: 'Post' as const,
|
||||
server: 'add' as const,
|
||||
client: () => '/wiki/add',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取知识库首页文档
|
||||
*/
|
||||
getHomeDocumentById: {
|
||||
method: 'Get' as const,
|
||||
server: 'homedoc/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/homedoc/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取知识库目录
|
||||
*/
|
||||
getTocsById: {
|
||||
method: 'Get' as const,
|
||||
server: 'tocs/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/tocs/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新知识库目录
|
||||
*/
|
||||
updateTocsById: {
|
||||
method: 'Patch' as const,
|
||||
server: 'tocs/:id/update' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/tocs/${id}/update`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取知识库所有文档
|
||||
*/
|
||||
getDocumentsById: {
|
||||
method: 'Get' as const,
|
||||
server: 'documents/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/documents/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取知识库详情
|
||||
*/
|
||||
getDetailById: {
|
||||
method: 'Get' as const,
|
||||
server: 'detail/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/detail/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新知识库
|
||||
*/
|
||||
updateById: {
|
||||
method: 'Patch' as const,
|
||||
server: 'update/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/update/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除知识库
|
||||
*/
|
||||
deleteById: {
|
||||
method: 'Delete' as const,
|
||||
server: 'delet/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/delet/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取知识库成员
|
||||
*/
|
||||
getMemberById: {
|
||||
method: 'Get' as const,
|
||||
server: 'member/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/member/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 添加知识库成员
|
||||
*/
|
||||
addMemberById: {
|
||||
method: 'Post' as const,
|
||||
server: 'member/:id/add' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/member/${id}/add`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新知识库成员
|
||||
*/
|
||||
updateMemberById: {
|
||||
method: 'Patch' as const,
|
||||
server: 'member/:id/update' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/member/${id}/update`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除知识库成员
|
||||
*/
|
||||
deleteMemberById: {
|
||||
method: 'Delete' as const,
|
||||
server: 'member/:id/delete' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/member/${id}/delete`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享知识库
|
||||
*/
|
||||
shareById: {
|
||||
method: 'Post' as const,
|
||||
server: 'share/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/share/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取公开知识库首页文档
|
||||
*/
|
||||
getPublicHomeDocumentById: {
|
||||
method: 'Get' as const,
|
||||
server: '/public/homedoc/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/public/homedoc/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取公开知识库目录
|
||||
*/
|
||||
getPublicTocsById: {
|
||||
method: 'Get' as const,
|
||||
server: '/public/tocs/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/public/tocs/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取知识库详情
|
||||
*/
|
||||
getPublicDetailById: {
|
||||
method: 'Get' as const,
|
||||
server: '/public/detail/:id' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/public/detail/${id}`,
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取所有公开知识库
|
||||
*/
|
||||
getPublicWikis: {
|
||||
method: 'Get' as const,
|
||||
server: '/public/wikis' as const,
|
||||
client: (id: IWiki['id']) => `/wiki/public/wikis`,
|
||||
},
|
||||
};
|
|
@ -1,2 +1,3 @@
|
|||
export * from './models';
|
||||
export * from './util';
|
||||
export * from './api';
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
Body,
|
||||
ClassSerializerInterceptor,
|
||||
Controller,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Post,
|
||||
|
@ -12,40 +13,53 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { CollectorService } from '@services/collector.service';
|
||||
import { CollectorApiDefinition } from '@think/domains';
|
||||
|
||||
@Controller('collector')
|
||||
export class CollectorController {
|
||||
constructor(private readonly collectorService: CollectorService) {}
|
||||
|
||||
/**
|
||||
* 收藏(或取消收藏)
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('toggle')
|
||||
@Post(CollectorApiDefinition.toggle.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async toggleStar(@Request() req, @Body() dto: CollectDto) {
|
||||
return await this.collectorService.toggleStar(req.user, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否收藏
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('check')
|
||||
@Post(CollectorApiDefinition.toggle.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async checkStar(@Request() req, @Body() dto: CollectDto) {
|
||||
return await this.collectorService.isStared(req.user, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收藏的知识库
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('documents')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getDocuments(@Request() req) {
|
||||
return await this.collectorService.getDocuments(req.user);
|
||||
}
|
||||
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('wikis')
|
||||
@Get(CollectorApiDefinition.wikis.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikis(@Request() req) {
|
||||
return await this.collectorService.getWikis(req.user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收藏的文档
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get(CollectorApiDefinition.documents.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getDocuments(@Request() req) {
|
||||
return await this.collectorService.getDocuments(req.user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,12 @@ import {
|
|||
Body,
|
||||
ClassSerializerInterceptor,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
|
@ -15,13 +17,17 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { CommentService } from '@services/comment.service';
|
||||
import { CommentApiDefinition } from '@think/domains';
|
||||
|
||||
@Controller('comment')
|
||||
export class CommentController {
|
||||
constructor(private readonly commentService: CommentService) {}
|
||||
|
||||
/**
|
||||
* 新建评论
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('add')
|
||||
@Post(CommentApiDefinition.add.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async create(@Request() req, @Body() dto: CommentDto) {
|
||||
|
@ -29,24 +35,33 @@ export class CommentController {
|
|||
return await this.commentService.create(req.user, userAgent, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新评论
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('update')
|
||||
@Patch(CommentApiDefinition.update.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async updateComment(@Request() req, @Body() dto: UpdateCommentDto) {
|
||||
return await this.commentService.updateComment(req.user, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('delete/:id')
|
||||
@Delete(CommentApiDefinition.delete.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async deleteComment(@Request() req, @Param('id') documentId) {
|
||||
return await this.commentService.deleteComment(req.user, documentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定文档评论
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('document/:id')
|
||||
@Get(CommentApiDefinition.documents.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getArticleComments(@Param('id') documentId, @Query() qurey) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
|
@ -21,7 +22,7 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { DocumentService } from '@services/document.service';
|
||||
import { DocumentStatus } from '@think/domains';
|
||||
import { DocumentApiDefinition, DocumentStatus } from '@think/domains';
|
||||
|
||||
@Controller('document')
|
||||
@UseGuards(DocumentAuthorityGuard)
|
||||
|
@ -29,8 +30,38 @@ import { DocumentStatus } from '@think/domains';
|
|||
export class DocumentController {
|
||||
constructor(private readonly documentService: DocumentService) {}
|
||||
|
||||
/**
|
||||
* 搜索文档
|
||||
* @param req
|
||||
* @param keyword
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('create')
|
||||
@Get(DocumentApiDefinition.search.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async search(@Request() req, @Query('keyword') keyword) {
|
||||
return await this.documentService.search(req.user, keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户最近访问的文档
|
||||
* @param req
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get(DocumentApiDefinition.recent.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWorkspaceDocuments(@Request() req) {
|
||||
return await this.documentService.getRecentDocuments(req.user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建文档
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post(DocumentApiDefinition.create.server)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@UseGuards(JwtGuard)
|
||||
async createDocument(@Request() req, @Body() dto: CreateDocumentDto) {
|
||||
|
@ -44,7 +75,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('detail/:id')
|
||||
@Get(DocumentApiDefinition.getDetailById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('readable')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -60,7 +91,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('update/:id')
|
||||
@Patch(DocumentApiDefinition.updateById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('editable')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -75,7 +106,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('version/:id')
|
||||
@Get(DocumentApiDefinition.getVersionById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('readable')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -83,66 +114,6 @@ export class DocumentController {
|
|||
return await this.documentService.getDocumentVersion(req.user, documentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档下的子文档
|
||||
* @param req
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('children')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('readable')
|
||||
@UseGuards(JwtGuard)
|
||||
async getChildrenDocuments(@Request() req, @Body() data) {
|
||||
return await this.documentService.getChildrenDocuments(req.user, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档
|
||||
* @param req
|
||||
* @param documentId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Delete('delete/:id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('createUser')
|
||||
@UseGuards(JwtGuard)
|
||||
async deleteDocument(@Request() req, @Param('id') documentId) {
|
||||
return await this.documentService.deleteDocument(req.user, documentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享(或关闭分享)文档
|
||||
* @param req
|
||||
* @param documentId
|
||||
* @param dto
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('share/:id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('editable')
|
||||
@UseGuards(JwtGuard)
|
||||
async shareDocument(@Request() req, @Param('id') documentId, @Body() dto: ShareDocumentDto) {
|
||||
return await this.documentService.shareDocument(req.user, documentId, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索文档
|
||||
* @param req
|
||||
* @param keyword
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('search')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async search(@Request() req, @Query('keyword') keyword) {
|
||||
return await this.documentService.search(req.user, keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档成员
|
||||
* @param req
|
||||
|
@ -150,7 +121,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('user/:id')
|
||||
@Get(DocumentApiDefinition.getMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('readable')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -166,7 +137,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('user/:id/add')
|
||||
@Post(DocumentApiDefinition.addMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('createUser')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -182,7 +153,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('user/:id/update')
|
||||
@Patch(DocumentApiDefinition.updateMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('createUser')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -198,7 +169,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('user/:id/delete')
|
||||
@Post(DocumentApiDefinition.deleteMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('createUser')
|
||||
@UseGuards(JwtGuard)
|
||||
|
@ -207,16 +178,49 @@ export class DocumentController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取用户最近访问的文档
|
||||
* 获取文档下的子文档
|
||||
* @param req
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('recent')
|
||||
@Post(DocumentApiDefinition.getChildren.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('readable')
|
||||
@UseGuards(JwtGuard)
|
||||
async getWorkspaceDocuments(@Request() req) {
|
||||
return await this.documentService.getRecentDocuments(req.user);
|
||||
async getChildrenDocuments(@Request() req, @Body() data) {
|
||||
return await this.documentService.getChildrenDocuments(req.user, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文档
|
||||
* @param req
|
||||
* @param documentId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Delete(DocumentApiDefinition.deleteById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('createUser')
|
||||
@UseGuards(JwtGuard)
|
||||
async deleteDocument(@Request() req, @Param('id') documentId) {
|
||||
return await this.documentService.deleteDocument(req.user, documentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享(或关闭分享)文档
|
||||
* @param req
|
||||
* @param documentId
|
||||
* @param dto
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post(DocumentApiDefinition.shareById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckDocumentAuthority('editable')
|
||||
@UseGuards(JwtGuard)
|
||||
async shareDocument(@Request() req, @Param('id') documentId, @Body() dto: ShareDocumentDto) {
|
||||
return await this.documentService.shareDocument(req.user, documentId, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,7 +231,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('public/detail/:id')
|
||||
@Post(DocumentApiDefinition.getPublicDetailById.server)
|
||||
@CheckDocumentStatus(DocumentStatus.public)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getShareDocumentDetail(@Request() req, @Param('id') documentId, @Body() dto: ShareDocumentDto) {
|
||||
|
@ -240,7 +244,7 @@ export class DocumentController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('public/children')
|
||||
@Post(DocumentApiDefinition.getPublicChildren.server)
|
||||
@CheckDocumentStatus(DocumentStatus.public)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getShareChildrenDocuments(@Body() data) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { JwtGuard } from '@guard/jwt.guard';
|
|||
import { Controller, Post, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { FileService } from '@services/file.service';
|
||||
import { FileApiDefinition } from '@think/domains';
|
||||
|
||||
@Controller('file')
|
||||
export class FileController {
|
||||
|
@ -11,7 +12,7 @@ export class FileController {
|
|||
* 上传文件
|
||||
* @param file
|
||||
*/
|
||||
@Post('upload')
|
||||
@Post(FileApiDefinition.upload.server)
|
||||
@UseInterceptors(
|
||||
FileInterceptor('file', {
|
||||
limits: {
|
||||
|
|
|
@ -13,37 +13,50 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { MessageService } from '@services/message.service';
|
||||
import { MessageApiDefinition } from '@think/domains';
|
||||
|
||||
@Controller('message')
|
||||
export class MessageController {
|
||||
constructor(private readonly messageService: MessageService) {}
|
||||
|
||||
/**
|
||||
* 获取未读消息
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('/unread')
|
||||
@Get(MessageApiDefinition.getUnread.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getUnreadMessages(@Request() req, @Query() query) {
|
||||
return this.messageService.getMessages(req.user, false, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已读消息
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('/read')
|
||||
@Get(MessageApiDefinition.getRead.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getReadMessages(@Request() req, @Query() query) {
|
||||
return this.messageService.getMessages(req.user, true, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有消息
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('/all')
|
||||
@Get(MessageApiDefinition.getAll.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getAllReadMessages(@Request() req, @Query() query) {
|
||||
return this.messageService.getAllMessages(req.user, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将消息标记为已读
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('/read/:id')
|
||||
@Post(MessageApiDefinition.readMessage.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async updateComment(@Request() req, @Param('id') messageId) {
|
||||
|
|
|
@ -4,10 +4,12 @@ import {
|
|||
Body,
|
||||
ClassSerializerInterceptor,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
|
@ -15,55 +17,74 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { TemplateService } from '@services/template.service';
|
||||
import { TemplateApiDefinition } from '@think/domains';
|
||||
|
||||
@Controller('template')
|
||||
export class TemplateController {
|
||||
constructor(private readonly templateService: TemplateService) {}
|
||||
|
||||
/**
|
||||
* 获取公开模板
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('add')
|
||||
@Get(TemplateApiDefinition.public.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getPublicTemplates(@Query() qurey) {
|
||||
return this.templateService.getPublicTemplates(qurey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人创建模板
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get(TemplateApiDefinition.own.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getOwnTemplates(@Request() req, @Query() qurey) {
|
||||
return this.templateService.getOwnTemplates(req.user, qurey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建模板
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post(TemplateApiDefinition.add.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async create(@Request() req, @Body() dto: TemplateDto) {
|
||||
return await this.templateService.create(req.user, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模板
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('update')
|
||||
@Patch(TemplateApiDefinition.updateById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async updateTemplat(@Request() req, @Body() dto: TemplateDto & { id: string }) {
|
||||
return await this.templateService.updateTemplate(req.user, dto.id, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模板详情
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('delete/:id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async deleteTemplat(@Request() req, @Param('id') documentId) {
|
||||
return await this.templateService.deleteTemplate(req.user, documentId);
|
||||
}
|
||||
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('detail/:id')
|
||||
@Get(TemplateApiDefinition.getDetailById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getTemplate(@Request() req, @Param('id') id) {
|
||||
return this.templateService.getTemplate(req.user, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('public')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getPublicTemplates(@Query() qurey) {
|
||||
return this.templateService.getPublicTemplates(qurey);
|
||||
}
|
||||
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('own')
|
||||
@Delete(TemplateApiDefinition.deleteById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getOwnTemplates(@Request() req, @Query() qurey) {
|
||||
return this.templateService.getOwnTemplates(req.user, qurey);
|
||||
async deleteTemplat(@Request() req, @Param('id') documentId) {
|
||||
return await this.templateService.deleteTemplate(req.user, documentId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,21 +17,39 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { UserApiDefinition } from '@think/domains';
|
||||
import { Response as ExpressResponse } from 'express';
|
||||
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
constructor(private readonly userService: UserService) {}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('register')
|
||||
@Get(UserApiDefinition.getAllUsers.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getUsers() {
|
||||
return this.userService.getUsers();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post(UserApiDefinition.register.server)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
async register(@Body() user: CreateUserDto) {
|
||||
return await this.userService.createUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('login')
|
||||
@Post(UserApiDefinition.login.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async login(@Body() user: LoginUserDto, @Res({ passthrough: true }) response: ExpressResponse) {
|
||||
const { user: data, token } = await this.userService.login(user);
|
||||
|
@ -39,25 +57,23 @@ export class UserController {
|
|||
return { ...data, token };
|
||||
}
|
||||
|
||||
@Get('logout')
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
@Get(UserApiDefinition.logout.server)
|
||||
async logout(@Res({ passthrough: true }) response: ExpressResponse) {
|
||||
response.cookie('token', '', { expires: new Date() });
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Patch('update')
|
||||
@Patch(UserApiDefinition.update.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async updateUser(@Request() req, @Body() dto: UpdateUserDto) {
|
||||
return await this.userService.updateUser(req.user, dto);
|
||||
}
|
||||
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('/')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getUsers() {
|
||||
return this.userService.getUsers();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,26 +22,12 @@ import {
|
|||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { WikiService } from '@services/wiki.service';
|
||||
import { IPagination, WikiStatus, WikiUserRole } from '@think/domains';
|
||||
import { IPagination, WikiApiDefinition, WikiStatus, WikiUserRole } from '@think/domains';
|
||||
|
||||
@Controller('wiki')
|
||||
export class WikiController {
|
||||
constructor(private readonly wikiService: WikiService) {}
|
||||
|
||||
/**
|
||||
* 新建知识库
|
||||
* @param req
|
||||
* @param dto
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('create')
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@UseGuards(JwtGuard)
|
||||
async register(@Request() req, @Body() dto: CreateWikiDto) {
|
||||
return await this.wikiService.createWiki(req.user, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户所有知识库(创建的、参与的)
|
||||
* @param req
|
||||
|
@ -49,7 +35,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('list/all')
|
||||
@Get(WikiApiDefinition.getAllWikis.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getAllWikis(@Request() req, @Query() pagination: IPagination) {
|
||||
|
@ -63,7 +49,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('list/own')
|
||||
@Get(WikiApiDefinition.getOwnWikis.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getOwnWikis(@Request() req, @Query() pagination: IPagination) {
|
||||
|
@ -77,7 +63,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('list/join')
|
||||
@Get(WikiApiDefinition.getJoinWikis.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(JwtGuard)
|
||||
async getJoinWikis(@Request() req, @Query() pagination: IPagination) {
|
||||
|
@ -85,19 +71,17 @@ export class WikiController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取知识库详情
|
||||
* 新建知识库
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @param dto
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('detail/:id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@Post(WikiApiDefinition.add.server)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikiDetail(@Request() req, @Param('id') wikiId) {
|
||||
return await this.wikiService.getWikiDetail(req.user, wikiId);
|
||||
async register(@Request() req, @Body() dto: CreateWikiDto) {
|
||||
return await this.wikiService.createWiki(req.user, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,7 +91,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('homedoc/:id')
|
||||
@Get(WikiApiDefinition.getHomeDocumentById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -116,6 +100,71 @@ export class WikiController {
|
|||
return await this.wikiService.getWikiHomeDocument(req.user, wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取知识库目录
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get(WikiApiDefinition.getTocsById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikiTocs(@Request() req, @Param('id') wikiId) {
|
||||
return await this.wikiService.getWikiTocs(req.user, wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新知识库目录(排序、父子关系)
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @param relations
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Patch(WikiApiDefinition.updateTocsById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async orderWikiTocs(@Body() relations) {
|
||||
return await this.wikiService.orderWikiTocs(relations);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取知识库所有文档
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get(WikiApiDefinition.getDocumentsById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikiDocs(@Request() req, @Param('id') wikiId) {
|
||||
return await this.wikiService.getWikiDocs(req.user, wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取知识库详情
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get(WikiApiDefinition.getDetailById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikiDetail(@Request() req, @Param('id') wikiId) {
|
||||
return await this.wikiService.getWikiDetail(req.user, wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改知识库
|
||||
* 只有管理员可操作
|
||||
|
@ -125,7 +174,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Patch('update/:id')
|
||||
@Patch(WikiApiDefinition.updateById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -142,7 +191,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Delete('delete/:id')
|
||||
@Delete(WikiApiDefinition.deleteById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -159,7 +208,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('user/:id')
|
||||
@Get(WikiApiDefinition.getMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -177,7 +226,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('user/:id/add')
|
||||
@Post(WikiApiDefinition.addMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -195,7 +244,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('user/:id/update')
|
||||
@Patch(WikiApiDefinition.updateMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -213,7 +262,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('user/:id/delete')
|
||||
@Delete(WikiApiDefinition.deleteMemberById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -231,7 +280,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('share/:id')
|
||||
@Post(WikiApiDefinition.shareById.server)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole(WikiUserRole.admin)
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
|
@ -240,59 +289,6 @@ export class WikiController {
|
|||
return await this.wikiService.shareWiki(req.user, wikiId, dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取知识库目录
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('tocs/:id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikiTocs(@Request() req, @Param('id') wikiId) {
|
||||
const sleep = (v) => {
|
||||
return new Promise((r) => setTimeout(r, v * 1000));
|
||||
};
|
||||
await sleep(4);
|
||||
return await this.wikiService.getWikiTocs(req.user, wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新知识库目录(排序、父子关系)
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @param relations
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('tocs/:id/update')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async orderWikiTocs(@Body() relations) {
|
||||
return await this.wikiService.orderWikiTocs(relations);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取知识库所有文档
|
||||
* @param req
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('docs/:id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@CheckWikiUserRole()
|
||||
@UseGuards(WikiUserRoleGuard)
|
||||
@UseGuards(JwtGuard)
|
||||
async getWikiDocs(@Request() req, @Param('id') wikiId) {
|
||||
return await this.wikiService.getWikiDocs(req.user, wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公开知识库首页文档
|
||||
* @param req
|
||||
|
@ -300,7 +296,7 @@ export class WikiController {
|
|||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Get('public/homedoc/:id')
|
||||
@Get(WikiApiDefinition.getPublicHomeDocumentById.server)
|
||||
@CheckWikiStatus(WikiStatus.public)
|
||||
@UseGuards(WikiStatusGuard)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
|
@ -308,20 +304,6 @@ export class WikiController {
|
|||
return await this.wikiService.getPublicWikiHomeDocument(wikiId, req.headers['user-agent']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公开知识库详情
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post('public/detail/:id')
|
||||
@CheckWikiStatus(WikiStatus.public)
|
||||
@UseGuards(WikiStatusGuard)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getPublicWorkspaceDetail(@Param('id') wikiId) {
|
||||
return await this.wikiService.getPublicWikiDetail(wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公开知识库目录
|
||||
* @param wikiId
|
||||
|
@ -329,13 +311,27 @@ export class WikiController {
|
|||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('public/tocs/:id')
|
||||
@Post(WikiApiDefinition.getPublicTocsById.server)
|
||||
@CheckWikiStatus(WikiStatus.public)
|
||||
@UseGuards(WikiStatusGuard)
|
||||
async getPublicWikiTocs(@Param('id') wikiId) {
|
||||
return await this.wikiService.getPublicWikiTocs(wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公开知识库详情
|
||||
* @param wikiId
|
||||
* @returns
|
||||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@Post(WikiApiDefinition.getPublicDetailById.server)
|
||||
@CheckWikiStatus(WikiStatus.public)
|
||||
@UseGuards(WikiStatusGuard)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getPublicWorkspaceDetail(@Param('id') wikiId) {
|
||||
return await this.wikiService.getPublicWikiDetail(wikiId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有公开知识库
|
||||
* @param pagination
|
||||
|
@ -343,7 +339,7 @@ export class WikiController {
|
|||
*/
|
||||
@UseInterceptors(ClassSerializerInterceptor)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Get('public/wikis')
|
||||
@Get(WikiApiDefinition.getPublicWikis.server)
|
||||
async getAllPublicWikis(@Query() pagination: IPagination) {
|
||||
return await this.wikiService.getAllPublicWikis(pagination);
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ importers:
|
|||
eslint: 8.14.0
|
||||
eslint-config-prettier: 8.5.0_eslint@8.14.0
|
||||
eslint-plugin-import: 2.26.0_eslint@8.14.0
|
||||
eslint-plugin-prettier: 4.0.0_740be41c8168d0cc214a306089357ad0
|
||||
eslint-plugin-prettier: 4.0.0_74ebb802163a9b4fa8f89d76ed02f62a
|
||||
eslint-plugin-react: 7.29.4_eslint@8.14.0
|
||||
eslint-plugin-react-hooks: 4.5.0_eslint@8.14.0
|
||||
eslint-plugin-simple-import-sort: 7.0.0_eslint@8.14.0
|
||||
|
@ -5415,6 +5415,22 @@ packages:
|
|||
prettier-linter-helpers: 1.0.0
|
||||
dev: true
|
||||
|
||||
/eslint-plugin-prettier/4.0.0_74ebb802163a9b4fa8f89d76ed02f62a:
|
||||
resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
peerDependencies:
|
||||
eslint: '>=7.28.0'
|
||||
eslint-config-prettier: '*'
|
||||
prettier: '>=2.0.0'
|
||||
peerDependenciesMeta:
|
||||
eslint-config-prettier:
|
||||
optional: true
|
||||
dependencies:
|
||||
eslint: 8.14.0
|
||||
eslint-config-prettier: 8.5.0_eslint@8.14.0
|
||||
prettier-linter-helpers: 1.0.0
|
||||
dev: true
|
||||
|
||||
/eslint-plugin-react-hooks/4.5.0_eslint@8.14.0:
|
||||
resolution: {integrity: sha512-8k1gRt7D7h03kd+SAAlzXkQwWK22BnK6GKZG+FJA6BAGy22CFvl8kCIXKpVux0cCxMWDQUPqSok0LKaZ0aOcCw==}
|
||||
engines: {node: '>=10'}
|
||||
|
|
Loading…
Reference in New Issue