esoe
1 week ago
37 changed files with 536 additions and 336 deletions
@ -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.OnDelete; |
||||||
import org.hibernate.annotations.OnDeleteAction; |
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.Entity; |
||||||
import jakarta.persistence.FetchType; |
import jakarta.persistence.FetchType; |
||||||
import jakarta.persistence.GeneratedValue; |
import jakarta.persistence.GeneratedValue; |
@ -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.data.jpa.repository.JpaRepository; |
||||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.user.account; |
package gsp.technologies.main.api.account; |
||||||
|
|
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.user.course; |
package gsp.technologies.main.api.course; |
||||||
|
|
||||||
import jakarta.persistence.Entity; |
import jakarta.persistence.Entity; |
||||||
import jakarta.persistence.GeneratedValue; |
import jakarta.persistence.GeneratedValue; |
@ -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.data.jpa.repository.JpaRepository; |
||||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.user.course; |
package gsp.technologies.main.api.course; |
||||||
|
|
||||||
import java.util.Collection; |
import java.util.Collection; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.supplier.organization; |
package gsp.technologies.main.api.organization; |
||||||
|
|
||||||
import org.slf4j.Logger; |
import org.slf4j.Logger; |
||||||
import org.slf4j.LoggerFactory; |
import org.slf4j.LoggerFactory; |
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.supplier.organization; |
package gsp.technologies.main.api.organization; |
||||||
|
|
||||||
import jakarta.persistence.Column; |
import jakarta.persistence.Column; |
||||||
import jakarta.persistence.Entity; |
import jakarta.persistence.Entity; |
@ -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.data.jpa.repository.JpaRepository; |
||||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.supplier.organization; |
package gsp.technologies.main.api.organization; |
||||||
|
|
||||||
import java.util.Collection; |
import java.util.Collection; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.supplier.position; |
package gsp.technologies.main.api.position; |
||||||
|
|
||||||
import java.util.Collection; |
import java.util.Collection; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.supplier.position; |
package gsp.technologies.main.api.position; |
||||||
|
|
||||||
import java.util.Collection; |
import java.util.Collection; |
||||||
|
|
@ -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.OnDelete; |
||||||
import org.hibernate.annotations.OnDeleteAction; |
import org.hibernate.annotations.OnDeleteAction; |
||||||
|
|
||||||
import gsp.technologies.main.supplier.position.PositionEntity; |
import gsp.technologies.main.api.course.CourseEntity; |
||||||
import gsp.technologies.main.user.course.CourseEntity; |
import gsp.technologies.main.api.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; |
@ -1,4 +1,4 @@ |
|||||||
package gsp.technologies.main.supplier.target; |
package gsp.technologies.main.api.target; |
||||||
|
|
||||||
import java.util.Collection; |
import java.util.Collection; |
||||||
|
|
@ -1,12 +1,9 @@ |
|||||||
package gsp.technologies.main.supplier.target; |
package gsp.technologies.main.api.target; |
||||||
|
|
||||||
import java.util.Collection; |
import java.util.Collection; |
||||||
|
|
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
import gsp.technologies.main.supplier.position.PositionEntity; |
|
||||||
import gsp.technologies.main.user.course.CourseEntity; |
|
||||||
|
|
||||||
@Service |
@Service |
||||||
public class TargetService { |
public class TargetService { |
||||||
private final TargetRepository repo; |
private final TargetRepository repo; |
@ -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"; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -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"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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"; |
|
||||||
} |
|
||||||
} |
|
@ -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. |
Loading…
Reference in new issue