Browse Source

core-face-api layers

master
esoe 4 days ago
parent
commit
9d617c951b
  1. 5
      main/src/main/java/gsp/technologies/main/api/OrganizationApiController.java
  2. 5
      main/src/main/java/gsp/technologies/main/api/PositionApiController.java
  3. 4
      main/src/main/java/gsp/technologies/main/core/account/AccountEntity.java
  4. 2
      main/src/main/java/gsp/technologies/main/core/account/AccountRepository.java
  5. 2
      main/src/main/java/gsp/technologies/main/core/account/AccountService.java
  6. 2
      main/src/main/java/gsp/technologies/main/core/course/CourseEntity.java
  7. 2
      main/src/main/java/gsp/technologies/main/core/course/CourseRepository.java
  8. 2
      main/src/main/java/gsp/technologies/main/core/course/CourseService.java
  9. 2
      main/src/main/java/gsp/technologies/main/core/organization/OrganizationEntity.java
  10. 2
      main/src/main/java/gsp/technologies/main/core/organization/OrganizationRepository.java
  11. 2
      main/src/main/java/gsp/technologies/main/core/organization/OrganizationService.java
  12. 4
      main/src/main/java/gsp/technologies/main/core/position/PositionEntity.java
  13. 2
      main/src/main/java/gsp/technologies/main/core/position/PositionRepository.java
  14. 2
      main/src/main/java/gsp/technologies/main/core/position/PositionService.java
  15. 35
      main/src/main/java/gsp/technologies/main/core/question/QuestionEntity.java
  16. 9
      main/src/main/java/gsp/technologies/main/core/question/QuestionRepository.java
  17. 27
      main/src/main/java/gsp/technologies/main/core/question/QuestionService.java
  18. 6
      main/src/main/java/gsp/technologies/main/core/target/TargetEntity.java
  19. 2
      main/src/main/java/gsp/technologies/main/core/target/TargetRepository.java
  20. 2
      main/src/main/java/gsp/technologies/main/core/target/TargetService.java
  21. 16
      main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java
  22. 6
      main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java
  23. 4
      main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java
  24. 8
      main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java
  25. 73
      main/src/main/java/gsp/technologies/main/face/supplier/SupQuestionController.java
  26. 16
      main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java
  27. 16
      main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java
  28. 6
      main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java
  29. 8
      main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java
  30. 27
      main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java
  31. 4
      main/src/main/resources/static/content/md/hello.md
  32. 27
      main/src/main/resources/templates/pages/supplier/questions.html
  33. 3
      main/src/main/resources/templates/pages/user/course.html
  34. 4
      main/src/main/resources/templates/pages/user/login.html
  35. 2
      main/src/main/resources/templates/pages/user/quiz.html
  36. 12
      main/src/main/resources/templates/shards/navi.html
  37. 65
      main/src/main/resources/templates/shards/questions.html

5
main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java → 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.Logger;
import org.slf4j.LoggerFactory; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import gsp.technologies.main.core.organization.OrganizationEntity;
import gsp.technologies.main.core.organization.OrganizationService;
@RestController @RestController
@RequestMapping(path = "/api/v1/organizations") @RequestMapping(path = "/api/v1/organizations")
public class OrganizationApiController { public class OrganizationApiController {

5
main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java → 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; 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.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import gsp.technologies.main.core.position.PositionEntity;
import gsp.technologies.main.core.position.PositionService;
@RestController @RestController
@RequestMapping(path = "/api/v1/positions") @RequestMapping(path = "/api/v1/positions")
public class PositionApiController { public class PositionApiController {

4
main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java → 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.OnDelete;
import org.hibernate.annotations.OnDeleteAction; 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.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;

2
main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java → 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

2
main/src/main/java/gsp/technologies/main/api/account/AccountService.java → 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; import org.springframework.stereotype.Service;

2
main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java → 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.Entity;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;

2
main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java → 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

2
main/src/main/java/gsp/technologies/main/api/course/CourseService.java → 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; import java.util.Collection;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java → 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.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java → 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

2
main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java → 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; import java.util.Collection;

4
main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java → 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.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.OnDeleteAction;
import gsp.technologies.main.api.organization.OrganizationEntity; import gsp.technologies.main.core.organization.OrganizationEntity;
@Data @Data
@AllArgsConstructor @AllArgsConstructor

2
main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java → 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; import java.util.Collection;

2
main/src/main/java/gsp/technologies/main/api/position/PositionService.java → 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; import java.util.Collection;

35
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;
}

9
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<QuestionEntity, Long> {
}

27
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<QuestionEntity> findAll() {
return repo.findAll();
}
public QuestionEntity save(QuestionEntity entity) {
return repo.save(entity);
}
public void delete(Long id) {
repo.deleteById(id);
}
}

6
main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java → 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.OnDelete;
import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.OnDeleteAction;
import gsp.technologies.main.api.course.CourseEntity; import gsp.technologies.main.core.course.CourseEntity;
import gsp.technologies.main.api.position.PositionEntity; import gsp.technologies.main.core.position.PositionEntity;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;

2
main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java → 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; import java.util.Collection;

2
main/src/main/java/gsp/technologies/main/api/target/TargetService.java → 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; import java.util.Collection;

16
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; 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.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;
/** /**
* Контроллер формы аккаунта * Контроллер формы аккаунта

6
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.account.AccountService; import gsp.technologies.main.core.account.AccountService;
import gsp.technologies.main.api.course.CourseEntity; import gsp.technologies.main.core.course.CourseEntity;
import gsp.technologies.main.api.course.CourseService; import gsp.technologies.main.core.course.CourseService;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;

4
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.organization.OrganizationEntity; import gsp.technologies.main.core.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService; import gsp.technologies.main.core.organization.OrganizationService;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;

8
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.organization.OrganizationEntity; import gsp.technologies.main.core.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService; import gsp.technologies.main.core.organization.OrganizationService;
import gsp.technologies.main.api.position.PositionEntity; import gsp.technologies.main.core.position.PositionEntity;
import gsp.technologies.main.api.position.PositionService; import gsp.technologies.main.core.position.PositionService;
@Controller @Controller
@RequestMapping(path = "/supplier") @RequestMapping(path = "/supplier")

73
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";
}
}

16
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.course.CourseEntity; import gsp.technologies.main.core.course.CourseEntity;
import gsp.technologies.main.api.course.CourseService; import gsp.technologies.main.core.course.CourseService;
import gsp.technologies.main.api.organization.OrganizationEntity; import gsp.technologies.main.core.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService; import gsp.technologies.main.core.organization.OrganizationService;
import gsp.technologies.main.api.position.PositionEntity; import gsp.technologies.main.core.position.PositionEntity;
import gsp.technologies.main.api.position.PositionService; import gsp.technologies.main.core.position.PositionService;
import gsp.technologies.main.api.target.TargetEntity; import gsp.technologies.main.core.target.TargetEntity;
import gsp.technologies.main.api.target.TargetService; import gsp.technologies.main.core.target.TargetService;
@Controller @Controller
@RequestMapping(path = "/supplier") @RequestMapping(path = "/supplier")

16
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; 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.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;
/** /**
* Контроллер формы аккаунта * Контроллер формы аккаунта

6
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.api.account.AccountService; import gsp.technologies.main.core.account.AccountService;
import gsp.technologies.main.api.course.CourseEntity; import gsp.technologies.main.core.course.CourseEntity;
import gsp.technologies.main.api.course.CourseService; import gsp.technologies.main.core.course.CourseService;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;

8
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.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import gsp.technologies.main.api.organization.OrganizationEntity; import gsp.technologies.main.core.organization.OrganizationEntity;
import gsp.technologies.main.api.organization.OrganizationService; import gsp.technologies.main.core.organization.OrganizationService;
import gsp.technologies.main.api.position.PositionEntity; import gsp.technologies.main.core.position.PositionEntity;
import gsp.technologies.main.api.position.PositionService; import gsp.technologies.main.core.position.PositionService;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;

27
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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import gsp.technologies.main.core.account.AccountService;
@Controller @Controller
@RequestMapping(path = "/quiz") @RequestMapping(path = "/user")
public class UserQuizController { public class UserQuizController {
private static final Logger log = LoggerFactory.getLogger(UserQuizController.class); 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";
} }
} }

4
main/src/main/resources/static/content/md/hello.md

@ -1,2 +1,4 @@
# Пояснения для пользователей # Учебрый центр ООО "ГСП-Технологии"
## Допуск на строительную площадку
- Запомни номер своей учетной записи!!! - Запомни номер своей учетной записи!!!

27
main/src/main/resources/templates/pages/supplier/questions.html

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>exam-questions</title>
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>
</head>
<header>
<!-- Кнопки навигации -->
<div th:insert="~{shards/navi :: supplier}"></div>
</header>
<body>
<h1>Вопросы</h1>
<!-- Давление нового вопроса -->
<div th:insert="~{shards/questions :: create(courses=${courses})}"></div>
<!-- Перечень вопросов -->
<div th:insert="~{shards/questions :: list(questions=${questions})}"></div>
</body>
<footer>
<div th:insert="~{shards/footer :: copy}"></div>
</footer>
</html>

3
main/src/main/resources/templates/pages/user/course.html

@ -22,7 +22,8 @@ xmlns:th="http://www.thymeleaf.org">
<body> <body>
<!-- курс --> <!-- курс -->
<div th:insert="~{shards/courses :: content(id=${courseid})}"></div> <div th:insert="~{shards/courses :: content(id=${courseid})}"></div>
<!-- <div th:insert="~{fragments/controls :: gotoQuiz(accountid=${account.id})}"></div> --> <!-- -->
<div th:insert="~{shards/navi :: goto-quiz(accountid=${account.id}, courseid=${courseid})}"></div>
</body> </body>
<footer> <footer>
<!-- Выход из аккаунта, обновление сессии --> <!-- Выход из аккаунта, обновление сессии -->

4
main/src/main/resources/templates/pages/user/login.html

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

2
main/src/main/resources/templates/pages/user/quiz.html

@ -21,7 +21,7 @@ xmlns:th="http://www.thymeleaf.org">
</header> </header>
<body> <body>
<!-- опрос --> <!-- опрос -->
<div th:insert="~{shards/quizes :: main}"></div> <!-- <div th:insert="~{shards/quizes :: main}"></div> -->
</body> </body>
<footer> <footer>
<div th:insert="~{shards/footer :: copy}"></div> <div th:insert="~{shards/footer :: copy}"></div>

12
main/src/main/resources/templates/shards/navi.html

@ -5,7 +5,7 @@
<!-- регистрация --> <!-- регистрация -->
<div th:fragment="exam(organizations)"> <div th:fragment="exam(organizations)">
<hr> <hr>
<p>Укажите данные для создания нового задания</p> <p><b>Первичный вход.</b> Укажите данные для создания нового задания</p>
<!-- Выбираем наименование компании, <!-- Выбираем наименование компании,
для формирвоания соответствующего списка должностей --> для формирвоания соответствующего списка должностей -->
@ -29,10 +29,12 @@
<!-- авторизация --> <!-- авторизация -->
<div th:fragment="auth"> <div th:fragment="auth">
<hr>
<!-- Отправляем запрос с параметром code <!-- Отправляем запрос с параметром code
открываем существующую попытку --> открываем существующую попытку -->
<form th:action="@{/reviewer/account}" th:method="get"> <form th:action="@{/reviewer/account}" th:method="get">
<label for="code">Если Вам нужно продолжить прохождение уже начатого курса - введите ID своего аккаунта: </label> <label for="code"><b>Повторный вход.</b> Введите код: </label>
<br>
<input type="text" id="code" name="accountid"> <input type="text" id="code" name="accountid">
<input type="submit" value="Проверить код"> <input type="submit" value="Проверить код">
</form> </form>
@ -47,10 +49,11 @@
</div> </div>
<!-- переход к опросу --> <!-- переход к опросу -->
<div th:fragment="gotoQuiz(accountid)"> <div th:fragment="goto-quiz(accountid, courseid)">
<hr> <hr>
<form th:action="@{/quiz}" th:method="get"> <form th:action="@{/user/quiz}" th:method="get">
<input type="hidden" th:value="${accountid}" th:name="accountid"/> <input type="hidden" th:value="${accountid}" th:name="accountid"/>
<input type="hidden" th:value="${courseid}" th:name="courseid"/>
<input type="submit" value="ПЕРЕЙТИ К ОПРОСУ"/> <input type="submit" value="ПЕРЕЙТИ К ОПРОСУ"/>
</form> </form>
</div> </div>
@ -61,6 +64,7 @@
<a th:href="@{/supplier/organizations}">Организации</a> <a th:href="@{/supplier/organizations}">Организации</a>
<a th:href="@{/supplier/positions}">Должности</a> <a th:href="@{/supplier/positions}">Должности</a>
<a th:href="@{/supplier/courses}">Курсы</a> <a th:href="@{/supplier/courses}">Курсы</a>
<a th:href="@{/supplier/questions}">Вопросы</a>
</div> </div>
</html> </html>

65
main/src/main/resources/templates/shards/questions.html

@ -0,0 +1,65 @@
<!-- Коллекция фрагментов для построения страницы организаций -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<!-- Перечень организаций -->
<div th:fragment="list(questions)">
<hr>
<h2>Список вопросов:</h2>
<table>
<thead>
<tr>
<th>Название курса</th>
<th>Содержание вопроса</th>
<th>Действия</th>
<th>Ответы</th>
</tr>
</thead>
<tbody>
<tr th:each="question : ${questions}">
<td th:text="${question.course.name}"></td>
<td th:text="${question.body}"></td>
<td>
<a th:href="@{/supplier/questions/{id}/delete(id=${question.id})}">Удалить вопрос</a>
<a th:href="@{/supplier/answers/{id}(id=${question.id})}">Добавить ответ</a>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Добавление нового вопроса -->
<div th:fragment="create(courses)">
<hr>
<h2>Добавление нового вопроса:</h2>
<form th:action="@{/supplier/questions}" th:method="post">
<!-- селект курса -->
<label for="course-select">Выберите курс</label>
<select id="course-select" name="courseid">
<option value="0" disabled selected>курс</option>
<option th:each="option : ${courses}" th:value="${option.id}" th:text="${option.name}"></option>
</select>
<br>
<label for="questions-body">Содержание вопроса: </label>
<br>
<textarea rows="5" cols="33" id="question-body" name="question-body" placeholder="введите вопрос тут..." required></textarea>
<br>
<input type="submit" value="Добавить">
</form>
</div>
<!-- Редактирование организации -->
<!-- <div th:fragment="edit(organization)">
<hr>
<h2>Редактирование организации: <span th:text="${organization.name}"></span></h2>
<form th:action="@{/supplier/organizations/{id}/edit(id=${organization.id})}" th:method="post">
<label for="name" >Название организации: </label>
<input type="text" th:name="name" th:value="${organization.name}">
<br>
<input type="submit" value="Сохранить">
</form>
</div> -->
</body>
</html>
Loading…
Cancel
Save