Browse Source

refactor

master
esoe 7 days ago
parent
commit
007d71cd38
  1. 4
      main/src/main/java/gsp/technologies/main/api/account/AccountEntity.java
  2. 2
      main/src/main/java/gsp/technologies/main/api/account/AccountRepository.java
  3. 2
      main/src/main/java/gsp/technologies/main/api/account/AccountService.java
  4. 2
      main/src/main/java/gsp/technologies/main/api/course/CourseEntity.java
  5. 2
      main/src/main/java/gsp/technologies/main/api/course/CourseRepository.java
  6. 2
      main/src/main/java/gsp/technologies/main/api/course/CourseService.java
  7. 2
      main/src/main/java/gsp/technologies/main/api/organization/OrganizationApiController.java
  8. 2
      main/src/main/java/gsp/technologies/main/api/organization/OrganizationEntity.java
  9. 2
      main/src/main/java/gsp/technologies/main/api/organization/OrganizationRepository.java
  10. 2
      main/src/main/java/gsp/technologies/main/api/organization/OrganizationService.java
  11. 10
      main/src/main/java/gsp/technologies/main/api/position/PositionApiController.java
  12. 4
      main/src/main/java/gsp/technologies/main/api/position/PositionEntity.java
  13. 2
      main/src/main/java/gsp/technologies/main/api/position/PositionRepository.java
  14. 2
      main/src/main/java/gsp/technologies/main/api/position/PositionService.java
  15. 6
      main/src/main/java/gsp/technologies/main/api/target/TargetEntity.java
  16. 2
      main/src/main/java/gsp/technologies/main/api/target/TargetRepository.java
  17. 5
      main/src/main/java/gsp/technologies/main/api/target/TargetService.java
  18. 104
      main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java
  19. 47
      main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java
  20. 42
      main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java
  21. 30
      main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java
  22. 37
      main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java
  23. 114
      main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java
  24. 90
      main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java
  25. 18
      main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java
  26. 6
      main/src/main/java/gsp/technologies/main/face/user/UserLogoutController.java
  27. 6
      main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java
  28. 149
      main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java
  29. 21
      main/src/main/resources/static/content/courses/52/main.md
  30. 0
      main/src/main/resources/templates/pages/reviewer/login.html
  31. 2
      main/src/main/resources/templates/pages/user/course.html
  32. 6
      main/src/main/resources/templates/shards/accounts.html
  33. 6
      main/src/main/resources/templates/shards/courses.html
  34. 4
      main/src/main/resources/templates/shards/navi.html
  35. 12
      main/src/main/resources/templates/shards/organizations.html
  36. 14
      main/src/main/resources/templates/shards/positions.html
  37. 111
      main/src/main/resources/templates/shards/targets.html

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

@ -1,9 +1,9 @@ @@ -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;

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

@ -1,4 +1,4 @@ @@ -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;

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

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

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

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

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

@ -1,4 +1,4 @@ @@ -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;

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

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

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

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

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

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

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

@ -1,4 +1,4 @@ @@ -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;

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

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

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

@ -1,4 +1,4 @@ @@ -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 { @@ -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<PositionEntity> page = positionService.findByOrganizationId(of, id);
return new ResponseEntity<>(page, HttpStatus.OK);
// return new ResponseEntity<PagedModel<EntityModel<PositionEntity>>>(assembler.toModel(page), HttpStatus.OK);
@ -71,11 +71,11 @@ public class PositionApiController { @@ -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);

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

@ -1,4 +1,4 @@ @@ -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; @@ -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

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

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

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

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

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

@ -1,10 +1,10 @@ @@ -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;

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

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

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

@ -1,12 +1,9 @@ @@ -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;

104
main/src/main/java/gsp/technologies/main/face/reviewer/ReviewController.java

@ -0,0 +1,104 @@ @@ -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<TargetEntity> targets = targetService.findAllByPositionId(account.getPosition().getId());
Collection<CourseEntity> 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";
}
}
}

47
main/src/main/java/gsp/technologies/main/user/course/CourseFaceController.java → main/src/main/java/gsp/technologies/main/face/supplier/SupCourseController.java

@ -1,4 +1,4 @@ @@ -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; @@ -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 { @@ -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 <CourseEntity> 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";
}
}

42
main/src/main/java/gsp/technologies/main/supplier/organization/OrganizationFaceController.java → main/src/main/java/gsp/technologies/main/face/supplier/SupOrganizationController.java

@ -1,4 +1,4 @@ @@ -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; @@ -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 { @@ -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<OrganizationEntity> organizations = service.findAll();
// сортируем по названию
@ -42,54 +46,54 @@ public class OrganizationFaceController { @@ -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";
}

30
main/src/main/java/gsp/technologies/main/supplier/position/PositionFaceController.java → main/src/main/java/gsp/technologies/main/face/supplier/SupPositionController.java

@ -1,4 +1,4 @@ @@ -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; @@ -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 { @@ -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 { @@ -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<OrganizationEntity> organizations = organizationService.findAll()
@ -51,29 +53,29 @@ public class PositionFaceController { @@ -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<PositionEntity> 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";
}
}

37
main/src/main/java/gsp/technologies/main/supplier/target/TargetFaceController.java → main/src/main/java/gsp/technologies/main/face/supplier/SupTargetFaceController.java

@ -1,7 +1,6 @@ @@ -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; @@ -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 { @@ -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 <OrganizationEntity> organizations = organizationService.findAll();
model.addAttribute("organizations", organizations);
@ -63,17 +64,17 @@ public class TargetFaceController { @@ -63,17 +64,17 @@ public class TargetFaceController {
Collection <TargetEntity> 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 { @@ -82,7 +83,7 @@ public class TargetFaceController {
.build();
targetService.save(entity);
return "redirect:/targets";
return "redirect:/supplier/targets";
}

114
main/src/main/java/gsp/technologies/main/face/user/UserAccountController.java

@ -0,0 +1,114 @@ @@ -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<TargetEntity> targets = targetService.findAllByPositionId(account.getPosition().getId());
Collection<CourseEntity> 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";
}
}
}

90
main/src/main/java/gsp/technologies/main/face/user/UserCourseController.java

@ -0,0 +1,90 @@ @@ -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 <CourseEntity> 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";
}
}

18
main/src/main/java/gsp/technologies/main/user/login/LoginController.java → main/src/main/java/gsp/technologies/main/face/user/UserLoginController.java

@ -1,4 +1,4 @@ @@ -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; @@ -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; @@ -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<OrganizationEntity> organizations = organizationService.findAll();

6
main/src/main/java/gsp/technologies/main/user/logout/LogoutController.java → main/src/main/java/gsp/technologies/main/face/user/UserLogoutController.java

@ -1,4 +1,4 @@ @@ -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; @@ -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() {

6
main/src/main/java/gsp/technologies/main/user/quiz/QuizController.java → main/src/main/java/gsp/technologies/main/face/user/UserQuizController.java

@ -1,4 +1,4 @@ @@ -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; @@ -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) {

149
main/src/main/java/gsp/technologies/main/user/account/AccountFaceController.java

@ -1,149 +0,0 @@ @@ -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<TargetEntity> targets = targetService.findAllByPositionId(account.getPosition().getId());
Collection<CourseEntity> courses = targets.stream()
.map(TargetEntity::getCourse)
.distinct()
.collect(Collectors.toList());
model.addAttribute("courses", courses);
//передаем в модель статусы прохождения курсов
return "account";
} catch (Exception e) {
StringBuilder msg = new StringBuilder();
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<TargetEntity> targets = targetService.findAllByPositionId(account.getPosition().getId());
Collection<CourseEntity> courses = targets.stream()
.map(TargetEntity::getCourse)
.distinct()
.collect(Collectors.toList());
model.addAttribute("courses", courses);
//передаем в модель статусы прохождения курсов
return "account";
} catch (Exception e) {
StringBuilder msg = new StringBuilder();
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";
}
}

21
main/src/main/resources/static/content/courses/52/main.md

@ -0,0 +1,21 @@ @@ -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.

0
main/src/main/resources/templates/pages/reviewer/find.html → main/src/main/resources/templates/pages/reviewer/login.html

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

@ -21,7 +21,7 @@ xmlns:th="http://www.thymeleaf.org"> @@ -21,7 +21,7 @@ xmlns:th="http://www.thymeleaf.org">
</header>
<body>
<!-- курс -->
<div th:insert="~{shards/courses :: main(id=${courseid})}"></div>
<div th:insert="~{shards/courses :: content(id=${courseid})}"></div>
<!-- <div th:insert="~{fragments/controls :: gotoQuiz(accountid=${account.id})}"></div> -->
</body>
<footer>

6
main/src/main/resources/templates/shards/accounts.html

@ -5,11 +5,7 @@ @@ -5,11 +5,7 @@
<!-- Данные об аккаунте: id, organization, position -->
<div th:fragment="info(account)">
<hr>
<!-- <span>id: <span th:text="${account.id}"></span></span>
<br> -->
<span class="code">ID: <span th:text="${account.code}"></span></span>
<!-- <br> -->
<!-- <span>session: <span th:text="${account.sessionid}"></span></span> -->
<br>
<span>organization: <span th:text="${account.position.organization.name}"></span></span>
<br>
@ -39,7 +35,7 @@ @@ -39,7 +35,7 @@
</div>
</td> -->
<td>
<form th:action="@{/courses/view}" th:method="get">
<form th:action="@{/user/course}" th:method="get">
<input type="hidden" name="courseid" th:value="${course.id}">
<input type="hidden" name="accountid" th:value="${account.id}">
<input type="submit" value=">>>">

6
main/src/main/resources/templates/shards/courses.html

@ -20,8 +20,8 @@ @@ -20,8 +20,8 @@
<td th:text="${course.id}"></td>
<td th:text="${course.name}"></td>
<td>
<a th:href="@{/courses/{id}/edit(id=${course.id})}">Редактировать</a>
<a th:href="@{/courses/{id}/delete(id=${course.id})}">Удалить</a>
<a th:href="@{/supplier/courses/{id}/edit(id=${course.id})}">Редактировать</a>
<a th:href="@{/supplier/courses/{id}/delete(id=${course.id})}">Удалить</a>
</td>
</tr>
</tbody>
@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
<div th:fragment="create">
<hr>
<h2>Добавление нового курса:</h2>
<form th:action="@{/courses}" th:method="post">
<form th:action="@{/supplier/courses}" th:method="post">
<label for="name">Наименование курса </label>
<input type="text" id="name" name="name">
<input type="submit" value="Добавить">

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

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
<!-- отправляем наименование наименование должности
для перехода на целевой курс -->
<form th:action="@{/account}" th:method="get">
<form th:action="@{/user/account}" th:method="get">
<label for="position-select">Выберите должность</label>
<select id="position-select" name="positionid">
<option value="0" disabled selected>должность</option>
@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
<div th:fragment="auth">
<!-- Отправляем запрос с параметром code
открываем существующую попытку -->
<form th:action="@{/account}" th:method="get">
<form th:action="@{/reviewer/account}" th:method="get">
<label for="code">Если Вам нужно продолжить прохождение уже начатого курса - введите ID своего аккаунта: </label>
<input type="text" id="code" name="accountid">
<input type="submit" value="Проверить код">

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

@ -18,23 +18,19 @@ @@ -18,23 +18,19 @@
<tr th:each="organization : ${organizations}">
<td th:text="${organization.name}"></td>
<td>
<a th:href="@{/organizations/{id}/edit(id=${organization.id})}">Редактировать</a>
<a th:href="@{/organizations/{id}/delete(id=${organization.id})}">Удалить</a>
<a th:href="@{/supplier/organizations/{id}/edit(id=${organization.id})}">Редактировать</a>
<a th:href="@{/supplier/organizations/{id}/delete(id=${organization.id})}">Удалить</a>
</td>
</tr>
</tbody>
</table>
<hr>
<div th:each="organization : ${organizations}">
<div th:text="${organization.name}"></div>
</div>
</div>
<!-- Добавление новой организации -->
<div th:fragment="create">
<hr>
<h2>Добавление новой организации:</h2>
<form th:action="@{/organizations}" th:method="post">
<form th:action="@{/supplier/organizations}" th:method="post">
<label for="name">Название организации: </label>
<input type="text" id="name" name="name">
<br>
@ -46,7 +42,7 @@ @@ -46,7 +42,7 @@
<div th:fragment="edit(organization)">
<hr>
<h2>Редактирование организации: <span th:text="${organization.name}"></span></h2>
<form th:action="@{/organizations/{id}/edit(id=${organization.id})}" th:method="post">
<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>

14
main/src/main/resources/templates/shards/positions.html

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<html xmlns:th="http://www.thymeleaf.org">
<body>
<!-- Перечень организаций -->
<!-- Перечень должностей -->
<div th:fragment="list(positions)">
<hr>
<h2>Список должностей:</h2>
@ -20,23 +20,19 @@ @@ -20,23 +20,19 @@
<td th:text="${position.organization.name}"></td>
<td th:text="${position.name}"></td>
<td>
<a th:href="@{/positions/{id}/edit(id=${position.id})}">Редактировать</a>
<a th:href="@{/positions/{id}/delete(id=${position.id})}">Удалить</a>
<a th:href="@{/supplier/positions/{id}/edit(id=${position.id})}">Редактировать</a>
<a th:href="@{/supplier/positions/{id}/delete(id=${position.id})}">Удалить</a>
</td>
</tr>
</tbody>
</table>
<hr>
<div th:each="position : ${positions}">
<div th:text="${position.name}"></div>
</div>
</div>
<!-- Добавление новой должности -->
<div th:fragment="create(organizations)">
<hr>
<h2>Добавление новой должности:</h2>
<form th:action="@{/positions}" th:method="post">
<form th:action="@{/supplier/positions}" th:method="post">
<label for="organizationId">Организация: </label>
<select id="organizationId" name="organizationId">
<option value="0" disabled >выберите организацию</option>
@ -49,7 +45,7 @@ @@ -49,7 +45,7 @@
</form>
</div>
<!-- Редактирование олжностей -->
<!-- Редактирование должностей -->
<!-- <div th:fragment="edit(position)">
<hr>
<h2>Редактирование должности: <span th:text="${position.name}"></span></h2>

111
main/src/main/resources/templates/shards/targets.html

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<!-- Перечень задачь -->
<div th:fragment="list(targets)">
<hr>
<h2>Список задачь:</h2>
<h2>Список задач:</h2>
<table>
<thead>
<tr>
@ -43,53 +43,86 @@ @@ -43,53 +43,86 @@
- указание лимита вопросов для положительного результата
-->
<div th:fragment="create(organizations, positions, courses)">
<hr>
<h2>Добавление новой задачи:</h2>
<form th:action="@{/targets}" th:method="post">
<!-- выбираем организацию -->
<label for="organization-select">Организация: </label>
<select id="organization-select" name="organizationid">
<option value="0" disabled selected>выберите организацию</option>
<option th:each="organization : ${organizations}" th:value="${organization.id}" th:text="${organization.name}"></option>
</select>
<br>
<!-- отрабатывает скрипт по добавлению селекта должности -->
<hr>
<h2>Добавление новой задачи:</h2>
<form th:action="@{/supplier/targets}" th:method="post">
<!-- выбираем должность -->
<label for="position-select">Должность: </label>
<select id="position-select" name="positionid">
<option value="0" disabled selected>выберите должность</option>
<option th:each="position : ${positions}" th:value="${position.id}" th:text="${position.name}"></option>
</select>
<br>
<label for="course-select">Курс: </label>
<select id="course-select" name="courseid">
<option value="0" disabled selected >выберите курс</option>
<option th:each="course : ${courses}" th:value="${course.id}" th:text="${course.name}"></option>
</select>
<br>
<table>
<thead>
<th>lables</th>
<th>inputs</th>
<th>edit</th>
</thead>
<tbody>
<tr>
<td>
<label for="organization-select">Организация: </label>
</td>
<td>
<!-- выбираем организацию -->
<select id="organization-select" name="organizationid">
<option value="0" disabled selected>выберите организацию</option>
<option th:each="organization : ${organizations}" th:value="${organization.id}" th:text="${organization.name}"></option>
</select>
</td>
<td>
<a href="#">изменить список</a>
</td>
</tr>
<tr>
<td>
<label for="position-select">Должность: </label>
</td>
<td>
<!-- выбираем должность -->
<select id="position-select" name="positionid">
<option value="0" disabled selected>выберите должность</option>
<option th:each="position : ${positions}" th:value="${position.id}" th:text="${position.name}"></option>
</select>
</td>
<td>
<a href="#">изменить список</a>
</td>
</tr>
<tr>
<td>
<label for="course-select">Курс: </label>
</td>
<td>
<!-- выбираем курс -->
<select id="course-select" name="courseid">
<option value="0" disabled selected >выберите курс</option>
<option th:each="course : ${courses}" th:value="${course.id}" th:text="${course.name}"></option>
</select>
</td>
<td>
<a href="#">изменить список</a>
</td>
</tr>
</tbody>
</table>
<label for="questions-count">Количество вопросов для проверки знаний: </label>
<br>
<input type="text" id="questions-count" name="questions-count">
<br>
<br>
<label for="questions-limit">Количество вопросов для положительной оценки: </label>
<br>
<input type="text" id="questions-limit" name="questions-limit">
<br>
<br>
<label for="questions-count">Количество вопросов для проверки знаний: </label>
<br>
<input type="text" id="questions-count" name="questions-count">
<br>
<br>
<label for="questions-limit">Количество вопросов для положительной оценки: </label>
<br>
<input type="text" id="questions-limit" name="questions-limit">
<br>
<br>
<input type="submit" value="Добавить">
</form>
<input type="submit" value="Добавить задачу">
</form>
</div>
<!-- Редактирование олжностей -->
<!-- Редактирование должностей -->
<!-- <div th:fragment="edit(position)">
<hr>
<h2>Редактирование должности: <span th:text="${position.name}"></span></h2>

Loading…
Cancel
Save