import { RedisModule } from "@buildingai/cache";
import { CloudStorageModule, UploadModule as CoreUploadModule } from "@buildingai/core";
import { TypeOrmModule } from "@buildingai/db/@nestjs/typeorm";
import { File } from "@buildingai/db/entities";
import { SystemModule } from "@modules/system/system.module";
import { UserModule } from "@modules/user/user.module";
import { Module } from "@nestjs/common";
import { MulterModule } from "@nestjs/platform-express";
import { memoryStorage } from "multer";

import { UploadController } from "./controllers/web/upload.controller";
import { UploadService } from "./services/upload.service";

/**
 * 文件上传模块
 *
 * 提供文件上传、存储和管理功能
 */
@Module({
    imports: [
        SystemModule,
        CoreUploadModule,
        CloudStorageModule,
        TypeOrmModule.forFeature([File]),
        MulterModule.register({
            storage: memoryStorage(),
        }),
        RedisModule,
        UserModule,
    ],
    controllers: [UploadController],
    providers: [UploadService],
    exports: [UploadService],
})
export class UploadModule {}
