2023-08-27 14:37:59 +08:00
|
|
|
import { Controller } from '@nestjs/common';
|
|
|
|
import { AppService } from './app.service';
|
|
|
|
import { EventPattern } from '@nestjs/microservices';
|
|
|
|
import * as dayjs from 'dayjs';
|
|
|
|
import { SymmetricCrypto } from '@tavi/util';
|
|
|
|
|
|
|
|
interface UserSignLoggerDto {
|
|
|
|
platform: string;
|
|
|
|
username: string;
|
|
|
|
finger: string;
|
|
|
|
finger2: string;
|
|
|
|
isLegal: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Controller()
|
|
|
|
export class AppController {
|
|
|
|
constructor(private readonly appService: AppService) {}
|
|
|
|
|
|
|
|
@EventPattern({ cmd: 'logger.user.signIn' })
|
|
|
|
async userSignIn(payload: UserSignLoggerDto) {
|
|
|
|
const dateTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
const { finger2, ...rest } = payload;
|
|
|
|
const browserInfo = new SymmetricCrypto().decrypt(finger2);
|
|
|
|
console.log({ ...rest, dateTime, browserInfo });
|
|
|
|
return 1;
|
|
|
|
}
|
2023-09-08 14:15:06 +08:00
|
|
|
|
|
|
|
@EventPattern({ cmd: 'logger.save' })
|
|
|
|
async saveLogger(payload: UserSignLoggerDto) {
|
|
|
|
return 'ok';
|
|
|
|
}
|
2023-09-13 17:40:06 +08:00
|
|
|
|
2023-09-13 18:10:23 +08:00
|
|
|
@EventPattern('alg.test')
|
2023-09-13 17:40:06 +08:00
|
|
|
async algTest(payload) {
|
2023-09-13 18:10:23 +08:00
|
|
|
console.log('来自: alg.test', payload);
|
|
|
|
return payload;
|
2023-09-13 17:40:06 +08:00
|
|
|
}
|
2023-08-27 14:37:59 +08:00
|
|
|
}
|