后台:添加操作日志
This commit is contained in:
@@ -980,4 +980,18 @@ export enum GM_API_TYPE {
|
||||
del = 'del', // 删
|
||||
update = 'update', // 改
|
||||
find = 'find', // 查
|
||||
}
|
||||
|
||||
export enum LOG_TYPE {
|
||||
LOGIN = 'login', // 登录
|
||||
LOGINOUT = 'logout', // 登出
|
||||
CE_CHANGE = 'ceChange', // 战力变化
|
||||
PAY = 'pay', // 充值
|
||||
ITEM_CHANGE = 'itemChange', // 道具变动
|
||||
RECEIVE_MAIL = 'receiveMail', // 领取邮件
|
||||
}
|
||||
|
||||
export enum CE_CHANGE_REASON {
|
||||
HERO = 'hero', // 武将
|
||||
|
||||
}
|
||||
@@ -140,6 +140,11 @@ export default class GMMail extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getGmMailByIdAndType(_id: string, mailType: GM_MAIL_TYPE, hasGoods: boolean) {
|
||||
const result: GMMailType = await GMMailModel.findOne({ _id, mailType, hasGoods }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
private static getSearchObj(form: SearchMailParam) {
|
||||
let searchObj = {};
|
||||
if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart * 1000) };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, ReturnModelType, mongoose } from '@typegoose/typegoose';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { SearchLogParam } from '../domain/backEndField/search';
|
||||
|
||||
/**
|
||||
* GM用户组接口
|
||||
@@ -22,6 +23,9 @@ export default class GMRecord extends BaseModel {
|
||||
@prop({ required: true })
|
||||
apiName: string;
|
||||
|
||||
@prop({ required: true })
|
||||
apiModule: string;
|
||||
|
||||
@prop({ required: true })
|
||||
body: string;
|
||||
|
||||
@@ -30,10 +34,28 @@ export default class GMRecord extends BaseModel {
|
||||
|
||||
public static async createRecord(uid: number, env: string, api: string, body: string, result: string) {
|
||||
let dicApi = gameData.apiByUrl.get(api);
|
||||
const r = await GMRecordModel.insertMany({uid, env, api, apiName: dicApi?.name, body, result});
|
||||
const r = await GMRecordModel.insertMany({uid, env, api, apiName: dicApi?.name, apiModule: dicApi?.module, body, result});
|
||||
return r;
|
||||
}
|
||||
|
||||
private static getSearchObj(form: SearchLogParam) {
|
||||
let searchObj = {};
|
||||
if (form.env) searchObj['env'] = form.env;
|
||||
if (form.uid) searchObj['uid'] = form.uid;
|
||||
if (form.apiModule) searchObj['apiModule'] = form.apiModule;
|
||||
if (form.api) searchObj['api'] = form.api;
|
||||
if (form.createTimeStart && form.createTimeEnd) {
|
||||
searchObj['createdAt'] = { $lte: new Date(form.createTimeEnd * 1000), $gte: new Date(form.createTimeStart * 100) };
|
||||
}
|
||||
return searchObj
|
||||
}
|
||||
|
||||
public static async findByCondition(page: number, pageSize: number, form: SearchLogParam = {}) {
|
||||
let searchObj = GMRecordModel.getSearchObj(form);
|
||||
const result: GMRecordType[] = await GMRecordModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort({ createdAt: -1 }).select('-_id').lean({ getters: true, virtuals: true });
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export let GMRecordModel: ReturnModelType<typeof GMRecord, {}>;
|
||||
|
||||
104
shared/db/UserLog.ts
Normal file
104
shared/db/UserLog.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
class Reward {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
@prop({ required: true })
|
||||
count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家充值订单
|
||||
*/
|
||||
@index({ localOrderID: 1 })
|
||||
|
||||
export default class UserLog extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
type: string; // 类型 LOG_TYPE
|
||||
|
||||
@prop({ required: true })
|
||||
uid: number; // uid
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色id
|
||||
|
||||
@prop({ required: true })
|
||||
roleName: string; // 角色名
|
||||
|
||||
@prop({ required: false })
|
||||
ip: string; // ip
|
||||
|
||||
// 战力相关
|
||||
@prop({ required: false })
|
||||
inc: number; // 改变值 战力改变/道具数量改变
|
||||
|
||||
@prop({ required: false })
|
||||
count: number; // 变化后的值 战力改变/道具数量改变
|
||||
|
||||
@prop({ required: false })
|
||||
ceChangeReason: number; // 战力变化原因
|
||||
|
||||
@prop({ required: false })
|
||||
ceChangeReasonInfo: string; // 战力变化原因信息,如武将id等
|
||||
|
||||
// 充值相关
|
||||
@prop({ required: false })
|
||||
productId: string; // 商品id
|
||||
|
||||
@prop({ required: false })
|
||||
productName: string; // 商品名字
|
||||
|
||||
@prop({ required: false })
|
||||
price: number; // 充值金额
|
||||
|
||||
@prop({ required: false })
|
||||
isYuanbao: boolean; // 是否为代币
|
||||
|
||||
@prop({ required: false })
|
||||
localOrderId: string; // 订单id
|
||||
|
||||
@prop({ required: false })
|
||||
totalPay: number; // 总充值金额
|
||||
|
||||
@prop({ required: false })
|
||||
orderStatus: number; // 订单状态
|
||||
|
||||
// 道具相关
|
||||
@prop({ required: false })
|
||||
itemId: number; // 道具id
|
||||
|
||||
@prop({ required: false })
|
||||
itemName: string; // 道具名
|
||||
|
||||
@prop({ required: false })
|
||||
itid: number; // 道具类型
|
||||
|
||||
@prop({ required: false })
|
||||
itemChangeModule: string; // 道具变更模块
|
||||
|
||||
@prop({ required: false })
|
||||
itemChangeReason: number; // 道具变更来源
|
||||
|
||||
// 邮件日志
|
||||
@prop({ required: false })
|
||||
mailId: string; // 邮件id
|
||||
|
||||
@prop({ required: false, type: Reward, _id: false })
|
||||
goods: Reward[]; // 邮件附带道具
|
||||
|
||||
@prop({ required: false })
|
||||
mailContent: string; // 邮件正文
|
||||
|
||||
@prop({ required: false })
|
||||
mailTitle: string; // 邮件标题
|
||||
|
||||
@prop({ required: false })
|
||||
mailSendName: string; // 邮件发件人
|
||||
}
|
||||
|
||||
export const UserLogModel = getModelForClass(UserLog);
|
||||
|
||||
export interface UserLogModelType extends Pick<DocumentType<UserLog>, keyof UserLog> { }
|
||||
export type UserLogModelTypeParam = Partial<UserLogModelType>; // 将所有字段变成可选项
|
||||
@@ -71,4 +71,13 @@ export interface SearchGiftCodeDetailParam {
|
||||
code?: string;
|
||||
roleId?: string;
|
||||
roleName?: string;
|
||||
}
|
||||
|
||||
export interface SearchLogParam {
|
||||
env?: string;
|
||||
apiModule?: string;
|
||||
api?: string;
|
||||
createTimeStart?: number;
|
||||
createTimeEnd?: number;
|
||||
uid?: number;
|
||||
}
|
||||
3
shared/pubUtils/logUtil.ts
Normal file
3
shared/pubUtils/logUtil.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function saveUserLog() {
|
||||
|
||||
}
|
||||
@@ -471,7 +471,7 @@
|
||||
{
|
||||
"id": 68,
|
||||
"api": "/api/mail/getcreatesinglemailtxt",
|
||||
"name": "获取火箭单人无道具邮件列表",
|
||||
"name": "获取创建单人无道具邮件列表",
|
||||
"module": "mail",
|
||||
"type": "find"
|
||||
},
|
||||
@@ -554,146 +554,167 @@
|
||||
},
|
||||
{
|
||||
"id": 80,
|
||||
"api": "gm.gmHandler.sendMail",
|
||||
"name": "发送邮件",
|
||||
"api": "gm.gmHandler.sendSingleMail",
|
||||
"name": "审批单人有道具邮件",
|
||||
"module": "mail",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 81,
|
||||
"api": "gm.gmHandler.sendSingleMailTxt",
|
||||
"name": "审批单人无道具邮件",
|
||||
"module": "mail",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 82,
|
||||
"api": "gm.gmHandler.sendServerMail",
|
||||
"name": "审批全服有道具邮件",
|
||||
"module": "mail",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 83,
|
||||
"api": "gm.gmHandler.sendServerMailTxt",
|
||||
"name": "审批全服无道具邮件",
|
||||
"module": "mail",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 84,
|
||||
"api": "gm.gmHandler.setGuildActivityDebug",
|
||||
"name": "开启军团活动",
|
||||
"module": "guildactivity",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 82,
|
||||
"id": 85,
|
||||
"api": "gm.gmHandler.cancelGuildActivityDebug",
|
||||
"name": "取消军团活动",
|
||||
"module": "guildactivity",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 83,
|
||||
"id": 86,
|
||||
"api": "/api/game/getregions",
|
||||
"name": "获取所有大区",
|
||||
"module": "server",
|
||||
"type": "find"
|
||||
},
|
||||
{
|
||||
"id": 84,
|
||||
"id": 87,
|
||||
"api": "/api/game/getservers",
|
||||
"name": "获取所有小区",
|
||||
"module": "server",
|
||||
"type": "find"
|
||||
},
|
||||
{
|
||||
"id": 85,
|
||||
"id": 88,
|
||||
"api": "/api/game/getregionstategy",
|
||||
"name": "获取大区策略",
|
||||
"module": "server",
|
||||
"type": "find"
|
||||
},
|
||||
{
|
||||
"id": 86,
|
||||
"id": 89,
|
||||
"api": "/api/game/getwhitelist",
|
||||
"name": "获取白名单",
|
||||
"module": "server",
|
||||
"type": "find"
|
||||
},
|
||||
{
|
||||
"id": 87,
|
||||
"id": 90,
|
||||
"api": "/api/game/updatewhitelist",
|
||||
"name": "更新白名单",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 88,
|
||||
"id": 91,
|
||||
"api": "/api/game/deletewhitelist",
|
||||
"name": "删除白名单",
|
||||
"module": "server",
|
||||
"type": "delete"
|
||||
},
|
||||
{
|
||||
"id": 89,
|
||||
"id": 92,
|
||||
"api": "/api/game/stopserverregister",
|
||||
"name": "小区停止注册",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 90,
|
||||
"id": 93,
|
||||
"api": "/api/game/swicthserverstatus",
|
||||
"name": "切换服务器状态",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 91,
|
||||
"id": 94,
|
||||
"api": "gm.gmServerHandler.saveRegionConf",
|
||||
"name": "保存大区设置",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 92,
|
||||
"id": 95,
|
||||
"api": "gm.gmServerHandler.createNewServer",
|
||||
"name": "手动开服",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 93,
|
||||
"id": 96,
|
||||
"api": "gm.gmServerHandler.startMaintenance",
|
||||
"name": "开始维护",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 94,
|
||||
"id": 97,
|
||||
"api": "gm.gmServerHandler.startRegionMaintenance",
|
||||
"name": "开始大区维护",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 95,
|
||||
"id": 98,
|
||||
"api": "gm.gmServerHandler.stopMaintenance",
|
||||
"name": "停止维护",
|
||||
"module": "server",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 96,
|
||||
"id": 99,
|
||||
"api": "/api/upload/hotupdate",
|
||||
"name": "上传热更新",
|
||||
"module": "upload",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 97,
|
||||
"id": 100,
|
||||
"api": "/api/upload/uploadjson",
|
||||
"name": "上传json",
|
||||
"module": "upload",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 98,
|
||||
"id": 101,
|
||||
"api": "/web/reloadresource",
|
||||
"name": "加载资源(web)",
|
||||
"module": "upload",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 99,
|
||||
"id": 102,
|
||||
"api": "/api/upload/reloadresource",
|
||||
"name": "加载资源(后台)",
|
||||
"module": "upload",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 100,
|
||||
"id": 103,
|
||||
"api": "gm.gmHandler.reloadResource",
|
||||
"name": "加载资源(游戏)",
|
||||
"module": "upload",
|
||||
|
||||
Reference in New Issue
Block a user