From 9d617c951bbcb3d67bb2cb7584550849b670852f Mon Sep 17 00:00:00 2001 From: esoe Date: Tue, 19 Nov 2024 09:13:56 +0300 Subject: [PATCH] core-face-api layers --- .../OrganizationApiController.java | 5 +- .../{position => }/PositionApiController.java | 5 +- .../{api => core}/account/AccountEntity.java | 4 +- .../account/AccountRepository.java | 2 +- .../{api => core}/account/AccountService.java | 2 +- .../{api => core}/course/CourseEntity.java | 2 +- .../course/CourseRepository.java | 2 +- .../{api => core}/course/CourseService.java | 2 +- .../organization/OrganizationEntity.java | 2 +- .../organization/OrganizationRepository.java | 2 +- .../organization/OrganizationService.java | 2 +- .../position/PositionEntity.java | 4 +- .../position/PositionRepository.java | 2 +- .../position/PositionService.java | 2 +- .../main/core/question/QuestionEntity.java | 35 +++++++++ .../core/question/QuestionRepository.java | 9 +++ .../main/core/question/QuestionService.java | 27 +++++++ .../{api => core}/target/TargetEntity.java | 6 +- .../target/TargetRepository.java | 2 +- .../{api => core}/target/TargetService.java | 2 +- .../main/face/reviewer/ReviewController.java | 16 ++-- .../face/supplier/SupCourseController.java | 6 +- .../supplier/SupOrganizationController.java | 4 +- .../face/supplier/SupPositionController.java | 8 +- .../face/supplier/SupQuestionController.java | 73 +++++++++++++++++++ .../supplier/SupTargetFaceController.java | 16 ++-- .../main/face/user/UserAccountController.java | 16 ++-- .../main/face/user/UserCourseController.java | 6 +- .../main/face/user/UserLoginController.java | 8 +- .../main/face/user/UserQuizController.java | 27 +++++-- .../main/resources/static/content/md/hello.md | 4 +- .../templates/pages/supplier/questions.html | 27 +++++++ .../templates/pages/user/course.html | 3 +- .../resources/templates/pages/user/login.html | 4 +- .../resources/templates/pages/user/quiz.html | 2 +- .../main/resources/templates/shards/navi.html | 12 ++- .../resources/templates/shards/questions.html | 65 +++++++++++++++++ 37 files changed, 341 insertions(+), 75 deletions(-) rename main/src/main/java/gsp/technologies/main/api/{organization => }/OrganizationApiController.java (88%) rename main/src/main/java/gsp/technologies/main/api/{position => }/PositionApiController.java (93%) rename main/src/main/java/gsp/technologies/main/{api => core}/account/AccountEntity.java (86%) rename main/src/main/java/gsp/technologies/main/{api => core}/account/AccountRepository.java (79%) rename main/src/main/java/gsp/technologies/main/{api => core}/account/AccountService.java (86%) rename main/src/main/java/gsp/technologies/main/{api => core}/course/CourseEntity.java (87%) rename main/src/main/java/gsp/technologies/main/{api => core}/course/CourseRepository.java (79%) rename main/src/main/java/gsp/technologies/main/{api => core}/course/CourseService.java (88%) rename main/src/main/java/gsp/technologies/main/{api => core}/organization/OrganizationEntity.java (88%) rename main/src/main/java/gsp/technologies/main/{api => core}/organization/OrganizationRepository.java (79%) rename main/src/main/java/gsp/technologies/main/{api => core}/organization/OrganizationService.java (89%) rename main/src/main/java/gsp/technologies/main/{api => core}/position/PositionEntity.java (86%) rename main/src/main/java/gsp/technologies/main/{api => core}/position/PositionRepository.java (88%) rename main/src/main/java/gsp/technologies/main/{api => core}/position/PositionService.java (91%) create mode 100644 main/src/main/java/gsp/technologies/main/core/question/QuestionEntity.java create mode 100644 main/src/main/java/gsp/technologies/main/core/question/QuestionRepository.java create mode 100644 main/src/main/java/gsp/technologies/main/core/question/QuestionService.java rename main/src/main/java/gsp/technologies/main/{api => core}/target/TargetEntity.java (86%) rename main/src/main/java/gsp/technologies/main/{api => core}/target/TargetRepository.java (84%) rename main/src/main/java/gsp/technologies/main/{api => core}/target/TargetService.java (88%) create mode 100644 main/src/main/java/gsp/technologies/main/face/supplier/SupQuestionController.java create mode 100644 main/src/main/resources/templates/pages/supplier/questions.html create mode 100644 main/src/main/resources/templates/shards/questions.html diff --git a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java b/main/src/main/java/gsp/technologies/main/api/OrganizationApiController.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java rename to main/src/main/java/gsp/technologies/main/api/OrganizationApiController.java index aba4da2..64df2f9 100644 --- a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java +++ b/main/src/main/java/gsp/technologies/main/api/OrganizationApiController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.organization; +package gsp.technologies.main.api; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import gsp.technologies.main.core.organization.OrganizationEntity; +import gsp.technologies.main.core.organization.OrganizationService; + @RestController @RequestMapping(path = "/api/v1/organizations") public class OrganizationApiController { diff --git a/main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java b/main/src/main/java/gsp/technologies/main/api/PositionApiController.java similarity index 93% rename from main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java rename to main/src/main/java/gsp/technologies/main/api/PositionApiController.java index a0c9830..74519f3 100644 --- a/main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java +++ b/main/src/main/java/gsp/technologies/main/api/PositionApiController.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.position; +package gsp.technologies.main.api; import java.util.Collection; @@ -20,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import gsp.technologies.main.core.position.PositionEntity; +import gsp.technologies.main.core.position.PositionService; + @RestController @RequestMapping(path = "/api/v1/positions") public class PositionApiController { diff --git a/main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java b/main/src/main/java/gsp/technologies/main/core/account/AccountEntity.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java rename to main/src/main/java/gsp/technologies/main/core/account/AccountEntity.java index 1cf0396..138f3b8 100644 --- a/main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java +++ b/main/src/main/java/gsp/technologies/main/core/account/AccountEntity.java @@ -1,9 +1,9 @@ -package gsp.technologies.main.api.account; +package gsp.technologies.main.core.account; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; -import gsp.technologies.main.api.position.PositionEntity; +import gsp.technologies.main.core.position.PositionEntity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; diff --git a/main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java b/main/src/main/java/gsp/technologies/main/core/account/AccountRepository.java similarity index 79% rename from main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java rename to main/src/main/java/gsp/technologies/main/core/account/AccountRepository.java index f0b6fbc..edd3a0f 100644 --- a/main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java +++ b/main/src/main/java/gsp/technologies/main/core/account/AccountRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.account; +package gsp.technologies.main.core.account; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/main/src/main/java/gsp/technologies/main/api/account/AccountService.java b/main/src/main/java/gsp/technologies/main/core/account/AccountService.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/api/account/AccountService.java rename to main/src/main/java/gsp/technologies/main/core/account/AccountService.java index 87ec70f..3a0614b 100644 --- a/main/src/main/java/gsp/technologies/main/api/account/AccountService.java +++ b/main/src/main/java/gsp/technologies/main/core/account/AccountService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.account; +package gsp.technologies.main.core.account; import org.springframework.stereotype.Service; diff --git a/main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java b/main/src/main/java/gsp/technologies/main/core/course/CourseEntity.java similarity index 87% rename from main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java rename to main/src/main/java/gsp/technologies/main/core/course/CourseEntity.java index 90c9779..80790b3 100644 --- a/main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java +++ b/main/src/main/java/gsp/technologies/main/core/course/CourseEntity.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.course; +package gsp.technologies.main.core.course; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java b/main/src/main/java/gsp/technologies/main/core/course/CourseRepository.java similarity index 79% rename from main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java rename to main/src/main/java/gsp/technologies/main/core/course/CourseRepository.java index 5eb4acf..dcf5b42 100644 --- a/main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java +++ b/main/src/main/java/gsp/technologies/main/core/course/CourseRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.course; +package gsp.technologies.main.core.course; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/main/src/main/java/gsp/technologies/main/api/course/CourseService.java b/main/src/main/java/gsp/technologies/main/core/course/CourseService.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/api/course/CourseService.java rename to main/src/main/java/gsp/technologies/main/core/course/CourseService.java index f5bd6e2..a973b8c 100644 --- a/main/src/main/java/gsp/technologies/main/api/course/CourseService.java +++ b/main/src/main/java/gsp/technologies/main/core/course/CourseService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.course; +package gsp.technologies.main.core.course; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java b/main/src/main/java/gsp/technologies/main/core/organization/OrganizationEntity.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java rename to main/src/main/java/gsp/technologies/main/core/organization/OrganizationEntity.java index 092b641..859e90c 100644 --- a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java +++ b/main/src/main/java/gsp/technologies/main/core/organization/OrganizationEntity.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.organization; +package gsp.technologies.main.core.organization; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java b/main/src/main/java/gsp/technologies/main/core/organization/OrganizationRepository.java similarity index 79% rename from main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java rename to main/src/main/java/gsp/technologies/main/core/organization/OrganizationRepository.java index d01436c..43cead5 100644 --- a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java +++ b/main/src/main/java/gsp/technologies/main/core/organization/OrganizationRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.organization; +package gsp.technologies.main.core.organization; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java b/main/src/main/java/gsp/technologies/main/core/organization/OrganizationService.java similarity index 89% rename from main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java rename to main/src/main/java/gsp/technologies/main/core/organization/OrganizationService.java index 111a51c..43e0e8f 100644 --- a/main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java +++ b/main/src/main/java/gsp/technologies/main/core/organization/OrganizationService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.organization; +package gsp.technologies.main.core.organization; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java b/main/src/main/java/gsp/technologies/main/core/position/PositionEntity.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java rename to main/src/main/java/gsp/technologies/main/core/position/PositionEntity.java index c92863b..5643e82 100644 --- a/main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java +++ b/main/src/main/java/gsp/technologies/main/core/position/PositionEntity.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.position; +package gsp.technologies.main.core.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.api.organization.OrganizationEntity; +import gsp.technologies.main.core.organization.OrganizationEntity; @Data @AllArgsConstructor diff --git a/main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java b/main/src/main/java/gsp/technologies/main/core/position/PositionRepository.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java rename to main/src/main/java/gsp/technologies/main/core/position/PositionRepository.java index f087f78..2aa4542 100644 --- a/main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java +++ b/main/src/main/java/gsp/technologies/main/core/position/PositionRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.position; +package gsp.technologies.main.core.position; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/api/position/PositionService.java b/main/src/main/java/gsp/technologies/main/core/position/PositionService.java similarity index 91% rename from main/src/main/java/gsp/technologies/main/api/position/PositionService.java rename to main/src/main/java/gsp/technologies/main/core/position/PositionService.java index 7c7e8ae..a7ee4ff 100644 --- a/main/src/main/java/gsp/technologies/main/api/position/PositionService.java +++ b/main/src/main/java/gsp/technologies/main/core/position/PositionService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.position; +package gsp.technologies.main.core.position; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/core/question/QuestionEntity.java b/main/src/main/java/gsp/technologies/main/core/question/QuestionEntity.java new file mode 100644 index 0000000..917ab56 --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/core/question/QuestionEntity.java @@ -0,0 +1,35 @@ +package gsp.technologies.main.core.question; + +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +import gsp.technologies.main.core.course.CourseEntity; +import gsp.technologies.main.core.organization.OrganizationEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity +public class QuestionEntity { + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + private Long id; + private String body; + + @ManyToOne(fetch = FetchType.EAGER, optional = false) + @JoinColumn(name = "course", referencedColumnName = "id") + @OnDelete(action = OnDeleteAction.CASCADE) + private CourseEntity course; +} diff --git a/main/src/main/java/gsp/technologies/main/core/question/QuestionRepository.java b/main/src/main/java/gsp/technologies/main/core/question/QuestionRepository.java new file mode 100644 index 0000000..c74ff9f --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/core/question/QuestionRepository.java @@ -0,0 +1,9 @@ +package gsp.technologies.main.core.question; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface QuestionRepository extends JpaRepository { + +} diff --git a/main/src/main/java/gsp/technologies/main/core/question/QuestionService.java b/main/src/main/java/gsp/technologies/main/core/question/QuestionService.java new file mode 100644 index 0000000..9386a8d --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/core/question/QuestionService.java @@ -0,0 +1,27 @@ +package gsp.technologies.main.core.question; + +import java.util.Collection; + +import org.springframework.stereotype.Service; + +@Service +public class QuestionService { + private final QuestionRepository repo; + + public QuestionService(QuestionRepository repo) { + this.repo = repo; + } + + public Collection findAll() { + return repo.findAll(); + } + + public QuestionEntity save(QuestionEntity entity) { + return repo.save(entity); + } + + public void delete(Long id) { + repo.deleteById(id); + } + +} diff --git a/main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java b/main/src/main/java/gsp/technologies/main/core/target/TargetEntity.java similarity index 86% rename from main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java rename to main/src/main/java/gsp/technologies/main/core/target/TargetEntity.java index 7e62455..1d1f7f0 100644 --- a/main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java +++ b/main/src/main/java/gsp/technologies/main/core/target/TargetEntity.java @@ -1,10 +1,10 @@ -package gsp.technologies.main.api.target; +package gsp.technologies.main.core.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.core.course.CourseEntity; +import gsp.technologies.main.core.position.PositionEntity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; diff --git a/main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java b/main/src/main/java/gsp/technologies/main/core/target/TargetRepository.java similarity index 84% rename from main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java rename to main/src/main/java/gsp/technologies/main/core/target/TargetRepository.java index e118733..3899ece 100644 --- a/main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java +++ b/main/src/main/java/gsp/technologies/main/core/target/TargetRepository.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.target; +package gsp.technologies.main.core.target; import java.util.Collection; diff --git a/main/src/main/java/gsp/technologies/main/api/target/TargetService.java b/main/src/main/java/gsp/technologies/main/core/target/TargetService.java similarity index 88% rename from main/src/main/java/gsp/technologies/main/api/target/TargetService.java rename to main/src/main/java/gsp/technologies/main/core/target/TargetService.java index 1858e58..0f0e5e5 100644 --- a/main/src/main/java/gsp/technologies/main/api/target/TargetService.java +++ b/main/src/main/java/gsp/technologies/main/core/target/TargetService.java @@ -1,4 +1,4 @@ -package gsp.technologies.main.api.target; +package gsp.technologies.main.core.target; import java.util.Collection; 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 index 2a9ac9e..a6b22d0 100644 --- a/main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java +++ b/main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java @@ -12,15 +12,15 @@ 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; +import gsp.technologies.main.core.account.AccountEntity; +import gsp.technologies.main.core.account.AccountService; +import gsp.technologies.main.core.course.CourseEntity; +import gsp.technologies.main.core.organization.OrganizationService; +import gsp.technologies.main.core.position.PositionEntity; +import gsp.technologies.main.core.position.PositionService; +import gsp.technologies.main.core.target.TargetEntity; +import gsp.technologies.main.core.target.TargetService; /** * Контроллер формы аккаунта diff --git a/main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java index c618d45..b2b98a9 100644 --- a/main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java @@ -11,9 +11,9 @@ 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 gsp.technologies.main.core.account.AccountService; +import gsp.technologies.main.core.course.CourseEntity; +import gsp.technologies.main.core.course.CourseService; import org.springframework.web.bind.annotation.PostMapping; diff --git a/main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java index ae91f30..18d7ea3 100644 --- a/main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java @@ -13,8 +13,8 @@ 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 gsp.technologies.main.core.organization.OrganizationEntity; +import gsp.technologies.main.core.organization.OrganizationService; import org.springframework.web.bind.annotation.PostMapping; diff --git a/main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java index d4c3274..627bf4a 100644 --- a/main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java @@ -16,10 +16,10 @@ 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.api.position.PositionEntity; -import gsp.technologies.main.api.position.PositionService; +import gsp.technologies.main.core.organization.OrganizationEntity; +import gsp.technologies.main.core.organization.OrganizationService; +import gsp.technologies.main.core.position.PositionEntity; +import gsp.technologies.main.core.position.PositionService; @Controller @RequestMapping(path = "/supplier") diff --git a/main/src/main/java/gsp/technologies/main/face/supplier/SupQuestionController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupQuestionController.java new file mode 100644 index 0000000..cb763dc --- /dev/null +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupQuestionController.java @@ -0,0 +1,73 @@ +package gsp.technologies.main.face.supplier; + +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.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import gsp.technologies.main.core.course.CourseService; +import gsp.technologies.main.core.question.QuestionEntity; +import gsp.technologies.main.core.question.QuestionService; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +@Controller +@RequestMapping(path = "/supplier") +public class SupQuestionController { + private static final Logger log = LoggerFactory.getLogger(SupQuestionController.class); + + @Autowired + private QuestionService questionService; + + @Autowired + private CourseService courseService; + + public SupQuestionController(QuestionService questionService, CourseService courseService) { + this.questionService = questionService; + this.courseService = courseService; + } + + @GetMapping("/questions") + public String questions(Model model) { + log.info("GET /supplier/questions"); + + //добавляем в модель перечень курсов + model.addAttribute("courses", courseService.findAll()); + + //добавляем в модель список вопросов + model.addAttribute("questions", questionService.findAll()); + + return "pages/supplier/questions"; + } + + @PostMapping("/questions") + public String createQuestion( + @RequestParam(name = "question-body", required = true) String body, + @RequestParam(name = "courseid", required = true) String courseid + ) { + log.info("POST /supplier/questions"); + + QuestionEntity entity = QuestionEntity.builder() + .body(body) + .course(courseService.findById(Long.parseLong(courseid))) + .build(); + + questionService.save(entity); + + return "redirect:/supplier/questions"; + } + + @GetMapping("/questions/{id}/delete") + public String deleteQuestion(@PathVariable Long id) { + log.info("GET /supplier/questions/{id}/delete"); + questionService.delete(id); + return "redirect:/supplier/questions"; + } + + +} diff --git a/main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java b/main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java index 2c8d573..1f18459 100644 --- a/main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java +++ b/main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java @@ -12,14 +12,14 @@ 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.api.target.TargetEntity; -import gsp.technologies.main.api.target.TargetService; +import gsp.technologies.main.core.course.CourseEntity; +import gsp.technologies.main.core.course.CourseService; +import gsp.technologies.main.core.organization.OrganizationEntity; +import gsp.technologies.main.core.organization.OrganizationService; +import gsp.technologies.main.core.position.PositionEntity; +import gsp.technologies.main.core.position.PositionService; +import gsp.technologies.main.core.target.TargetEntity; +import gsp.technologies.main.core.target.TargetService; @Controller @RequestMapping(path = "/supplier") 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 index c026495..5e56b46 100644 --- a/main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java @@ -12,15 +12,15 @@ 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; +import gsp.technologies.main.core.account.AccountEntity; +import gsp.technologies.main.core.account.AccountService; +import gsp.technologies.main.core.course.CourseEntity; +import gsp.technologies.main.core.organization.OrganizationService; +import gsp.technologies.main.core.position.PositionEntity; +import gsp.technologies.main.core.position.PositionService; +import gsp.technologies.main.core.target.TargetEntity; +import gsp.technologies.main.core.target.TargetService; /** * Контроллер формы аккаунта 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 index d097b50..cbd1791 100644 --- a/main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java @@ -11,9 +11,9 @@ 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 gsp.technologies.main.core.account.AccountService; +import gsp.technologies.main.core.course.CourseEntity; +import gsp.technologies.main.core.course.CourseService; import org.springframework.web.bind.annotation.PostMapping; diff --git a/main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java b/main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java index 2de28bb..80e9f6a 100644 --- a/main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java @@ -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.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.core.organization.OrganizationEntity; +import gsp.technologies.main.core.organization.OrganizationService; +import gsp.technologies.main.core.position.PositionEntity; +import gsp.technologies.main.core.position.PositionService; import org.springframework.web.bind.annotation.GetMapping; diff --git a/main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java b/main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java index 987de81..e4e3d4a 100644 --- a/main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java +++ b/main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java @@ -2,22 +2,39 @@ package gsp.technologies.main.face.user; 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.core.account.AccountService; + @Controller -@RequestMapping(path = "/quiz") +@RequestMapping(path = "/user") public class UserQuizController { private static final Logger log = LoggerFactory.getLogger(UserQuizController.class); + @Autowired + private AccountService accountService; + + public UserQuizController(AccountService accountService) { + this.accountService = accountService; + } + + @GetMapping("/quiz") + public String quiz(Model model, + @RequestParam(name = "accountid", required = true) String accountid, + @RequestParam(name = "courseid", required = true) String courseid) { + log.info("GET /user/quiz"); + + log.info("accountid: " + accountid); + log.info("courseid: " + courseid); + + model.addAttribute("account", accountService.findById(Long.valueOf(accountid))); - @GetMapping("") - public String quiz(Model model, @RequestParam(name = "accountid", required = true) String accountid) { - log.info("GET /quiz"); - return "quiz"; + return "pages/user/quiz"; } } diff --git a/main/src/main/resources/static/content/md/hello.md b/main/src/main/resources/static/content/md/hello.md index 82425ef..dc327c4 100644 --- a/main/src/main/resources/static/content/md/hello.md +++ b/main/src/main/resources/static/content/md/hello.md @@ -1,2 +1,4 @@ -# Пояснения для пользователей +# Учебрый центр ООО "ГСП-Технологии" +## Допуск на строительную площадку + - Запомни номер своей учетной записи!!! \ No newline at end of file diff --git a/main/src/main/resources/templates/pages/supplier/questions.html b/main/src/main/resources/templates/pages/supplier/questions.html new file mode 100644 index 0000000..2ea322a --- /dev/null +++ b/main/src/main/resources/templates/pages/supplier/questions.html @@ -0,0 +1,27 @@ + + + + + + exam-questions + + + +
+ +
+
+ + +

Вопросы

+ +
+ +
+ + +
+
+
+ \ No newline at end of file diff --git a/main/src/main/resources/templates/pages/user/course.html b/main/src/main/resources/templates/pages/user/course.html index 2156dc3..5b39fba 100644 --- a/main/src/main/resources/templates/pages/user/course.html +++ b/main/src/main/resources/templates/pages/user/course.html @@ -22,7 +22,8 @@ xmlns:th="http://www.thymeleaf.org">
- + +