Merge branch 'develop' into frontend/timo
This commit is contained in:
commit
2cace929d0
@ -68,6 +68,7 @@ module.exports = function (ctx) {
|
||||
'QEditor',
|
||||
'QSelect',
|
||||
'QField',
|
||||
'QBtnDropdown',
|
||||
],
|
||||
|
||||
directives: [
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
<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="profile" label="Profil" icon="perm_identity"/>
|
||||
<q-tab name="startedCaches" label="Angefangene Caches" icon="playlist_play"/>
|
||||
<q-tab name="finishedCaches" label="Beendete Caches" icon="playlist_add_check"/>
|
||||
</q-tabs>
|
||||
<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="profile" label="Profil" icon="perm_identity"/>
|
||||
<q-tab name="teams" label="Teams" 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>
|
||||
|
||||
@ -22,6 +23,145 @@
|
||||
<q-tab-panels v-model="tab" animated swipeable class="col">
|
||||
|
||||
<q-tab-panel name="profile" class=" fit">
|
||||
|
||||
<div class="row">
|
||||
<div class="col" align="center">
|
||||
<b>
|
||||
Mein Nutzername
|
||||
</b>
|
||||
</div>
|
||||
<div class="col" align="center">
|
||||
BuGaCacher2019
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<b>
|
||||
Meine Email
|
||||
</b>
|
||||
</div>
|
||||
<div class="col" align="center">
|
||||
muster.mail@muster.de
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col" align="center">
|
||||
<b>
|
||||
Meine Ranglistenposition
|
||||
</b>
|
||||
</div>
|
||||
<div class="col" align="center">
|
||||
1234
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col" align="center">
|
||||
<b>
|
||||
Mein Team
|
||||
</b>
|
||||
</div>
|
||||
<div class="col" align="center">
|
||||
BuGa19Community
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col" align="center">
|
||||
<b>
|
||||
Teamranglistenposition
|
||||
</b>
|
||||
</div>
|
||||
<div class="col" align="center">
|
||||
2019
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="teams">
|
||||
<div class="q-pa-md" align="center">
|
||||
<q-btn-dropdown color="primary" label="BuGa19Community" size="20px">
|
||||
<q-list>
|
||||
<q-item clickable v-close-popup>
|
||||
<q-item-section>
|
||||
<q-item-label>BuGa19Community</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-item clickable v-close-popup>
|
||||
<q-item-section avatar>
|
||||
<q-avatar icon="group_add" color="primary" text-color="white"/>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label>Offene Teameinladungen</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-item clickable v-close-popup>
|
||||
<q-item-section avatar>
|
||||
<q-avatar icon="add" color="primary" text-color="white"/>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label>Neues Team erstellen</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-btn-dropdown>
|
||||
</div>
|
||||
<hr/>
|
||||
<div align="center">
|
||||
<b>
|
||||
Teammitglieder
|
||||
</b>
|
||||
</div>
|
||||
<br/>
|
||||
<div align="center">
|
||||
BuGaCacher2019
|
||||
<br/>
|
||||
Max
|
||||
<br/>
|
||||
Timo
|
||||
<br/>
|
||||
Katharina
|
||||
<br/>
|
||||
Michael
|
||||
<br/>
|
||||
Robin
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col" align="center">
|
||||
<q-input outlined filled stack-label v-model="inviteMail"
|
||||
type="text" label="Email des Nutzers"
|
||||
:rules="[val=>validateEmail(val)||'Bitte Email verwenden']"/>
|
||||
</div>
|
||||
<div class="col" align="center">
|
||||
<q-btn label="Einladung versenden"
|
||||
color="primary"
|
||||
type="submit"/>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div align="center">
|
||||
<b>
|
||||
Aktueller Teamstatus
|
||||
</b>
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
Dienstag 15:00 Treffen zum Blumencache.
|
||||
</div>
|
||||
<br/>
|
||||
<q-input outlined filled stack-label v-model="teamStatus"
|
||||
type="text" label="Neuer Teamstatus"/>
|
||||
<div align="center">
|
||||
<q-btn label="Teamstatus aktualisieren"
|
||||
color="primary"
|
||||
type="submit"/>
|
||||
</div>
|
||||
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="startedCaches" class=" fit">
|
||||
@ -76,7 +216,9 @@
|
||||
<!--<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-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">
|
||||
@ -107,6 +249,8 @@
|
||||
return {
|
||||
tab: 'profile',
|
||||
startedCaches: [],
|
||||
inviteMail: "",
|
||||
teamStatus: "",
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
@ -116,17 +260,17 @@
|
||||
return this.$store.getters['auth/GET_ADMINSTATE'];
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
created: function () {
|
||||
this.fetchUserCaches();
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
},
|
||||
methods: {
|
||||
fetchUserCaches: function() {
|
||||
fetchUserCaches: function () {
|
||||
const token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
this.$axios.get('/api/getMyCaches', { params: {token}} )
|
||||
this.$axios.get('/api/getMyCaches', {params: {token}})
|
||||
.then((response) => {
|
||||
this.startedCaches = response.data;
|
||||
this.startedCaches = response.data;
|
||||
}).catch((error) => {
|
||||
// Error
|
||||
let msg;
|
||||
@ -147,11 +291,15 @@
|
||||
console.log('Error', 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: 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,}))$/;
|
||||
return re.test(String(email).toLowerCase());
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -3,6 +3,7 @@ package hhn.labsw.bugageocaching.controller;
|
||||
import com.google.gson.Gson;
|
||||
import hhn.labsw.bugageocaching.entities.*;
|
||||
import hhn.labsw.bugageocaching.helper.RankingListHelper;
|
||||
import hhn.labsw.bugageocaching.helper.TeamRankingListHelper;
|
||||
import hhn.labsw.bugageocaching.repositories.*;
|
||||
import hhn.labsw.bugageocaching.util.FinderUtil;
|
||||
import hhn.labsw.bugageocaching.util.VerificationUtil;
|
||||
@ -48,6 +49,9 @@ public class Controller {
|
||||
@Autowired
|
||||
User_InfoRepository user_infoRepository;
|
||||
|
||||
@Autowired
|
||||
TeamInviteRepository teamInviteRepository;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
fetchPublicKey();
|
||||
@ -396,6 +400,21 @@ public class Controller {
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getTeamRankingList")
|
||||
@ResponseBody
|
||||
public ResponseEntity getTeamRankingList() {
|
||||
|
||||
List<TeamRankingListHelper> sendBackTeams = new LinkedList<>();
|
||||
List<Object[]> rankingTeams = userRepository.getTeamRankingList();
|
||||
for (Object[] obj : rankingTeams) {
|
||||
TeamRankingListHelper tmp = new TeamRankingListHelper((String) obj[0], (Integer) obj[1]);
|
||||
System.out.println(tmp);
|
||||
sendBackTeams.add(tmp);
|
||||
}
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getUser")
|
||||
@ResponseBody
|
||||
@ -429,12 +448,14 @@ public class Controller {
|
||||
@ResponseBody
|
||||
public ResponseEntity createTeam(@RequestParam String token,
|
||||
@RequestParam String name) {
|
||||
// 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);
|
||||
@ -458,6 +479,7 @@ public class Controller {
|
||||
return ResponseEntity.status(400).body("You already have a team");
|
||||
}
|
||||
|
||||
// checkt, ob der name bereits vorhanden ist
|
||||
for (Team team : teamRepository.findAll()) {
|
||||
if (team.getName().equals(name)) {
|
||||
return ResponseEntity.status(400).body("The teamname is already taken");
|
||||
@ -479,12 +501,14 @@ public class Controller {
|
||||
@ResponseBody
|
||||
public ResponseEntity joinTeam(@RequestParam String token,
|
||||
@RequestParam String teamID) {
|
||||
// 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);
|
||||
@ -519,23 +543,272 @@ public class Controller {
|
||||
|
||||
int i = 0;
|
||||
|
||||
// zählt teammitglieder
|
||||
for (User_Info userInfo1 : user_infoRepository.findAll()) {
|
||||
if (userInfo1.getTeam().equals(team)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// wenn maximalanzahl der teammitglieder erreicht...
|
||||
if (i >= 10) {
|
||||
return ResponseEntity.status(400).body("The team already has 10 members");
|
||||
}
|
||||
|
||||
// tritt dem team bei
|
||||
user_info.setTeam(team);
|
||||
|
||||
user_infoRepository.save(user_info);
|
||||
|
||||
return ResponseEntity.status(200).body(team);
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(team));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/leaveTeam")
|
||||
@ResponseBody
|
||||
public ResponseEntity leaveTeam(@RequestParam String token) {
|
||||
|
||||
// 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 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();
|
||||
//----------------------
|
||||
if (user_info.getTeam() == null) {
|
||||
return ResponseEntity.status(400).body("You aren´t in any team");
|
||||
}
|
||||
|
||||
//Get team
|
||||
ResponseEntity getTeam = FinderUtil.findTeamById(String.valueOf(user_info.getTeam().getId()));
|
||||
|
||||
if (getTeam.getStatusCodeValue() != 200) {
|
||||
return getTeam;
|
||||
}
|
||||
|
||||
Team team = (Team) getTeam.getBody();
|
||||
|
||||
// verlässt team
|
||||
user_info.setTeam(null);
|
||||
|
||||
int i = 0;
|
||||
// zählt teammitglieder
|
||||
for (User_Info userInfo1 : user_infoRepository.findAll()) {
|
||||
if (userInfo1.getTeam().equals(team)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// löscht team, wenn keine teammitglieder mehr vorhanden
|
||||
if (i == 0) {
|
||||
teamRepository.delete(team);
|
||||
}
|
||||
|
||||
user_infoRepository.save(user_info);
|
||||
|
||||
return ResponseEntity.status(200).body("Ok");
|
||||
}
|
||||
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/sendTeamInvite")
|
||||
@ResponseBody
|
||||
public ResponseEntity sendTeamInvite(@RequestParam String token,
|
||||
@RequestParam String invitedUserEmail) {
|
||||
// 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 InvitedUser
|
||||
|
||||
User invitedUser = userRepository.findByEmail(invitedUserEmail);
|
||||
|
||||
if (invitedUser == null) {
|
||||
return ResponseEntity.status(404).body("There isnt any user with that email");
|
||||
}
|
||||
//----------------------
|
||||
|
||||
|
||||
//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();
|
||||
//----------------------
|
||||
if (user_info.getTeam() == null) {
|
||||
return ResponseEntity.status(400).body("You aren´t in any team");
|
||||
}
|
||||
|
||||
//Get team
|
||||
ResponseEntity getTeam = FinderUtil.findTeamById(String.valueOf(user_info.getTeam().getId()));
|
||||
|
||||
if (getTeam.getStatusCodeValue() != 200) {
|
||||
return getTeam;
|
||||
}
|
||||
|
||||
Team team = (Team) getTeam.getBody();
|
||||
|
||||
if (teamInviteRepository.findByUserAndTeam(invitedUser, team) != null) {
|
||||
return ResponseEntity.status(400).body("The user is already invited to this team");
|
||||
}
|
||||
|
||||
TeamInvite teamInvite = new TeamInvite();
|
||||
teamInvite.setUser(invitedUser);
|
||||
teamInvite.setTeam(team);
|
||||
|
||||
teamInviteRepository.save(teamInvite);
|
||||
|
||||
return ResponseEntity.status(200).body("OK");
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getMyTeamInvites")
|
||||
@ResponseBody
|
||||
public ResponseEntity getMyTeamInvites(@RequestParam String token) {
|
||||
// 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();
|
||||
|
||||
List<TeamInvite> teamInvitesList = new ArrayList<>();
|
||||
|
||||
for (TeamInvite teamInvite : teamInviteRepository.findAll()) {
|
||||
if (teamInvite.getUser() == user) {
|
||||
teamInvitesList.add(teamInvite);
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(teamInvitesList));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/deleteTeamInvite")
|
||||
@ResponseBody
|
||||
public ResponseEntity deleteTeamInvite(@RequestParam String token,
|
||||
@RequestParam String teamInviteID) {
|
||||
// verify user
|
||||
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||
|
||||
if (verifyToken.getStatusCodeValue() != 200) {
|
||||
return verifyToken;
|
||||
}
|
||||
|
||||
// get teaminvite
|
||||
ResponseEntity getTeamInvite = FinderUtil.findTeamInviteByID(teamInviteID);
|
||||
|
||||
if (getTeamInvite.getStatusCodeValue() != 200) {
|
||||
return getTeamInvite;
|
||||
}
|
||||
|
||||
TeamInvite teamInvite = (TeamInvite) getTeamInvite.getBody();
|
||||
|
||||
teamInviteRepository.delete(teamInvite);
|
||||
|
||||
return ResponseEntity.status(200).body("OK");
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/setTeamStatus")
|
||||
@ResponseBody
|
||||
public ResponseEntity setTeamStatus(@RequestParam String token,
|
||||
@RequestParam String teamStatus) {
|
||||
// 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 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();
|
||||
//----------------------
|
||||
if (user_info.getTeam() == null) {
|
||||
return ResponseEntity.status(400).body("You aren´t in any team");
|
||||
}
|
||||
|
||||
//Get team
|
||||
ResponseEntity getTeam = FinderUtil.findTeamById(String.valueOf(user_info.getTeam().getId()));
|
||||
|
||||
if (getTeam.getStatusCodeValue() != 200) {
|
||||
return getTeam;
|
||||
}
|
||||
|
||||
Team team = (Team) getTeam.getBody();
|
||||
team.setTeamStatus(teamStatus);
|
||||
|
||||
teamRepository.save(team);
|
||||
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(teamStatus));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/api/hello")
|
||||
public ResponseEntity hello(@RequestParam String name) {
|
||||
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
|
||||
|
||||
@ -14,6 +14,8 @@ public class Team {
|
||||
|
||||
private String name;
|
||||
|
||||
private String teamStatus;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@ -29,4 +31,12 @@ public class Team {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTeamStatus() {
|
||||
return teamStatus;
|
||||
}
|
||||
|
||||
public void setTeamStatus(String teamStatus) {
|
||||
this.teamStatus = teamStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
package hhn.labsw.bugageocaching.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
public class TeamInvite {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@OneToOne
|
||||
private User user;
|
||||
|
||||
@OneToOne
|
||||
private Team team;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Team getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void setTeam(Team team) {
|
||||
this.team = team;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package hhn.labsw.bugageocaching.helper;
|
||||
|
||||
public class TeamRankingListHelper {
|
||||
|
||||
private String teamname;
|
||||
private int rankingPointsSum;
|
||||
|
||||
public TeamRankingListHelper(String teamname, int ranking_Points) {
|
||||
this.teamname = teamname;
|
||||
this.rankingPointsSum = ranking_Points;
|
||||
}
|
||||
|
||||
public String getTeamname() {
|
||||
return teamname;
|
||||
}
|
||||
|
||||
public void setTeamname(String teamname) {
|
||||
this.teamname = teamname;
|
||||
}
|
||||
|
||||
public int getRanking_Points() {
|
||||
return rankingPointsSum;
|
||||
}
|
||||
|
||||
public void setRanking_Points(int ranking_Points) {
|
||||
this.rankingPointsSum = ranking_Points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "( " + teamname + " | " + rankingPointsSum + " )";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package hhn.labsw.bugageocaching.repositories;
|
||||
|
||||
import hhn.labsw.bugageocaching.entities.Cache;
|
||||
import hhn.labsw.bugageocaching.entities.Team;
|
||||
import hhn.labsw.bugageocaching.entities.TeamInvite;
|
||||
import hhn.labsw.bugageocaching.entities.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface TeamInviteRepository extends JpaRepository<TeamInvite, Integer> {
|
||||
TeamInvite findByUserAndTeam(User user, Team team);
|
||||
}
|
||||
@ -7,7 +7,7 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserRepository extends CrudRepository<User, Integer> {
|
||||
User findByUsername(String username);
|
||||
User findByEmail(String email);
|
||||
|
||||
@Query(value = "SELECT DISTINCT u.id AS ID, SUBSTRING_INDEX(u.email, '@', 1) AS Name, ui.ranking_points_sum AS Ranglistenpunkte\n" +
|
||||
"FROM user u,\n" +
|
||||
@ -35,4 +35,18 @@ public interface UserRepository extends CrudRepository<User, Integer> {
|
||||
"WHERE Name = ?1", nativeQuery = true)
|
||||
int getRankingPlaceFromUser(String username);
|
||||
|
||||
@Query(value = "SELECT DISTINCT t.name AS teamname, SUM(ui.ranking_points_sum) AS Ranglistenpunkte\n" +
|
||||
"FROM user u,\n" +
|
||||
" user_info ui,\n" +
|
||||
" user_roles ur,\n" +
|
||||
" team t\n" +
|
||||
"WHERE u.id = ui.user_id\n" +
|
||||
" AND u.id = ur.user_id\n" +
|
||||
" AND t.id = ui.team_id\n" +
|
||||
" AND ui.team_id IS NOT NULL\n" +
|
||||
"GROUP BY teamname\n" +
|
||||
"ORDER by ranking_points_sum DESC" +
|
||||
"LIMIT 10;", nativeQuery = true)
|
||||
List<Object[]> getTeamRankingList();
|
||||
|
||||
}
|
||||
|
||||
@ -31,6 +31,8 @@ public class FinderUtil {
|
||||
|
||||
static User_InfoRepository user_infoRepository;
|
||||
|
||||
static TeamInviteRepository teamInviteRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
public void setCacheRepository(CacheRepository cacheRepository) {
|
||||
@ -72,6 +74,11 @@ public class FinderUtil {
|
||||
FinderUtil.user_infoRepository = user_infoRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) {
|
||||
FinderUtil.teamInviteRepository = teamInviteRepository;
|
||||
}
|
||||
|
||||
|
||||
public static ResponseEntity findCacheById(String cacheID) {
|
||||
|
||||
@ -104,16 +111,6 @@ public class FinderUtil {
|
||||
return ResponseEntity.status(404).body("The user has not started this cache yet");
|
||||
}
|
||||
|
||||
public static ResponseEntity findUserByUsername(String username) {
|
||||
|
||||
User user = userRepository.findByUsername(username);
|
||||
if (user != null) {
|
||||
return ResponseEntity.status(200).body(user);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(404).body("Couldnt find user with username " + username);
|
||||
}
|
||||
|
||||
public static ResponseEntity findCacheAccesDefinitionById(String cacheAccesDefinitionID) {
|
||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional = cacheAccesDefinitionRepository.findById(Integer.valueOf(cacheAccesDefinitionID));
|
||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||
@ -161,4 +158,13 @@ public class FinderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static ResponseEntity findTeamInviteByID(String teamInviteID) {
|
||||
Optional<TeamInvite> teamInviteOptional = teamInviteRepository.findById(Integer.valueOf(teamInviteID));
|
||||
if (teamInviteOptional.isPresent()) {
|
||||
return ResponseEntity.status(200).body(teamInviteOptional.get());
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("Couldnt find User_Info " + teamInviteID);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user