-
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.
- Loading branch information
1 parent
4d8ec53
commit 2c6db62
Showing
19 changed files
with
2,725 additions
and
8,710 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
start-prod: | ||
docker-compose up -d | ||
|
||
stop-prod: | ||
docker-compose down | ||
|
||
start: | ||
docker-compose -f docker-compose.dev.yml up -d | ||
|
||
stop: | ||
docker-compose -f docker-compose.dev.yml down | ||
|
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src" | ||
} | ||
"sourceRoot": "src", | ||
"compilerOptions": { | ||
"webpack": false | ||
} | ||
} |
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 { PartialType } from '@nestjs/mapped-types'; | ||
import { StudentEntity } from '../../../entities/student.entity'; | ||
import { Gender, ParentType } from '../../../libs'; | ||
import { ParentEntity } from '../../../entities/parent.entity'; | ||
|
||
export class CreateStudentDto extends PartialType(StudentEntity) { | ||
first_name: string; | ||
last_name: string; | ||
contact: string; | ||
email: string; | ||
gender: Gender; | ||
date_of_birth: string; | ||
} | ||
|
||
export class CreateParentDto extends PartialType(ParentEntity){ | ||
|
||
} |
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 { CreateStudentDto } from './create-student.dto'; | ||
|
||
export class UpdateStudentDto extends PartialType(CreateStudentDto) {} |
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 { Gender, ParentType } from '../../../../libs'; | ||
|
||
export class CreateParentDto { | ||
first_name: string; | ||
last_name: string; | ||
contact: string; | ||
email: string; | ||
type: ParentType; | ||
gender: Gender; | ||
student_id: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { CreateParentDto } from './create-parent.dto'; | ||
|
||
export class UpdateParentDto extends PartialType(CreateParentDto) {} |
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,20 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ParentController } from './parent.controller'; | ||
import { ParentService } from './parent.service'; | ||
|
||
describe('ParentController', () => { | ||
let controller: ParentController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [ParentController], | ||
providers: [ParentService], | ||
}).compile(); | ||
|
||
controller = module.get<ParentController>(ParentController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).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,34 @@ | ||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; | ||
import { ParentService } from './parent.service'; | ||
import { CreateParentDto } from './dto/create-parent.dto'; | ||
import { UpdateParentDto } from './dto/update-parent.dto'; | ||
|
||
@Controller('student/parent') | ||
export class ParentController { | ||
constructor(private readonly parentService: ParentService) {} | ||
|
||
@Post() | ||
create(@Body() createParentDto: CreateParentDto) { | ||
return this.parentService.create(createParentDto); | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.parentService.findAll(); | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.parentService.findOne(+id); | ||
} | ||
|
||
@Patch(':id') | ||
update(@Param('id') id: string, @Body() updateParentDto: UpdateParentDto) { | ||
return this.parentService.update(+id, updateParentDto); | ||
} | ||
|
||
@Delete(':id') | ||
remove(@Param('id') id: string) { | ||
return this.parentService.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,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ParentService } from './parent.service'; | ||
import { ParentController } from './parent.controller'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { ParentRepository } from './parent.repository'; | ||
import { StudentRepository } from '../student.repository'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([ParentRepository, StudentRepository])], | ||
controllers: [ParentController], | ||
providers: [ParentService], | ||
}) | ||
export class ParentModule { | ||
} |
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 { ParentService } from './parent.service'; | ||
|
||
describe('ParentService', () => { | ||
let service: ParentService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ParentService], | ||
}).compile(); | ||
|
||
service = module.get<ParentService>(ParentService); | ||
}); | ||
|
||
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,47 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CreateParentDto } from './dto/create-parent.dto'; | ||
import { UpdateParentDto } from './dto/update-parent.dto'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { ParentRepository } from './parent.repository'; | ||
import { ParentEntity } from '../../../entities/parent.entity'; | ||
import { StudentEntity } from '../../../entities/student.entity'; | ||
import { StudentRepository } from '../student.repository'; | ||
|
||
@Injectable() | ||
export class ParentService { | ||
constructor( | ||
@InjectRepository(ParentRepository) | ||
private readonly parentRepository: ParentRepository, | ||
@InjectRepository(StudentRepository) | ||
private readonly studentRepository: StudentRepository) { | ||
} | ||
|
||
async create(createParentDto: CreateParentDto) { | ||
const entity = this.parentRepository.create(createParentDto); | ||
if (createParentDto.student_id) { | ||
entity.student = await this.studentRepository | ||
.findOne({ id: createParentDto.student_id }); | ||
} | ||
return this.parentRepository.save(entity); | ||
} | ||
|
||
async findAll(): Promise<ParentEntity[]> { | ||
return this.parentRepository.find(); | ||
} | ||
|
||
async findOne(id: number) { | ||
return this.parentRepository.findOne({ id }); | ||
} | ||
|
||
async update(id: number, updateParentDto: UpdateParentDto): Promise<ParentEntity> { | ||
const parent = await this.findOne(id); | ||
console.log(parent); | ||
if (!parent) return null; | ||
parent.student = await this.studentRepository.findOne(updateParentDto.student_id); | ||
return this.parentRepository.save(parent); | ||
} | ||
|
||
remove(id: number) { | ||
return `This action removes a #${id} parent`; | ||
} | ||
} |
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,20 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { StudentController } from './student.controller'; | ||
import { StudentService } from './student.service'; | ||
|
||
describe('StudentController', () => { | ||
let controller: StudentController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [StudentController], | ||
providers: [StudentService], | ||
}).compile(); | ||
|
||
controller = module.get<StudentController>(StudentController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).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,34 @@ | ||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; | ||
import { StudentService } from './student.service'; | ||
import { CreateStudentDto } from './dto/create-student.dto'; | ||
import { UpdateStudentDto } from './dto/update-student.dto'; | ||
|
||
@Controller('student') | ||
export class StudentController { | ||
constructor(private readonly studentService: StudentService) {} | ||
|
||
@Post() | ||
create(@Body() createStudentDto: CreateStudentDto) { | ||
return this.studentService.create(createStudentDto); | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.studentService.findAll(); | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.studentService.findOne(+id); | ||
} | ||
|
||
@Patch(':id') | ||
update(@Param('id') id: string, @Body() updateStudentDto: UpdateStudentDto) { | ||
return this.studentService.update(+id, updateStudentDto); | ||
} | ||
|
||
@Delete(':id') | ||
remove(@Param('id') id: string) { | ||
return this.studentService.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,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { StudentService } from './student.service'; | ||
import { StudentController } from './student.controller'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { StudentRepository } from './student.repository'; | ||
import { ParentModule } from './parent/parent.module'; | ||
|
||
@Module({ | ||
imports:[TypeOrmModule.forFeature([StudentRepository]), ParentModule], | ||
controllers: [StudentController], | ||
providers: [StudentService], | ||
}) | ||
export class StudentModule { | ||
} |
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 { StudentService } from './student.service'; | ||
|
||
describe('StudentService', () => { | ||
let service: StudentService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [StudentService], | ||
}).compile(); | ||
|
||
service = module.get<StudentService>(StudentService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.