|
@@ -34,8 +34,10 @@ module.exports = app => {
|
|
/**
|
|
/**
|
|
* 创建登录日志
|
|
* 创建登录日志
|
|
* @return {Boolean} 日志是否创建成功
|
|
* @return {Boolean} 日志是否创建成功
|
|
|
|
+ * @param {Number} type - 登录类型
|
|
|
|
+ * @param {Number} status - 是否显示记录
|
|
*/
|
|
*/
|
|
- async addLoginLog() {
|
|
|
|
|
|
+ async addLoginLog(type, status) {
|
|
const { ctx } = this;
|
|
const { ctx } = this;
|
|
const ip = ctx.request.ip ? ctx.request.ip : '';
|
|
const ip = ctx.request.ip ? ctx.request.ip : '';
|
|
const ipInfo = await this.getIpInfoFromApi(ip);
|
|
const ipInfo = await this.getIpInfoFromApi(ip);
|
|
@@ -50,6 +52,8 @@ module.exports = app => {
|
|
address: ipInfo,
|
|
address: ipInfo,
|
|
uid: ctx.session.sessionUser.accountId,
|
|
uid: ctx.session.sessionUser.accountId,
|
|
pid: ctx.session.sessionProject.id,
|
|
pid: ctx.session.sessionProject.id,
|
|
|
|
+ type,
|
|
|
|
+ show: status,
|
|
};
|
|
};
|
|
return await this.createLog(payload);
|
|
return await this.createLog(payload);
|
|
}
|
|
}
|
|
@@ -122,7 +126,7 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async getLoginLogs(pid, uid) {
|
|
async getLoginLogs(pid, uid) {
|
|
return this.db.select(this.tableName, {
|
|
return this.db.select(this.tableName, {
|
|
- where: { pid, uid },
|
|
|
|
|
|
+ where: { pid, uid, show: 0 },
|
|
orders: [['create_time', 'desc']],
|
|
orders: [['create_time', 'desc']],
|
|
columns: ['browser', 'create_time', 'ip', 'os', 'address'],
|
|
columns: ['browser', 'create_time', 'ip', 'os', 'address'],
|
|
limit: 10, offset: 0,
|
|
limit: 10, offset: 0,
|