Skip to content

Commit 62cf597

Browse files
committed
add: upload entities
1 parent f304a9a commit 62cf597

30 files changed

+9973
-0
lines changed

.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# dependencies
2+
node_modules/
3+
4+
# IDE
5+
/.idea
6+
/.awcache
7+
/.vscode
8+
/.devcontainer
9+
*.code-workspace
10+
11+
# Vim
12+
[._]*.s[a-v][a-z]
13+
[._]*.sw[a-p]
14+
[._]s[a-rt-v][a-z]
15+
[._]ss[a-gi-z]
16+
[._]sw[a-p]
17+
18+
# bundle
19+
packages/**/*.d.ts
20+
packages/**/*.js
21+
22+
# misc
23+
.DS_Store
24+
lerna-debug.log
25+
npm-debug.log
26+
yarn-error.log
27+
/**/npm-debug.log
28+
/packages/**/.npmignore
29+
/packages/**/LICENSE
30+
*.tsbuildinfo
31+
32+
# example
33+
/quick-start
34+
/example_dist
35+
/example
36+
37+
# tests
38+
/test
39+
/benchmarks/memory
40+
/coverage
41+
/.nyc_output
42+
/packages/graphql
43+
/benchmarks/memory
44+
build/config\.gypi

delimo-be/.eslintrc.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir : __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
ignorePatterns: ['.eslintrc.js'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};

delimo-be/.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

delimo-be/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Delimo Backend Server
2+
3+
## Database Modeling
4+
<img src="https://user-images.githubusercontent.com/71310074/208893989-008a01d4-43bd-4ca1-9d0c-987bca9d16b0.png" width=600>

delimo-be/nest-cli.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://json.schemastore.org/nest-cli",
3+
"collection": "@nestjs/schematics",
4+
"sourceRoot": "src"
5+
}
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import {
2+
Column,
3+
Entity,
4+
Index,
5+
JoinColumn,
6+
ManyToOne,
7+
OneToOne,
8+
} from "typeorm";
9+
import { PrivacyTbl } from "./PrivacyTbl";
10+
import { Questions } from "./Questions";
11+
import { UserTodayResponse } from "./UserTodayResponse";
12+
import { UserAnswerAnalysis } from "./UserAnswerAnalysis";
13+
14+
@Index("fk_privacy_state_id_idx", ["fkPrivacyStateId"], {})
15+
@Index("fk_question_id_fora_idx", ["fkQuestionId"], {})
16+
@Index("fk_response_id_for_answer_idx", ["fkResponseId"], {})
17+
@Entity("answer_tbl", { schema: "delimo" })
18+
export class AnswerTbl {
19+
@Column("int", { primary: true, name: "id" })
20+
id: number;
21+
22+
@Column("int", { name: "fk_question_id" })
23+
fkQuestionId: number;
24+
25+
@Column("date", { name: "created_at" })
26+
createdAt: string;
27+
28+
@Column("int", { name: "fk_privacy_state_id" })
29+
fkPrivacyStateId: number;
30+
31+
@Column("text", { name: "content" })
32+
content: string;
33+
34+
@Column("int", { primary: true, name: "fk_response_id" })
35+
fkResponseId: number;
36+
37+
@ManyToOne(() => PrivacyTbl, (privacyTbl) => privacyTbl.answerTbls, {
38+
onDelete: "NO ACTION",
39+
onUpdate: "NO ACTION",
40+
})
41+
@JoinColumn([{ name: "fk_privacy_state_id", referencedColumnName: "id" }])
42+
fkPrivacyState: PrivacyTbl;
43+
44+
@ManyToOne(() => Questions, (questions) => questions.answerTbls, {
45+
onDelete: "NO ACTION",
46+
onUpdate: "NO ACTION",
47+
})
48+
@JoinColumn([{ name: "fk_question_id", referencedColumnName: "id" }])
49+
fkQuestion: Questions;
50+
51+
@ManyToOne(
52+
() => UserTodayResponse,
53+
(userTodayResponse) => userTodayResponse.answerTbls,
54+
{ onDelete: "NO ACTION", onUpdate: "NO ACTION" }
55+
)
56+
@JoinColumn([{ name: "fk_response_id", referencedColumnName: "id" }])
57+
fkResponse: UserTodayResponse;
58+
59+
@OneToOne(
60+
() => UserAnswerAnalysis,
61+
(userAnswerAnalysis) => userAnswerAnalysis.fkAnswer
62+
)
63+
userAnswerAnalysis: UserAnswerAnalysis;
64+
}

delimo-be/output/entities/DiaryTbl.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
2+
import { UserTodayResponse } from "./UserTodayResponse";
3+
4+
@Index("fk_response_id_for_diary_idx", ["fkResponseId"], {})
5+
@Entity("diary_tbl", { schema: "delimo" })
6+
export class DiaryTbl {
7+
@Column("int", { primary: true, name: "id" })
8+
id: number;
9+
10+
@Column("int", { name: "fk_response_id" })
11+
fkResponseId: number;
12+
13+
@Column("date", { name: "content" })
14+
content: string;
15+
16+
@ManyToOne(
17+
() => UserTodayResponse,
18+
(userTodayResponse) => userTodayResponse.diaryTbls,
19+
{ onDelete: "NO ACTION", onUpdate: "NO ACTION" }
20+
)
21+
@JoinColumn([{ name: "fk_response_id", referencedColumnName: "id" }])
22+
fkResponse: UserTodayResponse;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Column, Entity, OneToMany } from "typeorm";
2+
import { FriendsTbl } from "./FriendsTbl";
3+
4+
@Entity("friend_status_tbl", { schema: "delimo" })
5+
export class FriendStatusTbl {
6+
@Column("int", { primary: true, name: "id" })
7+
id: number;
8+
9+
@Column("varchar", { name: "status_name", length: 45 })
10+
statusName: string;
11+
12+
@OneToMany(() => FriendsTbl, (friendsTbl) => friendsTbl.friendStatusCode2)
13+
friendsTbls: FriendsTbl[];
14+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
2+
import { FriendStatusTbl } from "./FriendStatusTbl";
3+
import { Users } from "./Users";
4+
5+
@Index("friend_status_code_id_idx", ["friendStatusCode"], {})
6+
@Index("user_friend1_id_idx", ["friend1Id"], {})
7+
@Index("user_friend2_id_idx", ["friend2Id"], {})
8+
@Entity("friends_tbl", { schema: "delimo" })
9+
export class FriendsTbl {
10+
@Column("int", { primary: true, name: "id" })
11+
id: number;
12+
13+
@Column("int", { name: "friend1_id" })
14+
friend1Id: number;
15+
16+
@Column("int", { name: "friend2_id" })
17+
friend2Id: number;
18+
19+
@Column("int", { name: "friend_status_code" })
20+
friendStatusCode: number;
21+
22+
@ManyToOne(
23+
() => FriendStatusTbl,
24+
(friendStatusTbl) => friendStatusTbl.friendsTbls,
25+
{ onDelete: "NO ACTION", onUpdate: "NO ACTION" }
26+
)
27+
@JoinColumn([{ name: "friend_status_code", referencedColumnName: "id" }])
28+
friendStatusCode2: FriendStatusTbl;
29+
30+
@ManyToOne(() => Users, (users) => users.friendsTbls, {
31+
onDelete: "NO ACTION",
32+
onUpdate: "NO ACTION",
33+
})
34+
@JoinColumn([{ name: "friend1_id", referencedColumnName: "id" }])
35+
friend1: Users;
36+
37+
@ManyToOne(() => Users, (users) => users.friendsTbls2, {
38+
onDelete: "NO ACTION",
39+
onUpdate: "NO ACTION",
40+
})
41+
@JoinColumn([{ name: "friend2_id", referencedColumnName: "id" }])
42+
friend2: Users;
43+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Column, Entity, OneToMany } from "typeorm";
2+
import { AnswerTbl } from "./AnswerTbl";
3+
4+
@Entity("privacy_tbl", { schema: "delimo" })
5+
export class PrivacyTbl {
6+
@Column("int", { primary: true, name: "id" })
7+
id: number;
8+
9+
@Column("varchar", { name: "title", nullable: true, length: 45 })
10+
title: string | null;
11+
12+
@Column("int", { name: "privacy_state", nullable: true })
13+
privacyState: number | null;
14+
15+
@OneToMany(() => AnswerTbl, (answerTbl) => answerTbl.fkPrivacyState)
16+
answerTbls: AnswerTbl[];
17+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Column, Entity, OneToMany } from "typeorm";
2+
import { AnswerTbl } from "./AnswerTbl";
3+
4+
@Entity("questions", { schema: "delimo" })
5+
export class Questions {
6+
@Column("int", { primary: true, name: "id" })
7+
id: number;
8+
9+
@Column("text", { name: "title" })
10+
title: string;
11+
12+
@OneToMany(() => AnswerTbl, (answerTbl) => answerTbl.fkQuestion)
13+
answerTbls: AnswerTbl[];
14+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Column, Entity, OneToMany } from "typeorm";
2+
import { UserAnswerAnalysis } from "./UserAnswerAnalysis";
3+
4+
@Entity("sentiment_tbl", { schema: "delimo" })
5+
export class SentimentTbl {
6+
@Column("int", { primary: true, name: "id" })
7+
id: number;
8+
9+
@Column("varchar", { name: "sentiment_name", nullable: true, length: 45 })
10+
sentimentName: string | null;
11+
12+
@Column("text", { name: "description", nullable: true })
13+
description: string | null;
14+
15+
@OneToMany(
16+
() => UserAnswerAnalysis,
17+
(userAnswerAnalysis) => userAnswerAnalysis.representativeSentimentCode2
18+
)
19+
userAnswerAnalyses: UserAnswerAnalysis[];
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
Column,
3+
Entity,
4+
Index,
5+
JoinColumn,
6+
ManyToOne,
7+
OneToOne,
8+
} from "typeorm";
9+
import { AnswerTbl } from "./AnswerTbl";
10+
import { SentimentTbl } from "./SentimentTbl";
11+
12+
@Index(
13+
"fk_representative_sentiment_id_idx",
14+
["representativeSentimentCode"],
15+
{}
16+
)
17+
@Entity("user_answer_analysis", { schema: "delimo" })
18+
export class UserAnswerAnalysis {
19+
@Column("int", { primary: true, name: "fk_answer_id" })
20+
fkAnswerId: number;
21+
22+
@Column("int", { name: "representative_sentiment_code", nullable: true })
23+
representativeSentimentCode: number | null;
24+
25+
@OneToOne(() => AnswerTbl, (answerTbl) => answerTbl.userAnswerAnalysis, {
26+
onDelete: "NO ACTION",
27+
onUpdate: "NO ACTION",
28+
})
29+
@JoinColumn([{ name: "fk_answer_id", referencedColumnName: "id" }])
30+
fkAnswer: AnswerTbl;
31+
32+
@ManyToOne(
33+
() => SentimentTbl,
34+
(sentimentTbl) => sentimentTbl.userAnswerAnalyses,
35+
{ onDelete: "NO ACTION", onUpdate: "NO ACTION" }
36+
)
37+
@JoinColumn([
38+
{ name: "representative_sentiment_code", referencedColumnName: "id" },
39+
])
40+
representativeSentimentCode2: SentimentTbl;
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {
2+
Column,
3+
Entity,
4+
Index,
5+
JoinColumn,
6+
ManyToOne,
7+
OneToMany,
8+
} from "typeorm";
9+
import { Users } from "./Users";
10+
import { UserTodayResponse } from "./UserTodayResponse";
11+
12+
@Index("fk_user_id_for_calendar_idx", ["fkUserId"], {})
13+
@Entity("user_calendar_tbl", { schema: "delimo" })
14+
export class UserCalendarTbl {
15+
@Column("int", { primary: true, name: "id" })
16+
id: number;
17+
18+
@Column("int", { name: "fk_user_id", nullable: true })
19+
fkUserId: number | null;
20+
21+
@ManyToOne(() => Users, (users) => users.userCalendarTbls, {
22+
onDelete: "NO ACTION",
23+
onUpdate: "NO ACTION",
24+
})
25+
@JoinColumn([{ name: "fk_user_id", referencedColumnName: "id" }])
26+
fkUser: Users;
27+
28+
@OneToMany(
29+
() => UserTodayResponse,
30+
(userTodayResponse) => userTodayResponse.fkCalendar
31+
)
32+
userTodayResponses: UserTodayResponse[];
33+
}

0 commit comments

Comments
 (0)