Spaces:
Sleeping
Sleeping
Viktoria435 commited on
Commit ·
c995cfc
1
Parent(s): a48a17c
Refactor import paths in Book, Visitor, and Worker modules to use relative paths
Browse files- Updated import statements in various files to use relative paths instead of absolute paths, improving code maintainability and consistency.
- Adjusted file paths for FileManager instances in services to ensure correct file access.
- src/book/book.controller.ts +3 -3
- src/book/book.module.ts +1 -1
- src/book/book.service.ts +3 -3
- src/book/dto/book.dto.ts +1 -1
- src/book/dto/create-book.dto.ts +1 -1
- src/common/LinkManager.ts +1 -1
- src/common/worker-link-manager.ts +2 -2
- src/filters/http-exception.filter.ts +1 -1
- src/utils/swagger.utils.ts +1 -1
- src/visitor/dto/visitor.dto.ts +1 -1
- src/visitor/visitor.controller.ts +1 -1
- src/visitor/visitor.module.ts +1 -1
- src/visitor/visitor.service.ts +7 -7
- src/worker/dto/create-worker.dto.ts +1 -1
- src/worker/dto/worker.dto.ts +2 -2
- src/worker/worker.controller.ts +3 -3
- src/worker/worker.service.ts +8 -8
src/book/book.controller.ts
CHANGED
|
@@ -14,10 +14,10 @@ import { VisitorService } from '../visitor/visitor.service';
|
|
| 14 |
import { CreateBookDto } from './dto/create-book.dto';
|
| 15 |
import { BorrowBookDto } from './dto/borrow-book.dto';
|
| 16 |
import { ReturnBookDto } from './dto/return-book.dto';
|
| 17 |
-
import { DateUtils } from '
|
| 18 |
-
import { WorkerService } from '
|
| 19 |
import { UpdateBookDto } from './dto/update-book.dto';
|
| 20 |
-
import { buildDownloadFile } from '
|
| 21 |
|
| 22 |
@Controller('books')
|
| 23 |
export class BookController {
|
|
|
|
| 14 |
import { CreateBookDto } from './dto/create-book.dto';
|
| 15 |
import { BorrowBookDto } from './dto/borrow-book.dto';
|
| 16 |
import { ReturnBookDto } from './dto/return-book.dto';
|
| 17 |
+
import { DateUtils } from '../utils/date.utils';
|
| 18 |
+
import { WorkerService } from '../worker/worker.service';
|
| 19 |
import { UpdateBookDto } from './dto/update-book.dto';
|
| 20 |
+
import { buildDownloadFile } from '../utils/download.utils';
|
| 21 |
|
| 22 |
@Controller('books')
|
| 23 |
export class BookController {
|
src/book/book.module.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import { Module } from '@nestjs/common';
|
| 2 |
import { BookController } from './book.controller';
|
| 3 |
import { BookService } from './book.service';
|
| 4 |
-
import { BookLinkManager } from '
|
| 5 |
import { VisitorModule } from '../visitor/visitor.module';
|
| 6 |
import { WorkerModule } from '../worker/worker.module';
|
| 7 |
|
|
|
|
| 1 |
import { Module } from '@nestjs/common';
|
| 2 |
import { BookController } from './book.controller';
|
| 3 |
import { BookService } from './book.service';
|
| 4 |
+
import { BookLinkManager } from '../common/book-link-manager';
|
| 5 |
import { VisitorModule } from '../visitor/visitor.module';
|
| 6 |
import { WorkerModule } from '../worker/worker.module';
|
| 7 |
|
src/book/book.service.ts
CHANGED
|
@@ -7,15 +7,15 @@ import { Book } from './dto/book.dto';
|
|
| 7 |
import { FileManager } from '../utils/file-manager';
|
| 8 |
import { parseTxtRow, serializeTxtRow } from '../utils/file.utils';
|
| 9 |
import { randomUUID } from 'crypto';
|
| 10 |
-
import { BookStatus } from '
|
| 11 |
import { CreateBookDto } from './dto/create-book.dto';
|
| 12 |
import { UpdateBookDto } from './dto/update-book.dto';
|
| 13 |
import { Visitor } from '../visitor/dto/visitor.dto';
|
| 14 |
-
import { bookLinkManager } from '
|
| 15 |
|
| 16 |
@Injectable()
|
| 17 |
export class BookService {
|
| 18 |
-
private file = new FileManager('
|
| 19 |
|
| 20 |
async getAll(): Promise<Book[]> {
|
| 21 |
const lines = await this.file.readLines();
|
|
|
|
| 7 |
import { FileManager } from '../utils/file-manager';
|
| 8 |
import { parseTxtRow, serializeTxtRow } from '../utils/file.utils';
|
| 9 |
import { randomUUID } from 'crypto';
|
| 10 |
+
import { BookStatus } from '../types/book.types';
|
| 11 |
import { CreateBookDto } from './dto/create-book.dto';
|
| 12 |
import { UpdateBookDto } from './dto/update-book.dto';
|
| 13 |
import { Visitor } from '../visitor/dto/visitor.dto';
|
| 14 |
+
import { bookLinkManager } from '../common/book-link-manager';
|
| 15 |
|
| 16 |
@Injectable()
|
| 17 |
export class BookService {
|
| 18 |
+
private file = new FileManager('../data/books.txt');
|
| 19 |
|
| 20 |
async getAll(): Promise<Book[]> {
|
| 21 |
const lines = await this.file.readLines();
|
src/book/dto/book.dto.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
| 9 |
IsNotEmpty,
|
| 10 |
IsEnum,
|
| 11 |
} from 'class-validator';
|
| 12 |
-
import { BookStatus, Genre } from '
|
| 13 |
|
| 14 |
export class Book {
|
| 15 |
@ApiProperty({
|
|
|
|
| 9 |
IsNotEmpty,
|
| 10 |
IsEnum,
|
| 11 |
} from 'class-validator';
|
| 12 |
+
import { BookStatus, Genre } from '../../types/book.types';
|
| 13 |
|
| 14 |
export class Book {
|
| 15 |
@ApiProperty({
|
src/book/dto/create-book.dto.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
| 9 |
IsNotEmpty,
|
| 10 |
IsEnum,
|
| 11 |
} from 'class-validator';
|
| 12 |
-
import { BookStatus, Genre } from '
|
| 13 |
|
| 14 |
export class CreateBookDto {
|
| 15 |
@ApiProperty({
|
|
|
|
| 9 |
IsNotEmpty,
|
| 10 |
IsEnum,
|
| 11 |
} from 'class-validator';
|
| 12 |
+
import { BookStatus, Genre } from '../../types/book.types';
|
| 13 |
|
| 14 |
export class CreateBookDto {
|
| 15 |
@ApiProperty({
|
src/common/LinkManager.ts
CHANGED
|
@@ -8,7 +8,7 @@ export abstract class LinkManager<T> {
|
|
| 8 |
protected abstract tableName: string;
|
| 9 |
|
| 10 |
private getFile() {
|
| 11 |
-
return new FileManager(`
|
| 12 |
}
|
| 13 |
|
| 14 |
toLink(id: string): Link {
|
|
|
|
| 8 |
protected abstract tableName: string;
|
| 9 |
|
| 10 |
private getFile() {
|
| 11 |
+
return new FileManager(`../data/${this.fileName}`);
|
| 12 |
}
|
| 13 |
|
| 14 |
toLink(id: string): Link {
|
src/common/worker-link-manager.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
import { Worker } from '
|
| 2 |
import { bookLinkManager } from './book-link-manager';
|
| 3 |
import { LinkManager } from './LinkManager';
|
| 4 |
import { Link } from './Link';
|
| 5 |
-
import { Book } from '
|
| 6 |
|
| 7 |
export interface WorkerWithBooks extends Omit<Worker, 'issuedBooks'> {
|
| 8 |
issuedBooks: Book[];
|
|
|
|
| 1 |
+
import { Worker } from '../worker/dto/worker.dto';
|
| 2 |
import { bookLinkManager } from './book-link-manager';
|
| 3 |
import { LinkManager } from './LinkManager';
|
| 4 |
import { Link } from './Link';
|
| 5 |
+
import { Book } from '../book/dto/book.dto';
|
| 6 |
|
| 7 |
export interface WorkerWithBooks extends Omit<Worker, 'issuedBooks'> {
|
| 8 |
issuedBooks: Book[];
|
src/filters/http-exception.filter.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
| 6 |
HttpStatus,
|
| 7 |
} from '@nestjs/common';
|
| 8 |
import { Response } from 'express';
|
| 9 |
-
import { ApiResponse, ErrorResponse } from '
|
| 10 |
|
| 11 |
@Catch()
|
| 12 |
export class HttpExceptionFilter implements ExceptionFilter {
|
|
|
|
| 6 |
HttpStatus,
|
| 7 |
} from '@nestjs/common';
|
| 8 |
import { Response } from 'express';
|
| 9 |
+
import { ApiResponse, ErrorResponse } from '../utils/response-wrapper.utils';
|
| 10 |
|
| 11 |
@Catch()
|
| 12 |
export class HttpExceptionFilter implements ExceptionFilter {
|
src/utils/swagger.utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
| 2 |
import type { INestApplication } from '@nestjs/common';
|
| 3 |
import { SwaggerModule } from '@nestjs/swagger';
|
| 4 |
-
import { getSwaggerConfig } from '
|
| 5 |
|
| 6 |
export function setupSwagger(app: INestApplication) {
|
| 7 |
const config = getSwaggerConfig();
|
|
|
|
| 1 |
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
| 2 |
import type { INestApplication } from '@nestjs/common';
|
| 3 |
import { SwaggerModule } from '@nestjs/swagger';
|
| 4 |
+
import { getSwaggerConfig } from '../config/swagger.config';
|
| 5 |
|
| 6 |
export function setupSwagger(app: INestApplication) {
|
| 7 |
const config = getSwaggerConfig();
|
src/visitor/dto/visitor.dto.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
| 8 |
ValidateNested,
|
| 9 |
} from 'class-validator';
|
| 10 |
import { Type } from 'class-transformer';
|
| 11 |
-
import { Link } from '
|
| 12 |
|
| 13 |
export class Visitor {
|
| 14 |
@ApiProperty({
|
|
|
|
| 8 |
ValidateNested,
|
| 9 |
} from 'class-validator';
|
| 10 |
import { Type } from 'class-transformer';
|
| 11 |
+
import { Link } from '../../common/Link';
|
| 12 |
|
| 13 |
export class Visitor {
|
| 14 |
@ApiProperty({
|
src/visitor/visitor.controller.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { VisitorService } from './visitor.service';
|
|
| 11 |
import { Visitor } from './dto/visitor.dto';
|
| 12 |
import { CreateVisitorDto } from './dto/create-visitor.dto';
|
| 13 |
import { UpdateVisitorDto } from './dto/update-visitor.dto';
|
| 14 |
-
import { buildDownloadFile } from '
|
| 15 |
|
| 16 |
@Controller('visitors')
|
| 17 |
export class VisitorController {
|
|
|
|
| 11 |
import { Visitor } from './dto/visitor.dto';
|
| 12 |
import { CreateVisitorDto } from './dto/create-visitor.dto';
|
| 13 |
import { UpdateVisitorDto } from './dto/update-visitor.dto';
|
| 14 |
+
import { buildDownloadFile } from '../utils/download.utils';
|
| 15 |
|
| 16 |
@Controller('visitors')
|
| 17 |
export class VisitorController {
|
src/visitor/visitor.module.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import { Module, forwardRef } from '@nestjs/common';
|
| 2 |
import { VisitorController } from './visitor.controller';
|
| 3 |
import { VisitorService } from './visitor.service';
|
| 4 |
-
import { VisitorLinkManager } from '
|
| 5 |
import { BookModule } from '../book/book.module';
|
| 6 |
|
| 7 |
@Module({
|
|
|
|
| 1 |
import { Module, forwardRef } from '@nestjs/common';
|
| 2 |
import { VisitorController } from './visitor.controller';
|
| 3 |
import { VisitorService } from './visitor.service';
|
| 4 |
+
import { VisitorLinkManager } from '../common/visitor-link-manager';
|
| 5 |
import { BookModule } from '../book/book.module';
|
| 6 |
|
| 7 |
@Module({
|
src/visitor/visitor.service.ts
CHANGED
|
@@ -4,20 +4,20 @@ import {
|
|
| 4 |
NotFoundException,
|
| 5 |
BadRequestException,
|
| 6 |
} from '@nestjs/common';
|
| 7 |
-
import { FileManager } from '
|
| 8 |
-
import { parseTxtRow, serializeTxtRow } from '
|
| 9 |
import { Visitor } from './dto/visitor.dto';
|
| 10 |
import { randomUUID } from 'crypto';
|
| 11 |
import { CreateVisitorDto } from './dto/create-visitor.dto';
|
| 12 |
import { UpdateVisitorDto } from './dto/update-visitor.dto';
|
| 13 |
-
import { Book } from '
|
| 14 |
-
import { bookLinkManager } from '
|
| 15 |
-
import { VisitorLinkManager } from '
|
| 16 |
-
import { Link } from '
|
| 17 |
|
| 18 |
@Injectable()
|
| 19 |
export class VisitorService {
|
| 20 |
-
private file = new FileManager('
|
| 21 |
private visitorLinkManager: VisitorLinkManager = new VisitorLinkManager();
|
| 22 |
|
| 23 |
async getAll(): Promise<Visitor[]> {
|
|
|
|
| 4 |
NotFoundException,
|
| 5 |
BadRequestException,
|
| 6 |
} from '@nestjs/common';
|
| 7 |
+
import { FileManager } from '../utils/file-manager';
|
| 8 |
+
import { parseTxtRow, serializeTxtRow } from '../utils/file.utils';
|
| 9 |
import { Visitor } from './dto/visitor.dto';
|
| 10 |
import { randomUUID } from 'crypto';
|
| 11 |
import { CreateVisitorDto } from './dto/create-visitor.dto';
|
| 12 |
import { UpdateVisitorDto } from './dto/update-visitor.dto';
|
| 13 |
+
import { Book } from '../book/dto/book.dto';
|
| 14 |
+
import { bookLinkManager } from '../common/book-link-manager';
|
| 15 |
+
import { VisitorLinkManager } from '../common/visitor-link-manager';
|
| 16 |
+
import { Link } from '../common/Link';
|
| 17 |
|
| 18 |
@Injectable()
|
| 19 |
export class VisitorService {
|
| 20 |
+
private file = new FileManager('../data/visitors.txt');
|
| 21 |
private visitorLinkManager: VisitorLinkManager = new VisitorLinkManager();
|
| 22 |
|
| 23 |
async getAll(): Promise<Visitor[]> {
|
src/worker/dto/create-worker.dto.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
| 10 |
Min,
|
| 11 |
Max,
|
| 12 |
} from 'class-validator';
|
| 13 |
-
import { DayOfWeek } from '
|
| 14 |
|
| 15 |
export class CreateWorkerDto {
|
| 16 |
@ApiProperty({
|
|
|
|
| 10 |
Min,
|
| 11 |
Max,
|
| 12 |
} from 'class-validator';
|
| 13 |
+
import { DayOfWeek } from '../../types/worker.types';
|
| 14 |
|
| 15 |
export class CreateWorkerDto {
|
| 16 |
@ApiProperty({
|
src/worker/dto/worker.dto.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import { ApiProperty } from '@nestjs/swagger';
|
| 2 |
import { IsEnum, IsInt, IsNotEmpty, IsString, Min } from 'class-validator';
|
| 3 |
-
import { Link } from '
|
| 4 |
-
import { DayOfWeek } from '
|
| 5 |
|
| 6 |
export class Worker {
|
| 7 |
@ApiProperty({ example: '3fa85f64-5717-4562-b3fc-2c963f66afa6' })
|
|
|
|
| 1 |
import { ApiProperty } from '@nestjs/swagger';
|
| 2 |
import { IsEnum, IsInt, IsNotEmpty, IsString, Min } from 'class-validator';
|
| 3 |
+
import { Link } from '../../common/Link';
|
| 4 |
+
import { DayOfWeek } from '../../types/worker.types';
|
| 5 |
|
| 6 |
export class Worker {
|
| 7 |
@ApiProperty({ example: '3fa85f64-5717-4562-b3fc-2c963f66afa6' })
|
src/worker/worker.controller.ts
CHANGED
|
@@ -21,9 +21,9 @@ import {
|
|
| 21 |
import { WorkerService } from './worker.service';
|
| 22 |
import { Worker } from './dto/worker.dto';
|
| 23 |
import { CreateWorkerDto } from './dto/create-worker.dto';
|
| 24 |
-
import { DayOfWeek } from '
|
| 25 |
-
import { WorkerWithBooks } from '
|
| 26 |
-
import { buildDownloadFile } from '
|
| 27 |
|
| 28 |
@ApiTags('Workers')
|
| 29 |
@Controller('workers')
|
|
|
|
| 21 |
import { WorkerService } from './worker.service';
|
| 22 |
import { Worker } from './dto/worker.dto';
|
| 23 |
import { CreateWorkerDto } from './dto/create-worker.dto';
|
| 24 |
+
import { DayOfWeek } from '../types/worker.types';
|
| 25 |
+
import { WorkerWithBooks } from '../common/worker-link-manager';
|
| 26 |
+
import { buildDownloadFile } from '../utils/download.utils';
|
| 27 |
|
| 28 |
@ApiTags('Workers')
|
| 29 |
@Controller('workers')
|
src/worker/worker.service.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
import { Injectable, NotFoundException } from '@nestjs/common';
|
| 2 |
import { randomUUID } from 'crypto';
|
| 3 |
-
import { Book } from '
|
| 4 |
-
import { bookLinkManager } from '
|
| 5 |
import {
|
| 6 |
WorkerLinkManager,
|
| 7 |
WorkerWithBooks,
|
| 8 |
-
} from '
|
| 9 |
-
import { FileManager } from '
|
| 10 |
-
import { parseTxtRow, serializeTxtRow } from '
|
| 11 |
import { CreateWorkerDto } from './dto/create-worker.dto';
|
| 12 |
import { Worker } from './dto/worker.dto';
|
| 13 |
-
import { DayOfWeek } from '
|
| 14 |
-
import { Link } from '
|
| 15 |
|
| 16 |
@Injectable()
|
| 17 |
export class WorkerService {
|
| 18 |
-
private file = new FileManager('
|
| 19 |
private workerLinkManager = new WorkerLinkManager();
|
| 20 |
|
| 21 |
async getAll(): Promise<Worker[]> {
|
|
|
|
| 1 |
import { Injectable, NotFoundException } from '@nestjs/common';
|
| 2 |
import { randomUUID } from 'crypto';
|
| 3 |
+
import { Book } from '../book/dto/book.dto';
|
| 4 |
+
import { bookLinkManager } from '../common/book-link-manager';
|
| 5 |
import {
|
| 6 |
WorkerLinkManager,
|
| 7 |
WorkerWithBooks,
|
| 8 |
+
} from '../common/worker-link-manager';
|
| 9 |
+
import { FileManager } from '../utils/file-manager';
|
| 10 |
+
import { parseTxtRow, serializeTxtRow } from '../utils/file.utils';
|
| 11 |
import { CreateWorkerDto } from './dto/create-worker.dto';
|
| 12 |
import { Worker } from './dto/worker.dto';
|
| 13 |
+
import { DayOfWeek } from '../types/worker.types';
|
| 14 |
+
import { Link } from '../common/Link';
|
| 15 |
|
| 16 |
@Injectable()
|
| 17 |
export class WorkerService {
|
| 18 |
+
private file = new FileManager('../data/workers.txt');
|
| 19 |
private workerLinkManager = new WorkerLinkManager();
|
| 20 |
|
| 21 |
async getAll(): Promise<Worker[]> {
|