-
Notifications
You must be signed in to change notification settings - Fork 2
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 #5 from CAU-MOAPP-2023/feat/2-feat-user-entity
✨ feat: implement all entities (#2)
- Loading branch information
Showing
19 changed files
with
947 additions
and
49 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forRoot({ | ||
type: 'mysql', | ||
host: '127.0.0.1', | ||
username: 'root', | ||
password: '12345678', | ||
database: 'family_app_db', | ||
entities: [], | ||
synchronize: true, | ||
}), | ||
], | ||
}) | ||
export class MysqlModule {} |
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 @@ | ||
export class CreateUserDto {} |
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,4 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { CreateUserDto } from './create-user.dto'; | ||
|
||
export class UpdateUserDto extends PartialType(CreateUserDto) {} |
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,42 @@ | ||
import { | ||
Controller, | ||
Get, | ||
Post, | ||
Body, | ||
Patch, | ||
Param, | ||
Delete, | ||
} from '@nestjs/common'; | ||
import { UserService } from './user.service'; | ||
import { CreateUserDto } from './dto/create-user.dto'; | ||
import { UpdateUserDto } from './dto/update-user.dto'; | ||
|
||
@Controller('user') | ||
export class UserController { | ||
constructor(private readonly userService: UserService) {} | ||
|
||
@Post() | ||
create(@Body() createUserDto: CreateUserDto) { | ||
return this.userService.create(createUserDto); | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.userService.findAll(); | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.userService.findOne(+id); | ||
} | ||
|
||
@Patch(':id') | ||
update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) { | ||
return this.userService.update(+id, updateUserDto); | ||
} | ||
|
||
@Delete(':id') | ||
remove(@Param('id') id: string) { | ||
return this.userService.remove(+id); | ||
} | ||
} |
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,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { UserService } from './user.service'; | ||
import { UserController } from './user.controller'; | ||
import { MysqlModule } from '../../database/mysql.module'; | ||
|
||
@Module({ | ||
imports: [MysqlModule], | ||
controllers: [UserController], | ||
providers: [UserService], | ||
}) | ||
export class UserModule {} |
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,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { UserService } from './user.service'; | ||
|
||
describe('UserService', () => { | ||
let service: UserService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [UserService], | ||
}).compile(); | ||
|
||
service = module.get<UserService>(UserService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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,26 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CreateUserDto } from './dto/create-user.dto'; | ||
import { UpdateUserDto } from './dto/update-user.dto'; | ||
|
||
@Injectable() | ||
export class UserService { | ||
create(createUserDto: CreateUserDto) { | ||
return 'This action adds a new user'; | ||
} | ||
|
||
findAll() { | ||
return `This action returns all user`; | ||
} | ||
|
||
findOne(id: number) { | ||
return `This action returns a #${id} user`; | ||
} | ||
|
||
update(id: number, updateUserDto: UpdateUserDto) { | ||
return `This action updates a #${id} user`; | ||
} | ||
|
||
remove(id: number) { | ||
return `This action removes a #${id} user`; | ||
} | ||
} |
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,36 @@ | ||
import { | ||
Column, | ||
Entity, | ||
Index, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToMany, | ||
} from 'typeorm'; | ||
import { FamilyEntity } from './family.entity'; | ||
import { PhotoEntity } from './photo.entity'; | ||
|
||
@Index('FK_family_TO_album_1', ['familyId'], {}) | ||
@Entity('album', { schema: 'family_app_db' }) | ||
export class AlbumEntity { | ||
@Column('int', { primary: true, name: 'ID' }) | ||
id: number; | ||
|
||
@Column('int', { primary: true, name: 'family_ID' }) | ||
familyId: number; | ||
|
||
@Column('int', { name: 'photo_number', nullable: true }) | ||
photoNumber: number | null; | ||
|
||
@Column('varchar', { name: 'album_name', nullable: true, length: 50 }) | ||
albumName: string | null; | ||
|
||
@ManyToOne(() => FamilyEntity, (family) => family.albums, { | ||
onDelete: 'CASCADE', | ||
onUpdate: 'NO ACTION', | ||
}) | ||
@JoinColumn([{ name: 'family_ID', referencedColumnName: 'id' }]) | ||
family: FamilyEntity; | ||
|
||
@OneToMany(() => PhotoEntity, (photo) => photo.album) | ||
photos: PhotoEntity[]; | ||
} |
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,28 @@ | ||
import { Column, Entity, OneToMany } from 'typeorm'; | ||
import { AlbumEntity } from './album.entity'; | ||
import { FamilymemberEntity } from './familymember.entity'; | ||
import { FamilyScheduleEntity } from './familySchedule.entity'; | ||
|
||
@Entity('family', { schema: 'family_app_db' }) | ||
export class FamilyEntity { | ||
@Column('int', { primary: true, name: 'ID' }) | ||
id: number; | ||
|
||
@Column('int', { name: 'member_number', nullable: true }) | ||
memberNumber: number | null; | ||
|
||
@Column('varchar', { name: 'family_name', nullable: true, length: 50 }) | ||
familyName: string | null; | ||
|
||
@Column('date', { name: 'created_date', nullable: true }) | ||
createdDate: string | null; | ||
|
||
@OneToMany(() => AlbumEntity, (album) => album.family) | ||
albums: AlbumEntity[]; | ||
|
||
@OneToMany(() => FamilymemberEntity, (familyMember) => familyMember.family) | ||
familyMembers: FamilymemberEntity[]; | ||
|
||
@OneToMany(() => FamilyScheduleEntity, (familySchedule) => familySchedule.family) | ||
familySchedules: FamilyScheduleEntity[]; | ||
} |
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,25 @@ | ||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; | ||
import { FamilyEntity } from './family.entity'; | ||
|
||
@Index('FK_family_TO_family_schedule_1', ['familyId'], {}) | ||
@Entity('family_schedule', { schema: 'family_app_db' }) | ||
export class FamilyScheduleEntity { | ||
@Column('int', { primary: true, name: 'ID' }) | ||
id: number; | ||
|
||
@Column('int', { primary: true, name: 'family_ID' }) | ||
familyId: number; | ||
|
||
@Column('varchar', { name: 'schedule_name', nullable: true, length: 50 }) | ||
scheduleName: string | null; | ||
|
||
@Column('date', { name: 'schedule_date', nullable: true }) | ||
scheduleDate: string | null; | ||
|
||
@ManyToOne(() => FamilyEntity, (family) => family.familySchedules, { | ||
onDelete: 'CASCADE', | ||
onUpdate: 'NO ACTION', | ||
}) | ||
@JoinColumn([{ name: 'family_ID', referencedColumnName: 'id' }]) | ||
family: FamilyEntity; | ||
} |
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,58 @@ | ||
import { | ||
Column, | ||
Entity, | ||
Index, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToMany, | ||
} from 'typeorm'; | ||
import { FamilyEntity } from './family.entity'; | ||
import { UserEntity } from './user.entity'; | ||
import { IndividualScheduleEntity } from './individualSchedule.entity'; | ||
import { PostEntity } from './post.entity'; | ||
|
||
@Index('FK_family_TO_family_member_1', ['familyId'], {}) | ||
@Index('FK_user_TO_family_member_1', ['userId'], {}) | ||
@Entity('family_member', { schema: 'family_app_db' }) | ||
export class FamilymemberEntity { | ||
@Column('int', { primary: true, name: 'ID' }) | ||
id: number; | ||
|
||
@Column('int', { primary: true, name: 'user_ID' }) | ||
userId: number; | ||
|
||
@Column('int', { primary: true, name: 'family_ID' }) | ||
familyId: number; | ||
|
||
@Column('int', { name: 'family_role', nullable: true }) | ||
familyRole: number | null; | ||
|
||
@Column('int', { name: 'poke_count', nullable: true }) | ||
pokeCount: number | null; | ||
|
||
@Column('int', { name: 'talk_count', nullable: true }) | ||
talkCount: number | null; | ||
|
||
@ManyToOne(() => FamilyEntity, (family) => family.familyMembers, { | ||
onDelete: 'CASCADE', | ||
onUpdate: 'NO ACTION', | ||
}) | ||
@JoinColumn([{ name: 'family_ID', referencedColumnName: 'id' }]) | ||
family: FamilyEntity; | ||
|
||
@ManyToOne(() => UserEntity, (user) => user.familyMembers, { | ||
onDelete: 'CASCADE', | ||
onUpdate: 'NO ACTION', | ||
}) | ||
@JoinColumn([{ name: 'user_ID', referencedColumnName: 'id' }]) | ||
user: UserEntity; | ||
|
||
@OneToMany( | ||
() => IndividualScheduleEntity, | ||
(individualSchedule) => individualSchedule.member, | ||
) | ||
individualSchedules: IndividualScheduleEntity[]; | ||
|
||
@OneToMany(() => PostEntity, (post) => post.srcMember) | ||
posts: PostEntity[]; | ||
} |
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,26 @@ | ||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; | ||
import { FamilymemberEntity } from './familymember.entity'; | ||
|
||
@Index('FK_family_member_TO_individual_schedule_1', ['memberId'], {}) | ||
@Entity('individual_schedule', { schema: 'family_app_db' }) | ||
export class IndividualScheduleEntity { | ||
@Column('int', { primary: true, name: 'ID' }) | ||
id: number; | ||
|
||
@Column('int', { primary: true, name: 'member_ID' }) | ||
memberId: number; | ||
|
||
@Column('varchar', { name: 'schedule_name', nullable: true, length: 50 }) | ||
scheduleName: string | null; | ||
|
||
@Column('date', { name: 'schedule_date', nullable: true }) | ||
scheduleDate: string | null; | ||
|
||
@ManyToOne( | ||
() => FamilymemberEntity, | ||
(familyMember) => familyMember.individualSchedules, | ||
{ onDelete: 'CASCADE', onUpdate: 'NO ACTION' }, | ||
) | ||
@JoinColumn([{ name: 'member_ID', referencedColumnName: 'id' }]) | ||
member: FamilymemberEntity; | ||
} |
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,28 @@ | ||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; | ||
import { AlbumEntity } from './album.entity'; | ||
|
||
@Index('FK_album_TO_photo_1', ['albumId'], {}) | ||
@Entity('photo', { schema: 'family_app_db' }) | ||
export class PhotoEntity { | ||
@Column('int', { primary: true, name: 'ID' }) | ||
id: number; | ||
|
||
@Column('int', { primary: true, name: 'album_ID' }) | ||
albumId: number; | ||
|
||
@Column('varchar', { name: 'S3_image_URL', nullable: true, length: 100 }) | ||
s3ImageUrl: string | null; | ||
|
||
@Column('varchar', { name: 'photo_name', nullable: true, length: 50 }) | ||
photoName: string | null; | ||
|
||
@Column('date', { name: 'created_date', nullable: true }) | ||
createdDate: string | null; | ||
|
||
@ManyToOne(() => AlbumEntity, (album) => album.photos, { | ||
onDelete: 'CASCADE', | ||
onUpdate: 'NO ACTION', | ||
}) | ||
@JoinColumn([{ name: 'album_ID', referencedColumnName: 'id' }]) | ||
album: AlbumEntity; | ||
} |
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,28 @@ | ||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; | ||
import { FamilymemberEntity } from './familymember.entity'; | ||
|
||
@Index('FK_family_member_TO_post_1', ['srcMemberId'], {}) | ||
@Entity('post', { schema: 'family_app_db' }) | ||
export class PostEntity { | ||
@Column('varchar', { primary: true, name: 'ID', length: 255 }) | ||
id: string; | ||
|
||
@Column('int', { primary: true, name: 'src_member_ID' }) | ||
srcMemberId: number; | ||
|
||
@Column('varchar', { name: 'title', nullable: true, length: 50 }) | ||
title: string | null; | ||
|
||
@Column('varchar', { name: 'post_context', nullable: true, length: 50 }) | ||
postContext: string | null; | ||
|
||
@Column('date', { name: 'created_date', nullable: true }) | ||
createdDate: string | null; | ||
|
||
@ManyToOne(() => FamilymemberEntity, (familyMember) => familyMember.posts, { | ||
onDelete: 'CASCADE', | ||
onUpdate: 'NO ACTION', | ||
}) | ||
@JoinColumn([{ name: 'src_member_ID', referencedColumnName: 'id' }]) | ||
srcMember: FamilymemberEntity; | ||
} |
Oops, something went wrong.