Skip to content

Commit

Permalink
Merge pull request #913 from pxgo/master
Browse files Browse the repository at this point in the history
调整、添加、修复
  • Loading branch information
pxgo authored Sep 5, 2023
2 parents ab348ba + 6055e4d commit 01e9b4d
Show file tree
Hide file tree
Showing 411 changed files with 17,724 additions and 12,658 deletions.
2 changes: 1 addition & 1 deletion dataModels/AccountBehaviorModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ schema.statics.ensurePermission = async (options) => {
const {
type, username, ip, mobile, nationCode, email
} = options;
const redLock = require("../nkcModules/redLock");
const { redLock } = require("../nkcModules/redLock");
const lock = await redLock.lock(`accountBehaviorPermission:${type}`, 6000);
try{
const {
Expand Down
44 changes: 44 additions & 0 deletions dataModels/ActivationCodeModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const mongoose = require('../settings/database');
const collectionName = 'activationCodes';
const schema = new mongoose.Schema(
{
_id: String,
toc: {
type: Date,
default: Date.now,
index: 1,
},
used: {
type: Boolean,
default: false,
index: 1,
},
// 激活码的来源,考试系统, 管理员等
source: {
type: String,
required: true,
},
// 来源ID
sid: {
type: String,
required: true,
},
uid: {
type: String,
default: '',
},
timeOfUse: {
type: Date,
default: null,
},
expiration: {
type: Date,
required: true,
},
},
{
collection: collectionName,
},
);

module.exports = mongoose.model(collectionName, schema);
7 changes: 4 additions & 3 deletions dataModels/ArticleModel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const mongoose = require('../settings/database');
const moment = require('moment');
const tools = require('../nkcModules/tools');
const { subscribeSources } = require('../settings/subscribe');

const articleSources = {
column: 'column',
Expand Down Expand Up @@ -374,7 +375,7 @@ schema.statics.changeKey = async (content) => {
* */
schema.statics.getNewId = async () => {
const ArticleModel = mongoose.model('articles');
const redLock = require('../nkcModules/redLock');
const { redLock } = require('../nkcModules/redLock');
const getRedisKeys = require('../nkcModules/getRedisKeys');
const { getRandomString } = require('../nkcModules/apiFunction');
const key = getRedisKeys('newArticleId');
Expand Down Expand Up @@ -1599,9 +1600,9 @@ schema.methods.addArticleHits = async function () {
schema.statics.getCollectedCountByAid = async function (aid) {
const SubscribeModel = mongoose.model('subscribes');
return await SubscribeModel.countDocuments({
type: 'article',
source: subscribeSources.collectionArticle,
cancel: false,
tid: aid,
sid: aid,
});
};

Expand Down
9 changes: 5 additions & 4 deletions dataModels/ColumnModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mongoose = require('../settings/database');
const { ThrowServerInternalError } = require('../nkcModules/error');
const moment = require('moment');
const Schema = mongoose.Schema;
const {subscribeSources} = require('../settings/subscribe')
const schema = new Schema(
{
_id: Number,
Expand Down Expand Up @@ -541,8 +542,8 @@ schema.methods.getSubscriptionTrends = async function (minTime, maxTime) {
let sub = await SubscribeModel.aggregate([
{
$match: {
type: 'column',
columnId: columnId,
source: subscribeSources.column,
sid: columnId,
toc: {
$gte: _minTime,
$lt: _maxTime,
Expand All @@ -566,8 +567,8 @@ schema.methods.getSubscriptionTrends = async function (minTime, maxTime) {
let unsub = await SubscribeModel.aggregate([
{
$match: {
type: 'column',
columnId: columnId,
source: subscribeSources.column,
sid: columnId,
tlm: {
$gte: _minTime,
$lt: _maxTime,
Expand Down
2 changes: 1 addition & 1 deletion dataModels/CommentModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ schema.methods.updateCommentsVote = async function () {
* */
schema.statics.getNewId = async () => {
const CommentModel = mongoose.model('comments');
const redLock = require('../nkcModules/redLock');
const { redLock } = require('../nkcModules/redLock');
const getRedisKeys = require('../nkcModules/getRedisKeys');
const { getRandomString } = require('../nkcModules/apiFunction');
const key = getRedisKeys('newArticleId');
Expand Down
Loading

0 comments on commit 01e9b4d

Please sign in to comment.