Browse Source

refactor

master
esoe 1 week ago
parent
commit
6ec17b88b9
  1. 55
      main/src/main/java/gsp/technologies/main/access/login/AuthController.java
  2. 25
      main/src/main/java/gsp/technologies/main/access/login/AuthDTO.java
  3. 2
      main/src/main/java/gsp/technologies/main/common/code/Code.java
  4. 4
      main/src/main/java/gsp/technologies/main/common/hello/HelloController.java
  5. 2
      main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationApiController.java
  6. 2
      main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationEntity.java
  7. 2
      main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationFaceController.java
  8. 2
      main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationRepository.java
  9. 2
      main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationService.java
  10. 2
      main/src/main/java/gsp/technologies/main/supplier/position/PositionApiController.java
  11. 4
      main/src/main/java/gsp/technologies/main/supplier/position/PositionEntity.java
  12. 6
      main/src/main/java/gsp/technologies/main/supplier/position/PositionFaceController.java
  13. 2
      main/src/main/java/gsp/technologies/main/supplier/position/PositionRepository.java
  14. 2
      main/src/main/java/gsp/technologies/main/supplier/position/PositionService.java
  15. 6
      main/src/main/java/gsp/technologies/main/supplier/target/TargetEntity.java
  16. 14
      main/src/main/java/gsp/technologies/main/supplier/target/TargetFaceController.java
  17. 6
      main/src/main/java/gsp/technologies/main/supplier/target/TargetRepository.java
  18. 10
      main/src/main/java/gsp/technologies/main/supplier/target/TargetService.java
  19. 4
      main/src/main/java/gsp/technologies/main/user/account/AccountEntity.java
  20. 33
      main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java
  21. 2
      main/src/main/java/gsp/technologies/main/user/account/AccountRepository.java
  22. 2
      main/src/main/java/gsp/technologies/main/user/account/AccountService.java
  23. 2
      main/src/main/java/gsp/technologies/main/user/course/CourseEntity.java
  24. 22
      main/src/main/java/gsp/technologies/main/user/course/CourseFaceController.java
  25. 2
      main/src/main/java/gsp/technologies/main/user/course/CourseRepository.java
  26. 2
      main/src/main/java/gsp/technologies/main/user/course/CourseService.java
  27. 28
      main/src/main/java/gsp/technologies/main/user/login/LoginController.java
  28. 2
      main/src/main/java/gsp/technologies/main/user/logout/LogoutController.java
  29. 2
      main/src/main/java/gsp/technologies/main/user/quiz/QuizController.java
  30. 13
      main/src/main/resources/static/content/courses/1/main.md
  31. 2
      main/src/main/resources/static/content/courses/2/main.md
  32. 10
      main/src/main/resources/templates/fragments/code.html
  33. 11
      main/src/main/resources/templates/fragments/course.html
  34. 0
      main/src/main/resources/templates/pages/common/hello.html
  35. 2
      main/src/main/resources/templates/pages/debuger/error.html
  36. 9
      main/src/main/resources/templates/pages/reviewer/find.html
  37. 6
      main/src/main/resources/templates/pages/supplier/courses.html
  38. 4
      main/src/main/resources/templates/pages/supplier/organizations-edit.html
  39. 6
      main/src/main/resources/templates/pages/supplier/organizations.html
  40. 6
      main/src/main/resources/templates/pages/supplier/positions.html
  41. 6
      main/src/main/resources/templates/pages/supplier/targets.html
  42. 8
      main/src/main/resources/templates/pages/user/account.html
  43. 8
      main/src/main/resources/templates/pages/user/course.html
  44. 12
      main/src/main/resources/templates/pages/user/login.html
  45. 6
      main/src/main/resources/templates/pages/user/quiz.html
  46. 12
      main/src/main/resources/templates/shards/accounts.html
  47. 20
      main/src/main/resources/templates/shards/courses.html
  48. 0
      main/src/main/resources/templates/shards/footer.html
  49. 0
      main/src/main/resources/templates/shards/header.html
  50. 0
      main/src/main/resources/templates/shards/hello.html
  51. 0
      main/src/main/resources/templates/shards/navi.html
  52. 0
      main/src/main/resources/templates/shards/organizations.html
  53. 0
      main/src/main/resources/templates/shards/positions.html
  54. 0
      main/src/main/resources/templates/shards/quizes.html
  55. 0
      main/src/main/resources/templates/shards/targets.html

55
main/src/main/java/gsp/technologies/main/access/login/AuthController.java

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
package gsp.technologies.main.access.login;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.mainframe.MainframeController;
/**
* Контроллер авторизации пользователя
* - обработка запросов с учетными данными пользователя (id аккаунта)
* - обработка запросов с данным сессии (id сессии)
*
* сюда обращаются сервисы, которые хотят получить доступ к аккаунту
* - mainframe (содержит поля для перехода к аккаунту)
* - login (разработка формы пока не предусмотрена)
*/
@Controller
@RequestMapping(path = "/auth")
public class AuthController {
private static final Logger log = LoggerFactory.getLogger(MainframeController.class);
/**
* Проверка наличия аккаунта в базе.
* В метод передается номер аккаунта в 35-ричной системе счисления
* номер аккаунта декодируется и направляется запрос на проверку в базу
* при отсутствии аккаунта в базе возвращается соответствующее сообщение
* при наличии аккаунта в базе возвращаются данные для перехода к запрошенному аккаунту
*
* @return
*
*/
@GetMapping("/check")
public AuthDTO checkAccount(@RequestParam("account") String account) {
log.info("GET /auth/check");
log.info("Запрошен номер аккаунта: {}", account);
//сравнить номер сессии с имеющимися в базе
//при наличии вернуть порядковый номер существующей сессии (в 35-ричной системе счисления)
//при отсутствии внести новую запись в базу и вернуть ее порядковый номер
return new AuthDTO();
}
@GetMapping("/current")
public AuthDTO checkSession(@RequestParam("session") String session) {
log.info("GET /auth/current");
log.info("Запрошен номер сессии: {}", session);
return new AuthDTO();
}
}

25
main/src/main/java/gsp/technologies/main/access/login/AuthDTO.java

@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
package gsp.technologies.main.access.login;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* DTO для обмена данными с сервисом авторизации
* хранит:
* - номер сессии пользователя
* - номер запрошенного аккаунта
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class AuthDTO implements Serializable {
private String sessionId;
private String accountId;
private String code35;
}

2
main/src/main/java/gsp/technologies/main/code/Code.java → main/src/main/java/gsp/technologies/main/common/code/Code.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.code;
package gsp.technologies.main.common.code;
/**
* Класс, содержащий методы преобразования id в 35-ричное представление

4
main/src/main/java/gsp/technologies/main/hello/HelloController.java → main/src/main/java/gsp/technologies/main/common/hello/HelloController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.hello;
package gsp.technologies.main.common.hello;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -13,6 +13,6 @@ public class HelloController { @@ -13,6 +13,6 @@ public class HelloController {
@CrossOrigin
@GetMapping("/hello")
public String hello(){
return "hello";
return "pages/common/hello";
}
}

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java → main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationApiController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.organization;
package gsp.technologies.main.supplier.organization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java → main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationEntity.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.organization;
package gsp.technologies.main.supplier.organization;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationFaceController.java → main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationFaceController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.organization;
package gsp.technologies.main.supplier.organization;
import java.util.Collection;
import java.util.stream.Collectors;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java → main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationRepository.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.organization;
package gsp.technologies.main.supplier.organization;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java → main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationService.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.organization;
package gsp.technologies.main.supplier.organization;
import java.util.Collection;

2
main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java → main/src/main/java/gsp/technologies/main/supplier/position/PositionApiController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.position;
package gsp.technologies.main.supplier.position;
import java.util.Collection;

4
main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java → main/src/main/java/gsp/technologies/main/supplier/position/PositionEntity.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.position;
package gsp.technologies.main.supplier.position;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
@ -15,7 +15,7 @@ import lombok.NoArgsConstructor; @@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import gsp.technologies.main.api.organization.OrganizationEntity;
import gsp.technologies.main.supplier.organization.OrganizationEntity;
@Data
@AllArgsConstructor

6
main/src/main/java/gsp/technologies/main/api/position/PositionFaceController.java → main/src/main/java/gsp/technologies/main/supplier/position/PositionFaceController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.position;
package gsp.technologies.main.supplier.position;
import java.util.Collection;
import java.util.stream.Collectors;
@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.PostMapping; @@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService;
import gsp.technologies.main.supplier.organization.OrganizationEntity;
import gsp.technologies.main.supplier.organization.OrganizationService;
@Controller
@RequestMapping(path = "/positions")

2
main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java → main/src/main/java/gsp/technologies/main/supplier/position/PositionRepository.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.position;
package gsp.technologies.main.supplier.position;
import java.util.Collection;

2
main/src/main/java/gsp/technologies/main/api/position/PositionService.java → main/src/main/java/gsp/technologies/main/supplier/position/PositionService.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.position;
package gsp.technologies.main.supplier.position;
import java.util.Collection;

6
main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java → main/src/main/java/gsp/technologies/main/supplier/target/TargetEntity.java

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
package gsp.technologies.main.api.target;
package gsp.technologies.main.supplier.target;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import gsp.technologies.main.api.course.CourseEntity;
import gsp.technologies.main.api.position.PositionEntity;
import gsp.technologies.main.supplier.position.PositionEntity;
import gsp.technologies.main.user.course.CourseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;

14
main/src/main/java/gsp/technologies/main/api/target/TargetFaceController.java → main/src/main/java/gsp/technologies/main/supplier/target/TargetFaceController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.target;
package gsp.technologies.main.supplier.target;
import java.util.Collection;
import java.util.Collections;
@ -13,12 +13,12 @@ import org.springframework.web.bind.annotation.PostMapping; @@ -13,12 +13,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.course.CourseEntity;
import gsp.technologies.main.api.course.CourseService;
import gsp.technologies.main.api.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService;
import gsp.technologies.main.api.position.PositionEntity;
import gsp.technologies.main.api.position.PositionService;
import gsp.technologies.main.supplier.organization.OrganizationEntity;
import gsp.technologies.main.supplier.organization.OrganizationService;
import gsp.technologies.main.supplier.position.PositionEntity;
import gsp.technologies.main.supplier.position.PositionService;
import gsp.technologies.main.user.course.CourseEntity;
import gsp.technologies.main.user.course.CourseService;
@Controller
@RequestMapping(path = "/targets")

6
main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java → main/src/main/java/gsp/technologies/main/supplier/target/TargetRepository.java

@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
package gsp.technologies.main.api.target;
package gsp.technologies.main.supplier.target;
import java.util.Collection;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface TargetRepository extends JpaRepository<TargetEntity, Long> {
Collection<TargetEntity> findAllByPositionId(Long id);
}

10
main/src/main/java/gsp/technologies/main/api/target/TargetService.java → main/src/main/java/gsp/technologies/main/supplier/target/TargetService.java

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
package gsp.technologies.main.api.target;
package gsp.technologies.main.supplier.target;
import java.util.Collection;
import org.springframework.stereotype.Service;
import gsp.technologies.main.api.course.CourseEntity;
import gsp.technologies.main.api.position.PositionEntity;
import gsp.technologies.main.supplier.position.PositionEntity;
import gsp.technologies.main.user.course.CourseEntity;
@Service
public class TargetService {
@ -23,10 +23,6 @@ public class TargetService { @@ -23,10 +23,6 @@ public class TargetService {
return repo.save(entity);
}
public Collection<CourseEntity> findAllByPosition(PositionEntity position) {
return repo.findAllByPosition(position);
}
public Collection<TargetEntity> findAllByPositionId(Long id) {
return repo.findAllByPositionId(id);
}

4
main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java → main/src/main/java/gsp/technologies/main/user/account/AccountEntity.java

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
package gsp.technologies.main.api.account;
package gsp.technologies.main.user.account;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import gsp.technologies.main.api.position.PositionEntity;
import gsp.technologies.main.supplier.position.PositionEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;

33
main/src/main/java/gsp/technologies/main/api/account/AccountFaceController.java → main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
package gsp.technologies.main.api.account;
package gsp.technologies.main.user.account;
import java.util.Collection;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -11,13 +12,13 @@ import org.springframework.web.bind.annotation.GetMapping; @@ -11,13 +12,13 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.course.CourseEntity;
import gsp.technologies.main.api.organization.OrganizationService;
import gsp.technologies.main.api.position.PositionEntity;
import gsp.technologies.main.api.position.PositionService;
import gsp.technologies.main.api.target.TargetEntity;
import gsp.technologies.main.api.target.TargetService;
import gsp.technologies.main.code.Code;
import gsp.technologies.main.common.code.Code;
import gsp.technologies.main.supplier.organization.OrganizationService;
import gsp.technologies.main.supplier.position.PositionEntity;
import gsp.technologies.main.supplier.position.PositionService;
import gsp.technologies.main.supplier.target.TargetEntity;
import gsp.technologies.main.supplier.target.TargetService;
import gsp.technologies.main.user.course.CourseEntity;
/**
* Контроллер формы аккаунта
@ -81,7 +82,10 @@ public class AccountFaceController { @@ -81,7 +82,10 @@ public class AccountFaceController {
//передаем в модель перечень доступных курсов
Collection<TargetEntity> targets = targetService.findAllByPositionId(account.getPosition().getId());
Collection<CourseEntity> courses = targetService.findAllByPosition(account.getPosition());
Collection<CourseEntity> courses = targets.stream()
.map(TargetEntity::getCourse)
.distinct()
.collect(Collectors.toList());
model.addAttribute("courses", courses);
//передаем в модель статусы прохождения курсов
@ -115,6 +119,17 @@ public class AccountFaceController { @@ -115,6 +119,17 @@ public class AccountFaceController {
account = accountService.save(account);
model.addAttribute("account", account);
//передаем в модель перечень доступных курсов
Collection<TargetEntity> targets = targetService.findAllByPositionId(account.getPosition().getId());
Collection<CourseEntity> courses = targets.stream()
.map(TargetEntity::getCourse)
.distinct()
.collect(Collectors.toList());
model.addAttribute("courses", courses);
//передаем в модель статусы прохождения курсов
return "account";
} catch (Exception e) {
StringBuilder msg = new StringBuilder();

2
main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java → main/src/main/java/gsp/technologies/main/user/account/AccountRepository.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.account;
package gsp.technologies.main.user.account;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

2
main/src/main/java/gsp/technologies/main/api/account/AccountService.java → main/src/main/java/gsp/technologies/main/user/account/AccountService.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.account;
package gsp.technologies.main.user.account;
import org.springframework.stereotype.Service;

2
main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java → main/src/main/java/gsp/technologies/main/user/course/CourseEntity.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.course;
package gsp.technologies.main.user.course;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

22
main/src/main/java/gsp/technologies/main/api/course/CourseFaceController.java → main/src/main/java/gsp/technologies/main/user/course/CourseFaceController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.course;
package gsp.technologies.main.user.course;
import java.util.Collection;
@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.GetMapping; @@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.user.account.AccountService;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
@ -21,8 +23,13 @@ public class CourseFaceController { @@ -21,8 +23,13 @@ public class CourseFaceController {
@Autowired
private CourseService courseService;
public CourseFaceController(CourseService courseService) {
@Autowired
private AccountService accountService;
public CourseFaceController(CourseService courseService, AccountService accountService) {
this.courseService = courseService;
this.accountService = accountService;
}
@GetMapping("")
@ -47,6 +54,17 @@ public class CourseFaceController { @@ -47,6 +54,17 @@ public class CourseFaceController {
return "redirect:/courses";
}
@GetMapping("/view")
public String view(
Model model,
@RequestParam(name = "courseid", required = true) Long courseid,
@RequestParam(name = "accountid", required = true) String accountid
){
model.addAttribute("account", accountService.findById(Long.valueOf(accountid)));
model.addAttribute("courseid", courseid);
return "course";
}

2
main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java → main/src/main/java/gsp/technologies/main/user/course/CourseRepository.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.course;
package gsp.technologies.main.user.course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

2
main/src/main/java/gsp/technologies/main/api/course/CourseService.java → main/src/main/java/gsp/technologies/main/user/course/CourseService.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.course;
package gsp.technologies.main.user.course;
import java.util.Collection;

28
main/src/main/java/gsp/technologies/main/mainframe/MainframeController.java → main/src/main/java/gsp/technologies/main/user/login/LoginController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.mainframe;
package gsp.technologies.main.user.login;
import java.util.Collection;
import java.util.stream.Collectors;
@ -6,19 +6,15 @@ import java.util.stream.Collectors; @@ -6,19 +6,15 @@ import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder;
import gsp.technologies.main.api.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService;
import gsp.technologies.main.api.position.PositionEntity;
import gsp.technologies.main.api.position.PositionService;
import gsp.technologies.main.supplier.organization.OrganizationEntity;
import gsp.technologies.main.supplier.organization.OrganizationService;
import gsp.technologies.main.supplier.position.PositionEntity;
import gsp.technologies.main.supplier.position.PositionService;
import org.springframework.web.bind.annotation.GetMapping;
@ -30,22 +26,22 @@ import org.springframework.web.bind.annotation.GetMapping; @@ -30,22 +26,22 @@ import org.springframework.web.bind.annotation.GetMapping;
*
*/
@Controller
@RequestMapping(path = "/mainframe")
public class MainframeController {
@RequestMapping(path = "/user/login")
public class LoginController {
@Autowired
private OrganizationService organizationService;
@Autowired
private PositionService positionService;
public MainframeController(PositionService positionService) {
public LoginController(PositionService positionService) {
this.positionService = positionService;
}
private static final Logger log = LoggerFactory.getLogger(MainframeController.class);
private static final Logger log = LoggerFactory.getLogger(LoginController.class);
@GetMapping("")
public String mainframe(Model model) {
log.info("GET /mainframe");
public String login(Model model) {
log.info("GET /login");
log.info("текущая сессия: {}", RequestContextHolder.currentRequestAttributes().getSessionId());
//получаем список организаций
Collection<OrganizationEntity> organizations = organizationService.findAll();
@ -64,6 +60,6 @@ public class MainframeController { @@ -64,6 +60,6 @@ public class MainframeController {
//при наличии вернуть порядковый номер существующей сессии (в 35-ричной системе счисления)
//при отсутствии внести новую запись в базу и вернуть ее порядковый номер
return "mainframe";
return "pages/user/login";
}
}

2
main/src/main/java/gsp/technologies/main/access/logout/LogoutController.java → main/src/main/java/gsp/technologies/main/user/logout/LogoutController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.access.logout;
package gsp.technologies.main.user.logout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

2
main/src/main/java/gsp/technologies/main/api/quiz/QuizController.java → main/src/main/java/gsp/technologies/main/user/quiz/QuizController.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
package gsp.technologies.main.api.quiz;
package gsp.technologies.main.user.quiz;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

13
main/src/main/resources/static/content/courses/1/main.md

@ -1,7 +1,16 @@ @@ -1,7 +1,16 @@
# Курс: Охрана труда
# Курс: Работы на высоте
## диаграмма usecase
Устанавливает роли и основные способы использования приложения
**Устанавливает роли и основные способы использования приложения**
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus.
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus.
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus.
<code>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis inventore eveniet sunt modi deserunt, officia saepe aut in architecto id eaque reiciendis ullam eos deleniti minima, facere asperiores temporibus necessitatibus.
</code>
![диаграмма usecase](/content/courses/1/pictures/usecase.png)

2
main/src/main/resources/static/content/courses/2/main.md

@ -1 +1 @@ @@ -1 +1 @@
# Курс: Работы на высоте
# Курс: Охрана труда

10
main/src/main/resources/templates/fragments/code.html

@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="main">
<hr>
CODE:
</div>
</body>
</html>

11
main/src/main/resources/templates/fragments/course.html

@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
<!-- Коллекция фрагментов для построения страницы курса -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="main(id)">
<hr>
<zero-md th:src="@{/content/courses/{id}/main.md (id=${id})}"></zero-md>
</div>
</body>
</html>

0
main/src/main/resources/templates/hello.html → main/src/main/resources/templates/pages/common/hello.html

2
main/src/main/resources/templates/error.html → main/src/main/resources/templates/pages/debuger/error.html

@ -20,7 +20,7 @@ xmlns:th="http://www.thymeleaf.org"> @@ -20,7 +20,7 @@ xmlns:th="http://www.thymeleaf.org">
</form>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

9
main/src/main/resources/templates/auth.html → main/src/main/resources/templates/pages/reviewer/find.html

@ -4,18 +4,17 @@ xmlns:th="http://www.thymeleaf.org"> @@ -4,18 +4,17 @@ xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>exam-auth</title>
<title>exam-reviewer-find</title>
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>
</head>
<header>
<div th:insert="~{fragments/common/header :: to-mainframe}"></div>
<hr>
</header>
<body>
<div th:insert="~{fragments/controls :: auth}"></div>
<!-- ищем существующий аккаунт -->
<div th:insert="~{shards/navi :: auth}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

6
main/src/main/resources/templates/courses/main.html → main/src/main/resources/templates/pages/supplier/courses.html

@ -14,12 +14,12 @@ xmlns:th="http://www.thymeleaf.org"> @@ -14,12 +14,12 @@ xmlns:th="http://www.thymeleaf.org">
<body>
<h1>Фрагменты для работы с курсами</h1>
<!-- Добавление нового курса -->
<div th:insert="~{courses/fragments/main :: create}"></div>
<div th:insert="~{shards/courses :: create}"></div>
<!-- Перечень курсов -->
<div th:insert="~{courses/fragments/main :: list(courses=${courses})}"></div>
<div th:insert="~{shards/courses :: list(courses=${courses})}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

4
main/src/main/resources/templates/organizations/edit.html → main/src/main/resources/templates/pages/supplier/organizations-edit.html

@ -14,10 +14,10 @@ xmlns:th="http://www.thymeleaf.org"> @@ -14,10 +14,10 @@ xmlns:th="http://www.thymeleaf.org">
<body>
<h1>Фрагменты для работы с данными организаций</h1>
<!-- Редактирование организации -->
<div th:insert="~{organizations/fragments/main :: edit(organization=${organization})}"></div>
<div th:insert="~{shards/organizations :: edit(organization=${organization})}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

6
main/src/main/resources/templates/organizations/main.html → main/src/main/resources/templates/pages/supplier/organizations.html

@ -14,12 +14,12 @@ xmlns:th="http://www.thymeleaf.org"> @@ -14,12 +14,12 @@ xmlns:th="http://www.thymeleaf.org">
<body>
<h1>Фрагменты для работы с данными организаций</h1>
<!-- Давление новой организации -->
<div th:insert="~{organizations/fragments/main :: create}"></div>
<div th:insert="~{shards/organizations :: create}"></div>
<!-- Перечень организаций -->
<div th:insert="~{organizations/fragments/main :: list(organizations=${organizations})}"></div>
<div th:insert="~{shards/organizations :: list(organizations=${organizations})}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

6
main/src/main/resources/templates/positions/main.html → main/src/main/resources/templates/pages/supplier/positions.html

@ -14,12 +14,12 @@ xmlns:th="http://www.thymeleaf.org"> @@ -14,12 +14,12 @@ xmlns:th="http://www.thymeleaf.org">
<body>
<h1>Фрагменты для работы с данными о должностях</h1>
<!-- Добавление новой должности -->
<div th:insert="~{positions/fragments/main :: create(organizations=${organizations})}"></div>
<div th:insert="~{shards/positions :: create(organizations=${organizations})}"></div>
<!-- Перечень должностей -->
<div th:insert="~{positions/fragments/main :: list(positions=${positions})}"></div>
<div th:insert="~{shards/positions :: list(positions=${positions})}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

6
main/src/main/resources/templates/targets/main.html → main/src/main/resources/templates/pages/supplier/targets.html

@ -14,13 +14,13 @@ xmlns:th="http://www.thymeleaf.org"> @@ -14,13 +14,13 @@ xmlns:th="http://www.thymeleaf.org">
<body>
<h1>Фрагменты для работы с назначением курсов</h1>
<!-- Добавление новой задачи -->
<div th:insert="~{targets/fragments/main :: create(organizations=${organizations}, positions=${positions}, courses=${courses})}"></div>
<div th:insert="~{shards/targets :: create(organizations=${organizations}, positions=${positions}, courses=${courses})}"></div>
<!-- Перечень задачь -->
<div th:insert="~{targets/fragments/main :: list(targets=${targets})}"></div>
<div th:insert="~{shards/targets :: list(targets=${targets})}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
<script>
// Функция для загрузки должностей

8
main/src/main/resources/templates/account.html → main/src/main/resources/templates/pages/user/account.html

@ -17,15 +17,15 @@ xmlns:th="http://www.thymeleaf.org"> @@ -17,15 +17,15 @@ xmlns:th="http://www.thymeleaf.org">
</head>
<header>
<!-- Информация об аккаунте: id, organization, position -->
<div th:insert="~{fragments/account :: info(account=${account})}"></div>
<div th:insert="~{shards/accounts :: info(account=${account})}"></div>
</header>
<body>
<!-- Перечень доступных курсов -->
<!-- <div th:insert="~{fragments/account :: courses(account=${account})}"></div> -->
<div th:insert="~{shards/accounts :: courses(account=${account}, courses=${courses})}"></div>
</body>
<footer>
<!-- Выход из аккаунта, обновление сессии -->
<div th:insert="~{fragments/controls :: logout}"></div>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/navi :: logout}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

8
main/src/main/resources/templates/course.html → main/src/main/resources/templates/pages/user/course.html

@ -17,16 +17,16 @@ xmlns:th="http://www.thymeleaf.org"> @@ -17,16 +17,16 @@ xmlns:th="http://www.thymeleaf.org">
</head>
<header>
<!-- Информация об аккаунте: id, organization, position -->
<!-- <div th:insert="~{fragments/account :: info(account=${account})}"></div> -->
<div th:insert="~{shards/accounts :: info(account=${account})}"></div>
</header>
<body>
<!-- курс -->
<div th:insert="~{fragments/course :: main(id=${courseid})}"></div>
<div th:insert="~{shards/courses :: main(id=${courseid})}"></div>
<!-- <div th:insert="~{fragments/controls :: gotoQuiz(accountid=${account.id})}"></div> -->
</body>
<footer>
<!-- Выход из аккаунта, обновление сессии -->
<!-- <div th:insert="~{fragments/controls :: logout}"></div>
<div th:insert="~{fragments/common/footer :: copy}"></div> -->
<div th:insert="~{shards/navi :: logout}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

12
main/src/main/resources/templates/mainframe.html → main/src/main/resources/templates/pages/user/login.html

@ -11,16 +11,16 @@ xmlns:th="http://www.thymeleaf.org"> @@ -11,16 +11,16 @@ xmlns:th="http://www.thymeleaf.org">
<header>
</header>
<body>
<!-- переходим к сохраненной попытке -->
<div th:insert="~{fragments/controls :: auth}"></div>
<!-- ищем существующий аккаунт -->
<!-- <div th:insert="~{shards/navi :: auth}"></div> -->
<!-- пояснения, приветствие -->
<div th:insert="~{fragments/hello :: main}"></div>
<div th:insert="~{shards/hello :: main}"></div>
<!-- создаем новую попытку -->
<div th:insert="~{fragments/controls :: exam(organizations=${organizations})}"></div>
<div th:insert="~{shards/navi :: exam(organizations=${organizations})}"></div>
</body>
<footer>
<div th:insert="~{fragments/controls :: logout}"></div>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/navi :: logout}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
<script>

6
main/src/main/resources/templates/quiz.html → main/src/main/resources/templates/pages/user/quiz.html

@ -17,13 +17,13 @@ xmlns:th="http://www.thymeleaf.org"> @@ -17,13 +17,13 @@ xmlns:th="http://www.thymeleaf.org">
</head>
<header>
<!-- Информация об аккаунте: id, organization, position -->
<div th:insert="~{fragments/account :: info(account=${account})}"></div>
<div th:insert="~{shards/accounts :: info(account=${account})}"></div>
</header>
<body>
<!-- опрос -->
<div th:insert="~{fragments/quiz :: main}"></div>
<div th:insert="~{shards/quizes :: main}"></div>
</body>
<footer>
<div th:insert="~{fragments/common/footer :: copy}"></div>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

12
main/src/main/resources/templates/fragments/account.html → main/src/main/resources/templates/shards/accounts.html

@ -18,28 +18,28 @@ @@ -18,28 +18,28 @@
</div>
<!-- Доступные на аккаунте курсы -->
<div th:fragment="courses(account)">
<div th:fragment="courses(account, courses)">
<hr>
<h2>Доступные курсы:</h1>
<table>
<thead>
<th>номер</th>
<th>наименование</th>
<th>статус</th>
<!-- <th>статус</th> -->
<th>просмотреть</th>
</thead>
<tbody>
<tr th:each="course : ${account.courses}">
<tr th:each="course : ${courses}">
<td th:text="${course.id}"></td>
<td th:text="${course.name}"></td>
<td>
<!-- <td>
<div th:switch="${course.passed}">
<span th:case="true">пройден</span>
<span th:case="false">не пройден</span>
</div>
</td>
</td> -->
<td>
<form th:action="@{/courses/view}" th:method="post">
<form th:action="@{/courses/view}" th:method="get">
<input type="hidden" name="courseid" th:value="${course.id}">
<input type="hidden" name="accountid" th:value="${account.id}">
<input type="submit" value=">>>">

20
main/src/main/resources/templates/courses/fragments/main.html → main/src/main/resources/templates/shards/courses.html

@ -27,9 +27,6 @@ @@ -27,9 +27,6 @@
</tbody>
</table>
<hr>
<!-- <div th:each="course : ${courses}">
<div th:text="${course.name}"></div>
</div> -->
</div>
<!-- Добавление нового курса -->
@ -43,6 +40,19 @@ @@ -43,6 +40,19 @@
</form>
</div>
<!-- Переход к опросу -->
<!-- передаем данные:
- аккаунта
- текущего курса
-->
<div th:frafment="goto-quiz(accountid, courseid)">
<form th:action="@{/quizes}" th:method="get">
<input type="hidden" name="accountid" th:value="${accountid}">
<input type="hidden" name="courseid" th:value="${courseid}">
<input type="submit" value="ПЕРЕЙТИ К ОПРОСУ">
</form>
</div>
<!-- Редактирование курсов -->
<!-- <div th:fragment="edit(position)">
<hr>
@ -54,5 +64,9 @@ @@ -54,5 +64,9 @@
<input type="submit" value="Сохранить">
</form>
</div> -->
<div th:fragment="content(id)">
<hr>
<zero-md th:src="@{/content/courses/{id}/main.md (id=${id})}"></zero-md>
</div>
</body>
</html>

0
main/src/main/resources/templates/fragments/common/footer.html → main/src/main/resources/templates/shards/footer.html

0
main/src/main/resources/templates/fragments/common/header.html → main/src/main/resources/templates/shards/header.html

0
main/src/main/resources/templates/fragments/hello.html → main/src/main/resources/templates/shards/hello.html

0
main/src/main/resources/templates/fragments/controls.html → main/src/main/resources/templates/shards/navi.html

0
main/src/main/resources/templates/organizations/fragments/main.html → main/src/main/resources/templates/shards/organizations.html

0
main/src/main/resources/templates/positions/fragments/main.html → main/src/main/resources/templates/shards/positions.html

0
main/src/main/resources/templates/fragments/quiz.html → main/src/main/resources/templates/shards/quizes.html

0
main/src/main/resources/templates/targets/fragments/main.html → main/src/main/resources/templates/shards/targets.html

Loading…
Cancel
Save