Merge branch 'develop' into frontend/robin

This commit is contained in:
rchrist 2019-05-03 15:21:46 +02:00
commit 6fb8cd8f91
35 changed files with 936 additions and 603 deletions

View File

@ -7,7 +7,7 @@ plugins {
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
apply plugin: 'com.moowork.node'
apply plugin: 'war'
//apply plugin: 'war'
group = 'de.hhn.labsw'
version = '0.0.1-SNAPSHOT'
@ -47,13 +47,17 @@ dependencies {
compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.1.4.RELEASE'
//compile group: 'at.favre.lib', name: 'bcrypt', version: '{latest-version}'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
//providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
//JWT
compile 'io.jsonwebtoken:jjwt-api:0.10.5'
runtime 'io.jsonwebtoken:jjwt-impl:0.10.5',
'io.jsonwebtoken:jjwt-jackson:0.10.5'
compile "io.springfox:springfox-swagger2:2.9.2"
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.0.2'
}
node {

View File

@ -109,11 +109,14 @@ module.exports = function (ctx) {
},
env: ctx.dev
? { // Base URL for API-Calls: DEV
API: JSON.stringify('http://localhost:8080')
//API: JSON.stringify('http://localhost:8080')
API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19geocaching'),
USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19usermanagement')
}
: { // Base URL for API-Calls: PRODUCTION (build)
//API: JSON.stringify('http://seserver.se.hs-heilbronn.de:8090/buga19geocaching')
API: JSON.stringify('http://localhost:8080')
API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19geocaching'),
USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19usermanagement')
//API: JSON.stringify('http://localhost:8080')
}
},

View File

@ -2,7 +2,7 @@ import axios from "axios";
const axiosInstance = axios.create({
baseURL: process.env.API,
timeout: 3000
timeout: 6000
});
console.log("process.env.DEV: "+process.env.DEV);
console.log("process.env.API: "+process.env.API);

View File

@ -44,6 +44,7 @@
</q-item-section>
</q-item>
<q-item
v-if="this.$store.state.auth.isAuthenticated"
clickable
class="text-primary"
v-ripple
@ -68,7 +69,21 @@
<q-icon name="map"/>
</q-item-section>
<q-item-section>
<q-item-label>Caches</q-item-label>
<q-item-label>Alle Caches</q-item-label>
</q-item-section>
</q-item>
<q-item
clickable
class="text-primary"
v-ripple
tag="a"
to="/mycaches"
>
<q-item-section avatar>
<q-icon name="map"/>
</q-item-section>
<q-item-section>
<q-item-label>Meine Caches</q-item-label>
</q-item-section>
</q-item>
<q-item
@ -86,6 +101,7 @@
</q-item-section>
</q-item>
<q-item
v-if="this.$store.state.auth.isAuthenticated"
clickable
class="text-primary"
v-ripple
@ -100,20 +116,7 @@
</q-item-section>
</q-item>
<q-item
clickable
class="text-primary"
v-ripple
tag="a"
to="/Login"
>
<q-item-section avatar>
<q-icon name="logout"/>
</q-item-section>
<q-item-section>
<q-item-label>Login</q-item-label>
</q-item-section>
</q-item>
<q-item
v-if="!this.$store.state.auth.isAuthenticated"
clickable
class="text-primary"
v-ripple
@ -124,7 +127,21 @@
<q-icon name="assignment"/>
</q-item-section>
<q-item-section>
<q-item-label>Register</q-item-label>
<q-item-label>Registrieren</q-item-label>
</q-item-section>
</q-item>
<q-item
clickable
class="text-primary"
v-ripple
tag="a"
to="/Login"
>
<q-item-section avatar>
<q-icon name="logout"/>
</q-item-section>
<q-item-section>
<q-item-label>{{ loginText }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
@ -172,37 +189,41 @@
};
},
computed: {
loginText() {
let text = this.$store.state.auth.isAuthenticated ? "Logout" : "Login";
return text;
},
dialogShow: {
get() {
console.log("get dialogShow: "+this.$store.state.dialog.dialog.show)
// console.log("get dialogShow: "+this.$store.state.dialog.dialog.show)
return this.$store.state.dialog.dialog.show;
},
set(val) {
console.log("set dialogShow: "+val)
// console.log("set dialogShow: "+val)
this.$store.state.dialog.dialog.show = val;
}
},
dialogMessage: {
get() {
console.log("get dialogMessage: "+this.$store.state.dialog.dialog.message)
// console.log("get dialogMessage: "+this.$store.state.dialog.dialog.message)
return this.$store.state.dialog.dialog.message;
},
},
dialogTitle: {
get() {
console.log("get dialogTitle: "+this.$store.state.dialog.dialog.title)
// console.log("get dialogTitle: "+this.$store.state.dialog.dialog.title)
return this.$store.state.dialog.dialog.title;
},
},
dialogColorBg: {
get() {
console.log("get dialogColorBg: " + this.$store.state.dialog.dialog.colorBackground)
// console.log("get dialogColorBg: " + this.$store.state.dialog.dialog.colorBackground)
return this.$store.state.dialog.dialog.colorBackground;
},
},
dialogColorBtn: {
get() {
console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton)
// console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton)
return this.$store.state.dialog.dialog.colorButton;
},
}

View File

@ -5,9 +5,8 @@
<form>
<div class="q-pa-md q-gutter-y-md">
<p class="text-h5">{{ isNewCache ? "Neuen Cache erstellen" : "Cache bearbeiten"}}</p>
<q-input class="col" dense stack-label filled v-model="tempCache.name" label="Name" @change="cacheToStore"/>
<q-input class="col" dense stack-label filled v-model="tempCache.rankingPoints" label="Punktewert"
@change="cacheToStore"/>
<q-input class="col" dense stack-label filled v-model="computedCache.name" label="Name"/>
<q-input class="col" dense stack-label filled v-model="computedCache.rankingPoints" label="Punktewert"/>
<p class="text-h6">Beschreibung</p>
<q-editor
:toolbar="[
@ -16,10 +15,9 @@
['hr', 'link'],
['fullscreen'],
]"
v-model="tempCache.description"
v-model="computedCache.description"
min-height="5rem"
max-height="50vh"
@change="cacheToStore"
/>
<p class="text-h6">Belohnung</p>
<q-editor
@ -29,15 +27,14 @@
['hr', 'link'],
['fullscreen'],
]"
v-model="tempCache.reward"
v-model="computedCache.reward.rewardDescription"
min-height="5rem"
max-height="50vh"
@change="cacheToStore"
/>
<p class="text-h6">Stationen</p>
<q-list bordered separator class="rounded-borders">
<q-item v-for="(station, index) in cache.stationen" :key="index">
<q-item v-for="(station, index) in computedCache.stationen" :key="index">
<q-item-section avatar>
<q-avatar color="primary" text-color="white">
{{ index + 1 }}
@ -73,19 +70,19 @@
<q-item>
<q-item-section avatar>
<q-avatar color="primary" text-color="white">
{{ tempCache.stationen.length + 1 }}
{{ computedCache.stationen.length + 1 }}
</q-avatar>
</q-item-section>
<q-item-section top>
<q-item-label lines="1">
<span class="text-grey-8">ID: {{ endStation.id ? endStation.id : "keine" }}</span>
<span class="text-grey-8">ID: {{ computedEndstation.id ? computedEndstation.id : "keine" }}</span>
</q-item-label>
<q-item-label lines="1" class="q-mt-xs text-body2">
<span class="cursor-pointer">Endstation</span>
</q-item-label>
<q-item-label caption lines="1">
Koordinaten: {{ endStation.lattitude }}, {{ endStation.longitude }}
Koordinaten: {{ computedEndstation.lattitude }}, {{ computedEndstation.longitude }}
</q-item-label>
</q-item-section>
@ -114,6 +111,8 @@
name: "Cache",
data() {
return {
// stations: [],
// endStation: {},
//endStation: {},
scrolldown: false,
isNewCache: this.$route.params.id === undefined,
@ -128,7 +127,7 @@
created: function () {
console.log("isNewCache: " + this.isNewCache);
console.log("fetch Caches from Store");
this.tempCache = JSON.parse(JSON.stringify(this.cache));
//this.tempCache = JSON.parse(JSON.stringify(this.cache));
},
beforeMount: function () {
},
@ -159,20 +158,32 @@
}
},
cacheToStore() {
// push tempCache to Store
console.log("set Cache");
this.$store.commit('cacheCollector/SET_CACHE', JSON.parse(JSON.stringify(this.tempCache)));
// this.SET_CACHE(JSON.parse(JSON.stringify(this.tempCache)));
},
// getStations() {
// console.log("get Stations");
// let stations = this.computedStations.get();
// this.stations = stations.filter(station => station.description !== "Endstation");
// console.log(this.stations);
// this.endStation = stations.filter(station => station.description === "Endstation");
// console.log(this.endStation);
// },
// setStations() {
// let stations = this.stations;
// stations.push(this.endStation);
// this.computedStations.set(stations);
// },
// cacheToStore() {
// // push tempCache to Store
// console.log("set Cache");
// this.$store.commit('cacheCollector/SET_CACHE', JSON.parse(JSON.stringify(this.tempCache)));
// // this.SET_CACHE(JSON.parse(JSON.stringify(this.tempCache)));
// },
addStation() {
this.$router.push({path: '/station'});
//this.swapComponent(station);
// create Station and add it to array tempCache.stationen
},
editStation(index) {
console.log("editStation(" + index + ")");
const station = this.cache.stationen[index];
console.log(this.$store.getters['cacheCollector/GET_STATIONS']);
const station = this.$store.getters['cacheCollector/GET_STATIONS'][index];
console.log(station);
if (station.hasOwnProperty('id')) {
//this.$router.push({ path: '/station/'+station.id});
@ -189,9 +200,9 @@
saveCache() {
// commit to store, send to api, if success -> reset store
if (this.isNewCache) {
console.log(this.cache);
let cache = this.cache;
cache.stationen.push(this.endStation);
let cache = JSON.parse(JSON.stringify(this.computedCache));
console.log(cache);
cache.stationen.push(this.computedEndstation);
this.$axios.post('/api/createCache', cache)
.then((response) => {
@ -227,18 +238,46 @@
},
computed: {
...mapGetters({
cache: 'cacheCollector/GET_CACHE',
endStation: 'cacheCollector/GET_ENDSTATION'
//cache: 'cacheCollector/GET_CACHE',
//endStation: 'cacheCollector/GET_ENDSTATION'
}),
// computedCache: {
// computedStations: {
// set(value) {
// console.log("set cache")
// console.log("set stations");
// this.computedCache.set(value);
// },
// get() {
// console.log("get cache");
// return this.$store.getters.cacheCollector.GET_CACHE
// console.log("get stations");
// let stations = this.computedCache.stationen;
// return stations.filter(station => station.description !== "Endstation");
// }
// }
// },
computedCache: {
set(value) {
console.log("set cache");
this.$store.commit('cacheCollector/SET_CACHE', value);
},
get() {
console.log("get cache");
return this.$store.getters['cacheCollector/GET_CACHE'];
}
},
computedStations: {
set(value) {
this.$store.commit('cacheCollector/SET_STATIONS', value);
},
get() {
return this.$store.getters['cacheCollector/GET_STATIONS'];
}
},
computedEndstation: {
set(value) {
this.$store.commit('cacheCollector/SET_ENDSTATION', value);
},
get() {
return this.$store.getters['cacheCollector/GET_ENDSTATION'];
}
},
}
}
</script>

View File

@ -10,7 +10,11 @@
<q-dialog v-model="reward">
<q-card>
<q-card-section>
<div>Jetzt ist eine gute Zeit, etwas Neues zu beginnen.</div>
<div class="text-h6">Deine Belohnung: </div>
</q-card-section>
<q-card-section>
<div>{{ cache.reward.rewardDescription }}</div>
</q-card-section>
</q-card>
</q-dialog>
@ -27,6 +31,9 @@
reward: false,
cacheID: "",
cacheName: "",
cache: {
reward: "",
},
rankingPoints: "",
end1: "Gut gemacht, Du hast alle Stationen dieses Cache gefunden. Dir wurden ",
end2: " Punkte gutgeschrieben." //TODO Punkte wirklich gutschreiben, ggf. Cache auf erledigt setzen
@ -45,10 +52,10 @@
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("/api/allCaches");
console.log(JSON.stringify(this.data));
console.log(this.data);
console.log(JSON.stringify(response.data));
console.log(response.data);
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
this.cache = cache;
this.cacheName = cache.name;
this.rankingPoints = cache.rankingPoints;
this.cacheID = this.$route.params.cache;

View File

@ -67,8 +67,6 @@
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("/api/allCaches");
console.log(JSON.stringify(this.data));
console.log(this.data);
console.log(response.data);
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
this.cacheName = cache.name;
@ -97,7 +95,8 @@
params.cacheID = this.result.split('/')[0];
params.stationID = this.result.split('/')[1];
params.durchgefuehrterCacheID = this.cacheID;
console.log(params.cacheID + " und " + params.stationID);
console.log("CacheID: " + params.cacheID + " und StationID: " + params.stationID);
console.log(params.durchgefuehrterCacheID);
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
}
@ -126,8 +125,14 @@
this.$axios.get('/api/checkStation', {params})
.then((response) => {
console.log("resolve(true)");
console.log("cache access definition");
console.log(response.data.cacheAccesDefinition);
resolve(true);
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
if (Number(response.data.cacheAccesDefinition.id) === 0) {
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
} else if (Number(response.data.cacheAccesDefinition.id) === 1) {
this.$router.push({path: `/CacheEnd/${params.cacheID}`});
}
}).catch((error) => {
console.log("resolve(false)");
// Error

View File

@ -1,6 +1,6 @@
<template>
<div class="q-pa-md">
<form class="login" @submit.prevent="login">
<form class="login">
<div class="q-pa-md">
<div class="column q-gutter-lg" style="">
<div class="col">
@ -29,7 +29,7 @@
label="Login"
color="primary"
class="full-width"
type="submit"
@click="login"
unelevated
>
<template v-slot:loading>
@ -61,8 +61,8 @@
return {
loading: false,
user: {
email: "volkmann@geocaching.de",
password: "0123456789",
email: "",
password: "",
//token: "",
// evalAuthentication: false
},
@ -80,14 +80,14 @@
},
computed: {
userAuthenticated() {
console.log("login: userAuthenticated()")
// console.log(this.$store.getters['auth/IS_AUTHENTICATED']);
// return this.$store.getters['auth/IS_AUTHENTICATED']
console.log("login: userAuthenticated()");
console.log(this.$store.state.auth.isAuthenticated);
return this.$store.state.auth.isAuthenticated;
}
},
methods: {
login: function () {
console.log("login called");
this.loading = true;
const data = {
email: this.user.email,
@ -96,7 +96,7 @@
console.log("GET /api/login/ - json: " + JSON.stringify(data));
this.$axios.post('http://www.se.hs-heilbronn.de:8090/buga19usermanagement/account/login', data)
this.$axios.post(process.env.USER_API+'/account/login', data)
.then((response) => {
console.log("GET/POST /api/login/ - response: ");
console.log(response.data);
@ -105,12 +105,13 @@
localStorage.setItem('userToken', JSON.stringify(response.data));
localStorage.setItem('userMail', JSON.stringify(data.email));
this.evalAuthentication();
this.$router.push({path: `/overview`})
})
.catch((error) => {
let message;
let header = "Fehler: ";
if (error.response) {
console.log("ERROR RESPONSE")
console.log("ERROR RESPONSE");
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
message = error.response.data.error;
@ -119,7 +120,7 @@
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
message = error.request;
message = "Anfrage fehlgeschlagen.";
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
@ -129,6 +130,7 @@
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
}).finally(() => {
this.loading = false;
this.evalAuthentication();
})
},
evalAuthentication: function () {

View File

@ -0,0 +1,266 @@
<template>
<q-page class="column no-wrap">
<div class="bg-red col col-shrink" style="">
<q-tabs
v-model="tab"
class="bg-grey-2"
inline-label
align="justify"
active-bg-color="bg-grey-1"
active-color="cyan-14"
indicator-color="cyan-14"
switch-indicator
>
<q-tab name="startedCaches" label="Angefangene Caches" icon="playlist_play"/>
<q-tab name="finishedCaches" label="Beendete Caches" icon="playlist_add_check"/>
</q-tabs>
<q-separator color="grey-4"/>
</div>
<div class="col flex column">
<q-tab-panels v-model="tab" animated swipeable class="col">
<q-tab-panel name="startedCaches" class=" fit">
<q-list>
<q-card
class="q-mb-md"
v-for="startedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 0)"
:key="startedCache.id"
>
<q-expansion-item
class=""
expand-icon-toggle
expand-separator
icon="location_on"
:label="startedCache.cache.name"
:caption=" startedCache.cache.description"
>
<q-item>
<q-item-section top avatar class="self-center">
</q-item-section>
<q-item-section>
<q-item-label caption>{{'Nächste Aufgabe: ' + startedCache.aktuelleStation.description }}
</q-item-label>
<q-item-label caption>{{'Ranglistenpunkte für diesen Cache: ' + startedCache.cache.rankingPoints}}
</q-item-label>
</q-item-section>
<q-item-section side top class="self-center">
</q-item-section>
</q-item>
<q-item class="q-pr-sm reverse q-gutter-x-sm">
<q-btn @click="continueCache(startedCache.cache.id)" unelevated color="positive" stack icon="arrow_forward"
label="Fortfahren" size="sm"/>
</q-item>
</q-expansion-item>
</q-card>
</q-list>
</q-tab-panel>
<q-tab-panel name="finishedCaches" class="fit">
<q-list>
<q-card class="q-mb-md" v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)" :key="finishedCache.id">
<q-expansion-item
class=""
expand-icon-toggle
expand-separator
icon="location_on"
:label="finishedCache.cache.name"
:caption=" finishedCache.cache.description"
>
<q-item>
<q-item-section top avatar class="self-center">
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
</q-item-section>
<q-item-section>
<q-item-label caption>{{'Erhaltene Punkte für diesen Cache: ' + finishedCache.cache.rankingPoints
}}
</q-item-label>
</q-item-section>
<q-item-section side top class="self-center">
</q-item-section>
</q-item>
<q-item class="q-pr-sm reverse q-gutter-x-sm">
<q-btn @click="goToReward(finishedCache.cache.id)" unelevated color="primary" stack icon="arrow_forward"
label="Belohnung ansehen" size="sm"/>
</q-item>
</q-expansion-item>
</q-card>
</q-list>
</q-tab-panel>
</q-tab-panels>
</div>
</q-page>
</template>
<style>
</style>
<script>
//import {dom} from 'quasar'
//const {height, width} = dom
export default {
data() {
return {
tab: 'startedCaches',
startedCaches: [],
inviteMail: "",
currentTeamStatus: "Dienstag 15:00 Treffen zum Blumencache",
teamStatus: "",
userName: null,
email: null,
}
},
mounted: function () {
},
computed: {
hasAdminState() {
return this.$store.getters['auth/GET_ADMINSTATE'];
},
},
created: function () {
this.fetchUserCaches();
this.$store.commit('auth/SET_AUTHENTICATED');
this.$store.commit('auth/SET_USER');
},
methods: {
fetchUserCaches: function () {
let token;
if (localStorage.getItem('userToken')) {
token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
this.$axios.get('/api/getMyCaches', {params: {token}})
.then((response) => {
console.log(response.data)
this.startedCaches = response.data;
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
},
continueCache(cacheID) {
console.log("cacheID");
console.log(cacheID);
let currentStationID;
if (localStorage.getItem('userToken')) {
let params = {cacheID: cacheID};
params.token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getCurrentStation', {params})
.then((response) => {
console.log(response.data);
currentStationID = response.data.aktuelleStation.id;
this.$router.push({path: `/station/${cacheID}/${currentStationID}`});
})
.catch((error) => {
});
}
},
goToReward(cacheID) {
console.log("cacheID");
console.log(cacheID);
let currentStationID;
if (localStorage.getItem('userToken')) {
let params = {cacheID: cacheID};
params.token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getCurrentStation', {params})
.then((response) => {
console.log(response.data);
currentStationID = response.data.aktuelleStation.id;
this.$router.push({path: `/CacheEnd/${params.cacheID}`});
})
.catch((error) => {
});
}
},
getPersonalRanking() {
const name = JSON.parse(localStorage.getItem('userToken')).name;
console.log(JSON.parse(localStorage.getItem('userToken')).name);
this.$axios.get('/api/hello', {params: {name}})
.then((response) => {
this.userRanking = response.data;
console.log(response.data);
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
},
getTeamData() {
const userName = {name: JSON.parse(localStorage.getItem('userToken')).name};
this.$axios.get('/api/getTeam', {params: userName})
.then(response => {
console.log("getTeam: " + response);
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
},
dropDownSelectItem(item) {
if (item === 'team') {
this.dropDownSelectedItem = this.teamName;
} else {
this.dropDownSelectedItem = item;
}
},
}
}
</script>

View File

@ -26,7 +26,6 @@
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
<q-expansion-item
class=""
expand-icon-toggle
expand-separator
icon="location_on"
:label="cache.name"
@ -37,7 +36,7 @@
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
</q-item-section>
<q-item-section>
<q-item-label caption>{{ cache.description }}</q-item-label>
<q-item-label caption v-html="cache.description"></q-item-label>
</q-item-section>
<q-item-section side top class="self-center">
@ -118,26 +117,26 @@
console.log("Caches: " + this.caches);
this.caches = response.data;
}).catch((error) => {
// Error
let msg;
let title;
let message;
let header = "Fehler: ";
if (error.response) {
console.log("ERROR RESPONSE");
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
// that falls out of the range of 2xx
message = error.response.data.error;
header += error.response.status;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
message = "Anfrage fehlgeschlagen.";
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
message = error.message;
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
})
},
addCache() {
@ -146,71 +145,45 @@
editCache() {
},
deleteCache(id) {
console.log('delete cache: ' + id)
this.$axios.delete('/api/deleteCache', {params: {cacheID: id}})
console.log('delete cache: ' + id);
this.$axios.get('/api/deleteCache', {params: {cacheID: id}})
.then((response) => {
this.fetchAllCaches()
}).catch((error) => {
// Error
let msg;
let title;
let message;
let header = "Fehler: ";
if (error.response) {
console.log("ERROR RESPONSE");
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
// that falls out of the range of 2xx
message = error.response.data.error;
header += error.response.status;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
message = "Anfrage fehlgeschlagen.";
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
message = error.message;
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
})
},
startCache(cacheID) {
const userToken = JSON.parse(localStorage.getItem('userToken')).token;
let params = {cacheID: cacheID};
if (userToken != null) {
params.token = userToken;
}
console.log(params);
this.$axios.get('/api/startCache', {params})
.then((response) => {
console.log(response.data);
// TODO wenn cache angefangen, dann suche die letzte gefundene Station
let stationID = this.caches.find(x => x.id === cacheID).stationen[0].id;
console.log(stationID);
//this.$router.push({path: `/station/${stationID}`})
this.$router.push({path: `/CacheStart/${cacheID}`})
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
})
console.log("startCache()");
// const userToken = JSON.parse(localStorage.getItem('userToken')).token;
// let params = {cacheID: cacheID};
// if (userToken != null) {
// params.token = userToken;
// }
// console.log(params);
this.$store.state.currentCache.cache = this.caches.find(cache => cache.id === Number(cacheID));
console.log(this.$store.state.currentCache.cache);
this.$store.state.currentCache.currentCacheID = Number(cacheID);
this.$router.push({path: `/CacheStart/${cacheID}`})
}
}
}

View File

@ -13,8 +13,6 @@
>
<q-tab name="profile" label="Profil" icon="perm_identity"/>
<q-tab name="teams" label="Team" icon="group"/>
<q-tab name="startedCaches" label="Angefangene Caches" icon="playlist_play"/>
<q-tab name="finishedCaches" label="Beendete Caches" icon="playlist_add_check"/>
</q-tabs>
<q-separator color="grey-4"/>
</div>
@ -95,71 +93,6 @@
</div>
</q-tab-panel>
<q-tab-panel name="startedCaches" class=" fit">
<q-list>
<q-card class="q-mb-md" v-for="startedCache in startedCaches" :key="startedCache.id">
<q-expansion-item
class=""
v-if="startedCache.cacheAccesDefinition.description === 'angefangen'"
expand-icon-toggle
expand-separator
icon="location_on"
:label="startedCache.cache.name"
:caption=" startedCache.cache.description"
>
<q-item>
<q-item-section top avatar class="self-center">
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
</q-item-section>
<q-item-section>
<q-item-label caption>{{'Nächste Aufgabe: ' + startedCache.aktuelleStation.description }}
</q-item-label>
<q-item-label caption>{{'Ranglistenpunkte für diesen Cache: ' + startedCache.cache.rankingPoints}}
</q-item-label>
</q-item-section>
<q-item-section side top class="self-center">
</q-item-section>
</q-item>
<q-item class="q-pr-sm reverse q-gutter-x-sm">
<q-btn @click="continueCache(startedCache.id)" unelevated color="positive" stack icon="arrow_forward"
label="Fortfahren" size="sm"/>
</q-item>
</q-expansion-item>
</q-card>
</q-list>
</q-tab-panel>
<q-tab-panel name="finishedCaches" class="fit">
<q-list>
<q-card class="q-mb-md" v-for="startedCache in startedCaches" :key="startedCache.id">
<q-expansion-item
class=""
v-if="startedCache.cacheAccesDefinition.description === 'abgeschlossen'"
expand-icon-toggle
expand-separator
icon="location_on"
:label="startedCache.cache.name"
:caption=" startedCache.cache.description"
>
<q-item>
<q-item-section top avatar class="self-center">
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
</q-item-section>
<q-item-section>
<q-item-label caption>{{'Erhaltene Punkte für diesen Cache: ' + startedCache.cache.rankingPoints
}}
</q-item-label>
</q-item-section>
<q-item-section side top class="self-center">
</q-item-section>
</q-item>
</q-expansion-item>
</q-card>
</q-list>
</q-tab-panel>
</q-tab-panels>
</div>
</q-page>
@ -294,7 +227,6 @@
},
},
created: function () {
this.fetchUserCaches();
this.$store.commit('auth/SET_AUTHENTICATED');
this.$store.commit('auth/SET_USER');
this.userName = JSON.parse(localStorage.getItem('userToken')).name;
@ -310,38 +242,8 @@
this.data[4].userData = this.teamRanking;
},
methods: {
fetchUserCaches: function () {
const token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getMyCaches', {params: {token}})
.then((response) => {
this.startedCaches = response.data;
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
})
},
continueCache(cacheID) {
},
validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
},
getPersonalRanking() {

View File

@ -47,10 +47,9 @@
<div class="" style="max-width: 440px">
<q-btn
:disabled="!validationSuccesful"
label="Sign up"
label="Registrieren"
color="primary"
class="full-width"
type="submit"
@click="register()"
unelevated
/>
@ -88,14 +87,17 @@
return false;
}
},
created() {
this.login();
},
methods: {
validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
},
register: function () {
if(this.user.email===this.user.checkemail&&this.user.password===this.user.checkpassword){
this.login();
const data = {
name: this.user.name,
password: this.user.password,
@ -110,7 +112,7 @@
console.log("POST /api/register/ - json: " + JSON.stringify(data));
const token = JSON.parse(localStorage.getItem('registerToken')).token;
this.$axios.post('http://www.se.hs-heilbronn.de:8090/buga19usermanagement/account/register', data,{
this.$axios.post(process.env.USER_API+'/account/register', data,{
headers: {
'Authorization': 'Bearer ' + token,
}
@ -158,7 +160,7 @@
}
}
},
login: function () {
login() {
const logindata = {
email: "register@bugageocaching.de",
@ -167,7 +169,7 @@
console.log("GET /api/login/ - json: " + JSON.stringify(logindata));
this.$axios.post('http://www.se.hs-heilbronn.de:8090/buga19usermanagement/account/login', logindata)
this.$axios.post(process.env.USER_API+'/account/login', logindata)
.then((response) => {
localStorage.setItem('registerToken', JSON.stringify(response.data));
})

View File

@ -49,7 +49,7 @@
description: "Rätsel, Aufgabe und Informationen zur Station.",
latlang: "",
station: {
description: "Beschreibung",
description: "Rätsel, Aufgabe und Informationen zur Station.",
lattitude: "0.000",
longitude: "0.000",
solution: "",

View File

@ -6,10 +6,10 @@
src="https://www.buga2019.de/we-bilder/3.Gartenausstellung/Gelaendeplan/190320_Gelaendeplan-quadratisch.jpg"
></q-img>
<div class="q-ma-md">
<p class="text-h4">{{ data.cacheName }}</p>
<p class="text-h4">{{ cache.name }}</p>
<p class="text-h5">Station {{ showCacheProgress }}</p>
<!-- <p class="text-h5">Station {{ data.station.position }}</p>-->
<p>{{ data.station.description }}</p>
<p>{{ station.description }}</p>
<!--<q-input-->
<!--v-model="description"-->
<!--filled-->
@ -52,19 +52,14 @@
data() {
return {
//code: "",
cache: null,
data: {
cacheId: 22,
cacheName: "Wasserfall Cache",
station: {
id: 22,
description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
longitude: 9.206628,
lattitude: 49.147734,
code: 213812,
solution: "Schneeglöckchen"
}
cacheID: "",
cacheName: "",
//cache: null,
cache: {
name: "",
stationen: [],
},
station: {},
// Following Params belong to QR-Code Scanner
askForPermission: true,
@ -79,21 +74,49 @@
}
},
beforeRouteUpdate (to, from, next) {
console.log("beforeRouteUpdate: reset data and fetch");
this.cacheID = "";
this.cacheName = "";
this.cache = {
name: "",
stationen: [],
};
this.station = {};
this.askForPermission = true;
this.activateCamera = false;
this.isValid = false;
this.validating = false;
this.loading = false;
this.paused = false;
this.result = null;
this.params = null;
this.noStreamApiSupport = false;
this.fetchData();
next()
},
created: function () {
console.log("StationView: ")
// console.log("'id' from url: " + this.$route.params.id)
// console.log("'cache' from url: " + this.$route.params.cache)
console.log("StationView: created!");
console.log("'id' from url: " + this.$route.params.id);
console.log("'cache' from url: " + this.$route.params.cache);
this.fetchData();
},
beforeMount: function () {
},
mounted: function () {
},
updated: function () {
},
computed: {
showCacheProgress() {
let stationCount = this.cache.stationen.length;
let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id));
return `${stationPos} von ${stationCount}`;
if (this.cache !== null) {
let stationCount = this.cache.stationen.length;
let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id));
return `${stationPos} von ${stationCount}`;
} else {
return "";
}
}
},
methods: {
@ -101,65 +124,16 @@
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("/api/allCaches");
console.log(JSON.stringify(this.data));
console.log(this.data);
console.log(response.data);
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
this.data.cacheId = cache.id;
this.data.cacheName = cache.name;
this.cache = cache;
console.log(JSON.stringify(this.data));
this.$axios.get('/api/getAllStations')
.then((response) => {
console.log("/api/getAllStations");
console.log(response.data);
const stationView = response.data.find(station => station.id === Number(this.$route.params.id));
console.log(JSON.stringify(stationView));
this.data.station = stationView;
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
})
}).catch((error) => {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
title = "Error";
msg = error.message;
console.log('Error', error.message);
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
})
this.station = cache.stationen.find(station => station.id === Number(this.$route.params.id));
this.cacheName = cache.name;
this.cacheID = this.$route.params.cache;
console.log(JSON.stringify(this.cache));
console.log(JSON.stringify(this.station));
console.log(this.cache);
})
},
setParams() {
@ -167,7 +141,8 @@
let params = {};
params.cacheID = this.result.split('/')[0];
params.stationID = this.result.split('/')[1];
params.durchgefuehrterCacheID = this.cacheID;
params.durchgefuehrterCacheID = params.cacheID;
console.log(params.durchgefuehrterCacheID);
console.log(params.cacheID + " und " + params.stationID);
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
@ -197,10 +172,12 @@
this.$axios.get('/api/checkStation', {params})
.then((response) => {
console.log("resolve(true)");
console.log("cache access definition");
console.log(response.data.cacheAccesDefinition);
resolve(true);
if (response.data.cache_acces_definition === 0) {
if (Number(response.data.cacheAccesDefinition.id) === 0) {
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
} else if (response.data.cache_acces_definition === 1) {
} else if (Number(response.data.cacheAccesDefinition.id) === 1) {
this.$router.push({path: `/CacheEnd/${params.cacheID}`});
}
}).catch((error) => {

View File

@ -1,6 +1,6 @@
<template>
<div>
<div v-if="askForPermission">
<div >
<div class="q-ma-md" v-if="askForPermission">
<p>Um den QR-Code scannen zu können, müssen Sie den Zugriff auf Ihre Kamera erlauben.</p>
<q-btn @click="toggleCamera(!activateCamera)" :loading="loading" unelevated color="positive" stack
@ -61,12 +61,18 @@
validate() {
return new Promise(resolve => {
this.setParams(0);
let params = this.params;
let params = this.setParams();
this.$axios.get('/api/checkStation', {params})
.then((response) => {
console.log("resolve(true)");
resolve(true)
console.log("cache access definition");
console.log(response.data.cacheAccesDefinition);
resolve(true);
if (Number(response.data.cacheAccesDefinition.id) === 0) {
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
} else if (Number(response.data.cacheAccesDefinition.id) === 1) {
this.$router.push({path: `/CacheEnd/${params.cacheID}`});
}
}).catch((error) => {
console.log("resolve(false)");
// Error
@ -96,20 +102,17 @@
})
},
setParams(cacheID) {
setParams() {
console.log("setParams: ");
let resCacheID = this.result.split('/')[0];
let resStationID = this.result.split('/')[1];
console.log(resCacheID + " und " + resStationID);
this.params = {
token: null,
cacheID: resCacheID,
stationID: resStationID,
durchgefuehrterCacheID: cacheID
};
let params = {};
params.cacheID = this.result.split('/')[0];
params.stationID = this.result.split('/')[1];
params.durchgefuehrterCacheID = params.cacheID;
console.log(params.cacheID + " und " + params.stationID);
if (localStorage.getItem('userToken')) {
this.params.token = JSON.parse(localStorage.getItem('userToken')).token;
params.token = JSON.parse(localStorage.getItem('userToken')).token;
}
return params;
},
pauseCamera() {

View File

@ -75,6 +75,11 @@ const routes = [
component: () => import("layouts/MyLayout.vue"),
children: [{ path: "", component: () => import("pages/Profile.vue") }]
},
{
path: "/mycaches/",
component: () => import("layouts/MyLayout.vue"),
children: [{ path: "", component: () => import("pages/MyCaches.vue") }]
},
{
path: "/register/",
component: () => import("layouts/MyLayout.vue"),

View File

@ -10,3 +10,7 @@ export const GET_ENDSTATION = (state) => {
console.log("GET_ENDSTATION: retrieve cache from store. ");
return state.endStation;
};
export const GET_STATIONS = (state) => {
console.log("GET_STATIONEN: retrieve cache from store. ");
return state.newCache.stationen;
};

View File

@ -10,6 +10,10 @@ export const SET_ENDSTATION = (state, station) => {
console.log("SET_ENDSTATION: "+station);
state.endStation = station;
};
export const SET_STATIONS = (state, station) => {
console.log("SET_STATIONEN: "+station);
state.newCache.stationen = station;
};
export const ADD_STATION = (state, station) => {
console.log("ADD_STATION: add new station to cache: "+station);
state.newCache.stationen.push(station);
@ -31,13 +35,18 @@ export const RESET_NEW_CACHE = (state) => {
name: "",
description: "",
rankingPoints: 0,
reward: {
rewardDescription: "",
},
stationen: []
};
state.endStation = {
description: "Endstation",
longitude: 0.0001,
lattitude: 0.0001,
longitude: 9.206628,
lattitude: 49.147734,
solution: "",
};
console.log("resetted new Cache");
};
export const LOAD_REMOTE_CACHE = (state, id) => {

View File

@ -3,48 +3,16 @@ export default {
name: "",
description: "",
rankingPoints: 0,
reward: "",
reward: {
rewardDescription: "",
},
stationen: []
},
// newCache: {
// name: "Blumencache",
// description: "Dieser Cache umfasst 4 Stationen mit Rätseln rund um das Thema Blumen",
// rankingPoints: 100,
// stationen: [
// {
// description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
// longitude: 9.206628,
// lattitude: 49.147734,
// code: 213812,
// solution: "Schneeglöckchen"
// },
// {
// description: "Ein blühendes Federvieh. Welche Blume ist damit gemeint?",
// longitude: 9.206806,
// lattitude: 49.147318,
// code: 237823,
// solution: "Gänseblümchen"
// },
// {
// description: "Eine wertvolle Farbe. Welche Blume ist damit gemeint?",
// longitude: 9.207844,
// lattitude: 49.148032,
// code: 899423,
// solution: "Edelweiß"
// },
// {
// description: "Ein Zerkleinerungsgerät in der Brüllöffnung eines Raubtieres. Welche Blume ist damit gemeint?",
// longitude: 9.207649,
// lattitude: 49.150142,
// code: 347923,
// solution: "Löwenzahn"
// }
// ]
// },
tempStation: {},
endStation: {
description: "Endstation",
longitude: 9.206628,
lattitude: 49.147734,
solution: "",
},
}

View File

@ -0,0 +1,4 @@
/*
export function someAction (context) {
}
*/

View File

@ -0,0 +1,4 @@
/*
export function someGetter (state) {
}
*/

View File

@ -0,0 +1,12 @@
import state from './state'
import * as getters from './getters'
import * as mutations from './mutations'
import * as actions from './actions'
export default {
namespaced: true,
state,
getters,
mutations,
actions
}

View File

@ -0,0 +1,4 @@
/*
export function someMutation (state) {
}
*/

View File

@ -0,0 +1,5 @@
export default {
cache: {},
currentCacheID: null,
currentStationID: null,
}

View File

@ -1,12 +1,12 @@
export function NEW_MESSAGE_DIALOG (state, messageObject) {
console.log("NEW_MESSAGE_DIALOG");
console.log(messageObject);
// console.log("NEW_MESSAGE_DIALOG");
// console.log(messageObject);
if (messageObject == null) {
state.dialog.show = true;
return;
}
console.log(messageObject);
// console.log(messageObject);
if (messageObject.hasOwnProperty('color')) {
switch (messageObject.color) {
@ -39,7 +39,7 @@ export function NEW_MESSAGE_DIALOG (state, messageObject) {
state.dialog.show = true;
}
export function RESET_MESSAGE_DIALOG (state) {
console.log("RESET_MESSAGE_DIALOG");
// console.log("RESET_MESSAGE_DIALOG");
state.dialog.colorBackground = "bg-red-9 text-white";
state.dialog.colorButton = "red-9";
state.dialog.message = "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es noch einmal.";

View File

@ -4,6 +4,7 @@ import Axios from "axios";
import auth from "./auth"
import cacheCollector from "./cacheCollector"
import dialog from "./dialog"
import currentCache from "./currentCache"
// import example from './module-example'
@ -19,7 +20,8 @@ export default function (/* { ssrContext } */) {
modules: {
auth,
cacheCollector,
dialog
dialog,
currentCache
},
// enable strict mode (adds overhead!)
@ -42,11 +44,15 @@ export default function (/* { ssrContext } */) {
module.hot.accept(['./cacheCollector'], () => {
const cacheCollector = require('./cacheCollector').default;
store.hotUpdate({ modules: { cacheCollector: newCacheCollector } })
})
});
module.hot.accept(['./dialog'], () => {
const dialog = require('./dialog').default;
store.hotUpdate({ modules: { dialog: newDialog } })
})
});
module.hot.accept(['./currentCache'], () => {
const currentCache = require('./currentCache').default;
store.hotUpdate({ modules: { currentCache: newCurrentCache } })
});
}
return Store

View File

@ -6,8 +6,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
@EnableSwagger2
public class Application extends SpringBootServletInitializer{
@Override
@ -18,4 +25,13 @@ public class Application extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public Docket swagger(){
return new Docket(DocumentationType.SWAGGER_2).useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}

View File

@ -8,6 +8,10 @@ import hhn.labsw.bugageocaching.repositories.*;
import hhn.labsw.bugageocaching.util.FinderUtil;
import hhn.labsw.bugageocaching.util.VerificationUtil;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@ -16,7 +20,6 @@ import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.createCacheUtil;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.deleteCacheUtil;
@ -57,98 +60,112 @@ public class Controller {
fetchPublicKey();
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/allCaches")
@ApiOperation(value = "Retrieves all Caches, including their Stations, from the Database")
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/allCaches", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getAllCaches() {
return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll()));
}
// alte startCache-methode
// @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
// @RequestMapping("/api/startCache")
// @ResponseBody
// public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token,
// @RequestParam String cacheID) {
//
// if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben)
//
// Bearbeitet bearbeitet = new Bearbeitet();
//
//
// //----------------------
// //Verify token
// ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
//
// //Error in token verification
// if (tokenVerification.getStatusCodeValue() != 200) {
// return tokenVerification;
// }
//
// Claims claims = (Claims) tokenVerification.getBody();
//
// ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
//
// if (getUser.getStatusCodeValue() != 200) {
// return getUser;
// }
//
// User user = (User) getUser.getBody();
//
// bearbeitet.setUser(user);
//
// //----------------------
// //Get Cache
// ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
//
// if (getCache.getStatusCodeValue() != 200) {
// return getCache;
// }
//
// Cache cache = (Cache) getCache.getBody();
// //----------------------
//
// if (bearbeitetRepository.findByUserAndCache(user, cache) != null) {
// Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache);
// return ResponseEntity.status(200).body(bearbeitet1);
// }
//
// bearbeitet.setCache(cache);
//
// Station startStation = cache.getStationen().get(0);
// bearbeitet.setAktuelleStation(startStation);
//
// //Get CacheAccesDefinition
// ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0");
//
// if (getCacheAccesDefinition.getStatusCodeValue() != 200) {
// return getCacheAccesDefinition;
// }
//
// CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody();
// //----------------------
// bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
//
// bearbeitetRepository.save(bearbeitet);
//
// return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
//
// } else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben)
//
// ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
//
// if (getCache.getStatusCodeValue() != 200) {
// return getCache;
// }
//
// Cache cache = (Cache) getCache.getBody();
//
// return ResponseEntity.status(200).body(new Gson().toJson(cache));
// }
// }
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/checkStation")
@ApiOperation(value = "Starts the given Cache for the given User")
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@RequestMapping(value = "/api/startCache", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token,
@RequestParam String cacheID) {
if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben)
Bearbeitet bearbeitet = new Bearbeitet();
//----------------------
//Verify token
ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
//Error in token verification
if (tokenVerification.getStatusCodeValue() != 200) {
return tokenVerification;
}
Claims claims = (Claims) tokenVerification.getBody();
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
if (getUser.getStatusCodeValue() != 200) {
return getUser;
}
User user = (User) getUser.getBody();
bearbeitet.setUser(user);
//----------------------
//Get Cache
ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
if (getCache.getStatusCodeValue() != 200) {
return getCache;
}
Cache cache = (Cache) getCache.getBody();
//----------------------
if (bearbeitetRepository.findByUserAndCache(user, cache) != null) {
Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache);
return ResponseEntity.status(200).body(bearbeitet1);
}
bearbeitet.setCache(cache);
Station startStation = cache.getStationen().get(0);
bearbeitet.setAktuelleStation(startStation);
//Get CacheAccesDefinition
ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0");
if (getCacheAccesDefinition.getStatusCodeValue() != 200) {
return getCacheAccesDefinition;
}
CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody();
//----------------------
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
//bearbeitetRepository.save(bearbeitet);
return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
} else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben)
ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
if (getCache.getStatusCodeValue() != 200) {
return getCache;
}
Cache cache = (Cache) getCache.getBody();
return ResponseEntity.status(200).body(new Gson().toJson(cache));
}
}
@ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/checkStation", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody
public ResponseEntity checkStation(@RequestParam String token,
@RequestParam String cacheID,
@ -208,8 +225,11 @@ public class Controller {
Station station = (Station) getStation.getBody();
//----------------------
if (cache != durchgefuehrterCache) {
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
System.out.println(cache.getName());
System.out.println(durchgefuehrterCache.getName());
if (!cacheID.equals(durchgefuehrterCacheID)) {
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station (Name)");
}
if (!cache.getStationen().contains(station)) {
@ -223,6 +243,7 @@ public class Controller {
if (getBearbeitet.getStatusCodeValue() != 200) {
if (cache.getStationen().get(0).equals(station)) {
// start Cache
System.out.println("Startstation");
Bearbeitet bearbeitet = new Bearbeitet();
bearbeitet.setUser(user);
bearbeitet.setCache(cache);
@ -259,7 +280,7 @@ public class Controller {
int i = cache.getStationen().indexOf(station);
if (i == 0) {
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station (i==0)");
}
if (cache.getStationen().get(i - 1).equals(aktuelleStation)) {
@ -277,13 +298,8 @@ public class Controller {
//----------------------
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
//Get User_Info
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
if (getUser_Info.getStatusCodeValue() != 200) {
return getUser_Info;
}
User_Info user_info = (User_Info) getUser_Info.getBody();
System.out.println(String.valueOf(user.getId()));
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
user_info.setRankingPointsSum(user_info.getRankingPointsSum() + cache.getRankingPoints());
user_infoRepository.save(user_info);
@ -291,20 +307,31 @@ public class Controller {
bearbeitetRepository.save(bearbeitet);
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet));
} else {
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station(nicht letzte)");
}
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/createCache")
@ApiOperation(value = "Creates a new Cache")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Something wrong with the given Parameters")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/createCache", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public ResponseEntity createCache(@RequestBody Cache cache) {
return createCacheUtil(cache);
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/checkAdmin")
@ApiOperation(value = "Checks if the given User has an admin role")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/checkAdmin", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity checkAdmin(@RequestParam String token) {
@ -334,23 +361,36 @@ public class Controller {
return ResponseEntity.status(401).body(false);
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getAllStations")
@ApiOperation(value = "Returns all Stations")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getAllStations", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getAllStations() {
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/deleteCache")
@ApiOperation(value = "Deletes a Cache")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/deleteCache", method = RequestMethod.DELETE, produces = "application/json")
@ResponseBody
public ResponseEntity deleteCache(@RequestParam String cacheID) {
return deleteCacheUtil(cacheID);
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getMyCaches")
@ApiOperation(value = "Returns all Caches finished/started by a given User")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getMyCaches", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getMyCaches(@RequestParam String token) {
@ -385,8 +425,12 @@ public class Controller {
}
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getRankingList")
@ApiOperation(value = "Returns the rankinglist")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getRankingList", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getRankingList() {
@ -400,8 +444,12 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getTeamRankingList")
@ApiOperation(value = "Returns the Team Rankinglist")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getTeamRankingList", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getTeamRankingList() {
@ -415,8 +463,14 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getUser")
@ApiOperation(value = "Returns a user from a given token")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getUser", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getUser(@RequestParam String token) {
@ -443,8 +497,14 @@ public class Controller {
}
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/createTeam")
@ApiOperation(value = "Creates a new Team")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/createTeam", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public ResponseEntity createTeam(@RequestParam String token,
@RequestParam String name) {
@ -467,13 +527,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
if (getUser_Info.getStatusCodeValue() != 200) {
return getUser_Info;
}
User_Info user_info = (User_Info) getUser_Info.getBody();
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() != null) {
return ResponseEntity.status(400).body("You already have a team");
@ -496,7 +550,9 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(team));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
//---------
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping("/api/joinTeam")
@ResponseBody
public ResponseEntity joinTeam(@RequestParam String token,
@ -520,13 +576,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
if (getUser_Info.getStatusCodeValue() != 200) {
return getUser_Info;
}
User_Info user_info = (User_Info) getUser_Info.getBody();
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() != null) {
return ResponseEntity.status(400).body("You already have a team");
@ -563,7 +613,7 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(team));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping("/api/leaveTeam")
@ResponseBody
public ResponseEntity leaveTeam(@RequestParam String token) {
@ -587,13 +637,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
if (getUser_Info.getStatusCodeValue() != 200) {
return getUser_Info;
}
User_Info user_info = (User_Info) getUser_Info.getBody();
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() == null) {
return ResponseEntity.status(400).body("You aren´t in any team");
@ -663,13 +707,7 @@ public class Controller {
//Get User_Info
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
if (getUser_Info.getStatusCodeValue() != 200) {
return getUser_Info;
}
User_Info user_info = (User_Info) getUser_Info.getBody();
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() == null) {
return ResponseEntity.status(400).body("You aren´t in any team");
@ -780,13 +818,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
if (getUser_Info.getStatusCodeValue() != 200) {
return getUser_Info;
}
User_Info user_info = (User_Info) getUser_Info.getBody();
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() == null) {
return ResponseEntity.status(400).body("You aren´t in any team");
@ -821,10 +853,42 @@ public class Controller {
return FinderUtil.findTeammemberByTeamName(name);
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/hello")
public ResponseEntity hello(@RequestParam String name) {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping("/api/getCurrentStation")
@ResponseBody
public ResponseEntity getStationFromUserAndCache(@RequestParam String token,
@RequestParam String cacheID){
// verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
if (verifyToken.getStatusCodeValue() != 200) {
return verifyToken;
}
// get user
Claims claims = (Claims) verifyToken.getBody();
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
if (getUser.getStatusCodeValue() != 200) {
return getUser;
}
User user = (User) getUser.getBody();
//----------------------
//Get Cache
ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
if (getCache.getStatusCodeValue() != 200) {
return getCache;
}
Cache cache = (Cache) getCache.getBody();
//----------------------
return ResponseEntity.status(200).body(bearbeitetRepository.findByUserAndCache(user, cache));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@ -852,6 +916,11 @@ public class Controller {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(user.getUsername()));
}
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping("/api/hello")
public ResponseEntity hello(@RequestParam String name) {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
}
}

View File

@ -1,6 +1,9 @@
package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@ -11,16 +14,24 @@ public class Cache {
@Id
@GeneratedValue
@ApiModelProperty(notes = "The autogenerated CacheID (Primary Key)")
private int id;
@ApiModelProperty(notes = "The name of the Cache")
private String name;
@ApiModelProperty(notes = "The Description of the Cache")
private String description;
@ApiModelProperty(notes = "The number of ranking points the user gets fro completing the cache")
private int rankingPoints;
@OneToMany
@ApiModelProperty(notes = "All stations included in the Cache")
private List<Station> stationen = new ArrayList<>();
@ManyToOne
@ApiModelProperty(notes = "The Reward for the Cache")
@ManyToOne (cascade = {CascadeType.ALL})
private Reward reward;
public Cache() {

View File

@ -1,7 +1,9 @@
package hhn.labsw.bugageocaching.entities;
import org.hibernate.validator.constraints.UniqueElements;
import org.springframework.context.annotation.Primary;
import javax.annotation.Generated;
import javax.persistence.*;
import java.io.Serializable;
@ -15,6 +17,9 @@ public class User_Info implements Serializable {
private User user;
@Id
@GeneratedValue
private int id;
private int rankingPointsSum;
@ManyToOne
@ -24,6 +29,14 @@ public class User_Info implements Serializable {
public User_Info() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public User getUser() {
return user;
}
@ -47,4 +60,5 @@ public class User_Info implements Serializable {
public void setTeam(Team team) {
this.team = team;
}
}

View File

@ -4,5 +4,5 @@ import java.io.Serializable;
public class User_InfoID implements Serializable {
private int user;
private int rankingPointsSum;
private int id;
}

View File

@ -1,8 +1,13 @@
package hhn.labsw.bugageocaching.repositories;
import hhn.labsw.bugageocaching.entities.User;
import hhn.labsw.bugageocaching.entities.User_Info;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
public interface User_InfoRepository extends CrudRepository<User_Info, Integer> {
import java.util.List;
import java.util.Optional;
public interface User_InfoRepository extends CrudRepository<User_Info, Integer> {
User_Info findUser_InfoByUser(User user);
}

View File

@ -35,6 +35,53 @@ public class FinderUtil {
static TeamInviteRepository teamInviteRepository;
@Autowired
public void setCacheRepository(CacheRepository cacheRepository) {
FinderUtil.cacheRepository = cacheRepository;
}
@Autowired
public void setRewardRepository(RewardRepository rewardRepository) {
FinderUtil.rewardRepository = rewardRepository;
}
@Autowired
public void setStationRepository(StationRepository stationRepository) {
FinderUtil.stationRepository = stationRepository;
}
@Autowired
public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) {
FinderUtil.bearbeitetRepository = bearbeitetRepository;
}
@Autowired
public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) {
FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository;
}
@Autowired
public void setTeamRepository(TeamRepository teamRepository) {
FinderUtil.teamRepository = teamRepository;
}
@Autowired
public void setUserRepository(UserRepository userRepository) {
FinderUtil.userRepository = userRepository;
}
@Autowired
public void setUser_infoRepository(User_InfoRepository user_infoRepository) {
FinderUtil.user_infoRepository = user_infoRepository;
}
@Autowired
public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) {
FinderUtil.teamInviteRepository = teamInviteRepository;
}
public static ResponseEntity findCacheById(String cacheID) {
Optional<Cache> cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID));
@ -75,15 +122,6 @@ public class FinderUtil {
}
}
public static ResponseEntity findUser_InfoByID(String infoID) {
Optional<User_Info> user_InfoOptional = user_infoRepository.findById(Integer.valueOf(infoID));
if (user_InfoOptional.isPresent()) {
return ResponseEntity.status(200).body(user_InfoOptional.get());
} else {
return ResponseEntity.status(404).body("Couldnt find User_Info " + infoID);
}
}
public static ResponseEntity findUserFromClaim(Claims claims) {
try {
@ -151,50 +189,4 @@ public class FinderUtil {
return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name);
}
}
@Autowired
public void setCacheRepository(CacheRepository cacheRepository) {
FinderUtil.cacheRepository = cacheRepository;
}
@Autowired
public void setRewardRepository(RewardRepository rewardRepository) {
FinderUtil.rewardRepository = rewardRepository;
}
@Autowired
public void setStationRepository(StationRepository stationRepository) {
FinderUtil.stationRepository = stationRepository;
}
@Autowired
public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) {
FinderUtil.bearbeitetRepository = bearbeitetRepository;
}
@Autowired
public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) {
FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository;
}
@Autowired
public void setTeamRepository(TeamRepository teamRepository) {
FinderUtil.teamRepository = teamRepository;
}
@Autowired
public void setUserRepository(UserRepository userRepository) {
FinderUtil.userRepository = userRepository;
}
@Autowired
public void setUser_infoRepository(User_InfoRepository user_infoRepository) {
FinderUtil.user_infoRepository = user_infoRepository;
}
@Autowired
public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) {
FinderUtil.teamInviteRepository = teamInviteRepository;
}
}

View File

@ -20,7 +20,7 @@ public class VerificationUtil {
public static void fetchPublicKey() {
RestTemplate restTemplate = new RestTemplate();
try {
PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:8090/buga19usermanagement/token/publickey", PublicKey.class);
PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:9080/buga19usermanagement/token/publickey", PublicKey.class);
byte[] decodedKey = Base64.getDecoder().decode(response.getMessage());
KeyFactory factory = KeyFactory.getInstance("RSA");
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(decodedKey);

View File

@ -5,4 +5,5 @@ spring.jmx.default-domain=buga19geocaching
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jooq.sql-dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.show-sql=true
debug=true