mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
题目搜索,收藏功能
This commit is contained in:
1 parent
a248425db6
commit
441eeadaf3
23 files changed
+158
-97
No files matched your search
@@ -123,8 +123,11 @@ function getStatus(domainId, did, uid) {
|
||||
return document.getStatus(domainId, document.TYPE_DISCUSSION, did, uid);
|
||||
}
|
||||
|
||||
function addNode(domainId, _id, category) {
|
||||
return document.add(domainId, category, 1, document.TYPE_DISCUSSION_NODE, _id);
|
||||
function addNode(domainId, _id, category, args) {
|
||||
return document.add(
|
||||
domainId, category, 1, document.TYPE_DISCUSSION_NODE,
|
||||
_id, null, null, args,
|
||||
);
|
||||
}
|
||||
|
||||
function getNode(domainId, _id) {
|
||||
@@ -166,6 +169,10 @@ async function getVnode(domainId, ddoc, handler) {
|
||||
};
|
||||
}
|
||||
|
||||
function getNodes(domainId) {
|
||||
return document.getMulti(domainId, document.TYPE_DISCUSSION_NODE).toArray();
|
||||
}
|
||||
|
||||
async function getListVnodes(domainId, ddocs, handler) {
|
||||
const tasks = [];
|
||||
const res = {};
|
||||
@@ -201,6 +208,7 @@ global.Hydro.model.discussion = module.exports = {
|
||||
setStar,
|
||||
getStatus,
|
||||
addNode,
|
||||
getNodes,
|
||||
getVnode,
|
||||
getListVnodes,
|
||||
};
|
||||
+1
-1
@@ -15,7 +15,7 @@ function _timestamp() {
|
||||
async function add(streamOrPath, filename, meta = {}) {
|
||||
if (typeof streamOrPath === 'string') streamOrPath = fs.createReadStream(streamOrPath);
|
||||
const w = gridfs.openUploadStream(filename);
|
||||
await coll.insertOne({ ...meta, _id: w.id });
|
||||
await coll.insertOne({ ...meta, _id: w.id, secret: String.random(32) });
|
||||
await new Promise((resolve, reject) => {
|
||||
w.on('error', reject);
|
||||
w.on('finish', resolve);
|
||||
|
||||
@@ -31,7 +31,6 @@ async function add(domainId, title, content, owner, {
|
||||
}) {
|
||||
const d = await domain.inc(domainId, 'pidCounter', 1);
|
||||
if (!pid) pid = d.pidCounter.toString();
|
||||
// eslint-disable-next-line no-return-await
|
||||
return await document.add(
|
||||
domainId, content, owner, document.TYPE_PROBLEM, d.pidCounter, null, null,
|
||||
{
|
||||
@@ -47,6 +46,7 @@ async function add(domainId, title, content, owner, {
|
||||
* @returns {Promise<Pdoc>}
|
||||
*/
|
||||
async function get(domainId, pid, uid = null, doThrow = true) {
|
||||
if (!Number.isNaN(parseInt(pid, 10))) pid = parseInt(pid, 10);
|
||||
const pdoc = Number.isInteger(pid)
|
||||
? await document.get(domainId, document.TYPE_PROBLEM, pid)
|
||||
: (await document.getMulti(domainId, document.TYPE_PROBLEM, { pid }).toArray())[0];
|
||||
@@ -95,7 +95,7 @@ function getMultiStatus(domainId, query) {
|
||||
* @param {string} domainId
|
||||
* @param {ObjectID} _id
|
||||
* @param {object} query
|
||||
* @returns {Pdoc}
|
||||
* @returns {Promise<Pdoc>}
|
||||
*/
|
||||
function edit(domainId, _id, $set) {
|
||||
return document.set(domainId, document.TYPE_PROBLEM, _id, $set);
|
||||
@@ -156,6 +156,10 @@ async function updateStatus(domainId, pid, uid, rid, status) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function setStar(domainId, pid, uid, star) {
|
||||
return document.setStatus(domainId, document.TYPE_PROBLEM, pid, uid, { star });
|
||||
}
|
||||
|
||||
async function setTestdata(domainId, _id, filePath) {
|
||||
const pdoc = await get(domainId, _id);
|
||||
const config = await readConfig(filePath);
|
||||
@@ -176,6 +180,7 @@ global.Hydro.model.problem = module.exports = {
|
||||
getList,
|
||||
getListStatus,
|
||||
getMultiStatus,
|
||||
setStar,
|
||||
setTestdata,
|
||||
updateStatus,
|
||||
};
|
||||
@@ -102,6 +102,7 @@ SystemSetting(
|
||||
Setting('setting_server', 'server.host', null, null, 'text', 'Server Host'),
|
||||
Setting('setting_server', 'server.url', null, null, 'text', 'Server BaseURL'),
|
||||
Setting('setting_server', 'server.port', null, 8888, 'number', 'Server Port'),
|
||||
Setting('setting_server', 'server.log', null, false, 'checkbox', 'Disable Access Log'),
|
||||
Setting('setting_oauth', 'oauth.githubappid', null, null, 'text', 'Github Oauth AppID'),
|
||||
Setting('setting_oauth', 'oauth.githubsecret', null, null, 'text', 'Github Oauth Secret'),
|
||||
Setting('setting_oauth', 'oauth.googleappid', null, null, 'text', 'Google Oauth ClientID'),
|
||||
|
||||
Reference in new issue
Block a user