From 007d71cd38e760c0f6455dfb5f579d8af509b36b Mon Sep 17 00:00:00 2001 From: esoe Date: Fri, 15 Nov 2024 16:35:38 +0300 Subject: [PATCH] refactor --- .../{user => api}/account/AccountEntity.java | 4 +- .../account/AccountRepository.java | 2 +- .../{user => api}/account/AccountService.java | 2 +- .../{user => api}/course/CourseEntity.java | 2 +- .../course/CourseRepository.java | 2 +- .../{user => api}/course/CourseService.java | 2 +- .../OrganizationApiController.java | 2 +- .../organization/OrganizationEntity.java | 2 +- .../organization/OrganizationRepository.java | 2 +- .../organization/OrganizationService.java | 2 +- .../position/PositionApiController.java | 10 +- .../position/PositionEntity.java | 4 +- .../position/PositionRepository.java | 2 +- .../position/PositionService.java | 2 +- .../target/TargetEntity.java | 6 +- .../target/TargetRepository.java | 2 +- .../target/TargetService.java | 5 +- .../main/face/reviewer/ReviewController.java | 104 ++++++++++++ .../supplier/SupCourseController.java} | 47 +++--- .../supplier/SupOrganizationController.java} | 42 ++--- .../supplier/SupPositionController.java} | 30 ++-- .../supplier/SupTargetFaceController.java} | 37 ++--- .../main/face/user/UserAccountController.java | 114 ++++++++++++++ .../main/face/user/UserCourseController.java | 90 +++++++++++ .../user/UserLoginController.java} | 18 +-- .../user/UserLogoutController.java} | 6 +- .../user/UserQuizController.java} | 6 +- .../user/account/AccountFaceController.java | 149 ------------------ .../static/content/courses/52/main.md | 21 +++ .../pages/reviewer/{find.html => login.html} | 0 .../templates/pages/user/course.html | 2 +- .../resources/templates/shards/accounts.html | 6 +- .../resources/templates/shards/courses.html | 6 +- .../main/resources/templates/shards/navi.html | 4 +- .../templates/shards/organizations.html | 12 +- .../resources/templates/shards/positions.html | 14 +- .../resources/templates/shards/targets.html | 111 ++++++++----- 37 files changed, 536 insertions(+), 336 deletions(-) rename main/src/main/java/gsp/technologies/main/{user => api}/account/AccountEntity.java (86%) rename main/src/main/java/gsp/technologies/main/{user => api}/account/AccountRepository.java (79%) rename main/src/main/java/gsp/technologies/main/{user => api}/account/AccountService.java (86%) rename main/src/main/java/gsp/technologies/main/{user => api}/course/CourseEntity.java (87%) rename main/src/main/java/gsp/technologies/main/{user => api}/course/CourseRepository.java (79%) rename main/src/main/java/gsp/technologies/main/{user => api}/course/CourseService.java (88%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/organization/OrganizationApiController.java (94%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/organization/OrganizationEntity.java (88%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/organization/OrganizationRepository.java (77%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/organization/OrganizationService.java (88%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/position/PositionApiController.java (89%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/position/PositionEntity.java (85%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/position/PositionRepository.java (87%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/position/PositionService.java (91%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/target/TargetEntity.java (86%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/target/TargetRepository.java (83%) rename main/src/main/java/gsp/technologies/main/{supplier => api}/target/TargetService.java (73%) create mode 100644 main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java rename main/src/main/java/gsp/technologies/main/{user/course/CourseFaceController.java => face/supplier/SupCourseController.java} (53%) rename main/src/main/java/gsp/technologies/main/{supplier/organization/OrganizationFaceController.java => face/supplier/SupOrganizationController.java} (68%) rename main/src/main/java/gsp/technologies/main/{supplier/position/PositionFaceController.java => face/supplier/SupPositionController.java} (70%) rename main/src/main/java/gsp/technologies/main/{supplier/target/TargetFaceController.java => face/supplier/SupTargetFaceController.java} (68%) create mode 100644 main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java create mode 100644 main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java rename main/src/main/java/gsp/technologies/main/{user/login/LoginController.java => face/user/UserLoginController.java} (80%) rename main/src/main/java/gsp/technologies/main/{user/logout/LogoutController.java => face/user/UserLogoutController.java} (85%) rename main/src/main/java/gsp/technologies/main/{user/quiz/QuizController.java => face/user/UserQuizController.java} (75%) delete mode 100644 main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java create mode 100644 main/src/main/resources/static/content/courses/52/main.md rename main/src/main/resources/templates/pages/reviewer/{find.html => login.html} (100%) diff --git a/main/src/main/java/gsp/technologies/main/user/account/AccountEntity.java b/main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/user/account/AccountEntity.java rename to main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java index dd8c498..1cf0396 100644 --- a/main/src/main/java/gsp/technologies/main/user/account/AccountEntity.java +++ b/main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java @@ -1,9 +1,9 @@ -package gsp.technologies.main.user.account; +package gsp.technologies.main.api.account; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; -import gsp.technologies.main.supplier.position.PositionEntity; +import gsp.technologies.main.api.position.PositionEntity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; diff --git a/main/src/main/java/gsp/technologies/main/user/account/AccountRepository.java b/main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java similarity index 79% rename from main/src/main/java/gsp/technologies/main/user/account/AccountRepository.java rename to main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java index e038c4e..f0b6fbc 100644 --- a/main/src/main/java/gsp/technologies/main/user/account/AccountRepository.java +++ b/main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.account; +package gsp.technologies.main.api.account; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/main/src/main/java/gsp/technologies/main/user/account/AccountService.java b/main/src/main/java/gsp/technologies/main/api/account/AccountService.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/user/account/AccountService.java rename to main/src/main/java/gsp/technologies/main/api/account/AccountService.java index de6efa8..87ec70f 100644 --- a/main/src/main/java/gsp/technologies/main/user/account/AccountService.java +++ b/main/src/main/java/gsp/technologies/main/api/account/AccountService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.account; +package gsp.technologies.main.api.account; import org.springframework.stereotype.Service; diff --git a/main/src/main/java/gsp/technologies/main/user/course/CourseEntity.java b/main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java similarity index 87% rename from main/src/main/java/gsp/technologies/main/user/course/CourseEntity.java rename to main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java index 1f04cea..90c9779 100644 --- a/main/src/main/java/gsp/technologies/main/user/course/CourseEntity.java +++ b/main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.course; +package gsp.technologies.main.api.course; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/main/src/main/java/gsp/technologies/main/user/course/CourseRepository.java b/main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java similarity index 79% rename from main/src/main/java/gsp/technologies/main/user/course/CourseRepository.java rename to main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java index 1110711..5eb4acf 100644 --- a/main/src/main/java/gsp/technologies/main/user/course/CourseRepository.java +++ b/main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.course; +package gsp.technologies.main.api.course; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/main/src/main/java/gsp/technologies/main/user/course/CourseService.java b/main/src/main/java/gsp/technologies/main/api/course/CourseService.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/user/course/CourseService.java rename to main/src/main/java/gsp/technologies/main/api/course/CourseService.java index 121a3c2..f5bd6e2 100644 --- a/main/src/main/java/gsp/technologies/main/user/course/CourseService.java +++ b/main/src/main/java/gsp/technologies/main/api/course/CourseService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.course; +package gsp.technologies.main.api.course; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationApiController.java b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java similarity index 94% rename from main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationApiController.java rename to main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java index ad05089..aba4da2 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationApiController.java +++ b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.organization; +package gsp.technologies.main.api.organization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationEntity.java b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationEntity.java rename to main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java index 1c7a6db..092b641 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationEntity.java +++ b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.organization; +package gsp.technologies.main.api.organization; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationRepository.java b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java similarity index 77% rename from main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationRepository.java rename to main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java index b58aad3..d01436c 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationRepository.java +++ b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.organization; +package gsp.technologies.main.api.organization; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationService.java b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationService.java rename to main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java index ebe6887..111a51c 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationService.java +++ b/main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.organization; +package gsp.technologies.main.api.organization; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/supplier/position/PositionApiController.java b/main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java similarity index 89% rename from main/src/main/java/gsp/technologies/main/supplier/position/PositionApiController.java rename to main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java index 7a7391a..a0c9830 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/position/PositionApiController.java +++ b/main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.position; +package gsp.technologies.main.api.position; import java.util.Collection; @@ -45,13 +45,13 @@ public class PositionApiController { @RequestParam(name = "number", required = false, defaultValue = "0") int number, @RequestParam(name = "size", required = false, defaultValue = "10") int size, @RequestParam(name = "sortBy", required = false, defaultValue = "name") String sortBy) { - log.info("GET /positions"); + log.info("GET /api/v1/positions"); Sort sort = Sort.by(sortBy); Pageable of = PageRequest.of(number, size, sort); if (id != 0) { - log.info("GET /positions, organizationId: {}", id); + log.info("GET /api/v1/positions, organizationId: {}", id); Page page = positionService.findByOrganizationId(of, id); return new ResponseEntity<>(page, HttpStatus.OK); // return new ResponseEntity>>(assembler.toModel(page), HttpStatus.OK); @@ -71,11 +71,11 @@ public class PositionApiController { consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity savePosition(@RequestBody PositionEntity position) { - log.info("POST /positions, position: {}", position); + log.info("POST /api/v1/positions, position: {}", position); try { positionService.save(position); } catch (Exception e) { - log.error("POST /positions", e.getMessage()); + log.error("POST /api/v1/positions", e.getMessage()); return new ResponseEntity<>(e.getMessage(), HttpStatus.OK); } return new ResponseEntity<>(position, HttpStatus.CREATED); diff --git a/main/src/main/java/gsp/technologies/main/supplier/position/PositionEntity.java b/main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java similarity index 85% rename from main/src/main/java/gsp/technologies/main/supplier/position/PositionEntity.java rename to main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java index 35940f3..c92863b 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/position/PositionEntity.java +++ b/main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.position; +package gsp.technologies.main.api.position; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -15,7 +15,7 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; -import gsp.technologies.main.supplier.organization.OrganizationEntity; +import gsp.technologies.main.api.organization.OrganizationEntity; @Data @AllArgsConstructor diff --git a/main/src/main/java/gsp/technologies/main/supplier/position/PositionRepository.java b/main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java similarity index 87% rename from main/src/main/java/gsp/technologies/main/supplier/position/PositionRepository.java rename to main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java index 1405320..f087f78 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/position/PositionRepository.java +++ b/main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.position; +package gsp.technologies.main.api.position; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/supplier/position/PositionService.java b/main/src/main/java/gsp/technologies/main/api/position/PositionService.java similarity index 91% rename from main/src/main/java/gsp/technologies/main/supplier/position/PositionService.java rename to main/src/main/java/gsp/technologies/main/api/position/PositionService.java index 302ad08..7c7e8ae 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/position/PositionService.java +++ b/main/src/main/java/gsp/technologies/main/api/position/PositionService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.position; +package gsp.technologies.main.api.position; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/supplier/target/TargetEntity.java b/main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/supplier/target/TargetEntity.java rename to main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java index 5880b6d..7e62455 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/target/TargetEntity.java +++ b/main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java @@ -1,10 +1,10 @@ -package gsp.technologies.main.supplier.target; +package gsp.technologies.main.api.target; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; -import gsp.technologies.main.supplier.position.PositionEntity; -import gsp.technologies.main.user.course.CourseEntity; +import gsp.technologies.main.api.course.CourseEntity; +import gsp.technologies.main.api.position.PositionEntity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; diff --git a/main/src/main/java/gsp/technologies/main/supplier/target/TargetRepository.java b/main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java similarity index 83% rename from main/src/main/java/gsp/technologies/main/supplier/target/TargetRepository.java rename to main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java index 1b2a471..e118733 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/target/TargetRepository.java +++ b/main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.target; +package gsp.technologies.main.api.target; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/supplier/target/TargetService.java b/main/src/main/java/gsp/technologies/main/api/target/TargetService.java similarity index 73% rename from main/src/main/java/gsp/technologies/main/supplier/target/TargetService.java rename to main/src/main/java/gsp/technologies/main/api/target/TargetService.java index 498348a..1858e58 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/target/TargetService.java +++ b/main/src/main/java/gsp/technologies/main/api/target/TargetService.java @@ -1,12 +1,9 @@ -package gsp.technologies.main.supplier.target; +package gsp.technologies.main.api.target; import java.util.Collection; import org.springframework.stereotype.Service; -import gsp.technologies.main.supplier.position.PositionEntity; -import gsp.technologies.main.user.course.CourseEntity; - @Service public class TargetService { private final TargetRepository repo; diff --git a/main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java b/main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java new file mode 100644 index 0000000..2a9ac9e --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java @@ -0,0 +1,104 @@ +package gsp.technologies.main.face.reviewer; + +import java.util.Collection; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +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.account.AccountEntity; +import gsp.technologies.main.api.account.AccountService; +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.common.code.Code; + +/** + * Контроллер формы аккаунта + * возвращает thymeleaf шаблон + */ +@Controller +@RequestMapping(path = "/reviewer") +public class ReviewController { + private static final Logger log = LoggerFactory.getLogger(ReviewController.class); + @Autowired + private OrganizationService organizationService; + + @Autowired + private PositionService positionService; + + @Autowired + private AccountService accountService; + + @Autowired + private TargetService targetService; + + public ReviewController( + PositionService positionService + , OrganizationService organizationService + , AccountService accountService + , TargetService targetService + ) { + this.positionService = positionService; + this.organizationService = organizationService; + this.accountService = accountService; + this.targetService = targetService; + } + + @GetMapping("/login") + public String login(Model model) { + log.info("GET /reviewer"); + return "pages/reviewer/login"; + } + + /** + * Форма аккаунта: + * - данные аккаунта (id, organization, position) + * - список курсов аккаунта + * + * @param model + * @param accountid + * @param positionid + * @return + */ + @GetMapping("/account") + public String account(Model model, + @RequestParam(name = "accountid", required = true) String accountid + ) { + log.info("GET /user/account"); + log.info("accountid: " + accountid); + + try{ + //передаем в модель данные аккаунта + AccountEntity account = accountService.findById(Long.valueOf(accountid)); + model.addAttribute("account", account); + + //передаем в модель перечень доступных курсов + Collection targets = targetService.findAllByPositionId(account.getPosition().getId()); + Collection courses = targets.stream() + .map(TargetEntity::getCourse) + .distinct() + .collect(Collectors.toList()); + model.addAttribute("courses", courses); + //передаем в модель статусы прохождения курсов + return "pages/user/account"; + + } catch (Exception e) { + StringBuilder msg = new StringBuilder(); + msg.append("Не удалось получить данные аккаунта: " + e.getMessage()); + log.error(msg.toString()); + model.addAttribute("error", msg.toString()); + return "pages/debuger/error"; + } + + } +} diff --git a/main/src/main/java/gsp/technologies/main/user/course/CourseFaceController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java similarity index 53% rename from main/src/main/java/gsp/technologies/main/user/course/CourseFaceController.java rename to main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java index e647aa9..c618d45 100644 --- a/main/src/main/java/gsp/technologies/main/user/course/CourseFaceController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.course; +package gsp.technologies.main.face.supplier; import java.util.Collection; @@ -11,15 +11,17 @@ 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 gsp.technologies.main.api.account.AccountService; +import gsp.technologies.main.api.course.CourseEntity; +import gsp.technologies.main.api.course.CourseService; import org.springframework.web.bind.annotation.PostMapping; @Controller -@RequestMapping(path = "/courses") -public class CourseFaceController { +@RequestMapping(path = "/supplier") +public class SupCourseController { - private static final Logger log = LoggerFactory.getLogger(CourseFaceController.class); + private static final Logger log = LoggerFactory.getLogger(SupCourseController.class); @Autowired private CourseService courseService; @@ -27,45 +29,38 @@ public class CourseFaceController { @Autowired private AccountService accountService; - public CourseFaceController(CourseService courseService, AccountService accountService) { + public SupCourseController(CourseService courseService, AccountService accountService) { this.courseService = courseService; this.accountService = accountService; } - @GetMapping("") + /** + * Перечень курсов размещенных на сервере + * - перенести в контроллер supplier + * @param model + * @return + */ + @GetMapping("/courses") public String course(Model model) { - log.info("GET /courses"); + log.info("GET /supplier/courses"); Collection courses = courseService.findAll(); model.addAttribute("courses", courses); - return "courses/main"; + return "/pages/supplier/courses"; } /** * Создание нового курса + * - перенести в контроллер supplier */ - @PostMapping("") + @PostMapping("/courses") public String create(@RequestParam(name = "name", required = true) String name) { - log.info("POST /courses"); + log.info("POST /supplier/courses"); CourseEntity entity = new CourseEntity(); entity.setName(name); courseService.save(entity); - 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"; + return "redirect:/supplier/courses"; } - - - } diff --git a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationFaceController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java similarity index 68% rename from main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationFaceController.java rename to main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java index 8a5b6f3..ae91f30 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationFaceController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.organization; +package gsp.technologies.main.face.supplier; import java.util.Collection; import java.util.stream.Collectors; @@ -12,18 +12,22 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; 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 org.springframework.web.bind.annotation.PostMapping; @Controller -@RequestMapping(path = "/organizations") -public class OrganizationFaceController { - private static final Logger log = LoggerFactory.getLogger(OrganizationFaceController.class); +@RequestMapping(path = "/supplier") +public class SupOrganizationController { + private static final Logger log = LoggerFactory.getLogger(SupOrganizationController.class); @Autowired private OrganizationService service; - public OrganizationFaceController(OrganizationService organizationService) { + public SupOrganizationController(OrganizationService organizationService) { this.service = organizationService; } @@ -32,9 +36,9 @@ public class OrganizationFaceController { * Главная страница для работы с перечнем организаций * @return */ - @GetMapping("") + @GetMapping("/organizations") public String organizations(Model model) { - log.info("GET /organizations"); + log.info("GET /supplier/organizations"); // получаем список организаций Collection organizations = service.findAll(); // сортируем по названию @@ -42,54 +46,54 @@ public class OrganizationFaceController { // передаем список организаций в шаблон model.addAttribute("organizations", organizations); model.addAttribute("organizationService", service); - return "organizations/main"; + return "pages/supplier/organizations"; } /** * Добавление новой организации */ - @PostMapping("") + @PostMapping("/organizations") public String create(@RequestParam(name = "name", required = true) String name) { - log.info("POST /organizations"); + log.info("POST /supplier/organizations"); OrganizationEntity entity = new OrganizationEntity(); entity.setName(name); service.save(entity); - return "redirect:/organizations"; + return "redirect:/supplier/organizations"; } /** * Удаление организации * @param id */ - @GetMapping("/{id}/delete") + @GetMapping("/organizations/{id}/delete") public String delete(@PathVariable(name = "id", required = true) Long id) { - log.info("GET /organizations/{id}/delete"); + log.info("GET /supplier/organizations/{id}/delete"); service.deleteById(id); - return "redirect:/organizations"; + return "redirect:/supplier/organizations"; } /** * Переход к форме редактирования организации */ - @GetMapping("/{id}/edit") + @GetMapping("/organizations/{id}/edit") public String edit(@PathVariable(name = "id", required = true) Long id, Model model) { log.info("GET /organizations/{id}/edit"); OrganizationEntity entity = service.findById(id); model.addAttribute("organization", entity); - return "organizations/edit"; + return "pages/supplier/organizations-edit"; } /** * Редакрирование организации */ - @PostMapping("/{id}/edit") + @PostMapping("/organizations/{id}/edit") public String update(@PathVariable(name = "id", required = true) Long id, @RequestParam(name = "name", required = true) String name) { - log.info("POST /organizations/{id}/edit"); + log.info("POST /supplier/organizations/{id}/edit"); OrganizationEntity entity = new OrganizationEntity(); entity.setName(name); entity.setId(id); service.save(entity); - return "redirect:/organizations"; + return "redirect:/supplier/organizations"; } diff --git a/main/src/main/java/gsp/technologies/main/supplier/position/PositionFaceController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java similarity index 70% rename from main/src/main/java/gsp/technologies/main/supplier/position/PositionFaceController.java rename to main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java index 448751c..d4c3274 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/position/PositionFaceController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.supplier.position; +package gsp.technologies.main.face.supplier; import java.util.Collection; import java.util.stream.Collectors; @@ -16,13 +16,15 @@ 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.supplier.organization.OrganizationEntity; -import gsp.technologies.main.supplier.organization.OrganizationService; +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; @Controller -@RequestMapping(path = "/positions") -public class PositionFaceController { - private static final Logger log = LoggerFactory.getLogger(PositionFaceController.class); +@RequestMapping(path = "/supplier") +public class SupPositionController { + private static final Logger log = LoggerFactory.getLogger(SupPositionController.class); @Autowired private OrganizationService organizationService; @@ -30,7 +32,7 @@ public class PositionFaceController { @Autowired private PositionService positionService; - public PositionFaceController(PositionService positionService, OrganizationService organizationService) { + public SupPositionController(PositionService positionService, OrganizationService organizationService) { this.positionService = positionService; this.organizationService = organizationService; } @@ -38,9 +40,9 @@ public class PositionFaceController { /** * Главная страница работы с должностями */ - @GetMapping("") + @GetMapping("/positions") public String positions(Model model) { - log.info("GET /positions"); + log.info("GET /supplier/positions"); // получаем список организаций Collection organizations = organizationService.findAll() @@ -51,29 +53,29 @@ public class PositionFaceController { //получаем список должностей int number = 0; int size = 100; - String sortBy = "name"; + String sortBy = "organization.name"; Sort sort = Sort.by(sortBy); Pageable of = PageRequest.of(number, size, sort); Collection positions = positionService.findAll(of).getContent(); model.addAttribute("positions", positions); - return "positions/main"; + return "pages/supplier/positions"; } /** * Добавление должности */ - @PostMapping("") + @PostMapping("/positions") public String create( @RequestParam(name = "name", required = true) String name, @RequestParam(name = "organizationId", required = true) Long organizationId) { - log.info("POST /positions"); + log.info("POST /supplier/positions"); PositionEntity entity = new PositionEntity(); entity.setName(name); entity.setOrganization(organizationService.findById(organizationId)); positionService.save(entity); - return "redirect:/positions"; + return "redirect:/supplier/positions"; } } diff --git a/main/src/main/java/gsp/technologies/main/supplier/target/TargetFaceController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java similarity index 68% rename from main/src/main/java/gsp/technologies/main/supplier/target/TargetFaceController.java rename to main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java index 6396dde..2c8d573 100644 --- a/main/src/main/java/gsp/technologies/main/supplier/target/TargetFaceController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java @@ -1,7 +1,6 @@ -package gsp.technologies.main.supplier.target; +package gsp.technologies.main.face.supplier; import java.util.Collection; -import java.util.Collections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,17 +12,19 @@ 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.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; +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.api.target.TargetEntity; +import gsp.technologies.main.api.target.TargetService; @Controller -@RequestMapping(path = "/targets") -public class TargetFaceController { - private static final Logger log = LoggerFactory.getLogger(TargetFaceController.class); +@RequestMapping(path = "/supplier") +public class SupTargetFaceController { + private static final Logger log = LoggerFactory.getLogger(SupTargetFaceController.class); @Autowired private TargetService targetService; @@ -37,16 +38,16 @@ public class TargetFaceController { @Autowired private CourseService courseService; - public TargetFaceController(TargetService targetService, OrganizationService organizationService, PositionService positionService, CourseService courseService) { + public SupTargetFaceController(TargetService targetService, OrganizationService organizationService, PositionService positionService, CourseService courseService) { this.targetService = targetService; this.organizationService = organizationService; this.positionService = positionService; this.courseService = courseService; } - @GetMapping("") + @GetMapping("/targets") public String targets(Model model) { - log.info("GET /targets"); + log.info("GET /supplier/targets"); //передаем в шаблон перечень организаций Collection organizations = organizationService.findAll(); model.addAttribute("organizations", organizations); @@ -63,17 +64,17 @@ public class TargetFaceController { Collection targets = targetService.findAll(); model.addAttribute("targets", targets); - return "targets/main"; + return "pages/supplier/targets"; } - @PostMapping("") + @PostMapping("/targets") public String create( @RequestParam(name = "courseid", required = true) Long courseid, @RequestParam(name = "positionid", required = true) Long positionid, @RequestParam(name = "questions-count", required = true) Integer questionsCount, @RequestParam(name = "questions-limit", required = true) Integer questionsLimit ){ - log.info("POST /targets"); + log.info("POST /supplier/targets"); TargetEntity entity = TargetEntity.builder() .course(courseService.findById(courseid)) .position(positionService.findById(positionid)) @@ -82,7 +83,7 @@ public class TargetFaceController { .build(); targetService.save(entity); - return "redirect:/targets"; + return "redirect:/supplier/targets"; } diff --git a/main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java b/main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java new file mode 100644 index 0000000..c026495 --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java @@ -0,0 +1,114 @@ +package gsp.technologies.main.face.user; + +import java.util.Collection; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +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.account.AccountEntity; +import gsp.technologies.main.api.account.AccountService; +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.common.code.Code; + +/** + * Контроллер формы аккаунта + * возвращает thymeleaf шаблон + */ +@Controller +@RequestMapping(path = "/user/account") +public class UserAccountController { + private static final Logger log = LoggerFactory.getLogger(UserAccountController.class); + @Autowired + private OrganizationService organizationService; + + @Autowired + private PositionService positionService; + + @Autowired + private AccountService accountService; + + @Autowired + private TargetService targetService; + + public UserAccountController( + PositionService positionService + , OrganizationService organizationService + , AccountService accountService + , TargetService targetService + ) { + this.positionService = positionService; + this.organizationService = organizationService; + this.accountService = accountService; + this.targetService = targetService; + } + + /** + * Форма аккаунта: + * - данные аккаунта (id, organization, position) + * - список курсов аккаунта + * + * @param model + * @param accountid + * @param positionid + * @return + */ + @GetMapping("") + public String account(Model model, + @RequestParam(name = "positionid", required = true) String positionid + ) { + log.info("GET /user/account"); + //данные аккаунта (id, organization, position) + log.info("positionid: " + positionid); + + try{ + log.info("positionid: " + positionid); + PositionEntity position = positionService.findById(Long.valueOf(positionid)); + //обработать вход нового пользователя + AccountEntity account = AccountEntity.builder() + .position(position) + .build(); + + //сохранить в базе данных + account = accountService.save(account); + log.info("сохраняем account: " + account); + + //получить id аккаунта + String code = Code.encode(account.getId() + ""); + account.setCode(code); + //обновили аккаунт в базе данных + account = accountService.save(account); + + model.addAttribute("account", account); + + //передаем в модель перечень доступных курсов + Collection targets = targetService.findAllByPositionId(account.getPosition().getId()); + + Collection courses = targets.stream() + .map(TargetEntity::getCourse) + .distinct() + .collect(Collectors.toList()); + model.addAttribute("courses", courses); + //передаем в модель статусы прохождения курсов + + return "pages/user/account"; + } catch (Exception e) { + StringBuilder msg = new StringBuilder(); + msg.append("Не удалось получить данные аккаунта: " + e.getMessage()); + log.error(msg.toString()); + model.addAttribute("error", msg.toString()); + return "pages/debuger/error"; + } + } +} diff --git a/main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java b/main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java new file mode 100644 index 0000000..d097b50 --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java @@ -0,0 +1,90 @@ +package gsp.technologies.main.face.user; + +import java.util.Collection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +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.account.AccountService; +import gsp.technologies.main.api.course.CourseEntity; +import gsp.technologies.main.api.course.CourseService; + +import org.springframework.web.bind.annotation.PostMapping; + +@Controller +@RequestMapping(path = "/user") +public class UserCourseController { + + private static final Logger log = LoggerFactory.getLogger(UserCourseController.class); + + @Autowired + private CourseService courseService; + + @Autowired + private AccountService accountService; + + public UserCourseController(CourseService courseService, AccountService accountService) { + this.courseService = courseService; + this.accountService = accountService; + } + + /** + * Перечень курсов размещенных на сервере + * - перенести в контроллер supplier + * @param model + * @return + */ + @GetMapping("/courses") + public String course(Model model) { + log.info("GET /user/courses"); + + Collection courses = courseService.findAll(); + model.addAttribute("courses", courses); + return "/pages/user/course"; + } + + /** + * Создание нового курса + * - перенести в контроллер supplier + */ + @PostMapping("/courses") + public String create(@RequestParam(name = "name", required = true) String name) { + log.info("POST /user/courses"); + CourseEntity entity = new CourseEntity(); + entity.setName(name); + + courseService.save(entity); + + return "redirect:/user/courses"; + } + + /** + * Просмотр контента курса назначенного пользователю + * - перенести в метод course() + * - добавить id курса в переменную пути + * @param model + * @param courseid + * @param accountid + * @return + */ + @GetMapping("/course") + public String view( + Model model, + @RequestParam(name = "courseid", required = true) Long courseid, + @RequestParam(name = "accountid", required = true) String accountid + ){ + log.info("GET /user/courses/view"); + model.addAttribute("account", accountService.findById(Long.valueOf(accountid))); + model.addAttribute("courseid", courseid); + return "/pages/user/course"; + } + + + +} diff --git a/main/src/main/java/gsp/technologies/main/user/login/LoginController.java b/main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java similarity index 80% rename from main/src/main/java/gsp/technologies/main/user/login/LoginController.java rename to main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java index 9f454ea..2de28bb 100644 --- a/main/src/main/java/gsp/technologies/main/user/login/LoginController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.login; +package gsp.technologies.main.face.user; import java.util.Collection; import java.util.stream.Collectors; @@ -11,10 +11,10 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.request.RequestContextHolder; -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.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 org.springframework.web.bind.annotation.GetMapping; @@ -27,21 +27,21 @@ import org.springframework.web.bind.annotation.GetMapping; */ @Controller @RequestMapping(path = "/user/login") -public class LoginController { +public class UserLoginController { @Autowired private OrganizationService organizationService; @Autowired private PositionService positionService; - public LoginController(PositionService positionService) { + public UserLoginController(PositionService positionService) { this.positionService = positionService; } - private static final Logger log = LoggerFactory.getLogger(LoginController.class); + private static final Logger log = LoggerFactory.getLogger(UserLoginController.class); @GetMapping("") public String login(Model model) { - log.info("GET /login"); + log.info("GET /user/login"); log.info("текущая сессия: {}", RequestContextHolder.currentRequestAttributes().getSessionId()); //получаем список организаций Collection organizations = organizationService.findAll(); diff --git a/main/src/main/java/gsp/technologies/main/user/logout/LogoutController.java b/main/src/main/java/gsp/technologies/main/face/user/UserLogoutController.java similarity index 85% rename from main/src/main/java/gsp/technologies/main/user/logout/LogoutController.java rename to main/src/main/java/gsp/technologies/main/face/user/UserLogoutController.java index 8a8e165..625aafe 100644 --- a/main/src/main/java/gsp/technologies/main/user/logout/LogoutController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserLogoutController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.logout; +package gsp.technologies.main.face.user; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,8 +13,8 @@ import org.springframework.web.context.request.ServletRequestAttributes; */ @Controller @RequestMapping(path = "/logout") -public class LogoutController { - private static final Logger log = LoggerFactory.getLogger(LogoutController.class); +public class UserLogoutController { + private static final Logger log = LoggerFactory.getLogger(UserLogoutController.class); @GetMapping("") public String mainframe() { diff --git a/main/src/main/java/gsp/technologies/main/user/quiz/QuizController.java b/main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java similarity index 75% rename from main/src/main/java/gsp/technologies/main/user/quiz/QuizController.java rename to main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java index b74740b..987de81 100644 --- a/main/src/main/java/gsp/technologies/main/user/quiz/QuizController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.user.quiz; +package gsp.technologies.main.face.user; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam; @Controller @RequestMapping(path = "/quiz") -public class QuizController { - private static final Logger log = LoggerFactory.getLogger(QuizController.class); +public class UserQuizController { + private static final Logger log = LoggerFactory.getLogger(UserQuizController.class); @GetMapping("") public String quiz(Model model, @RequestParam(name = "accountid", required = true) String accountid) { diff --git a/main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java b/main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java deleted file mode 100644 index 5ddb5d2..0000000 --- a/main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java +++ /dev/null @@ -1,149 +0,0 @@ -package gsp.technologies.main.user.account; - -import java.util.Collection; -import java.util.stream.Collectors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -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.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; - -/** - * Контроллер формы аккаунта - * возвращает thymeleaf шаблон - */ -@Controller -@RequestMapping(path = "/account") -public class AccountFaceController { - private static final Logger log = LoggerFactory.getLogger(AccountFaceController.class); - @Autowired - private OrganizationService organizationService; - - @Autowired - private PositionService positionService; - - @Autowired - private AccountService accountService; - - @Autowired - private TargetService targetService; - - public AccountFaceController( - PositionService positionService - , OrganizationService organizationService - , AccountService accountService - , TargetService targetService - ) { - this.positionService = positionService; - this.organizationService = organizationService; - this.accountService = accountService; - this.targetService = targetService; - } - - /** - * Форма аккаунта: - * - данные аккаунта (id, organization, position) - * - список курсов аккаунта - * - * @param model - * @param accountid - * @param positionid - * @return - */ - @GetMapping("") - public String account(Model model, - @RequestParam(name = "accountid", required = false) String accountid, - @RequestParam(name = "positionid", required = false) String positionid - ) { - log.info("GET /account"); - //данные аккаунта (id, organization, position) - log.info("accountid: " + accountid); - log.info("positionid: " + positionid); - - if (accountid != null) { - log.info("accountid: " + accountid); - try{ - //передаем в модель данные аккаунта - AccountEntity account = accountService.findById(Long.valueOf(accountid)); - model.addAttribute("account", account); - - //передаем в модель перечень доступных курсов - Collection targets = targetService.findAllByPositionId(account.getPosition().getId()); - - Collection courses = targets.stream() - .map(TargetEntity::getCourse) - .distinct() - .collect(Collectors.toList()); - model.addAttribute("courses", courses); - //передаем в модель статусы прохождения курсов - - return "account"; - } catch (Exception e) { - StringBuilder msg = new StringBuilder(); - msg.append("Не удалось получить данные аккаунта: " + e.getMessage()); - log.error(msg.toString()); - model.addAttribute("error", msg.toString()); - return "error"; - } - } - - if (positionid != null) { - try{ - log.info("positionid: " + positionid); - PositionEntity position = positionService.findById(Long.valueOf(positionid)); - //обработать вход нового пользователя - AccountEntity account = AccountEntity.builder() - .position(position) - .build(); - - //сохранить в базе данных - account = accountService.save(account); - log.info("сохраняем account: " + account); - - //получить id аккаунта - String code = Code.encode(account.getId() + ""); - account.setCode(code); - //обновили аккаунт в базе данных - account = accountService.save(account); - - model.addAttribute("account", account); - - //передаем в модель перечень доступных курсов - Collection targets = targetService.findAllByPositionId(account.getPosition().getId()); - - Collection courses = targets.stream() - .map(TargetEntity::getCourse) - .distinct() - .collect(Collectors.toList()); - model.addAttribute("courses", courses); - //передаем в модель статусы прохождения курсов - - return "account"; - } catch (Exception e) { - StringBuilder msg = new StringBuilder(); - msg.append("Не удалось получить данные аккаунта: " + e.getMessage()); - log.error(msg.toString()); - model.addAttribute("error", msg.toString()); - return "error"; - } - } - //вернуть страницу ошибки - StringBuilder msg = new StringBuilder(); - msg.append("Не указаны данные для доступа к аккаунту."); - log.error(msg.toString()); - model.addAttribute("error", msg.toString()); - return "error"; - } -} diff --git a/main/src/main/resources/static/content/courses/52/main.md b/main/src/main/resources/static/content/courses/52/main.md new file mode 100644 index 0000000..65e8196 --- /dev/null +++ b/main/src/main/resources/static/content/courses/52/main.md @@ -0,0 +1,21 @@ +# Стропальщик + +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. + +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. + +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. + +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. \ No newline at end of file diff --git a/main/src/main/resources/templates/pages/reviewer/find.html b/main/src/main/resources/templates/pages/reviewer/login.html similarity index 100% rename from main/src/main/resources/templates/pages/reviewer/find.html rename to main/src/main/resources/templates/pages/reviewer/login.html diff --git a/main/src/main/resources/templates/pages/user/course.html b/main/src/main/resources/templates/pages/user/course.html index a110295..2156dc3 100644 --- a/main/src/main/resources/templates/pages/user/course.html +++ b/main/src/main/resources/templates/pages/user/course.html @@ -21,7 +21,7 @@ xmlns:th="http://www.thymeleaf.org"> -
+