39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
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;
|
|
}
|
|
|
|
@EventPattern({ cmd: 'logger.save' })
|
|
async saveLogger(payload: UserSignLoggerDto) {
|
|
return 'ok';
|
|
}
|
|
|
|
@EventPattern('alg.test')
|
|
async algTest(payload) {
|
|
console.log('来自: alg.test', payload);
|
|
return payload;
|
|
}
|
|
}
|