Added points ranking to entity

This commit is contained in:
Filip Izydorczyk 2021-01-02 13:45:03 +01:00
parent 3bce1f91ec
commit a41c6f2583
2 changed files with 50 additions and 3 deletions

View File

@ -32,6 +32,7 @@ public class User {
private String token; private String token;
private String refreshToken; private String refreshToken;
private Timestamp tokenUsageDate; private Timestamp tokenUsageDate;
private Integer ranking;
public User() { public User() {
} }
@ -63,6 +64,21 @@ public class User {
this.usosId = usosId; this.usosId = usosId;
} }
/**
*
* @param name name given to the user
* @param surname surname given to the user
* @param mail mail given to the user
* @param usosId id in the USOS system
* @param role user's role
* @param ranking ranking points <100;500>. It's calculated by
* gradesAvg*100*studiesYear
*/
public User(String name, String surname, String mail, String usosId, UserRoles role, Integer ranking) {
this(name, surname, mail, usosId, role);
this.ranking = ranking;
}
/** /**
* usos id getter * usos id getter
* *
@ -189,6 +205,25 @@ public class User {
return this.id; return this.id;
} }
/**
* Ranking points are <100;500>. It's calculated by gradesAvg*100*studiesYear
*
* @return ranking points <100;500>
*/
public Integer getRanking() {
return ranking;
}
/**
* Ranking points setter. Ranking points are <100;500>. It's calculated by
* gradesAvg*100*studiesYear
*
* @param ranking ranking points <100;500>
*/
public void setRanking(Integer ranking) {
this.ranking = ranking;
}
/** /**
* updates user entity with data got by UsosApiService::getUserData * updates user entity with data got by UsosApiService::getUserData
* *

View File

@ -2,6 +2,7 @@ package com.plannaplan;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Date; import java.sql.Date;
import java.util.Random;
import com.plannaplan.models.ConfigData; import com.plannaplan.models.ConfigData;
import com.plannaplan.models.TourData; import com.plannaplan.models.TourData;
@ -30,7 +31,7 @@ public class App {
private ConfiguratorService contrl; private ConfiguratorService contrl;
@Autowired @Autowired
UserService userService; private UserService userService;
@Value("${plannaplan.dev}") @Value("${plannaplan.dev}")
private boolean isDev; private boolean isDev;
@ -52,8 +53,9 @@ public class App {
System.out.println(Logo.getInitInfo(isDev)); System.out.println(Logo.getInitInfo(isDev));
if (this.isDev) { if (this.isDev) {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); final Random generator = new Random();
ConfigData data = new ConfigData( final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
final ConfigData data = new ConfigData(
new TourData(new Date(System.currentTimeMillis()), new TourData(new Date(System.currentTimeMillis()),
new Date(System.currentTimeMillis() + 86400000)), new Date(System.currentTimeMillis() + 86400000)),
new TourData(new Date(System.currentTimeMillis() + 86400000), new TourData(new Date(System.currentTimeMillis() + 86400000),
@ -65,6 +67,7 @@ public class App {
newuser.setEmail("tommy@st.amu.edu.pl"); newuser.setEmail("tommy@st.amu.edu.pl");
newuser.setName("Tomek"); newuser.setName("Tomek");
newuser.setSurname("Atomek"); newuser.setSurname("Atomek");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -72,6 +75,7 @@ public class App {
newuser.setEmail("robercik@st.amu.edu.pl"); newuser.setEmail("robercik@st.amu.edu.pl");
newuser.setName("Robert"); newuser.setName("Robert");
newuser.setSurname("Głowacki"); newuser.setSurname("Głowacki");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -79,6 +83,7 @@ public class App {
newuser.setEmail("mewa@st.amu.edu.pl"); newuser.setEmail("mewa@st.amu.edu.pl");
newuser.setName("Poznanska"); newuser.setName("Poznanska");
newuser.setSurname("Mewa"); newuser.setSurname("Mewa");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -86,6 +91,7 @@ public class App {
newuser.setEmail("tkul2@st.amu.edu.pl"); newuser.setEmail("tkul2@st.amu.edu.pl");
newuser.setName("Tomasz"); newuser.setName("Tomasz");
newuser.setSurname("Kula"); newuser.setSurname("Kula");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -93,6 +99,7 @@ public class App {
newuser.setEmail("annana@st.amu.edu.pl"); newuser.setEmail("annana@st.amu.edu.pl");
newuser.setName("Anna"); newuser.setName("Anna");
newuser.setSurname("Na"); newuser.setSurname("Na");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -100,6 +107,7 @@ public class App {
newuser.setEmail("mnart@st.amu.edu.pl"); newuser.setEmail("mnart@st.amu.edu.pl");
newuser.setName("Marta"); newuser.setName("Marta");
newuser.setSurname("Narta"); newuser.setSurname("Narta");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -107,6 +115,7 @@ public class App {
newuser.setEmail("zmineniane@st.amu.edu.pl"); newuser.setEmail("zmineniane@st.amu.edu.pl");
newuser.setName("Tutaj"); newuser.setName("Tutaj");
newuser.setSurname("Koncza"); newuser.setSurname("Koncza");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -114,6 +123,7 @@ public class App {
newuser.setEmail("mi@st.amu.edu.pl"); newuser.setEmail("mi@st.amu.edu.pl");
newuser.setName("Mi"); newuser.setName("Mi");
newuser.setSurname("Sie"); newuser.setSurname("Sie");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
@ -121,11 +131,13 @@ public class App {
newuser.setEmail("pms@st.amu.edu.pl"); newuser.setEmail("pms@st.amu.edu.pl");
newuser.setName("Pomysly"); newuser.setName("Pomysly");
newuser.setSurname("Sad"); newuser.setSurname("Sad");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
newuser = new User(); newuser = new User();
newuser.setEmail("iamnull@st.amu.edu.pl"); newuser.setEmail("iamnull@st.amu.edu.pl");
newuser.setRanking(generator.nextInt(400) + 100);
newuser.setRole(UserRoles.STUDENT); newuser.setRole(UserRoles.STUDENT);
this.userService.save(newuser); this.userService.save(newuser);
} }