Skip to content

Commit

Permalink
Merge pull request #77 from boostcampwm2023/fix/76-update-user-diary-…
Browse files Browse the repository at this point in the history
…entity-dto

[Refactor] 사용자와 일기에 대한 엔티티, DTO 업데이트
  • Loading branch information
JoonSoo-Kim authored Nov 21, 2023
2 parents 4db272a + c6d03e0 commit bcdd0c1
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions BE/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class AppModule {
userId: "commonUser",
password: process.env.COMMON_USER_PASS,
nickname: "commonUser",
email: "[email protected]",
}));

await this.shapesRepository.createDefaultShapes(commonUser);
Expand Down
4 changes: 2 additions & 2 deletions BE/src/configs/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const typeORMConfig: TypeOrmModuleOptions = {
password: process.env.DB_PASS,
database: process.env.DB_NAME,
entities: ["dist/**/*.entity{.ts,.js}"],
synchronize: true,
synchronize: false,
timezone: "+09:00",
};

Expand All @@ -19,7 +19,7 @@ export const typeORMTestConfig: TypeOrmModuleOptions = {
port: 3306,
username: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
database: process.env.TEST_DB_NAME,
entities: ["src/**/*.entity{.ts,.js}"],
synchronize: true,
timezone: "+09:00",
Expand Down
14 changes: 13 additions & 1 deletion BE/src/diaries/diaries.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class CreateDiaryDto {

@IsArray()
tags: string[];

@IsUUID()
shapeUuid: string;
}

export class ReadDiaryDto {
Expand All @@ -35,10 +38,19 @@ export class UpdateDiaryDto {
@IsString()
content: string;

@IsString()
@Matches(RegExp("^-?d+(.d+)?,-?d+(.d+)?,-?d+(.d+)?$"), {
message: "적절하지 않은 포인트 양식입니다",
})
point: string;

@IsDate()
date: Date;

@IsString()
@IsArray()
tags: string[];

@IsUUID()
shapeUuid: string;
}

Expand Down
3 changes: 0 additions & 3 deletions BE/src/diaries/diaries.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export class Diary extends BaseEntity {
@Column({ type: "text" })
content: string;

@Column({ length: 7 })
color: string;

@Column({ type: "float" })
positiveRatio: number;

Expand Down
2 changes: 0 additions & 2 deletions BE/src/diaries/diaries.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class DiariesRepository {
const content = encodedContent;

// 미구현 기능을 대체하기 위한 임시 값
const color = "#FFFFFF";
const positiveRatio = 0.0;
const negativeRatio = 100.0;
const neutralRatio = 0.0;
Expand All @@ -34,7 +33,6 @@ export class DiariesRepository {
content,
point,
date,
color,
positiveRatio,
negativeRatio,
neutralRatio,
Expand Down
1 change: 1 addition & 0 deletions BE/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AppModule } from "./app.module";

async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
await app.listen(process.env.BE_PORT);
}
bootstrap();
15 changes: 10 additions & 5 deletions BE/src/users/users.dto.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { IsString, IsNumber, IsEnum, MaxLength } from "class-validator";
import { premiumStatus } from "src/utils/enum";
import { IsString, Length, MaxLength, Matches } from "class-validator";

export class CreateUserDto {
@IsString()
@MaxLength(20)
@Length(4, 21)
userId: string;

@IsString()
@MaxLength(20)
@Matches("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$")
email: string;

@IsString()
@Length(4, 21)
password: string;

@IsString()
@MaxLength(20)
@MaxLength(21)
nickname: string;
}

export class LoginUserDto {
@IsString()
@Length(4, 21)
userId: string;

@IsString()
@Length(4, 21)
password: string;
}
3 changes: 3 additions & 0 deletions BE/src/users/users.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class User extends BaseEntity {
@Column({ length: 20, unique: true })
userId: string;

@Column({ unique: true })
email: string;

@Column({ length: 60 })
password: string;

Expand Down

0 comments on commit bcdd0c1

Please sign in to comment.