From 10bf5295a928e4e412e541e7994805c82cf23eb9 Mon Sep 17 00:00:00 2001
From: Samuli Virtapohja <l4721@student.jamk.fi>
Date: Mon, 3 Jun 2019 16:21:12 +0300
Subject: [PATCH] returns info from mapmarkers

---
 src/mapmarkers/mapmarker.entity.ts      |  6 +++---
 src/mapmarkers/mapmarker.service.ts     | 17 ++++++++++-------
 src/mapmarkers/mapmarkers.controller.ts | 16 +++++++++++-----
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/mapmarkers/mapmarker.entity.ts b/src/mapmarkers/mapmarker.entity.ts
index 81a0695..1314e95 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 98e4309..c95748f 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 121cc76..793f3cb 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();
     }
 }
-- 
GitLab