Compare commits
No commits in common. "ac998b9cc782ffea77a0480d27c8ac41c3584738" and "90a3fd5861c388fe11229efbcefe0ba30358a9cb" have entirely different histories.
ac998b9cc7
...
90a3fd5861
|
@ -27,13 +27,11 @@ import { ForbiddenExceptionFilter } from './filter/forbid.filter';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -8,13 +8,11 @@ import { ClientsModule, Transport } from '@nestjs/microservices';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } from '@nestjs/microservices';
|
||||
import { getFileExt } from './app.util';
|
||||
import { clientConfig } from './app.config';
|
||||
import { MinioOSS } from '@tavi/oss';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
@MessagePattern('report-upload-image')
|
||||
@EventPattern('report-upload-image')
|
||||
async uploadImageHandler({ buffer, originalName }) {
|
||||
const objectName = Date.now() + '.' + getFileExt(originalName);
|
||||
const { bucketName, ...config } = clientConfig;
|
||||
|
|
|
@ -6,14 +6,11 @@ async function bootstrap() {
|
|||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AppModule,
|
||||
{
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } 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,三者保持一致
|
||||
*/
|
||||
@MessagePattern('cert.token.create')
|
||||
@EventPattern('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中
|
||||
*/
|
||||
@MessagePattern('cert.token.decode')
|
||||
@EventPattern('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
|
||||
*/
|
||||
@MessagePattern('cert.token.config')
|
||||
@EventPattern('cert.token.config')
|
||||
async tokenConfig() {
|
||||
return {
|
||||
tokenResignIn: this.configService.get('TOKEN_RESIGN_IN'),
|
||||
|
@ -56,7 +56,7 @@ export class AppController {
|
|||
};
|
||||
}
|
||||
|
||||
@MessagePattern('cert.token.deprecated')
|
||||
@EventPattern('cert.token.deprecated')
|
||||
async removeToken(payload) {
|
||||
const { username } = payload;
|
||||
console.log('username', username);
|
||||
|
|
|
@ -6,14 +6,11 @@ async function bootstrap() {
|
|||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AppModule,
|
||||
{
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } from '@nestjs/microservices';
|
||||
import { RbacService } from './rbac/rbac.service';
|
||||
|
||||
@Controller()
|
||||
|
@ -10,59 +10,59 @@ export class AppController {
|
|||
private readonly rbacService: RbacService,
|
||||
) {}
|
||||
|
||||
@MessagePattern('cert.authorize')
|
||||
@EventPattern('cert.authorize')
|
||||
async authorize(payload) {
|
||||
console.log('获取user的token,进行payload权限的验证', payload);
|
||||
return false;
|
||||
}
|
||||
|
||||
@MessagePattern('cert.init.role.admin')
|
||||
@EventPattern('cert.init.role.admin')
|
||||
async initRole() {
|
||||
await this.rbacService.initSuperAdminRole();
|
||||
await this.rbacService.initSuperAdminAccount();
|
||||
}
|
||||
|
||||
@MessagePattern('cert.create.role')
|
||||
@EventPattern('cert.create.role')
|
||||
async createRole(payload) {
|
||||
return await this.rbacService.createRole(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.remove.role')
|
||||
@EventPattern('cert.remove.role')
|
||||
async removeRole(payload) {
|
||||
return await this.rbacService.removeRole(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.find.role.all')
|
||||
@EventPattern('cert.find.role.all')
|
||||
async findAllRole() {
|
||||
return await this.rbacService.findAllRole();
|
||||
}
|
||||
|
||||
@MessagePattern('cert.init.permission.resource')
|
||||
@EventPattern('cert.init.permission.resource')
|
||||
async initPermission(payload) {
|
||||
await this.rbacService.initPermission(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.find.role.permission')
|
||||
@EventPattern('cert.find.role.permission')
|
||||
async findRolePermission(payload) {
|
||||
return await this.rbacService.findRolePermission(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.update.role.permissions')
|
||||
@EventPattern('cert.update.role.permissions')
|
||||
async updateRolePermissions(payload) {
|
||||
return await this.rbacService.updateRolePermissions(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.update.role')
|
||||
@EventPattern('cert.update.role')
|
||||
async updateRole(payload) {
|
||||
return await this.rbacService.updateRole(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.find.all.user')
|
||||
@EventPattern('cert.find.all.user')
|
||||
async findAllUser() {
|
||||
return await this.rbacService.findAllUser();
|
||||
}
|
||||
|
||||
@MessagePattern('cert.role.authorize')
|
||||
@EventPattern('cert.role.authorize')
|
||||
async roleAuthorize({ user, url }) {
|
||||
const allow = await this.rbacService.roleAuthorize(user, url);
|
||||
return { allow };
|
||||
|
|
|
@ -6,14 +6,11 @@ async function bootstrap() {
|
|||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AppModule,
|
||||
{
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } from '@nestjs/microservices';
|
||||
import { UserService } from './user.service';
|
||||
import { BcryptService } from '../bcrypt/bcrypt.service';
|
||||
|
||||
|
@ -12,7 +12,7 @@ export class UserController {
|
|||
/**
|
||||
* 用户账号、密码、是否可用
|
||||
*/
|
||||
@MessagePattern('cert.user.account')
|
||||
@EventPattern('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 };
|
||||
}
|
||||
|
||||
@MessagePattern('cert.user.encrypt')
|
||||
@EventPattern('cert.user.encrypt')
|
||||
async encrypt(plainText: string) {
|
||||
return await this.bcryptService.hashPassword(plainText);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.encrypt.compare')
|
||||
@EventPattern('cert.encrypt.compare')
|
||||
async compare(plainText: string, hash: string) {
|
||||
return await this.bcryptService.comparePassword(plainText, hash);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.user.create')
|
||||
@EventPattern('cert.user.create')
|
||||
async createUser(payload) {
|
||||
return await this.userService.create(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.user.update')
|
||||
@EventPattern('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);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.user.delete')
|
||||
@EventPattern('cert.user.delete')
|
||||
async deleteUser(userIds: number[]) {
|
||||
return await this.userService.delete(userIds);
|
||||
}
|
||||
|
||||
@MessagePattern('cert.user.find.annotator')
|
||||
@EventPattern('cert.user.find.annotator')
|
||||
async findAnnotators() {
|
||||
const annotators = await this.userService.findAnnotators();
|
||||
return { data: annotators };
|
||||
|
|
|
@ -8,13 +8,11 @@ import { ClientsModule, Transport } from '@nestjs/microservices';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -21,14 +21,11 @@ import { AdminModule } from './admin/admin.module';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } from '@nestjs/microservices';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import axios from 'axios';
|
||||
|
||||
|
@ -75,7 +75,7 @@ export class AppController {
|
|||
private readonly configService: ConfigService,
|
||||
) {}
|
||||
|
||||
@MessagePattern('dicom.find')
|
||||
@EventPattern('dicom.find')
|
||||
async findDicoms() {
|
||||
const pacsUrl = this.configService.get('PACS_URL');
|
||||
try {
|
||||
|
@ -118,7 +118,7 @@ export class AppController {
|
|||
}
|
||||
}
|
||||
|
||||
@MessagePattern('dicom.archive.url')
|
||||
@EventPattern('dicom.archive.url')
|
||||
async archiveUrl({ ID, Type }: { ID: string; Type: string }) {
|
||||
const pacsUrl = this.configService.get('PACS_URL');
|
||||
const mapping = {
|
||||
|
|
|
@ -6,14 +6,11 @@ async function bootstrap() {
|
|||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AppModule,
|
||||
{
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } from '@nestjs/microservices';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@MessagePattern('archive.task.create')
|
||||
@EventPattern('archive.task.create')
|
||||
async createArchiveTask(payload) {
|
||||
return await this.appService.createArchiveTask(payload);
|
||||
}
|
||||
|
||||
@MessagePattern('archive.task.find')
|
||||
@EventPattern('archive.task.find')
|
||||
async findArchiveTask(payload) {
|
||||
return await this.appService.findArchiveTask(payload);
|
||||
}
|
||||
|
|
|
@ -6,14 +6,11 @@ async function bootstrap() {
|
|||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AppModule,
|
||||
{
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
@ -7,13 +7,11 @@ import { ClientsModule, Transport } from '@nestjs/microservices';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -7,13 +7,11 @@ import { ClientsModule, Transport } from '@nestjs/microservices';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -21,13 +21,11 @@ import * as cookieParser from 'cookie-parser';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -7,13 +7,11 @@ import { ClientsModule, Transport } from '@nestjs/microservices';
|
|||
ClientsModule.register([
|
||||
{
|
||||
name: 'Client',
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
servers: ['nats://localhost:4222'],
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
]),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { EventPattern, MessagePattern } from '@nestjs/microservices';
|
||||
import { EventPattern } 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) {}
|
||||
|
||||
@MessagePattern('logger.user.signIn')
|
||||
@EventPattern('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;
|
||||
}
|
||||
|
||||
@MessagePattern('logger.save')
|
||||
@EventPattern('logger.save')
|
||||
async saveLogger(payload: UserSignLoggerDto) {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
@MessagePattern('alg.test')
|
||||
@EventPattern('alg.test')
|
||||
async algTest(payload) {
|
||||
console.log('来自: alg.test', payload);
|
||||
return payload;
|
||||
|
|
|
@ -6,14 +6,11 @@ async function bootstrap() {
|
|||
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
|
||||
AppModule,
|
||||
{
|
||||
transport: Transport.RMQ,
|
||||
transport: Transport.NATS,
|
||||
options: {
|
||||
urls: ['amqp://localhost:5672'],
|
||||
queue: 'cats_queue',
|
||||
queueOptions: {
|
||||
durable: false,
|
||||
},
|
||||
maxConnectionAttempts: 10,
|
||||
servers: ['nats://localhost:4222'], // 可以指定链接到多个nats的消息队列
|
||||
maxReconnectAttempts: 5,
|
||||
reconnectTimeWait: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
@ -14,7 +14,7 @@ async getHello(): Promise<any> {
|
|||
}
|
||||
|
||||
// 服务
|
||||
@MessagePattern('sum')
|
||||
@EventPattern('sum')
|
||||
sum(data: number[]): number {
|
||||
return (data || []).reduce((a, b) => a + b);
|
||||
}
|
||||
|
|
|
@ -11,13 +11,6 @@ services:
|
|||
environment:
|
||||
- RABBITMQ_DEFAULT_USER=guest
|
||||
- RABBITMQ_DEFAULT_PASS=guest
|
||||
- TZ=Asia/Shanghai # 将此值设置为您所在的时区
|
||||
# volumes:
|
||||
# - rabbitmq-data:/var/lib/rabbitmq
|
||||
command: >
|
||||
bash -c "rabbitmq-plugins enable rabbitmq_management &&
|
||||
rabbitmq-plugins enable rabbitmq_tracing &&
|
||||
rabbitmq-server"
|
||||
|
||||
mongodb:
|
||||
image: mongo:5.0
|
||||
|
|
Loading…
Reference in New Issue
Block a user