This commit is contained in:
IDONTSUDO 2024-10-28 11:52:53 +03:00
parent 00c553ecd7
commit 29dcfb6ac1
5 changed files with 59 additions and 6 deletions

View file

@ -0,0 +1,48 @@
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
import { Result } from "../../../core/helpers/result";
import { StaticFilesProject } from "../../../core/models/static_files";
import { ReadFileAndParseJsonUseCase } from "../../../core/usecases/read_file_and_parse_json";
import { SearchManyDataBaseModelUseCase } from "../../../core/usecases/search_many_database_model_usecase";
import { IProjectModel, ProjectDBModel } from "../models/project_model_database_model";
export interface Parts {
name: string;
part_path: string;
material_path: string;
stlUrl: string;
image: string;
glUrl: string;
daeUrl: string;
fbx: string;
objUrl: string;
solidType: string;
}
export class RobossemblerAssetsLocaleMapperScenario extends CallbackStrategyWithEmpty {
call = async (): ResponseBase =>
(
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
{ isActive: true },
"is dont active projects"
)
).map(async (projectModel) => {
const { rootDir } = projectModel[0];
return (await new ReadFileAndParseJsonUseCase().call<Parts[]>(rootDir + StaticFilesProject.parts)).map(
(model) => {
model.map((el) => {
const assetLibsAddress = rootDir + "/libs/objects/" + el.name;
el.fbx = `${assetLibsAddress}.fbx`;
el.stlUrl = `${assetLibsAddress}${el.part_path}`;
el.glUrl = `${assetLibsAddress}.glb`;
el.daeUrl = `${assetLibsAddress}.dae`;
el.objUrl = `${assetLibsAddress}.obj`;
el.image = `${assetLibsAddress}.png`;
el.solidType = "active";
return el;
});
return Result.ok(model);
}
);
// );
});
}

View file

@ -2,6 +2,7 @@ import { CrudController } from "../../core/controllers/crud_controller";
import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase";
import { CreateNewProjectInstanceScenario, ProjectValidationModel } from "./domain/create_new_project_scenario";
import { GetActiveProjectIdScenario } from "./domain/get_active_project_id_scenario";
import { RobossemblerAssetsLocaleMapperScenario } from "./domain/robossembler_assets_absolute_path_mapper_scenario";
import { RobossemblerAssetsNetworkMapperScenario } from "./domain/robossembler_assets_network_mapper_scenario";
import { SetActiveProjectScenario } from "./domain/set_active_project_use_scenario";
import { UploadCadFileToProjectScenario } from "./domain/upload_file_to_to_project_scenario";
@ -39,11 +40,12 @@ export class ProjectsPresentation extends CrudController<ProjectValidationModel,
subUrl: "assets",
fn: new RobossemblerAssetsNetworkMapperScenario(),
});
// this.subRoutes.push({
// method: "POST",
// subUrl: "upload/env",
// fn: new UploadNewEnvScenario(),
// });
this.subRoutes.push({
method: "GET",
subUrl: "local/assets",
fn: new RobossemblerAssetsLocaleMapperScenario(),
});
this.router.post("/projects/upload/env", async (req, res) => {
try {
} catch (error) {}