diff --git a/src/mapmarkers/mapmarker.entity.ts b/src/mapmarkers/mapmarker.entity.ts index 81a06955dc37e1fef4b87e19b9d6e8270097fba3..1314e95cb31357e1c7ab872c5a1cc0ed1597ce41 100644 --- a/src/mapmarkers/mapmarker.entity.ts +++ b/src/mapmarkers/mapmarker.entity.ts @@ -3,11 +3,11 @@ import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, PrimaryColumn } f import * as jwt from 'jsonwebtoken'; import { identifier } from '@babel/types'; -@Entity('Powerup') +@Entity('MapMarker') export class MapMarkerEntity { @PrimaryGeneratedColumn('uuid') id: string; - @Column({type: 'text'}) name: string; - @Column({type: 'text'}) cooldown: string; + @Column({type: 'text'}) latitude: string; + @Column({type: 'text'}) longitude: string; } \ No newline at end of file diff --git a/src/mapmarkers/mapmarker.service.ts b/src/mapmarkers/mapmarker.service.ts index 98e4309323ee11d884cbdbd36606d303dc569513..c95748fed0d8a5d1d59b11e91564f85732f629c3 100644 --- a/src/mapmarkers/mapmarker.service.ts +++ b/src/mapmarkers/mapmarker.service.ts @@ -12,15 +12,18 @@ export class MapMarkerService { // insert markers async insertLocation(data: MapMarkerDTO){ - // check for token return if not set + // check for token return if not set return null or something const { latitude, longitude } = data; - //let location = await this.mapmarkerRepository.create(data); - //await this.mapmarkerRepository.save(location); - } + let location = await this.mapmarkerRepository.create(data); + await this.mapmarkerRepository.save(location); + } // get all markers - async getAllMarkers(): Promise<string>{ - //this.mapmarkerRepository.findByIds(); - return 'all markers'; + async getAllMarkers(): Promise<MapMarkerEntity[]>{ + + // const users= this.mapmarkerRepository.find(); + // users.map + // user. + return this.mapmarkerRepository.find(); } } \ No newline at end of file diff --git a/src/mapmarkers/mapmarkers.controller.ts b/src/mapmarkers/mapmarkers.controller.ts index 121cc76ebbae3b8f4fe6b6da9d048f19ac320951..793f3cb61481cd5bec84b5ed18ed664f7564f2cd 100644 --- a/src/mapmarkers/mapmarkers.controller.ts +++ b/src/mapmarkers/mapmarkers.controller.ts @@ -7,18 +7,24 @@ import { MapMarkerDTO } from './mapmarker.dto'; export class MapMarkersController { constructor(private mapmarkerservice: MapMarkerService){} + // update user location @Post('location') - getLoctaion(@Body() data: MapMarkerDTO){ + async getLoctaion(@Body() data: MapMarkerDTO){ + // get user location && id + // update location to database return this.mapmarkerservice.insertLocation(data); } - + + // Insert figure location @Put('insertLocation') - insertLocation(@Body() data: MapMarkerDTO){ - + async insertLocation(@Body() data: MapMarkerDTO){ + this.mapmarkerservice.insertLocation(data); } @Get('getall') - getAll(){ + async getAll(){ + // hakee kaikki + // palauttaa vain halutut return this.mapmarkerservice.getAllMarkers(); } }