军团数据库表
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
import {Application, BackendSession, pinus} from 'pinus';
|
||||||
|
|
||||||
|
export default function(app: Application) {
|
||||||
|
return new GuildHandler(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GuildHandler {
|
||||||
|
constructor(private app: Application) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO创建军团
|
||||||
|
async createGuild() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO 获取军团列表
|
||||||
|
async getGuildList() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -110,7 +110,7 @@ export class PvpHandler {
|
|||||||
refOppCnt = oldSeasonData.refOppCnt;
|
refOppCnt = oldSeasonData.refOppCnt;
|
||||||
challengeCnt = oldSeasonData.challengeCnt;
|
challengeCnt = oldSeasonData.challengeCnt;
|
||||||
challengeRefTime = oldSeasonData.challengeRefTime;
|
challengeRefTime = oldSeasonData.challengeRefTime;
|
||||||
} else if(show) {
|
} else if (show) {
|
||||||
await PvpSeasonResultModel.updatePvpSeasonResult(roleId, {show: false});
|
await PvpSeasonResultModel.updatePvpSeasonResult(roleId, {show: false});
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
var Redlock = require('redlock');
|
||||||
|
var RedisService = module.exports;
|
||||||
|
|
||||||
|
export class RedlockService {
|
||||||
|
_redisClient: any;
|
||||||
|
ttl: number;
|
||||||
|
redlock: any;
|
||||||
|
constructor(redisClient) {
|
||||||
|
this._redisClient = redisClient;
|
||||||
|
this._redisClient.on("error", function (err) {
|
||||||
|
console.error("Redis:Error:" + err);
|
||||||
|
});
|
||||||
|
this.ttl = 1000;
|
||||||
|
this.redlock = new Redlock(
|
||||||
|
[this._redisClient],
|
||||||
|
{
|
||||||
|
// the expected clock drift; for more details
|
||||||
|
// see http://redis.io/topics/distlock
|
||||||
|
driftFactor: 0.01, // time in ms
|
||||||
|
|
||||||
|
// the max number of times Redlock will attempt
|
||||||
|
// to lock a resource before erroring
|
||||||
|
retryCount: 10,
|
||||||
|
|
||||||
|
// the time in ms between attempts
|
||||||
|
retryDelay: 200, // time in ms
|
||||||
|
|
||||||
|
// the max time in ms randomly added to retries
|
||||||
|
// to improve performance under high contention
|
||||||
|
// see https://www.awsarchitectureblog.com/2015/03/backoff.html
|
||||||
|
retryJitter: 200 // time in ms
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.redlock.on('clientError', function(err) {
|
||||||
|
console.error('A redis error has occurred:', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getWithModify() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -232,6 +232,7 @@ export async function resetPvpRanks() {
|
|||||||
const client: Redis.RedisClient = pinus.app.get('redis');
|
const client: Redis.RedisClient = pinus.app.get('redis');
|
||||||
await client.delAsync(REDIS_KEY.PVP_RANK);
|
await client.delAsync(REDIS_KEY.PVP_RANK);
|
||||||
let { seasonNum } = await SystemConfigModel.findSystemConfig();
|
let { seasonNum } = await SystemConfigModel.findSystemConfig();
|
||||||
|
console.log('execute season resetPvpRanks seasonNum = ' + seasonNum);
|
||||||
let pvpRank = await PvpDefenseModel.getRank(seasonNum);
|
let pvpRank = await PvpDefenseModel.getRank(seasonNum);
|
||||||
for(let {roleId, role: _role, score, updatedAt } of pvpRank) {
|
for(let {roleId, role: _role, score, updatedAt } of pvpRank) {
|
||||||
let role = <RoleType>_role;
|
let role = <RoleType>_role;
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import BaseModel from './BaseModel';
|
||||||
|
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
||||||
|
import Role from './Role';
|
||||||
|
export interface pvpUpdate {
|
||||||
|
}
|
||||||
|
|
||||||
|
class Building {
|
||||||
|
@prop({ required: true })
|
||||||
|
id: number;
|
||||||
|
@prop({ required: true })
|
||||||
|
lv: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
@index({ roleId: 1 })
|
||||||
|
export default class Guild extends BaseModel {
|
||||||
|
@prop({ required: true })
|
||||||
|
code: string;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
icon: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
lv: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
peopleNum: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
leader: Ref<Role>;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
isAuto: boolean;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
ceCondition: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
notice: string;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
introduce: string;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
fund: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
activeDaily: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
refTimeDaily: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
refTimeWeekly: number;
|
||||||
|
|
||||||
|
@prop({ required: true, type: Building })
|
||||||
|
building: Building[]
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
status:number;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GuildModel = getModelForClass(Guild);
|
||||||
|
|
||||||
|
export interface GuildType extends Pick<DocumentType<Guild>, keyof Guild> { };
|
||||||
Reference in New Issue
Block a user