Added init test data on dev profile
This commit is contained in:
parent
751d4b1744
commit
495098eeed
@ -1,24 +1,35 @@
|
|||||||
package com.plannaplan;
|
package com.plannaplan;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.plannaplan.models.ConfigData;
|
||||||
import com.plannaplan.entities.User;
|
import com.plannaplan.entities.User;
|
||||||
import com.plannaplan.services.UserService;
|
import com.plannaplan.services.UserService;
|
||||||
import com.plannaplan.types.UserRoles;
|
import com.plannaplan.types.UserRoles;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
|
import com.plannaplan.services.ConfiguratorService;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public final static String API_VERSION = "v1";
|
public final static String API_VERSION = "v1";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfiguratorService contrl;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
UserService userService;
|
UserService userService;
|
||||||
|
|
||||||
|
@Value("${plannaplan.dev}")
|
||||||
|
private boolean isDev;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Logo logo = new Logo("beta");
|
Logo logo = new Logo("beta");
|
||||||
System.out.println(logo.getLogo());
|
System.out.println(logo.getLogo());
|
||||||
@ -29,12 +40,106 @@ public class App {
|
|||||||
|
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
public void importData() {
|
public void importData() {
|
||||||
|
System.out.println(Logo.getInitInfo(isDev));
|
||||||
|
|
||||||
|
if (this.isDev) {
|
||||||
|
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
|
||||||
|
ConfigData data = new ConfigData(null, null, inputStream);
|
||||||
|
this.contrl.config(data);
|
||||||
|
|
||||||
|
User filip = new User();
|
||||||
|
filip.setEmail("filizy@st.amu.edu.pl");
|
||||||
|
filip.setName("Filip");
|
||||||
|
filip.setSurname("Izydorczyk");
|
||||||
|
filip.setRole(UserRoles.ADMIN);
|
||||||
|
this.userService.save(filip);
|
||||||
|
|
||||||
|
User hub = new User();
|
||||||
|
hub.setEmail("hubwrz1@st.amu.edu.pl");
|
||||||
|
hub.setName("Hubert");
|
||||||
|
hub.setSurname("Wrzesiński");
|
||||||
|
hub.setRole(UserRoles.DEANERY);
|
||||||
|
this.userService.save(hub);
|
||||||
|
|
||||||
|
User mac = new User();
|
||||||
|
mac.setEmail("macglo2@st.amu.edu.pl");
|
||||||
|
mac.setName("Maciej");
|
||||||
|
mac.setSurname("Głowacki");
|
||||||
|
mac.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(mac);
|
||||||
|
|
||||||
|
User mar = new User();
|
||||||
|
mar.setEmail("marwoz16@st.amu.edu.pl");
|
||||||
|
mar.setName("Marcin");
|
||||||
|
mar.setSurname("Woźniak");
|
||||||
|
mar.setRole(UserRoles.ADMIN);
|
||||||
|
this.userService.save(mar);
|
||||||
|
|
||||||
|
User newuser = new User();
|
||||||
|
newuser.setEmail("tommy@st.amu.edu.pl");
|
||||||
|
newuser.setName("Tomek");
|
||||||
|
newuser.setSurname("Atomek");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("robercik@st.amu.edu.pl");
|
||||||
|
newuser.setName("Robert");
|
||||||
|
newuser.setSurname("Głowacki");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("mewa@st.amu.edu.pl");
|
||||||
|
newuser.setName("Poznanska");
|
||||||
|
newuser.setSurname("Mewa");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("tkul2@st.amu.edu.pl");
|
||||||
|
newuser.setName("Tomasz");
|
||||||
|
newuser.setSurname("Kula");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("annana@st.amu.edu.pl");
|
||||||
|
newuser.setName("Anna");
|
||||||
|
newuser.setSurname("Na");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("mnart@st.amu.edu.pl");
|
||||||
|
newuser.setName("Marta");
|
||||||
|
newuser.setSurname("Narta");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("zmineniane@st.amu.edu.pl");
|
||||||
|
newuser.setName("Tutaj");
|
||||||
|
newuser.setSurname("Koncza");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("mi@st.amu.edu.pl");
|
||||||
|
newuser.setName("Mi");
|
||||||
|
newuser.setSurname("Sie");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
|
||||||
|
newuser = new User();
|
||||||
|
newuser.setEmail("pms@st.amu.edu.pl");
|
||||||
|
newuser.setName("Pomysly");
|
||||||
|
newuser.setSurname("Sad");
|
||||||
|
newuser.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(newuser);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(Logo.getStartedInfo(isDev));
|
||||||
|
|
||||||
User mac = new User();
|
|
||||||
mac.setEmail("macglo2@st.amu.edu.pl");
|
|
||||||
mac.setName("Maciej");
|
|
||||||
mac.setSurname("Głowacki");
|
|
||||||
mac.setRole(UserRoles.STUDENT);
|
|
||||||
this.userService.save(mac);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package com.plannaplan;
|
package com.plannaplan;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public class Logo {
|
public class Logo {
|
||||||
|
|
||||||
public static final String ANSI_RESET = "\u001B[0m";
|
public static final String ANSI_RESET = "\u001B[0m";
|
||||||
public static final String ANSI_YELLOW = "\u001B[33m";
|
public static final String ANSI_YELLOW = "\u001B[33m";
|
||||||
public static final String ANSI_BLUE = "\u001B[34m";
|
public static final String ANSI_BLUE = "\u001B[34m";
|
||||||
public static final String ANSI_BLACK = "\u001B[30m";
|
public static final String ANSI_BLACK = "\u001B[37m";
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
public Logo(String version){
|
public Logo(String version){
|
||||||
@ -30,4 +33,25 @@ public class Logo {
|
|||||||
ANSI_RESET;
|
ANSI_RESET;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getInitInfo(boolean isDev){
|
||||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
if(isDev){
|
||||||
|
return ANSI_BLACK + dtf.format(now) + ANSI_YELLOW + " plannaplan" + ANSI_RESET + " initializing [" +ANSI_BLUE + "dev" + ANSI_RESET +"]";
|
||||||
|
}
|
||||||
|
return ANSI_BLACK + dtf.format(now) + ANSI_YELLOW + " plannaplan" + ANSI_RESET + " initializing [" +ANSI_BLUE + "prod" + ANSI_RESET +"]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getStartedInfo(boolean isDev){
|
||||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
if(isDev){
|
||||||
|
return ANSI_BLACK + dtf.format(now) +ANSI_YELLOW + " plannaplan" + ANSI_RESET + " started [" +ANSI_BLUE + "dev" + ANSI_RESET +"]";
|
||||||
|
}
|
||||||
|
return ANSI_BLACK + dtf.format(now) + ANSI_YELLOW + " plannaplan" + ANSI_RESET + " started [" +ANSI_BLUE + "prod" + ANSI_RESET +"]";
|
||||||
|
}
|
||||||
}
|
}
|
BIN
restservice/src/main/resources/Zajecia.xlsx
Executable file
BIN
restservice/src/main/resources/Zajecia.xlsx
Executable file
Binary file not shown.
@ -1 +1 @@
|
|||||||
spring.profiles.active=prod
|
spring.profiles.active=dev
|
Loading…
Reference in New Issue
Block a user