slaba baterija
parent
88975de6e9
commit
e5a7e4e01f
|
@ -0,0 +1,7 @@
|
||||||
|
package ba.steleks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by admin on 01/04/2017.
|
||||||
|
*/
|
||||||
|
public class EventController {
|
||||||
|
}
|
|
@ -37,7 +37,7 @@ class MessageRestController {
|
||||||
// return "temp " + Long.toString(id);
|
// return "temp " + Long.toString(id);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@RequestMapping(value = "/whoami/{user}", method = RequestMethod.GET)
|
@RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET)
|
||||||
public String whoami(@PathVariable("username") String username) {
|
public String whoami(@PathVariable("username") String username) {
|
||||||
return String.format("Hello! You're %s and you'll become a(n) root, " +
|
return String.format("Hello! You're %s and you'll become a(n) root, " +
|
||||||
"but only if your password is '%s'!\n",
|
"but only if your password is '%s'!\n",
|
||||||
|
|
|
@ -3,7 +3,7 @@ spring.datasource.url = jdbc:mysql://localhost:3306/events
|
||||||
spring.datasource.username = root
|
spring.datasource.username = root
|
||||||
spring.datasource.password = skorpion
|
spring.datasource.password = skorpion
|
||||||
spring.jpa.generate-ddl=true
|
spring.jpa.generate-ddl=true
|
||||||
|
user.password=dizda
|
||||||
#
|
#
|
||||||
#spring.datasource.url = jdbc:mysql://localhost:3306/events
|
#spring.datasource.url = jdbc:mysql://localhost:3306/events
|
||||||
#spring.datasource.username = root
|
#spring.datasource.username = root
|
||||||
|
|
|
@ -28,4 +28,5 @@ dependencies {
|
||||||
runtime('com.h2database:h2')
|
runtime('com.h2database:h2')
|
||||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||||
compile('mysql:mysql-connector-java')
|
compile('mysql:mysql-connector-java')
|
||||||
|
compile('org.hibernate:hibernate-validator')
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package ba.steleks.repository;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.data.rest.webmvc.support.RepositoryConstraintViolationExceptionMessage;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by admin on 01/04/2017.
|
||||||
|
*/
|
||||||
|
@ControllerAdvice
|
||||||
|
public class GlobalExceptionController {
|
||||||
|
|
||||||
|
@ExceptionHandler(CustomGenericException.class)
|
||||||
|
public ModelAndView handleCustomException(CustomGenericException ex) {
|
||||||
|
|
||||||
|
ModelAndView model = new ModelAndView("error/generic_error");
|
||||||
|
model.addObject("errCode", ex.getErrCode());
|
||||||
|
model.addObject("errMsg", ex.getErrMsg());
|
||||||
|
|
||||||
|
return model;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public ModelAndView handleAllException(Exception ex) {
|
||||||
|
|
||||||
|
ModelAndView model = new ModelAndView("error/generic_error");
|
||||||
|
model.addObject("errMsg", "this is Exception.class");
|
||||||
|
|
||||||
|
return model;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,13 @@ package ba.steleks.repository.model;/**
|
||||||
* Created by ensar on 22/03/17.
|
* Created by ensar on 22/03/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.sql.Time;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -15,14 +21,22 @@ public class User {
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private int cardNumber;
|
private int cardNumber;
|
||||||
|
@NotNull
|
||||||
private String firstName;
|
private String firstName;
|
||||||
|
@NotNull
|
||||||
private String lastName;
|
private String lastName;
|
||||||
private String registrationDate;
|
@NotNull
|
||||||
|
@Column(updatable = false, insertable = false)
|
||||||
|
private Timestamp registrationDate;
|
||||||
|
@NotNull
|
||||||
private String email;
|
private String email;
|
||||||
|
@NotNull
|
||||||
private String contactNumber;
|
private String contactNumber;
|
||||||
|
@NotNull
|
||||||
private String passwordHash;
|
private String passwordHash;
|
||||||
|
@NotNull
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String profilePictureUrl;
|
private String profilePictureUrl;
|
||||||
|
@ -71,11 +85,11 @@ public class User {
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegistrationDate() {
|
public Timestamp getRegistrationDate() {
|
||||||
return registrationDate;
|
return registrationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegistrationDate(String registrationDate) {
|
public void setRegistrationDate(Timestamp registrationDate) {
|
||||||
this.registrationDate = registrationDate;
|
this.registrationDate = registrationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,4 +156,9 @@ public class User {
|
||||||
public void setUserRoles(Set<UserRole> userRoles) {
|
public void setUserRoles(Set<UserRole> userRoles) {
|
||||||
this.userRoles = userRoles;
|
this.userRoles = userRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
protected void onCreate() {
|
||||||
|
this.registrationDate = new Timestamp(new Date().getTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue