Commit d4255207 authored by ml's avatar ml

修改

parent 8f986c86
import * as aclPositionService from "../service/aclPosition.service";
import { AclAuthVO, AclAuthPageVO, AclRolePageVO, AclRoleVO } from "../service/aclRoleAuth.service";
import { getCurrentUserId, } from "../../../utils/aclUserUtils";
import { ErrorCode } from "../../../constant/errorCode";
import { AclAuthPageVO, } from "../service/aclRoleAuth.service";
let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } = require('@madex/ex-js-public');
let { logger, Res3Utils, } = require('@madex/ex-js-public');
/**
* 列表
......
......@@ -62,7 +62,7 @@ export const update = async (req: any, aclUserInfoVO: AclUserInfoVO) => {
};
/**
* 修改用户状态
* 修改用户状态(目前没用,需要启用的话可能需要调整逻辑,增加日志)
* @param req
* @param infoVO
*/
......@@ -81,7 +81,7 @@ export const updateStatus = async (req: any, aclUserInfoVO: AclUserInfoVO) => {
};
/**
* 重置密码
* 重置密码 (目前没用,需要启用的话可能需要调整逻辑,增加日志)
* @param req
* @param infoVO
*/
......@@ -147,3 +147,23 @@ async function updatePreCheck(aclUserInfoVO: AclUserInfoVO) {
}
}
/**
* 分页查询用户操作日志列表
* @param req
* @param infoVO
*/
export const optLogList = async (req: any, aclUserInfoPageVO: AclUserInfoPageVO) => {
let func_name = "aclUserCtrl.optLogList";
let cmd = req.path;
try {
aclUserInfoPageVO.page = Optional.opt(aclUserInfoPageVO, 'page', 1);
aclUserInfoPageVO.size = Optional.opt(aclUserInfoPageVO, 'size', 20);
let res = await aclUserService.optLogList(aclUserInfoPageVO);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
......@@ -5,7 +5,7 @@ let { logger, Res3Utils, optionalUtils: Optional, apiAssertUtils: ApiAssert } =
import { ErrorCode } from "../../../constant/errorCode";
/**
* Madex 用户操作日志列表
* Madex 用户操作日志列表 (目前没用)
* @param req
* @param infoVO
*/
......
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { madAdminOrmDB, aclDepartment, aclUserDepartmentPosition, aclPosition, aclUserInfo } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { getOneAclUserByUid } from "../../../utils/aclUserUtils";
import * as userOptLogService from "./userOptLog.service";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog, } from "./userOptLog.service";
let _ = require("lodash");
......@@ -131,7 +129,7 @@ export const add = async function (aclDepartmentVO: AclDepartmentVO, currentUser
updatedAt: new Date(),
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},新增部门:${JSON.stringify(aclDepartmentVO)}`, LogType.ADD);
addOptLog(currentUserId, 0, '新增部门', ip, JSON.stringify(aclDepartmentVO), '组织结构');
return 'success'
}
......@@ -180,7 +178,7 @@ export const update = async function (aclDepartmentVO: AclDepartmentVO, currentU
}
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},修改部门:${JSON.stringify(aclDepartmentVO)}`, LogType.UPDATE);
addOptLog(currentUserId, 0, '修改部门', ip, JSON.stringify(aclDepartmentVO), '组织结构');
return 'success'
}
......@@ -214,7 +212,7 @@ export const del = async function (id: number, currentUserId: any, ip: string |
}
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},删除部门:${JSON.stringify(dbInfo)}`, LogType.DEL);
addOptLog(currentUserId, 0, '删除部门', ip, JSON.stringify(dbInfo), '组织结构');
return 'success'
}
......@@ -302,7 +300,7 @@ export const getUserList = async function (aclDepartmentPageVO: AclDepartmentPag
async function getDpUserPageData(dIds: string, page: number, size: number, uids: number[]) {
let where = {};
if (dIds) {
where['department_id'] = {[madAdminOrmDB.Op.like]:`${dIds}%`};
where['department_id'] = { [madAdminOrmDB.Op.like]: `${dIds}%` };
}
if (uids.length) {
where['user_id'] = { [madAdminOrmDB.Op.in]: uids }
......
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { madAdminOrmDB, aclPosition } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { getOneAclUserByUid } from "../../../utils/aclUserUtils";
import * as userOptLogService from "./userOptLog.service";
let { logger } = require('@madex/ex-js-public');
import { aclPosition } from "@madex/ex-ts-dao";
export const getAllPosition = async function () {
......
......@@ -2,7 +2,7 @@
import { madAdminOrmDB, aclAuth, aclUserRole, aclRoleAuth, aclRole } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { getOneAclUserByUid } from "../../../utils/aclUserUtils";
import * as userOptLogService from "./userOptLog.service";
import { addOptLog } from "./userOptLog.service";
let { logger } = require('@madex/ex-js-public');
......@@ -164,7 +164,7 @@ export const saveAuth = async (aclAuthVO: AclAuthVO, session_id: any) => {
await _checkUrl(aclAuthVO.url);
aclAuth.prototype.create(aclAuthVO);
}
userOptLogService.addOptLog(null, `save auth : ${JSON.stringify(aclAuthVO)}`, userOptLogService.LogType.SAVE, '', session_id);
addOptLog(null, 0, '新增/修改权限', "", JSON.stringify(aclAuthVO), '权限管理', session_id);
return "ok";
};
......@@ -212,7 +212,7 @@ export const delAuth = async (id: number | undefined, session_id: any) => {
}
throw e
}
userOptLogService.addOptLog(null, `del auth : ${JSON.stringify(exist)}`, userOptLogService.LogType.DEL, '', session_id);
addOptLog(null, 0, '删除权限', "", JSON.stringify(exist), '权限管理', session_id);
return "ok"
};
......@@ -277,7 +277,7 @@ export const saveRole = async (aclRoleVO: AclRoleVO) => {
})
}
userOptLogService.addOptLog(aclRoleVO.creator, `save role : ${JSON.stringify(aclRoleVO)}`, userOptLogService.LogType.SAVE, '');
addOptLog(aclRoleVO.creator, 0, '保存角色', "", JSON.stringify(aclRoleVO), '后台角色管理');
return "ok";
};
......@@ -333,7 +333,8 @@ export const delRole = async (id: number | any, currentUserId: number) => {
}
throw e
}
userOptLogService.addOptLog(currentUserId, `del role : ${JSON.stringify(exist)}`, userOptLogService.LogType.DEL, '');
addOptLog(currentUserId, 0, '删除角色', "", JSON.stringify(exist), '后台角色管理');
return "ok"
};
......@@ -430,7 +431,7 @@ export const changeRoleAuth = async (id: number | any, authIds: any, session_id:
throw e
}
}
userOptLogService.addOptLog(null, `change role auth : role_id : ${id}, authIds : ${authIds}`, userOptLogService.LogType.UPDATE, '', session_id);
addOptLog(null, 0, '修改角色权限', "", `role_id:${id},authIds:${authIds}`, '后台角色管理', session_id);
return "ok"
......@@ -523,7 +524,8 @@ export const changeUserRole = async (userId: number | any, roleIds: any, session
throw e
}
}
userOptLogService.addOptLog(null, `change user role : user_id : ${userId}, roleIds : ${roleIDArr}`, userOptLogService.LogType.UPDATE, '', session_id);
addOptLog(null, userId, '修改用户角色', "", `user_id:${userId},roleIds:${roleIDArr}`, '后台用户管理', session_id);
return "ok"
};
......
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { madAdminOrmDB, aclUserInfo, ormDB, aclUserDepartmentPosition, aclUserRole } from "@madex/ex-ts-dao";
import { madAdminOrmDB, aclUserInfo, ormDB, aclUserDepartmentPosition, aclUserRole, aclUserOptLog } from "@madex/ex-ts-dao";
import { AclUserInfoConst } from "../../../constant/aclUserConstant";
import { CryptUtils } from "../../../utils/crypt-utils";
import { ErrorCode } from "../../../constant/errorCode";
import { getDepartmentPositionByUids, getOneAclUserByAccount, getOneAclUserByUid } from "../../../utils/aclUserUtils";
import * as userOptLogService from "./userOptLog.service";
import { changeUserRoleWithTx, getUserRoleListByUids } from "./aclRoleAuth.service";
import { _deleteAllSessionByUserId } from "./userAuthConfig.service";
import { addOptLog } from "./userOptLog.service";
let { logger } = require('@madex/ex-js-public');
let { authCommon: AuthCommon, redisUtilsCommon: RedisClient, } = require('@madex/ex-js-common');
......@@ -59,6 +59,12 @@ export interface AclUserInfoPageVO extends AclUserInfoVO {
page?: number,
size?: number
condition?: string
from_time?: Date | any;
to_time?: Date | any;
}
export const list = async (aclUserInfoPageVO: AclUserInfoPageVO) => {
......@@ -135,10 +141,11 @@ export const add = async (aclUserInfoVO: AclUserInfoVO, session_id: any) => {
}
let tx;
let insertUser;
try {
tx = await madAdminOrmDB.transaction();
//创建用户
let insertUser = await aclUserInfo.prototype.create(insertInfo, {
insertUser = await aclUserInfo.prototype.create(insertInfo, {
transaction: tx
});
//保存部门和职位
......@@ -176,7 +183,8 @@ export const add = async (aclUserInfoVO: AclUserInfoVO, session_id: any) => {
}
throw e;
}
userOptLogService.addOptLog(null, `add user : ${JSON.stringify(aclUserInfoVO)}`, userOptLogService.LogType.ADD, '', session_id);
addOptLog(null, insertUser.user_id, '新增管理后台用户', "", JSON.stringify(aclUserInfoVO), '后台用户管理', session_id);
return 'ok';
};
......@@ -258,7 +266,7 @@ export const update = async (aclUserInfoVO: AclUserInfoVO, session_id: any) => {
if (aclUserInfoVO.totp_encrypt != dbInfo.totp_encrypt) {
_deleteAllSessionByUserId(Number(aclUserInfoVO.user_id));
}
userOptLogService.addOptLog(null, `update user : ${JSON.stringify(aclUserInfoVO)}`, userOptLogService.LogType.UPDATE, '', session_id);
addOptLog(null, Number(aclUserInfoVO.user_id), '修改管理后台用户', "", JSON.stringify(aclUserInfoVO), '后台用户管理', session_id);
return 'ok';
};
......@@ -277,7 +285,6 @@ export const updateStatus = async (aclUserInfoVO: AclUserInfoVO, session_id: any
user_id: userId
}
});
userOptLogService.addOptLog(null, `update status : ${JSON.stringify(aclUserInfoVO)}`, userOptLogService.LogType.UPDATE, '', session_id);
return 'ok';
};
......@@ -298,7 +305,6 @@ export const resetPwd = async (aclUserInfoVO: AclUserInfoVO, session_id: any) =>
user_id: userId
}
});
userOptLogService.addOptLog(null, `reset pwd : ${JSON.stringify(aclUserInfoVO)}`, userOptLogService.LogType.UPDATE, '', session_id);
return 'ok';
};
......@@ -344,4 +350,37 @@ async function dealReturnData(rows: any) {
}
export const optLogList = async (aclUserInfoPageVO: AclUserInfoPageVO) => {
if (!aclUserInfoPageVO.condition) {
throw ErrorCode.PARAM_MISS
}
let where = {}
if (!isNaN(Number(aclUserInfoPageVO.condition))) {
where = {
user_id: Number(aclUserInfoPageVO.condition),
}
}
else {
where = {
module: { [madAdminOrmDB.Op.like]: `%${aclUserInfoPageVO.condition}%` },
}
}
if (aclUserInfoPageVO.from_time && aclUserInfoPageVO.to_time){
where['createdAt'] = { [ormDB.Op.between]: [aclUserInfoPageVO.from_time, aclUserInfoPageVO.to_time] }
}
let page = Number(aclUserInfoPageVO.page);
let size = Number(aclUserInfoPageVO.size);
let res = await aclUserOptLog.prototype.findAndCount({
where: where,
limit: size,
offset: (page - 1) * size,
order: [["createdAt", "desc"]],
raw: true
});
return res;
};
import { ormDB, usefulLink, commonUserFeeSetting, feeRateContractLog, feeRateBaseCoinContractLog, feeRateSpotLog } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog } from "./userOptLog.service";
import { COMMENT_USER_FEE_SUBMIT, FEE_STATUS, FEE_TYPE } from "../../../constant/marketMakerConst";
import { SYMBOL_ALL } from "../../../constant/symbolConst";
......@@ -135,7 +135,7 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any,
await commonUserFeeSetting.prototype.bulkCreate(insertList);
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},新增用户手续费:${JSON.stringify(commonUserFeeVO)}`, LogType.ADD);
addOptLog(currentUserId, Number(commonUserFeeVO.user_id), '新增用户手续费', ip, JSON.stringify(commonUserFeeVO), '费率管理');
}
......@@ -173,7 +173,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
})
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},修改用户手续费:${JSON.stringify(commonUserFeeVO)}`, LogType.UPDATE);
addOptLog(currentUserId, Number(commonUserFeeVO.user_id), '修改用户手续费', ip, JSON.stringify(commonUserFeeVO), '费率管理');
}
......@@ -200,7 +200,8 @@ export async function del(id: number, currentUserId: any, ip: string | undefined
}
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},删除用户手续费:${JSON.stringify(id)}`, LogType.DEL);
addOptLog(currentUserId, Number(dbInfo.user_id), '删除用户手续费', ip, JSON.stringify(dbInfo), '费率管理');
return 'success'
}
......@@ -282,7 +283,8 @@ export async function del(id: number, currentUserId: any, ip: string | undefined
}
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},删除用户手续费:${JSON.stringify(id)}`, LogType.DEL);
addOptLog(currentUserId, Number(dbInfo.user_id), '删除用户手续费', ip, JSON.stringify(dbInfo), '费率管理');
return 'success';
}
......@@ -392,7 +394,8 @@ export async function submit(id: number, currentUserId: any, ip: string | undefi
throw e;
}
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},提交用户手续费:${JSON.stringify(id)}`, LogType.ADD);
addOptLog(currentUserId, Number(dbInfo.user_id), '提交用户手续费', ip, JSON.stringify(dbInfo), '费率管理');
return 'success'
......
import { ormDB, usefulLink, userMailLog, userSub } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog, } from "./userOptLog.service";
import { sendEmail } from "../../../utils/mUserUtils";
import { TYPE_MAIL } from "../../../constant/statusConst";
......@@ -111,7 +111,8 @@ export async function mailSend(userMailLogVO: UserMailLogVO, currentUserId: any,
updatedAt: new Date(),
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},发送订阅邮件:${JSON.stringify(insertInfo)}`, LogType.SUB_MAIL_SEND);
addOptLog(currentUserId, Number(insertInfo.user_id), '发送订阅邮件', ip, JSON.stringify(insertInfo), '邮件和PUSH');
return insertInfo;
}
......@@ -158,7 +159,8 @@ export async function maiSendGroup(subject: string, content: string, currentUser
logger.error(`maiSendGroup.bulkCreate.error:` + e);
}
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},群发邮件:主题:${JSON.stringify(subject)},用户:${uids}`, LogType.SUB_MAIL_SEND_GROUP);
addOptLog(currentUserId, 0, '群发邮件', ip, `主题:${JSON.stringify(subject)},用户:${uids}`, '邮件和PUSH');
return "success"
}
......
......@@ -7,7 +7,7 @@ import { getMUserInfoByEmail, getMUserInfoByUid, getUserInfoMapByUids, sendEmail
import { existEmail, getProcessingEmailListByMUserId } from "./mUserAccountChangeLog.service";
import { AFTER_MODIFIED_MAILBOX_TIP, EMAIL_FORBID_TEMPLATE } from "../../../constant/emailTemplateType";
import { addLog, MUserLogType } from "./mUserOptLog.service";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog } from "./userOptLog.service";
import { checkTotp } from "../../../utils/aclUserUtils";
import { getFatherUserId, getUidsByFatherUid } from "./mUserInfoSon.service";
import { recordMUserOperateLog, TYPE } from "./mUserAccountOperateLog.service";
......@@ -191,7 +191,8 @@ export async function updateUserEmail(currentUserId: number, m_user_id: any, ema
//记录Madex的用户自己的日志
addLog(m_user_id, MUserLogType.UP_EMAIL, ip, currentUserId, `运营修改用户邮箱为:${email}`);
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},修改用户:${m_user_id} 邮箱,原邮箱: ${dbEmail},新邮箱:${email}`, LogType.UPDATE_MUSER_EMAIL);
addOptLog(currentUserId, Number(m_user_id), '修改用户邮箱', ip, `原邮箱: ${dbEmail},新邮箱:${email}`, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(m_user_id, currentUserId, TYPE.MAIL, `ip:${ip},修改邮箱`, dbEmail, email);
return 'success';
......@@ -241,7 +242,8 @@ export async function lockAccount(currentUserId: number, m_user_id: any, ip: any
}
//管理后台操作日志
addOptLog(currentUserId, comment, LogType.LOCK_MUSER);
addOptLog(currentUserId, Number(m_user_id), '锁定用户', ip, comment, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(fatherUserId, currentUserId, TYPE.ACCOUNT_STATUS, comment, "0", "1");
......@@ -297,7 +299,7 @@ export async function unlockAccount(currentUserId: number, m_user_id: any, ip: a
}
//管理后台操作日志
addOptLog(currentUserId, comment, LogType.UNLOCK_MUSER);
addOptLog(currentUserId, Number(m_user_id), '解锁用户', ip, comment, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(fatherUserId, currentUserId, TYPE.ACCOUNT_STATUS, comment, "1", "0");
......@@ -311,7 +313,8 @@ export async function clearLoginLimit(currentUserId: number, m_user_id: any, ip:
await redisUtilsCommon.delSync(m_user_id + MUserRedisKey.USER_LOCK_SUFFIX);
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},清除用户登陆限制:${m_user_id}`, LogType.CLEAR_LOGIN_LIMIT);
addOptLog(currentUserId, Number(m_user_id), '清除用户登陆限制', ip, "", '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(m_user_id, currentUserId, TYPE.TWO_HOUR_LIMIT, `ip:${ip},清除用户登陆限制:${m_user_id}`, "", "");
......@@ -333,7 +336,8 @@ export async function clear24WithdrawLimit(currentUserId: number, m_user_id: any
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},清除用户24小时提现限制:${m_user_id}`, LogType.WITHDRAW_24_LIMIT);
addOptLog(currentUserId, Number(m_user_id), '清除用户24小时提现限制', ip, "", '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(m_user_id, currentUserId, TYPE.TWENTY_FOUR_HOUR_LIMIT, `ip:${ip},清除用户24小时提现限制:${m_user_id}`, "", "");
......
......@@ -5,7 +5,7 @@ import * as ossUtils from "../../../utils/OSSUtils";
import { getMUserInfoByUid, sendEmail } from "../../../utils/mUserUtils";
import { EMAIL_FORBID_TEMPLATE, REAL_NAME_DENY, REAL_NAME_PASS } from "../../../constant/emailTemplateType";
import { KYC_STATUS, SETTING_FLAG } from "../../../constant/mUserInfoConst";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog, } from "./userOptLog.service";
import { recordMUserOperateLog, TYPE } from "./mUserAccountOperateLog.service";
import { isNaN } from "lodash";
......@@ -238,8 +238,8 @@ export async function audit(queryVO: QueryVO, currentUserId: any, ip: string | u
//发邮件
sendEmail(dbEmail, dbUserInfo.user_id, template);
//日志记录
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},实名认证审核:${dbUserInfo.user_id}${remark}`, LogType.KYC_AUDIT);
addOptLog(currentUserId, Number(dbUserInfo.user_id), '实名认证审核', ip, remark, '用户管理');
//管理后台操作Madex 用户的日志
recordMUserOperateLog(dbUserInfo.user_id, currentUserId, TYPE.KYC, `ip:${ip},实名认证审核:${dbUserInfo.user_id}${remark}`, "", "");
return 'success';
......
import { ormDB, usefulLink, userSub } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog, } from "./userOptLog.service";
let _ = require('lodash');
......@@ -69,7 +69,7 @@ export async function del(id: number, currentUserId: any, ip: string | undefined
}
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},删除用户订阅:${JSON.stringify(dbInfo)}`, LogType.DEL);
addOptLog(currentUserId, Number(dbInfo.user_id), '删除用户订阅', ip, dbInfo, '邮件和PUSH');
return 'success'
}
......
import { ormDB, usefulLink } from "@madex/ex-ts-dao";
import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog, LogType } from "./userOptLog.service";
import { addOptLog, } from "./userOptLog.service";
let _ = require('lodash');
......@@ -78,7 +78,8 @@ export async function add(usefulLinkVO: UsefulLinkVO, currentUserId: any, ip: st
//日志
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},添加链接记录:${JSON.stringify(dbInfo.id)}`, LogType.ADD);
addOptLog(currentUserId, 0, '添加链接记录', ip, JSON.stringify(dbInfo.id), '活动位管理');
return 'success'
}
......@@ -135,7 +136,8 @@ export async function update(usefulLinkVO: UsefulLinkVO, currentUserId: any, ip:
}
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},修改链接记录:原记录:${JSON.stringify(dbInfo.id)}`, LogType.UPDATE);
addOptLog(currentUserId, 0, '修改链接记录', ip, JSON.stringify(dbInfo.id), '活动位管理');
return 'success'
}
......@@ -159,7 +161,8 @@ export async function del(id: number, currentUserId: any, ip: string | undefined
}
});
//管理后台操作日志
addOptLog(currentUserId, `ip:${ip},删除链接记录:${JSON.stringify(dbInfo.id)}`, LogType.DEL);
addOptLog(currentUserId, 0, '删除链接记录', ip, JSON.stringify(dbInfo.id), '活动位管理');
return 'success'
}
......
......@@ -11,6 +11,7 @@ import { RedisVal } from "../../../constant/redis-val";
import Config from "../../../../config";
import * as userOptLogService from "./userOptLog.service";
import { getRoleByUser, getUserAclAndTree } from "../service/aclRoleAuth.service";
import { addOptLog } from "./userOptLog.service";
const Otplib = require('otplib');
......@@ -106,7 +107,7 @@ export const getInfoDetailByUserId = async (user_id: number | any) => {
};
export async function login(account: any, pwd: any, s: string) {
export async function login(account: any, pwd: any, ip: string) {
let userInfo = await getOneAclUserByAccount(account);
ApiAssert.isNotEmpty(ErrorCode.ACCOUNT_OR_PWD_ERR, userInfo);
......@@ -149,7 +150,7 @@ export async function login(account: any, pwd: any, s: string) {
await _unlockPwd(userInfo.user_id);
userOptLogService.addOptLog(userInfo.user_id, `user login`, userOptLogService.LogType.LOGIN, '');
addOptLog(userInfo.user_id, 0, '用户登录', ip, "", '登录');
return {
result: "success",
......@@ -219,7 +220,6 @@ export async function updatePwd(userId: any, originPwd: any, newPwd: any) {
user_id: userId
}
});
userOptLogService.addOptLog(userInfo.user_id, `update self pwd`, userOptLogService.LogType.UPDATE, '');
return 'success';
}
......@@ -266,7 +266,8 @@ export async function bindTotpConfirm(sessionId: any, userId: any, totpCode: any
cookies.needConfirm = 0
await RedisClient.writeSync(sessionId, cookies, Config.LOGIN_EXPIRED)
}
userOptLogService.addOptLog(null, `bind totp`, userOptLogService.LogType.TOTP, '', sessionId);
addOptLog(null, 0, '绑定谷歌', "", "", '绑定谷歌',sessionId);
return "success"
}
......
......@@ -4,40 +4,37 @@ import { getCurrentUserId } from "../../../utils/aclUserUtils";
let { logger } = require('@madex/ex-js-public');
export const LogType = {
DEFAULT: 0,//默认
LOGIN: 1,//登陆
ADD: 2,//添加
UPDATE: 3,//修改
DEL: 4,//删除
TOTP: 5,//谷歌
SAVE: 6,//保存(添加或修改)
UPDATE_MUSER_EMAIL: 7,//修改 Madex 用户邮箱
LOCK_MUSER: 8,//锁定用户
UNLOCK_MUSER: 9,//解锁用户
CLEAR_LOGIN_LIMIT: 10,//清除用户登陆限制
WITHDRAW_24_LIMIT: 11,//清除用户24小时限制
KYC_AUDIT: 12,//用户实名认证审核
SUB_MAIL_SEND: 13,//邮件订阅发送
SUB_MAIL_SEND_GROUP: 14,//邮件订阅群发
}
export const addOptLog = async function (user_id: any, msg: any, type: any, fail_reason?: any, session_id?: any) {
/**
*
* @param current_user_id 当前登陆用户的ID
* @param opt_user_id 操作的目标用户的UID
* @param opt_info 操作信息(添加、修改、审核、删除...)
* @param ip ip (传空的话,就默认 0.0.0.0)
* @param opt_detail 操作详情
* @param module 操作模块
* @param session_id session_id 可选 有 current_user_id 无需传
*/
export const addOptLog = async function (current_user_id: number | any, opt_user_id: number,
opt_info: string, ip: string | any, opt_detail: string, module: string, session_id?: any) {
try {
if ((!user_id && !session_id) || !msg) {
throw 'user_id or session_id or msg is null'
if ((!current_user_id && !session_id)) {
throw 'current_user_id or session_id or opt_detail is null'
}
if (!user_id) {
user_id = await getCurrentUserId(session_id);
if (!current_user_id) {
current_user_id = await getCurrentUserId(session_id);
}
let detail = {
ip: ip ? ip : '0.0.0.0',
detail: opt_detail ? opt_detail : ''
}
await aclUserOptLog.prototype.create({
user_id: user_id,
msg: msg,
type: type ? type : LogType.DEFAULT,
user_id: current_user_id,
opt_user_id: opt_user_id ? opt_user_id : 0,
opt_info: opt_info ? opt_info : "",
opt_detail: JSON.stringify(detail),
module: module ? module : "",
createdAt: new Date(),
updatedAt: new Date(),
fail_reason: fail_reason ? fail_reason : ''
})
}
catch (e) {
......
......@@ -84,6 +84,7 @@ const postFunc = {
'acl/user/update': aclUserCtrl.update,
'acl/user/checkTotpCode': aclUserCtrl.checkTotpCode,
'acl/changeUserRole': aclRoleAuthCtrl.changeUserRole,
'acl/user/opt/log/list': aclUserCtrl.optLogList,
'user/login': userOptCtrl.login,
'user/logout': userOptCtrl.logout,
......
......@@ -56,6 +56,7 @@ let cmdWhiteList = {
'acl/user/update': 1,
'acl/user/checkTotpCode': 1,
'acl/changeUserRole': 1,
'acl/user/opt/log/list': 1,
'user/login': 1,
'user/logout': 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment