后台:权限

This commit is contained in:
luying
2021-12-21 19:42:37 +08:00
parent 151ac33b91
commit 7d0808a9dc
26 changed files with 1009 additions and 818 deletions
+8
View File
@@ -482,6 +482,7 @@ export const FILENAME = {
DIC_WHITE_IP: 'dic_pay_white_ip',
FILTER_WORDS: 'filterWords',
DIC_GUILD_WISH_REWARD: 'dic_army_wishReward',
DIC_API: 'dic_api',
}
export const WAR_RELATE_TABLES = [
@@ -972,4 +973,11 @@ export enum TA_USERSET_TYPE {
export enum TRAIN_REWARD_TYPE {
SCORE = 1, // 练兵场压制积分
ITEM = 2, // 练兵场物品奖励
}
export enum GM_API_TYPE {
add = 'ad', // 增
del = 'del', // 删
update = 'update', // 改
find = 'find', // 查
}
-47
View File
@@ -1,47 +0,0 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';
import { COUNTER } from './../consts';
import { CounterModel } from './Counter';
/**
* 接口字段接口
*/
@index({ apiId: 1 })
@index({ api: 1 })
export default class Api extends BaseModel {
@prop({ required: true })
apiId: number;
@prop({ required: true })
api: string;
@prop({ required: true })
name: string;
public static async getApi(api: string, lean = true) {
let result: ApiType = await ApiModel.findOne({ api }).select('apiId api name').lean(lean);
return result;
}
public static async getAllApi(lean = true) {
const api: ApiType[] = await ApiModel.find().sort({ apiId: 1 }).lean(lean);
return api;
}
public static async createApi(api: string, name: string, lean = true) {
const apiId = await CounterModel.getNewCounter(COUNTER.API);
const result: ApiType = await ApiModel.findOneAndUpdate({ apiId }, { $set: { api, name } }, { upsert: true, new: true }).lean(lean);
return result;
}
}
export let ApiModel: ReturnModelType<typeof Api, {}>;
export function loadApiModel(connect: mongoose.Connection) {
ApiModel = getModelForClass(Api, {
existingConnection: connect
});
}
export interface ApiType extends Pick<DocumentType<Api>, keyof Api> { }
+2 -2
View File
@@ -1,5 +1,5 @@
import { COUNTER } from './../consts';
import { CounterModel } from './Counter';
import { CounterAllModal } from './CounterAll';
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';
const bcrypt = require('bcrypt');
@@ -72,7 +72,7 @@ export default class GMUser extends BaseModel {
}
public static async createGmAccount(username: string, password: string, name: string, token: string, lean = true) {
const uid = await CounterModel.getNewCounter(COUNTER.GMUID);
const uid = await CounterAllModal.getNewCounter(COUNTER.GMUID);
let r = await this.encryptPass(password);
const user: GMUserType = await GMUserModel.findOneAndUpdate({ username }, { uid, password: r.npassword, salt: r.salt, name, token }, { upsert: true, new: true }).select('uid username name').lean(lean);
return user;
+10 -9
View File
@@ -4,30 +4,31 @@ import { index, getModelForClass, prop, DocumentType, ReturnModelType, mongoose
/**
* GM账号和用户组关系接口
*/
@index({ uid: 1, serverId: 1, groupId: 1 })
@index({ uid: 1, groupId: 1 })
@index({ uid: 1, env: 1 })
export default class GMUserGroup extends BaseModel {
@prop({ required: true })
uid: number;
@prop({ required: true })
serverId: number;
@prop({ required: true, type: String })
envs: string[];
@prop({ required: true })
groupId: number;
public static async getUserGroupByUid(uid: number, serverId: number, lean = true) {
const user: GMUserGroupType[] = await GMUserGroupModel.find({uid, serverId}).lean(lean);
public static async getUserGroupByUid(uid: number) {
const user: GMUserGroupType = await GMUserGroupModel.findOne({ uid }).lean();
return user;
}
public static async removeUserGroup(uid: number, serverId: number, groups: Array<number>) {
const user = await GMUserGroupModel.deleteMany({uid, serverId, groupId: {$in: groups}});
public static async removeUserGroup(uid: number, groups: Array<number>) {
const user = await GMUserGroupModel.deleteMany({uid, groupId: {$in: groups}});
return user;
}
public static async addUserGroup(uid: number, serverId: number, groupId: number, lean = true) {
const result: GMUserGroupType = await GMUserGroupModel.findOneAndUpdate({uid, serverId, groupId}, {}, {new:true, upsert:true}).lean(lean);
public static async addUserGroup(uid: number, groupId: number, envs: string[]) {
const result: GMUserGroupType = await GMUserGroupModel.findOneAndUpdate({uid}, { envs, groupId }, {new:true, upsert:true}).lean();
return result;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { COUNTER } from './../consts';
import { CounterModel } from './Counter';
import { CounterAllModal } from './CounterAll';
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';
import ServerStategy from './ServerStategy';
@@ -49,7 +49,7 @@ export default class Region extends BaseModel {
stategy: ServerStategy; // 策略配置
public static async createNewRegion(params: RegionUpdate, uid = 1) {
let id = await CounterModel.getNewCounter(COUNTER.REGION);
let id = await CounterAllModal.getNewCounter(COUNTER.REGION);
const rec: RegionType = await RegionModel.findOneAndUpdate({ id }, { $setOnInsert: { ...params, createdBy: uid}, $set: { updatedBy: uid } }, { new: true, upsert: true }).lean();
return rec;
-2
View File
@@ -1,5 +1,4 @@
import { mongoose } from "@typegoose/typegoose";
import { loadApiModel } from "./Api";
import { loadGMGroupModel } from "./GMGroup";
import { loadGMRecordModel } from "./GMRecord";
import { loadGMUserModel } from './GMUser'
@@ -12,7 +11,6 @@ import { loadMarqueeModel } from "./Marquee";
export function loadGmDb(connect: mongoose.Connection) {
// console.log('************')
loadApiModel(connect);
loadGMGroupModel(connect);
loadGMUserModel(connect);
loadGMUserGroupModel(connect);
+4
View File
@@ -96,6 +96,7 @@ import { dicGuildTrainInfo, loadGuildTrainInfo } from './dictionary/DicGuildTrai
import { dicPvpDifficultRatio, loadPvpDifficultRatio } from './dictionary/DicPvpDifficultRatio';
import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
import { dicGuildWishReward, loadGuildWishReward } from './dictionary/DicGuildWishReward';
import { dicApiById, dicApiByUrl, loadApi } from './dictionary/DicApi';
import { pick } from "underscore";
import _ = require("underscore");
@@ -242,6 +243,8 @@ export const gameData = {
auctionTime: new Map<number, { hour: number, minute: number, seconds: number}>(),
whiteip: dicWhiteIp,
guildWishReward: dicGuildWishReward,
apiById: dicApiById,
apiByUrl: dicApiByUrl,
};
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
@@ -990,6 +993,7 @@ function loadDatas() {
loadWhiteIp();
treatTaskGroup();
loadGuildWishReward();
loadApi();
}
// 重载dicParam
+28
View File
@@ -0,0 +1,28 @@
import { readFileAndParse } from '../util'
import { FILENAME } from '../../consts'
export interface DicApi {
// id
readonly id: number;
// 消耗
readonly api: string;
// 描述
readonly name: string;
// 模块
readonly module: string;
// 类型 增删改查
readonly type: string;
}
export const dicApiByUrl = new Map<string, DicApi>();
export const dicApiById = new Map<number, DicApi>();
export function loadApi() {
dicApiByUrl.clear();
dicApiById.clear();
let arr = readFileAndParse(FILENAME.DIC_API);
arr.forEach(o => {
dicApiByUrl.set(o.api, o);
dicApiById.set(o.id, o);
});
arr = undefined;
}
+702
View File
@@ -0,0 +1,702 @@
[
{
"id": 1,
"api": "/api/login/account",
"name": "登录",
"module": "base",
"type": "update"
},
{
"id": 2,
"api": "/api/login/changeMyPass",
"name": "修改密码",
"module": "base",
"type": "update"
},
{
"id": 3,
"api": "/api/currentUser",
"name": "当前账号",
"module": "base",
"type": "find"
},
{
"id": 4,
"api": "/api/upload/hotupdate",
"name": "上传热更新",
"module": "upload",
"type": "update"
},
{
"id": 5,
"api": "/api/upload/uploadjson",
"name": "上传json",
"module": "upload",
"type": "update"
},
{
"id": 6,
"api": "/api/upload/reloadresource",
"name": "加载资源",
"module": "upload",
"type": "update"
},
{
"id": 7,
"api": "/api/gmaccount/getgmlist",
"name": "获取gm账号列表",
"module": "gmaccount",
"type": "find"
},
{
"id": 8,
"api": "/api/gmaccount/createaccount",
"name": "创建gm账号",
"module": "gmaccount",
"type": "add"
},
{
"id": 9,
"api": "/api/gmaccount/savegmgrouptouser",
"name": "将账号组保存至账号",
"module": "gmaccount",
"type": "update"
},
{
"id": 10,
"api": "/api/gmaccount/getgrouplist",
"name": "获取账号组列表",
"module": "gmaccount",
"type": "find"
},
{
"id": 11,
"api": "/api/gmaccount/getapilist",
"name": "获取api列表",
"module": "gmaccount",
"type": "find"
},
{
"id": 12,
"api": "/api/gmaccount/creategmgroup",
"name": "创建账号组",
"module": "gmaccount",
"type": "add"
},
{
"id": 13,
"api": "/api/gmaccount/savegmgroup",
"name": "保存账号组",
"module": "gmaccount",
"type": "update"
},
{
"id": 14,
"api": "/api/gmaccount/saveapitogroup",
"name": "将api保存至账号组",
"module": "gmaccount",
"type": "update"
},
{
"id": 15,
"api": "/api/users/getuserlist",
"name": "获取玩家账号列表",
"module": "user",
"type": "find"
},
{
"id": 16,
"api": "/api/users/fixsms",
"name": "固定玩家短信",
"module": "user",
"type": "update"
},
{
"id": 17,
"api": "/api/users/getrolelist",
"name": "获取玩家角色列表",
"module": "user",
"type": "find"
},
{
"id": 18,
"api": "/api/users/deleterole",
"name": "删除角色",
"module": "user",
"type": "delete"
},
{
"id": 19,
"api": "/api/users/setwar",
"name": "设置关卡",
"module": "user",
"type": "update"
},
{
"id": 20,
"api": "/api/users/getherolist",
"name": "获取玩家武将列表",
"module": "user",
"type": "find"
},
{
"id": 21,
"api": "/api/users/deletehero",
"name": "删除武将",
"module": "user",
"type": "delete"
},
{
"id": 22,
"api": "/api/users/getequiplist",
"name": "获取玩家装备列表",
"module": "user",
"type": "find"
},
{
"id": 23,
"api": "/api/users/getitemlist",
"name": "获取玩家道具列表",
"module": "user",
"type": "find"
},
{
"id": 24,
"api": "/api/users/getguildlist",
"name": "获取军团列表",
"module": "user",
"type": "find"
},
{
"id": 25,
"api": "/api/users/getmembersbyguildcode",
"name": "获取军团成员列表",
"module": "user",
"type": "find"
},
{
"id": 26,
"api": "/api/users/deleteequip",
"name": "删除装备",
"module": "user",
"type": "delete"
},
{
"id": 27,
"api": "/api/users/deleteitem",
"name": "删除道具",
"module": "user",
"type": "delete"
},
{
"id": 28,
"api": "/api/users/createandgenerategift",
"name": "创建并生成礼包码",
"module": "giftcode",
"type": "add"
},
{
"id": 29,
"api": "/api/users/updategiftcode",
"name": "更新礼包码",
"module": "giftcode",
"type": "update"
},
{
"id": 30,
"api": "/api/users/generategiftcode",
"name": "追加礼包码",
"module": "giftcode",
"type": "update"
},
{
"id": 31,
"api": "/api/users/cancelgiftCode",
"name": "取消礼包码",
"module": "giftcode",
"type": "delete"
},
{
"id": 32,
"api": "/api/users/getgiftcodedetaillist",
"name": "获取礼包码列表",
"module": "giftcode",
"type": "find"
},
{
"id": 33,
"api": "/api/game/getregions",
"name": "获取所有大区",
"module": "server",
"type": "find"
},
{
"id": 34,
"api": "/api/game/getservers",
"name": "获取所有小区",
"module": "server",
"type": "find"
},
{
"id": 35,
"api": "/api/game/getregionstategy",
"name": "获取大区策略",
"module": "server",
"type": "find"
},
{
"id": 36,
"api": "/api/game/getwhitelist",
"name": "获取白名单",
"module": "server",
"type": "find"
},
{
"id": 37,
"api": "/api/game/updatewhitelist",
"name": "更新白名单",
"module": "server",
"type": "update"
},
{
"id": 38,
"api": "/api/game/deletewhitelist",
"name": "删除白名单",
"module": "server",
"type": "delete"
},
{
"id": 39,
"api": "/api/game/stopserverregister",
"name": "小区停止注册",
"module": "server",
"type": "update"
},
{
"id": 40,
"api": "/api/game/swicthserverstatus",
"name": "切换服务器状态",
"module": "server",
"type": "update"
},
{
"id": 41,
"api": "/api/dic/getdicgoods",
"name": "获取物品字典表",
"module": "base",
"type": "find"
},
{
"id": 42,
"api": "/api/dic/getdichero",
"name": "获取武将字典表",
"module": "base",
"type": "find"
},
{
"id": 43,
"api": "/api/dic/getdicrmb",
"name": "获取商品字典表",
"module": "base",
"type": "find"
},
{
"id": 44,
"api": "/api/dic/getdicactivitytype",
"name": "获取活动类型字典表",
"module": "base",
"type": "find"
},
{
"id": 45,
"api": "/api/dic/getdictasktype",
"name": "获取任务类型字典表",
"module": "base",
"type": "find"
},
{
"id": 46,
"api": "/api/dic/getservername",
"name": "获取服务器名称字典表",
"module": "base",
"type": "find"
},
{
"id": 47,
"api": "/api/game/getnoticelist",
"name": "获取公告列表",
"module": "notice",
"type": "find"
},
{
"id": 48,
"api": "/api/game/updatenotice",
"name": "更新公告",
"module": "notice",
"type": "update"
},
{
"id": 49,
"api": "/api/game/delnotice",
"name": "删除公告",
"module": "notice",
"type": "delete"
},
{
"id": 50,
"api": "/api/game/getmarqueelist",
"name": "获取跑马灯列表",
"module": "marquee",
"type": "find"
},
{
"id": 51,
"api": "/api/game/updatemarquee",
"name": "更新跑马灯",
"module": "marquee",
"type": "update"
},
{
"id": 52,
"api": "/api/game/getaccuse",
"name": "获取举报列表",
"module": "accuse",
"type": "find"
},
{
"id": 53,
"api": "/api/activity/getactivitylist",
"name": "获取活动列表",
"module": "activity",
"type": "find"
},
{
"id": 54,
"api": "/api/activity/getallactivities",
"name": "获取所有活动",
"module": "base",
"type": "find"
},
{
"id": 55,
"api": "/api/activity/getactivitygrouplist",
"name": "获取活动组列表",
"module": "activity",
"type": "find"
},
{
"id": 56,
"api": "/api/activity/getallactivitygroups",
"name": "获取所有活动组",
"module": "base",
"type": "find"
},
{
"id": 57,
"api": "/api/activity/creategroup",
"name": "创建活动组",
"module": "activity",
"type": "add"
},
{
"id": 58,
"api": "/api/activity/deletegroup",
"name": "删除活动组",
"module": "activity",
"type": "delete"
},
{
"id": 59,
"api": "/api/activity/getactivitygrouptypelist",
"name": "获取活动组类型列表",
"module": "activity",
"type": "find"
},
{
"id": 60,
"api": "/api/activity/getallactivitygrouptypes",
"name": "获取所有活动组类型",
"module": "base",
"type": "find"
},
{
"id": 61,
"api": "/api/activity/saveactivitygrouptypelist",
"name": "保存活动组类型",
"module": "activity",
"type": "update"
},
{
"id": 62,
"api": "/api/activity/deleteactivitygrouptype",
"name": "删除活动组类型",
"module": "activity",
"type": "delete"
},
{
"id": 63,
"api": "/api/activity/getactivitytaskpoint",
"name": "获取活动和任务对应",
"module": "activity",
"type": "find"
},
{
"id": 64,
"api": "/api/activity/createtasktoactivity",
"name": "创建活动和任务对应点",
"module": "activity",
"type": "add"
},
{
"id": 65,
"api": "/api/activity/updateactivitytaskpoint",
"name": "更新活动和任务对应点",
"module": "activity",
"type": "update"
},
{
"id": 66,
"api": "/api/activity/delactivitytaskpoint",
"name": "删除活动和任务对应点",
"module": "activity",
"type": "delete"
},
{
"id": 67,
"api": "/api/mail/getcreatesinglemail",
"name": "获取创建单人有道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 68,
"api": "/api/mail/getcreatesinglemailtxt",
"name": "获取火箭单人无道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 69,
"api": "/api/mail/getcreateservermail",
"name": "获取创建全服有道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 70,
"api": "/api/mail/getcreateservermailtxt",
"name": "获取创建全服无道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 71,
"api": "/api/mail/getviewsinglemail",
"name": "获取审批单人有道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 72,
"api": "/api/mail/getviewsinglemailtxt",
"name": "获取审批单人无道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 73,
"api": "/api/mail/getviewservermail",
"name": "获取审批全服有道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 74,
"api": "/api/mail/getviewservermailtxt",
"name": "获取审批全服无道具邮件列表",
"module": "mail",
"type": "find"
},
{
"id": 75,
"api": "/api/mail/findrolebyidorname",
"name": "根据玩家名获取玩家",
"module": "base",
"type": "find"
},
{
"id": 76,
"api": "/api/mail/updatesinglemail",
"name": "更新单人有道具邮件",
"module": "mail",
"type": "update"
},
{
"id": 77,
"api": "/api/mail/updatesinglemailtxt",
"name": "更新单人无道具邮件",
"module": "mail",
"type": "update"
},
{
"id": 78,
"api": "/api/mail/updateservermail",
"name": "更新全服有道具邮件",
"module": "mail",
"type": "update"
},
{
"id": 79,
"api": "/api/mail/updateservermailtxt",
"name": "更新全服无道具邮件",
"module": "mail",
"type": "update"
},
{
"id": 80,
"api": "gm.gmHandler.sendMail",
"name": "发送邮件",
"module": "mail",
"type": "update"
},
{
"id": 81,
"api": "gm.gmHandler.reloadResource",
"name": "加载资源",
"module": "upload",
"type": "update"
},
{
"id": 82,
"api": "gm.gmHandler.updateActivity",
"name": "更新活动",
"module": "activity",
"type": "update"
},
{
"id": 83,
"api": "gm.gmHandler.deleteActivity",
"name": "删除活动",
"module": "activity",
"type": "delete"
},
{
"id": 84,
"api": "gm.gmHandler.updateActivityGroup",
"name": "更新活动组",
"module": "activity",
"type": "update"
},
{
"id": 85,
"api": "gm.gmHandler.setGuildActivityDebug",
"name": "开启军团活动",
"module": "guildactivity",
"type": "update"
},
{
"id": 86,
"api": "gm.gmHandler.cancelGuildActivityDebug",
"name": "取消军团活动",
"module": "guildactivity",
"type": "update"
},
{
"id": 87,
"api": "gm.gmRoleHandler.addItems",
"name": "增加道具",
"module": "user",
"type": "update"
},
{
"id": 88,
"api": "gm.gmRoleHandler.handleBlock",
"name": "封禁",
"module": "user",
"type": "update"
},
{
"id": 89,
"api": "gm.gmRoleHandler.updateGuild",
"name": "更新军团",
"module": "guild",
"type": "update"
},
{
"id": 90,
"api": "gm.gmRoleHandler.dismissGuild",
"name": "解散军团",
"module": "guild",
"type": "update"
},
{
"id": 91,
"api": "gm.gmRoleHandler.setGuildLeader",
"name": "设置军团长",
"module": "guild",
"type": "update"
},
{
"id": 92,
"api": "gm.gmServerHandler.saveRegionConf",
"name": "保存大区设置",
"module": "server",
"type": "update"
},
{
"id": 93,
"api": "gm.gmServerHandler.createNewServer",
"name": "手动开服",
"module": "server",
"type": "update"
},
{
"id": 94,
"api": "gm.gmServerHandler.startMaintenance",
"name": "开始维护",
"module": "server",
"type": "update"
},
{
"id": 95,
"api": "gm.gmServerHandler.startRegionMaintenance",
"name": "开始大区维护",
"module": "server",
"type": "update"
},
{
"id": 96,
"api": "gm.gmServerHandler.stopMaintenance",
"name": "停止维护",
"module": "server",
"type": "update"
},
{
"id": 97,
"api": "gm.gmServerHandler.sendMarquee",
"name": "发送跑马灯",
"module": "marquee",
"type": "update"
},
{
"id": 98,
"api": "gm.gmServerHandler.cancelMarquee",
"name": "取消跑马灯",
"module": "marquee",
"type": "update"
},
{
"id": 99,
"api": "/web/reloadresource",
"name": "加载资源",
"module": "upload",
"type": "update"
},
{
"id": 100,
"api": "/api/users/getgiftcodelist",
"name": "获取礼包码列表",
"module": "giftcode",
"type": "find"
}
]