Merge branch '72-link-to-timetable' into 'dev'
Resolve "Ссылка на расписание пользователя" Closes #72 See merge request romanov73/ng-tracker!31
This commit is contained in:
commit
ae58a5b6e4
@ -58,7 +58,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
.anyRequest()
|
.anyRequest()
|
||||||
.permitAll();
|
.permitAll();
|
||||||
http.anonymous()
|
http.anonymous()
|
||||||
.principal("developer")
|
.principal("admin")
|
||||||
.authorities(UserRoleConstants.ADMIN);
|
.authorities(UserRoleConstants.ADMIN);
|
||||||
} else {
|
} else {
|
||||||
log.debug("Security enabled");
|
log.debug("Security enabled");
|
||||||
|
@ -6,7 +6,7 @@ import org.springframework.validation.FieldError;
|
|||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import ru.ulstu.core.error.EntityIdIsNullException;
|
import ru.ulstu.core.error.EntityIdIsNullException;
|
||||||
import ru.ulstu.core.model.ErrorConstants;
|
import ru.ulstu.core.model.ErrorConstants;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
@ -20,14 +20,30 @@ import ru.ulstu.user.error.UserNotActivatedException;
|
|||||||
import ru.ulstu.user.error.UserNotFoundException;
|
import ru.ulstu.user.error.UserNotFoundException;
|
||||||
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
|
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
|
||||||
import ru.ulstu.user.error.UserResetKeyError;
|
import ru.ulstu.user.error.UserResetKeyError;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class AdviceController {
|
public class AdviceController {
|
||||||
|
private final static String USER_NAME_TEMPLATE = "%s %s %s";
|
||||||
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
public AdviceController(UserService userService) {
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("currentUser")
|
||||||
|
public String getCurrentUser() {
|
||||||
|
User user = userService.getCurrentUser();
|
||||||
|
return String.format(USER_NAME_TEMPLATE,
|
||||||
|
user.getLastName(),
|
||||||
|
user.getFirstName().substring(0, 1),
|
||||||
|
user.getPatronymic().substring(0, 1));
|
||||||
|
}
|
||||||
|
|
||||||
private Response<Void> handleException(ErrorConstants error) {
|
private Response<Void> handleException(ErrorConstants error) {
|
||||||
log.warn(error.toString());
|
log.warn(error.toString());
|
||||||
|
21
src/main/java/ru/ulstu/index/controller/IndexController.java
Normal file
21
src/main/java/ru/ulstu/index/controller/IndexController.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package ru.ulstu.index.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import ru.ulstu.core.controller.AdviceController;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
@RequestMapping(value = "/index")
|
||||||
|
public class IndexController extends AdviceController {
|
||||||
|
public IndexController(UserService userService) {
|
||||||
|
super(userService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public void currentUser(ModelMap modelMap) {
|
||||||
|
//нужен здесь для добавления параметров на стартовой странице
|
||||||
|
}
|
||||||
|
}
|
@ -45,6 +45,10 @@ public class User extends BaseEntity {
|
|||||||
@Column(name = "last_name", length = 50, nullable = false)
|
@Column(name = "last_name", length = 50, nullable = false)
|
||||||
private String lastName;
|
private String lastName;
|
||||||
|
|
||||||
|
@Size(max = 50)
|
||||||
|
@Column(name = "patronymic", length = 50)
|
||||||
|
private String patronymic;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Email
|
@Email
|
||||||
@Size(min = 5, max = 100)
|
@Size(min = 5, max = 100)
|
||||||
@ -174,4 +178,12 @@ public class User extends BaseEntity {
|
|||||||
this.roles.clear();
|
this.roles.clear();
|
||||||
this.roles.addAll(roles);
|
this.roles.addAll(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPatronymic() {
|
||||||
|
return patronymic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPatronymic(String patronymic) {
|
||||||
|
this.patronymic = patronymic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,4 +315,13 @@ public class UserService implements UserDetailsService {
|
|||||||
public User findById(Integer id) {
|
public User findById(Integer id) {
|
||||||
return userRepository.findOne(id);
|
return userRepository.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User getCurrentUser() {
|
||||||
|
String login = UserUtils.getCurrentUserLogin();
|
||||||
|
User user = userRepository.findOneByLoginIgnoreCase(login);
|
||||||
|
if (user == null) {
|
||||||
|
throw new UserNotFoundException(login);
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,4 +18,5 @@
|
|||||||
<include file="db/changelog-20181111_000000-schema.xml"/>
|
<include file="db/changelog-20181111_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20181208_000000-schema.xml"/>
|
<include file="db/changelog-20181208_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20181224_000000-schema.xml"/>
|
<include file="db/changelog-20181224_000000-schema.xml"/>
|
||||||
|
<include file="db/common/changelog-20190312_130000-schema.xml"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="orion" id="20190312_130000-1">
|
||||||
|
<addColumn tableName="users">
|
||||||
|
<column name="patronymic" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20190312_130000-2">
|
||||||
|
<sql>
|
||||||
|
update users
|
||||||
|
set first_name = 'Антон', patronymic = 'Алексеевич', last_name = 'Романов' where id = 1;
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -1,6 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ru"
|
<html lang="ru"
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
@ -53,6 +53,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link js-scroll-trigger" target="_blank" href="http://is.ulstu.ru">Сайт кафедры</a>
|
<a class="nav-link js-scroll-trigger" target="_blank" href="http://is.ulstu.ru">Сайт кафедры</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link js-scroll-trigger" target="_blank" th:href="@{'http://timetable.athene.tech?filter='+${currentUser}}">Расписание</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link js-scroll-trigger" target="_blank" href="https://kias.rfbr.ru/">КИАС РФФИ</a>
|
<a class="nav-link js-scroll-trigger" target="_blank" href="https://kias.rfbr.ru/">КИАС РФФИ</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user