diff --git a/apps/services/aorta/report/src/app.controller.ts b/apps/services/aorta/report/src/app.controller.ts index caba8c0..3fb59d2 100644 --- a/apps/services/aorta/report/src/app.controller.ts +++ b/apps/services/aorta/report/src/app.controller.ts @@ -1,12 +1,12 @@ import { Controller } from '@nestjs/common'; -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; import { getFileExt } from './app.util'; import { clientConfig } from './app.config'; import { MinioOSS } from '@tavi/oss'; @Controller() export class AppController { - @EventPattern('report-upload-image') + @MessagePattern('report-upload-image') async uploadImageHandler({ buffer, originalName }) { const objectName = Date.now() + '.' + getFileExt(originalName); const { bucketName, ...config } = clientConfig; diff --git a/apps/services/aorta/report/src/main.ts b/apps/services/aorta/report/src/main.ts index 1f6619d..68ed02b 100644 --- a/apps/services/aorta/report/src/main.ts +++ b/apps/services/aorta/report/src/main.ts @@ -13,6 +13,7 @@ async function bootstrap() { queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ); diff --git a/apps/services/cert/authenticate/src/app.controller.ts b/apps/services/cert/authenticate/src/app.controller.ts index 215384c..e371e1a 100644 --- a/apps/services/cert/authenticate/src/app.controller.ts +++ b/apps/services/cert/authenticate/src/app.controller.ts @@ -1,4 +1,4 @@ -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; import { RedisService } from './redis/redis.service'; import { ConfigService } from '@nestjs/config'; import { Controller } from '@nestjs/common'; @@ -16,7 +16,7 @@ export class AppController { * 给业务系统登录接口进行token签发,注入用户的角色信息 * @description redis的EX、cookie的maxAge(ms)、jwt的expiresIn,三者保持一致 */ - @EventPattern('cert.token.create') + @MessagePattern('cert.token.create') async createToken(payload) { const { username } = payload; const token = await this.jwtService.sign(payload); @@ -28,7 +28,7 @@ export class AppController { * 检查token有效性 && 解token * @description 业务系统的guard对请求token进行拦截,校验每次请求token是否合法&是否在redis中 */ - @EventPattern('cert.token.decode') + @MessagePattern('cert.token.decode') async decodeToken( token: string, ): Promise<{ tokenValid: boolean; payload: unknown; error?: unknown }> { @@ -47,7 +47,7 @@ export class AppController { * 获取token在cookie中存储的key * @description cookie的maxAge单位是毫秒,如果给cookie使用expires需要 x1000 */ - @EventPattern('cert.token.config') + @MessagePattern('cert.token.config') async tokenConfig() { return { tokenResignIn: this.configService.get('TOKEN_RESIGN_IN'), @@ -56,7 +56,7 @@ export class AppController { }; } - @EventPattern('cert.token.deprecated') + @MessagePattern('cert.token.deprecated') async removeToken(payload) { const { username } = payload; console.log('username', username); diff --git a/apps/services/cert/authenticate/src/main.ts b/apps/services/cert/authenticate/src/main.ts index 1f6619d..68ed02b 100644 --- a/apps/services/cert/authenticate/src/main.ts +++ b/apps/services/cert/authenticate/src/main.ts @@ -13,6 +13,7 @@ async function bootstrap() { queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ); diff --git a/apps/services/cert/authorize/src/app.controller.ts b/apps/services/cert/authorize/src/app.controller.ts index 5b7bd56..0e86695 100644 --- a/apps/services/cert/authorize/src/app.controller.ts +++ b/apps/services/cert/authorize/src/app.controller.ts @@ -1,6 +1,6 @@ import { Controller } from '@nestjs/common'; import { AppService } from './app.service'; -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; import { RbacService } from './rbac/rbac.service'; @Controller() @@ -10,59 +10,59 @@ export class AppController { private readonly rbacService: RbacService, ) {} - @EventPattern('cert.authorize') + @MessagePattern('cert.authorize') async authorize(payload) { console.log('获取user的token,进行payload权限的验证', payload); return false; } - @EventPattern('cert.init.role.admin') + @MessagePattern('cert.init.role.admin') async initRole() { await this.rbacService.initSuperAdminRole(); await this.rbacService.initSuperAdminAccount(); } - @EventPattern('cert.create.role') + @MessagePattern('cert.create.role') async createRole(payload) { return await this.rbacService.createRole(payload); } - @EventPattern('cert.remove.role') + @MessagePattern('cert.remove.role') async removeRole(payload) { return await this.rbacService.removeRole(payload); } - @EventPattern('cert.find.role.all') + @MessagePattern('cert.find.role.all') async findAllRole() { return await this.rbacService.findAllRole(); } - @EventPattern('cert.init.permission.resource') + @MessagePattern('cert.init.permission.resource') async initPermission(payload) { await this.rbacService.initPermission(payload); } - @EventPattern('cert.find.role.permission') + @MessagePattern('cert.find.role.permission') async findRolePermission(payload) { return await this.rbacService.findRolePermission(payload); } - @EventPattern('cert.update.role.permissions') + @MessagePattern('cert.update.role.permissions') async updateRolePermissions(payload) { return await this.rbacService.updateRolePermissions(payload); } - @EventPattern('cert.update.role') + @MessagePattern('cert.update.role') async updateRole(payload) { return await this.rbacService.updateRole(payload); } - @EventPattern('cert.find.all.user') + @MessagePattern('cert.find.all.user') async findAllUser() { return await this.rbacService.findAllUser(); } - @EventPattern('cert.role.authorize') + @MessagePattern('cert.role.authorize') async roleAuthorize({ user, url }) { const allow = await this.rbacService.roleAuthorize(user, url); return { allow }; diff --git a/apps/services/cert/authorize/src/main.ts b/apps/services/cert/authorize/src/main.ts index 546d18a..86548bd 100644 --- a/apps/services/cert/authorize/src/main.ts +++ b/apps/services/cert/authorize/src/main.ts @@ -13,6 +13,7 @@ async function bootstrap() { queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ); diff --git a/apps/services/cert/authorize/src/user/user.controller.ts b/apps/services/cert/authorize/src/user/user.controller.ts index 7e89dc3..10b6782 100644 --- a/apps/services/cert/authorize/src/user/user.controller.ts +++ b/apps/services/cert/authorize/src/user/user.controller.ts @@ -1,5 +1,5 @@ import { Controller } from '@nestjs/common'; -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; import { UserService } from './user.service'; import { BcryptService } from '../bcrypt/bcrypt.service'; @@ -12,7 +12,7 @@ export class UserController { /** * 用户账号、密码、是否可用 */ - @EventPattern('cert.user.account') + @MessagePattern('cert.user.account') async findUser( payload, ): Promise<{ isLegal: boolean; msg?: string; data?: any }> { @@ -28,22 +28,22 @@ export class UserController { return { isLegal: true, data: user }; } - @EventPattern('cert.user.encrypt') + @MessagePattern('cert.user.encrypt') async encrypt(plainText: string) { return await this.bcryptService.hashPassword(plainText); } - @EventPattern('cert.encrypt.compare') + @MessagePattern('cert.encrypt.compare') async compare(plainText: string, hash: string) { return await this.bcryptService.comparePassword(plainText, hash); } - @EventPattern('cert.user.create') + @MessagePattern('cert.user.create') async createUser(payload) { return await this.userService.create(payload); } - @EventPattern('cert.user.update') + @MessagePattern('cert.user.update') async updateUser(payload) { const { password, ...rest } = payload; const updateFields = password @@ -52,12 +52,12 @@ export class UserController { return await this.userService.update(updateFields); } - @EventPattern('cert.user.delete') + @MessagePattern('cert.user.delete') async deleteUser(userIds: number[]) { return await this.userService.delete(userIds); } - @EventPattern('cert.user.find.annotator') + @MessagePattern('cert.user.find.annotator') async findAnnotators() { const annotators = await this.userService.findAnnotators(); return { data: annotators }; diff --git a/apps/services/cert/gateway/src/app.module.ts b/apps/services/cert/gateway/src/app.module.ts index 02d5c0c..756c67d 100644 --- a/apps/services/cert/gateway/src/app.module.ts +++ b/apps/services/cert/gateway/src/app.module.ts @@ -28,6 +28,7 @@ import { AdminModule } from './admin/admin.module'; queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ]), diff --git a/apps/services/dicom/src/app.controller.ts b/apps/services/dicom/src/app.controller.ts index 68df715..4ffe46f 100644 --- a/apps/services/dicom/src/app.controller.ts +++ b/apps/services/dicom/src/app.controller.ts @@ -1,6 +1,6 @@ import { Controller } from '@nestjs/common'; import { AppService } from './app.service'; -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; import { ConfigService } from '@nestjs/config'; import axios from 'axios'; @@ -75,7 +75,7 @@ export class AppController { private readonly configService: ConfigService, ) {} - @EventPattern('dicom.find') + @MessagePattern('dicom.find') async findDicoms() { const pacsUrl = this.configService.get('PACS_URL'); try { @@ -118,7 +118,7 @@ export class AppController { } } - @EventPattern('dicom.archive.url') + @MessagePattern('dicom.archive.url') async archiveUrl({ ID, Type }: { ID: string; Type: string }) { const pacsUrl = this.configService.get('PACS_URL'); const mapping = { diff --git a/apps/services/dicom/src/main.ts b/apps/services/dicom/src/main.ts index 1f6619d..68ed02b 100644 --- a/apps/services/dicom/src/main.ts +++ b/apps/services/dicom/src/main.ts @@ -13,6 +13,7 @@ async function bootstrap() { queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ); diff --git a/apps/services/dmp/archive/src/app.controller.ts b/apps/services/dmp/archive/src/app.controller.ts index 2076031..7b67985 100644 --- a/apps/services/dmp/archive/src/app.controller.ts +++ b/apps/services/dmp/archive/src/app.controller.ts @@ -1,17 +1,17 @@ import { Controller } from '@nestjs/common'; import { AppService } from './app.service'; -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; @Controller() export class AppController { constructor(private readonly appService: AppService) {} - @EventPattern('archive.task.create') + @MessagePattern('archive.task.create') async createArchiveTask(payload) { return await this.appService.createArchiveTask(payload); } - @EventPattern('archive.task.find') + @MessagePattern('archive.task.find') async findArchiveTask(payload) { return await this.appService.findArchiveTask(payload); } diff --git a/apps/services/dmp/archive/src/main.ts b/apps/services/dmp/archive/src/main.ts index 1f6619d..68ed02b 100644 --- a/apps/services/dmp/archive/src/main.ts +++ b/apps/services/dmp/archive/src/main.ts @@ -13,6 +13,7 @@ async function bootstrap() { queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ); diff --git a/apps/services/logger/src/app.controller.ts b/apps/services/logger/src/app.controller.ts index 5a400a3..5f554e8 100644 --- a/apps/services/logger/src/app.controller.ts +++ b/apps/services/logger/src/app.controller.ts @@ -1,6 +1,6 @@ import { Controller } from '@nestjs/common'; import { AppService } from './app.service'; -import { EventPattern } from '@nestjs/microservices'; +import { EventPattern, MessagePattern } from '@nestjs/microservices'; import * as dayjs from 'dayjs'; import { SymmetricCrypto } from '@tavi/util'; @@ -16,7 +16,7 @@ interface UserSignLoggerDto { export class AppController { constructor(private readonly appService: AppService) {} - @EventPattern('logger.user.signIn') + @MessagePattern('logger.user.signIn') async userSignIn(payload: UserSignLoggerDto) { const dateTime = dayjs().format('YYYY-MM-DD HH:mm:ss'); const { finger2, ...rest } = payload; @@ -25,12 +25,12 @@ export class AppController { return 1; } - @EventPattern('logger.save') + @MessagePattern('logger.save') async saveLogger(payload: UserSignLoggerDto) { return 'ok'; } - @EventPattern('alg.test') + @MessagePattern('alg.test') async algTest(payload) { console.log('来自: alg.test', payload); return payload; diff --git a/apps/services/logger/src/main.ts b/apps/services/logger/src/main.ts index 1f6619d..68ed02b 100644 --- a/apps/services/logger/src/main.ts +++ b/apps/services/logger/src/main.ts @@ -13,6 +13,7 @@ async function bootstrap() { queueOptions: { durable: false, }, + maxConnectionAttempts: 10, }, }, ); diff --git a/apps/services/readme.md b/apps/services/readme.md index 65300be..3750291 100644 --- a/apps/services/readme.md +++ b/apps/services/readme.md @@ -14,7 +14,7 @@ async getHello(): Promise { } // 服务 -@EventPattern('sum') +@MessagePattern('sum') sum(data: number[]): number { return (data || []).reduce((a, b) => a + b); } diff --git a/docker-compose.rabbit.yml b/docker-compose.rabbit.yml index c3f5181..7183dd6 100644 --- a/docker-compose.rabbit.yml +++ b/docker-compose.rabbit.yml @@ -11,6 +11,7 @@ services: environment: - RABBITMQ_DEFAULT_USER=guest - RABBITMQ_DEFAULT_PASS=guest + - TZ=Asia/Shanghai # 将此值设置为您所在的时区 # volumes: # - rabbitmq-data:/var/lib/rabbitmq command: >