zarsa
2 years ago
20 changed files with 307 additions and 0 deletions
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm'; |
||||
import { Person } from './person.entity'; |
||||
|
||||
@Entity() |
||||
export class Group { |
||||
@PrimaryGeneratedColumn() |
||||
id: number; |
||||
@Column('nvarchar') |
||||
name: string; |
||||
@ManyToMany(() => Person, (person) => person.groups) |
||||
persons: Person[]; |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
import { |
||||
Column, |
||||
Entity, |
||||
JoinTable, |
||||
ManyToMany, |
||||
OneToMany, |
||||
PrimaryGeneratedColumn, |
||||
} from 'typeorm'; |
||||
import { Point } from './point.entity'; |
||||
import { Group } from './group.entity'; |
||||
|
||||
@Entity() |
||||
export class Person { |
||||
@PrimaryGeneratedColumn() |
||||
id: number; |
||||
@Column({ length: 25, type: 'nvarchar' }) |
||||
firstName: string; |
||||
@Column({ length: 25, type: 'nvarchar' }) |
||||
lastName: string; |
||||
@Column('int') |
||||
phoneNumber: number; |
||||
@OneToMany(() => Point, (point) => point.person) |
||||
points: Point[]; |
||||
@ManyToMany(() => Group, (group) => group.persons) |
||||
@JoinTable() |
||||
groups: Group[]; |
||||
} |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
import { Column, Entity, PrimaryColumn } from 'typeorm'; |
||||
|
||||
@Entity() |
||||
export class PointType { |
||||
@PrimaryColumn() |
||||
code: number; |
||||
@Column({ length: 25, type: 'nvarchar' }) |
||||
name: string; |
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; |
||||
import { Person } from './person.entity'; |
||||
|
||||
@Entity() |
||||
export class Point { |
||||
@PrimaryGeneratedColumn() |
||||
id: number; |
||||
@Column('text') |
||||
desc: string; |
||||
@Column('int') |
||||
numOf: number; |
||||
@ManyToOne(() => Person, (person) => person.points) |
||||
person: Person; |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; |
||||
|
||||
@Entity() |
||||
export class User { |
||||
@PrimaryGeneratedColumn() |
||||
id: number; |
||||
@Column({ length: 25, type: 'nvarchar' }) |
||||
firstName: string; |
||||
@Column({ length: 25, type: 'nvarchar' }) |
||||
lastName: string; |
||||
@Column({ length: 25 }) |
||||
username: string; |
||||
@Column({ length: 25 }) |
||||
password: string; |
||||
} |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
export class CreateGroupDto {} |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types'; |
||||
import { CreateGroupDto } from './create-group.dto'; |
||||
|
||||
export class UpdateGroupDto extends PartialType(CreateGroupDto) {} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; |
||||
import { GroupsService } from './groups.service'; |
||||
import { CreateGroupDto } from './dto/create-group.dto'; |
||||
import { UpdateGroupDto } from './dto/update-group.dto'; |
||||
|
||||
@Controller('groups') |
||||
export class GroupsController { |
||||
constructor(private readonly groupsService: GroupsService) {} |
||||
|
||||
@Post() |
||||
create(@Body() createGroupDto: CreateGroupDto) { |
||||
return this.groupsService.create(createGroupDto); |
||||
} |
||||
|
||||
@Get() |
||||
findAll() { |
||||
return this.groupsService.findAll(); |
||||
} |
||||
|
||||
@Get(':id') |
||||
findOne(@Param('id') id: string) { |
||||
return this.groupsService.findOne(+id); |
||||
} |
||||
|
||||
@Patch(':id') |
||||
update(@Param('id') id: string, @Body() updateGroupDto: UpdateGroupDto) { |
||||
return this.groupsService.update(+id, updateGroupDto); |
||||
} |
||||
|
||||
@Delete(':id') |
||||
remove(@Param('id') id: string) { |
||||
return this.groupsService.remove(+id); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common'; |
||||
import { GroupsService } from './groups.service'; |
||||
import { GroupsController } from './groups.controller'; |
||||
|
||||
@Module({ |
||||
controllers: [GroupsController], |
||||
providers: [GroupsService] |
||||
}) |
||||
export class GroupsModule {} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common'; |
||||
import { CreateGroupDto } from './dto/create-group.dto'; |
||||
import { UpdateGroupDto } from './dto/update-group.dto'; |
||||
|
||||
@Injectable() |
||||
export class GroupsService { |
||||
create(createGroupDto: CreateGroupDto) { |
||||
return 'This action adds a new group'; |
||||
} |
||||
|
||||
findAll() { |
||||
return `This action returns all groups`; |
||||
} |
||||
|
||||
findOne(id: number) { |
||||
return `This action returns a #${id} group`; |
||||
} |
||||
|
||||
update(id: number, updateGroupDto: UpdateGroupDto) { |
||||
return `This action updates a #${id} group`; |
||||
} |
||||
|
||||
remove(id: number) { |
||||
return `This action removes a #${id} group`; |
||||
} |
||||
} |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
export class CreatePersonDto {} |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types'; |
||||
import { CreatePersonDto } from './create-person.dto'; |
||||
|
||||
export class UpdatePersonDto extends PartialType(CreatePersonDto) {} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; |
||||
import { PersonsService } from './persons.service'; |
||||
import { CreatePersonDto } from './dto/create-person.dto'; |
||||
import { UpdatePersonDto } from './dto/update-person.dto'; |
||||
|
||||
@Controller('persons') |
||||
export class PersonsController { |
||||
constructor(private readonly personsService: PersonsService) {} |
||||
|
||||
@Post() |
||||
create(@Body() createPersonDto: CreatePersonDto) { |
||||
return this.personsService.create(createPersonDto); |
||||
} |
||||
|
||||
@Get() |
||||
findAll() { |
||||
return this.personsService.findAll(); |
||||
} |
||||
|
||||
@Get(':id') |
||||
findOne(@Param('id') id: string) { |
||||
return this.personsService.findOne(+id); |
||||
} |
||||
|
||||
@Patch(':id') |
||||
update(@Param('id') id: string, @Body() updatePersonDto: UpdatePersonDto) { |
||||
return this.personsService.update(+id, updatePersonDto); |
||||
} |
||||
|
||||
@Delete(':id') |
||||
remove(@Param('id') id: string) { |
||||
return this.personsService.remove(+id); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common'; |
||||
import { PersonsService } from './persons.service'; |
||||
import { PersonsController } from './persons.controller'; |
||||
|
||||
@Module({ |
||||
controllers: [PersonsController], |
||||
providers: [PersonsService] |
||||
}) |
||||
export class PersonsModule {} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common'; |
||||
import { CreatePersonDto } from './dto/create-person.dto'; |
||||
import { UpdatePersonDto } from './dto/update-person.dto'; |
||||
|
||||
@Injectable() |
||||
export class PersonsService { |
||||
create(createPersonDto: CreatePersonDto) { |
||||
return 'This action adds a new person'; |
||||
} |
||||
|
||||
findAll() { |
||||
return `This action returns all persons`; |
||||
} |
||||
|
||||
findOne(id: number) { |
||||
return `This action returns a #${id} person`; |
||||
} |
||||
|
||||
update(id: number, updatePersonDto: UpdatePersonDto) { |
||||
return `This action updates a #${id} person`; |
||||
} |
||||
|
||||
remove(id: number) { |
||||
return `This action removes a #${id} person`; |
||||
} |
||||
} |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
export class CreateUserDto {} |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types'; |
||||
import { CreateUserDto } from './create-user.dto'; |
||||
|
||||
export class UpdateUserDto extends PartialType(CreateUserDto) {} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
import { |
||||
Controller, |
||||
Get, |
||||
Post, |
||||
Body, |
||||
Patch, |
||||
Param, |
||||
Delete, |
||||
} from '@nestjs/common'; |
||||
import { UsersService } from './users.service'; |
||||
import { CreateUserDto } from './dto/create-user.dto'; |
||||
import { UpdateUserDto } from './dto/update-user.dto'; |
||||
|
||||
@Controller('users') |
||||
export class UsersController { |
||||
constructor(private readonly usersService: UsersService) {} |
||||
|
||||
@Post() |
||||
create(@Body() createUserDto: CreateUserDto) { |
||||
return this.usersService.create(createUserDto); |
||||
} |
||||
|
||||
@Get() |
||||
findAll() { |
||||
return this.usersService.findAll(); |
||||
} |
||||
|
||||
@Get(':id') |
||||
findOne(@Param('id') id: string) { |
||||
return this.usersService.findOne(+id); |
||||
} |
||||
|
||||
@Patch(':id') |
||||
update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) { |
||||
return this.usersService.update(+id, updateUserDto); |
||||
} |
||||
|
||||
@Delete(':id') |
||||
remove(@Param('id') id: string) { |
||||
return this.usersService.remove(+id); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common'; |
||||
import { UsersService } from './users.service'; |
||||
import { UsersController } from './users.controller'; |
||||
|
||||
@Module({ |
||||
controllers: [UsersController], |
||||
providers: [UsersService] |
||||
}) |
||||
export class UsersModule {} |
@ -0,0 +1,26 @@
@@ -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 UsersService { |
||||
create(createUserDto: CreateUserDto) { |
||||
return 'This action adds a new user'; |
||||
} |
||||
|
||||
findAll() { |
||||
return `This action returns all users`; |
||||
} |
||||
|
||||
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`; |
||||
} |
||||
} |
Loading…
Reference in new issue