-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #565 from SidorovVladimir/backend_user_settings
#501 Backend user settings
- Loading branch information
Showing
11 changed files
with
207 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
Column, | ||
CreateDateColumn, | ||
Entity, | ||
JoinColumn, | ||
OneToOne, | ||
PrimaryGeneratedColumn, | ||
UpdateDateColumn, | ||
} from 'typeorm'; | ||
import type { User } from './user.entity'; | ||
|
||
@Entity('user_settings') | ||
export class UserSettings { | ||
@PrimaryGeneratedColumn() | ||
settings_id: number; | ||
|
||
@Column('text', { default: 'ru' }) | ||
language: string; | ||
|
||
@Column('text', { default: 'system' }) | ||
theme: string; | ||
|
||
@CreateDateColumn() | ||
created_at: string; | ||
|
||
@UpdateDateColumn() | ||
updated_at: string; | ||
|
||
@OneToOne('User', 'user_settings') | ||
@JoinColumn({ name: 'userId' }) | ||
user: User; | ||
|
||
@Column({ name: 'userId' }) | ||
userId: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
backend/src/migrations/1730013613468-backend_user_settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { MigrationInterface, QueryRunner, Table } from 'typeorm'; | ||
|
||
export class BackendUserSettings1730013613468 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.createTable( | ||
new Table({ | ||
name: 'user_settings', | ||
columns: [ | ||
{ | ||
name: 'settings_id', | ||
type: 'integer', | ||
isGenerated: true, | ||
generatedIdentity: 'ALWAYS', | ||
generationStrategy: 'increment', | ||
isNullable: false, | ||
isPrimary: true, | ||
}, | ||
{ | ||
name: 'language', | ||
type: 'varchar(50)', | ||
isNullable: false, | ||
}, | ||
|
||
{ | ||
name: 'theme', | ||
type: 'varchar(50)', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'created_at', | ||
type: 'timestamp', | ||
isNullable: false, | ||
default: 'CURRENT_TIMESTAMP', | ||
}, | ||
{ | ||
name: 'updated_at', | ||
type: 'timestamp', | ||
isNullable: false, | ||
default: 'CURRENT_TIMESTAMP', | ||
}, | ||
{ | ||
name: 'userId', | ||
type: 'int', | ||
}, | ||
], | ||
foreignKeys: [ | ||
{ | ||
name: 'userId', | ||
columnNames: ['userId'], | ||
referencedTableName: 'users', | ||
referencedColumnNames: ['id'], | ||
}, | ||
], | ||
}), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "user_settings"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IsString } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class UpdateUserSettingsDto { | ||
@ApiProperty() | ||
@IsString() | ||
theme?: string; | ||
|
||
@ApiProperty() | ||
@IsString() | ||
language?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters