Commit 82edf1fb authored by Дмитрий Малюгин's avatar Дмитрий Малюгин 🕓
Browse files

change image settings in process

parent e1717c7c
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ model Entity {
  text_position         String?
  image_path            String? @db.Text
  image_width           Int?
  image_height          Int?
  file_width            Int?
  file_height           Int?
  entity_position       String?
  entity_title_position String?
  image_scale           String?
@@ -82,7 +83,11 @@ model Image {
  entity_order          Int
  image_path            String? @db.Text
  image_width           Int?
  image_height          Int?
  file_width_initial    Int
  file_height_initial   Int
  image_url_initial     String?
  file_width            Int?
  file_height           Int?
  image_scale           String?
  title                 String?
  text                  String? @db.Text
+7 −0
Original line number Diff line number Diff line
@@ -39,6 +39,13 @@ class EntitiesController {
      console.log(error);
    }
  }
  async returnOriginalSizeImage(req: IWSRequest<'returnOriginalSizeImage', IEntity>) {
    try {
      return await EntitiesService.returnOriginalSizeImage(req.body);
    } catch (error) {
      console.log(error);
    }
  }
  async changeEntitiesOrder(req: IChangeEntitiesOrder) {
    try {
      return await EntitiesService.changeEntitiesOrder(req.body);
+23 −1
Original line number Diff line number Diff line
import { bot } from '../telegramBot';
import { PrismaClient } from '@prisma/client';
import path from 'node:path';

export const validateMessage = async (
  response: any,
@@ -57,6 +58,27 @@ export const getPrismaEntity = async (body: any) => {
    //     });
  }
};
export const getImagePathByUuid = (entity_uuid: string, isOriginal?: boolean) => {
  const imagePath = path.join(path.resolve(), `/public/images/image.jpg`);
  let newImagePath;
  if (process.platform.includes('win')) {
    newImagePath = imagePath.split('\\');
  } else {
    newImagePath = imagePath.split('/');
  }
  newImagePath.splice(-1);
  if (isOriginal) {
    newImagePath.push(`original${entity_uuid}.jpg`);
  } else {
    newImagePath.push(`${entity_uuid}.jpg`);
  }
  if (process.platform.includes('win')) {
    newImagePath = newImagePath.join('\\');
  } else {
    newImagePath = newImagePath.join('/');
  }
  return newImagePath;
};
export const updatePrismaEntity = async (body: any) => {
  switch (body.entity_type) {
    case 'divider':
@@ -74,7 +96,7 @@ export const updatePrismaEntity = async (body: any) => {
        data: { ...body }
      });
    case 'image':
      delete body.imageUrl;
      delete body.image_url;
      return prisma.image.update({
        where: {
          entity_uuid: body.entity_uuid
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ export interface IEntity {
  text_position?: string | null;
  image_buffer?: string;
  image_path?: string;
  imageUrl?: string;
  image_url?: string;
  image_width?: number;
  image_height?: number;
  entity_position?: string;
+6 −0
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ export const websocketRoute = async (req: any) => {
      submitToUsers('editEntity', editedEntity);
      break;
    }
    case 'returnOriginalSizeImage': {
      const result = await EntitiesController!.returnOriginalSizeImage(req);
      submitFilesToUsers(result.buffer);
      submitToUsers('returnOriginalSizeImage', result.entity);
      break;
    }
    case 'changeEntitiesOrder':
      const changedEntitiesOrders = await EntitiesController.changeEntitiesOrder(req);
      submitToUsers('changeEntitiesOrder', changedEntitiesOrders);
Loading