осталось ограничить функцианал
This commit is contained in:
parent
ee2f2cd7df
commit
70f597fac8
@ -28,12 +28,6 @@ public class CreatorController {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
public CreatorMangaDto createCreator(@RequestParam("creatorName") String creatorName,
|
|
||||||
@RequestParam("password") String password) {
|
|
||||||
return new CreatorMangaDto(creatorService.addCreator(creatorName, password));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public CreatorMangaDto updateCreator(@PathVariable Long id,
|
public CreatorMangaDto updateCreator(@PathVariable Long id,
|
||||||
@RequestParam("creatorName") String creatorName,
|
@RequestParam("creatorName") String creatorName,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.LabWork.app.MangaStore.controller.Reader;
|
package com.LabWork.app.MangaStore.controller.Reader;
|
||||||
|
|
||||||
|
import com.LabWork.app.MangaStore.model.Dto.CreatorMangaDto;
|
||||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
||||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||||
import com.LabWork.app.MangaStore.service.ReaderService;
|
import com.LabWork.app.MangaStore.service.ReaderService;
|
||||||
@ -26,6 +27,20 @@ public class ReaderActionMvcController {
|
|||||||
this.mangaService = mangaService;
|
this.mangaService = mangaService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{user}")
|
||||||
|
public String getReader(@PathVariable String user, Model model) {
|
||||||
|
model.addAttribute("readers",
|
||||||
|
readerService.findAllReaders().stream()
|
||||||
|
.map(ReaderMangaDto::new)
|
||||||
|
.toList());
|
||||||
|
ReaderMangaDto currentReader = new ReaderMangaDto(readerService.findReader(readerService.findByLogin(user).getId()));
|
||||||
|
model.addAttribute("readerId", currentReader.getId());
|
||||||
|
model.addAttribute("reader", new ReaderMangaDto(readerService.findReader(currentReader.getId())));
|
||||||
|
model.addAttribute("MangaDto", new MangaDto());
|
||||||
|
model.addAttribute("mangaList", mangaService.findAllMangas());
|
||||||
|
return "readerAction";
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String getReader(@RequestParam(value = "readerId", required = false) Long readerId, Model model) {
|
public String getReader(@RequestParam(value = "readerId", required = false) Long readerId, Model model) {
|
||||||
model.addAttribute("readers",
|
model.addAttribute("readers",
|
||||||
|
@ -30,12 +30,6 @@ public class ReaderController {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
public ReaderMangaDto createReader(@RequestParam("readerName") String readerName,
|
|
||||||
@RequestParam("password") String password) {
|
|
||||||
return new ReaderMangaDto(readerService.addReader(readerName, password));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ReaderMangaDto updateReader(@PathVariable Long id,
|
public ReaderMangaDto updateReader(@PathVariable Long id,
|
||||||
@RequestParam("readerName") String readerName,
|
@RequestParam("readerName") String readerName,
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
package com.LabWork.app.MangaStore.controller.Reader;
|
|
||||||
|
|
||||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
|
||||||
import com.LabWork.app.MangaStore.service.ReaderService;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/reader")
|
|
||||||
public class ReaderMvcController {
|
|
||||||
private final ReaderService readerService;
|
|
||||||
|
|
||||||
public ReaderMvcController(ReaderService readerService) {
|
|
||||||
this.readerService = readerService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public String getReaders(Model model) {
|
|
||||||
model.addAttribute("readers",
|
|
||||||
readerService.findAllReaders().stream()
|
|
||||||
.map(ReaderMangaDto::new)
|
|
||||||
.toList());
|
|
||||||
return "reader";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping(value = {"/edit", "/edit/{id}"})
|
|
||||||
public String editReader(@PathVariable(required = false) Long id,
|
|
||||||
Model model) {
|
|
||||||
if (id == null || id <= 0) {
|
|
||||||
model.addAttribute("ReaderMangaDto", new ReaderMangaDto());
|
|
||||||
} else {
|
|
||||||
model.addAttribute("readerId", id);
|
|
||||||
model.addAttribute("ReaderMangaDto", new ReaderMangaDto(readerService.findReader(id)));
|
|
||||||
}
|
|
||||||
return "reader-edit";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = {"", "/{id}"})
|
|
||||||
public String saveReader(@PathVariable(required = false) Long id,
|
|
||||||
@ModelAttribute @Valid ReaderMangaDto readerMangaDto,
|
|
||||||
BindingResult bindingResult,
|
|
||||||
Model model) {
|
|
||||||
if (bindingResult.hasErrors()) {
|
|
||||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
|
||||||
return "reader-edit";
|
|
||||||
}
|
|
||||||
if (id == null || id <= 0) {
|
|
||||||
readerService.addReader(readerMangaDto.getReaderName(), readerMangaDto.getHashedPassword());
|
|
||||||
} else {
|
|
||||||
readerService.updateReader(id, readerMangaDto.getReaderName(), readerMangaDto.getHashedPassword());
|
|
||||||
}
|
|
||||||
return "redirect:/reader";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/delete/{id}")
|
|
||||||
public String deleteReader(@PathVariable Long id) {
|
|
||||||
readerService.deleteReader(id);
|
|
||||||
return "redirect:/reader";
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,7 @@ public class Creator {
|
|||||||
@Id
|
@Id
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
@MapsId
|
@MapsId
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
@ -24,12 +24,6 @@ public class Creator {
|
|||||||
public Creator() {
|
public Creator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Creator(String creatorName, String hashedPassword) {
|
|
||||||
this.user = user;
|
|
||||||
this.id = user.getId();
|
|
||||||
this.mangas = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Creator(User user) {
|
public Creator(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.id = user.getId();
|
this.id = user.getId();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.LabWork.app.MangaStore.model.Default;
|
package com.LabWork.app.MangaStore.model.Default;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import com.LabWork.app.MangaStore.user.model.User;
|
||||||
import org.hibernate.annotations.Cascade;
|
import org.hibernate.annotations.Cascade;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -10,14 +12,11 @@ import java.util.Objects;
|
|||||||
@Entity
|
@Entity
|
||||||
public class Reader {
|
public class Reader {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
private String readerName;
|
@MapsId
|
||||||
|
private User user;
|
||||||
@Column
|
|
||||||
private String hashedPassword;
|
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
|
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
|
||||||
/*@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)*/
|
/*@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)*/
|
||||||
@ -27,9 +26,15 @@ public class Reader {
|
|||||||
public Reader() {
|
public Reader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reader(String readerName, String hashedPassword) {
|
public Reader(String creatorName, String hashedPassword) {
|
||||||
this.readerName = readerName;
|
this.user = user;
|
||||||
this.hashedPassword = hashedPassword;
|
this.id = user.getId();
|
||||||
|
this.mangas = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reader(User user) {
|
||||||
|
this.user = user;
|
||||||
|
this.id = user.getId();
|
||||||
this.mangas = new ArrayList<>();
|
this.mangas = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,20 +42,12 @@ public class Reader {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getReaderName() { return readerName; }
|
|
||||||
|
|
||||||
public void setReaderName(String readerName) { this.readerName = readerName; }
|
|
||||||
|
|
||||||
public String getHashedPassword() { return hashedPassword; }
|
|
||||||
|
|
||||||
public void setHashedPassword(String hashedPassword) { this.hashedPassword = hashedPassword; }
|
|
||||||
|
|
||||||
public List<Manga> getMangas() { return mangas; }
|
public List<Manga> getMangas() { return mangas; }
|
||||||
|
|
||||||
public void setMangas(List<Manga> mangas) { this.mangas = mangas; }
|
public void setMangas(List<Manga> mangas) { this.mangas = mangas; }
|
||||||
|
|
||||||
|
public User getUser() { return user; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
@ -68,8 +65,6 @@ public class Reader {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "Reader{" +
|
return "Reader{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", readerName='" + readerName + '\'' +
|
|
||||||
", hashedPassword='" + hashedPassword + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ public class ReaderMangaDto {
|
|||||||
|
|
||||||
public ReaderMangaDto(Reader reader) {
|
public ReaderMangaDto(Reader reader) {
|
||||||
this.id = reader.getId();
|
this.id = reader.getId();
|
||||||
this.readerName = reader.getReaderName();
|
this.readerName = reader.getUser().getLogin();
|
||||||
this.hashedPassword = reader.getHashedPassword();
|
this.hashedPassword = reader.getUser().getPassword();
|
||||||
this.mangas = reader.getMangas().stream()
|
this.mangas = reader.getMangas().stream()
|
||||||
.map(y -> new MangaDto(y))
|
.map(y -> new MangaDto(y))
|
||||||
.toList();
|
.toList();
|
||||||
|
@ -16,8 +16,8 @@ public class ReaderDto {
|
|||||||
|
|
||||||
public ReaderDto(Reader reader) {
|
public ReaderDto(Reader reader) {
|
||||||
this.id = reader.getId();
|
this.id = reader.getId();
|
||||||
this.readerName = reader.getReaderName();
|
this.readerName = reader.getUser().getLogin();
|
||||||
this.hashedPassword = reader.getHashedPassword();
|
this.hashedPassword = reader.getUser().getPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
@ -49,8 +49,8 @@ public class CreatorService {
|
|||||||
public List<Creator> findAllCreators() { return creatorRepository.findAll(); }
|
public List<Creator> findAllCreators() { return creatorRepository.findAll(); }
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Creator addCreator(String creatorName, String password) {
|
public Creator addCreator(User user) {
|
||||||
final Creator creator = new Creator(creatorName, password);
|
final Creator creator = new Creator(user);
|
||||||
validatorUtil.validate(creator);
|
validatorUtil.validate(creator);
|
||||||
return creatorRepository.save(creator);
|
return creatorRepository.save(creator);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package com.LabWork.app.MangaStore.service;
|
package com.LabWork.app.MangaStore.service;
|
||||||
|
|
||||||
|
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||||
import com.LabWork.app.MangaStore.model.Default.Manga;
|
import com.LabWork.app.MangaStore.model.Default.Manga;
|
||||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||||
|
import com.LabWork.app.MangaStore.service.Exception.CreatorNotFoundException;
|
||||||
import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
||||||
import com.LabWork.app.MangaStore.service.Repository.ReaderRepository;
|
import com.LabWork.app.MangaStore.service.Repository.ReaderRepository;
|
||||||
import com.LabWork.app.MangaStore.service.Exception.MangaNotFoundException;
|
import com.LabWork.app.MangaStore.service.Exception.MangaNotFoundException;
|
||||||
import com.LabWork.app.MangaStore.service.Exception.ReaderNotFoundException;
|
import com.LabWork.app.MangaStore.service.Exception.ReaderNotFoundException;
|
||||||
|
import com.LabWork.app.MangaStore.user.model.User;
|
||||||
|
import com.LabWork.app.MangaStore.user.repository.UserRepository;
|
||||||
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -16,15 +20,18 @@ import java.util.Optional;
|
|||||||
@Service
|
@Service
|
||||||
public class ReaderService {
|
public class ReaderService {
|
||||||
private final ReaderRepository readerRepository;
|
private final ReaderRepository readerRepository;
|
||||||
|
private final UserRepository userRepository;
|
||||||
private final MangaRepository mangaRepository;
|
private final MangaRepository mangaRepository;
|
||||||
private final ValidatorUtil validatorUtil;
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
public ReaderService(ReaderRepository readerRepository,
|
public ReaderService(ReaderRepository readerRepository,
|
||||||
ValidatorUtil validatorUtil,
|
ValidatorUtil validatorUtil,
|
||||||
|
UserRepository userRepository,
|
||||||
MangaRepository mangaRepository) {
|
MangaRepository mangaRepository) {
|
||||||
this.readerRepository = readerRepository;
|
this.readerRepository = readerRepository;
|
||||||
this.mangaRepository = mangaRepository;
|
this.mangaRepository = mangaRepository;
|
||||||
this.validatorUtil = validatorUtil;
|
this.validatorUtil = validatorUtil;
|
||||||
|
this.userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@ -33,25 +40,35 @@ public class ReaderService {
|
|||||||
return reader.orElseThrow(() -> new ReaderNotFoundException(id));
|
return reader.orElseThrow(() -> new ReaderNotFoundException(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User findByLogin(String login) {
|
||||||
|
return userRepository.findOneByLoginIgnoreCase(login);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public User findUser(Long id) {
|
||||||
|
final Optional<User> user = userRepository.findById(id);
|
||||||
|
return user.orElseThrow(() -> new CreatorNotFoundException(id));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<Reader> findAllReaders() {
|
public List<Reader> findAllReaders() {
|
||||||
return readerRepository.findAll();
|
return readerRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Reader addReader(String readerName, String password) {
|
public Reader addReader(User user) {
|
||||||
final Reader reader = new Reader(readerName, password);
|
final Reader reader = new Reader(user);
|
||||||
validatorUtil.validate(reader);
|
validatorUtil.validate(reader);
|
||||||
return readerRepository.save(reader);
|
return readerRepository.save(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Reader updateReader(Long id, String readername, String password) {
|
public Reader updateReader(Long id, String creatorName, String password) {
|
||||||
final Reader currentReader = findReader(id);
|
final User currentUser = findUser(id);
|
||||||
currentReader.setReaderName(readername);
|
currentUser.setLogin(creatorName);
|
||||||
currentReader.setHashedPassword(password);
|
currentUser.setPassword(password);
|
||||||
validatorUtil.validate(currentReader);
|
validatorUtil.validate(currentUser);
|
||||||
return currentReader;
|
return findReader(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.LabWork.app.MangaStore.user.service;
|
package com.LabWork.app.MangaStore.user.service;
|
||||||
|
|
||||||
import com.LabWork.app.MangaStore.model.Default.Creator;
|
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||||
import com.LabWork.app.MangaStore.service.Repository.CreatorRepository;
|
import com.LabWork.app.MangaStore.service.ReaderService;
|
||||||
import com.LabWork.app.MangaStore.user.model.UserRole;
|
import com.LabWork.app.MangaStore.user.model.UserRole;
|
||||||
import com.LabWork.app.MangaStore.util.validation.ValidationException;
|
import com.LabWork.app.MangaStore.util.validation.ValidationException;
|
||||||
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
||||||
@ -21,16 +21,19 @@ import java.util.Objects;
|
|||||||
@Service
|
@Service
|
||||||
public class UserService implements UserDetailsService {
|
public class UserService implements UserDetailsService {
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final CreatorRepository creatorRepository;
|
private final ReaderService readerService;
|
||||||
|
private final CreatorService creatorService;
|
||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
private final ValidatorUtil validatorUtil;
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
public UserService(UserRepository userRepository,
|
public UserService(UserRepository userRepository,
|
||||||
CreatorRepository creatorRepository,
|
CreatorService creatorService,
|
||||||
|
ReaderService readerService,
|
||||||
PasswordEncoder passwordEncoder,
|
PasswordEncoder passwordEncoder,
|
||||||
ValidatorUtil validatorUtil) {
|
ValidatorUtil validatorUtil) {
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
this.creatorRepository = creatorRepository;
|
this.readerService = readerService;
|
||||||
|
this.creatorService = creatorService;
|
||||||
this.passwordEncoder = passwordEncoder;
|
this.passwordEncoder = passwordEncoder;
|
||||||
this.validatorUtil = validatorUtil;
|
this.validatorUtil = validatorUtil;
|
||||||
}
|
}
|
||||||
@ -57,8 +60,8 @@ public class UserService implements UserDetailsService {
|
|||||||
throw new ValidationException("Passwords not equals");
|
throw new ValidationException("Passwords not equals");
|
||||||
}
|
}
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
final Creator creator = new Creator(user);
|
if (user.getRole() == UserRole.ADMIN) creatorService.addCreator(user);
|
||||||
creatorRepository.save(creator);
|
else readerService.addReader(user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">Index</a>
|
th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">Index</a>
|
||||||
<a class="nav-link" th:href="@{/creatorAction/{login}(login=${#authentication.name})}"
|
<a class="nav-link" th:href="@{/creatorAction/{login}(login=${#authentication.name})}"
|
||||||
th:classappend="${#strings.equals(activeLink, '/creatorAction')} ? 'active' : ''">CreatorAction</a>
|
th:classappend="${#strings.equals(activeLink, '/creatorAction')} ? 'active' : ''">CreatorAction</a>
|
||||||
<a class="nav-link" href="/readerAction/"
|
<a class="nav-link" th:href="@{/readerAction/{login}(login=${#authentication.name})}"
|
||||||
th:classappend="${#strings.equals(activeLink, '/readerAction')} ? 'active' : ''">ReaderAction</a>
|
th:classappend="${#strings.equals(activeLink, '/readerAction')} ? 'active' : ''">ReaderAction</a>
|
||||||
<a class="nav-link" href="/manga"
|
<a class="nav-link" href="/manga"
|
||||||
th:classappend="${#strings.equals(activeLink, '/manga')} ? 'active' : ''">Catalog</a>
|
th:classappend="${#strings.equals(activeLink, '/manga')} ? 'active' : ''">Catalog</a>
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div layout:fragment="content">
|
|
||||||
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
|
||||||
<form action="#" th:action="@{/reader/{id}(id=${id})}" th:object="${ReaderMangaDto}" method="post">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="readerName" class="form-label">readerName</label>
|
|
||||||
<input id="readerName" type='text' value class="form-control" th:field="${ReaderMangaDto.readerName}" required="true"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="hashedPassword" class="form-label">hashedPassword</label>
|
|
||||||
<input id="hashedPassword" type='text' value class="form-control" th:field="${ReaderMangaDto.hashedPassword}" required="true"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<button type="submit" class="btn btn-primary button-fixed">
|
|
||||||
<span th:if="${id == null}">Добавить</span>
|
|
||||||
<span th:if="${id != null}">Обновить</span>
|
|
||||||
</button>
|
|
||||||
<a class="btn btn-secondary button-fixed" th:href="@{/reader}">
|
|
||||||
Назад
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,60 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{default}">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container" id="root-div" layout:fragment="content">
|
|
||||||
<div class="content">
|
|
||||||
<h1>Reader</h1>
|
|
||||||
<a class="btn btn-success"
|
|
||||||
th:href="@{/reader/edit}">
|
|
||||||
<i class="fa-solid fa-plus"></i> Добавить
|
|
||||||
</a>
|
|
||||||
<div class="row table-responsive text-white">
|
|
||||||
<table class="table mt-3 text-white">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">ReaderName</th>
|
|
||||||
<th scope="col">Password</th>
|
|
||||||
<th scope="col">Mangas</th>
|
|
||||||
<th scope="col"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="reader, iterator: ${readers}">
|
|
||||||
<td th:text="${reader.id}"/>
|
|
||||||
<td th:text="${reader.readerName}"/>
|
|
||||||
<td th:text="${reader.hashedPassword}"/>
|
|
||||||
<td>
|
|
||||||
<select className="form-select" aria-label="Default select example">
|
|
||||||
<option th:each="manga, iterator: ${reader.mangas}" th:text="${manga.mangaName}"/>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td style="width: 10%">
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic example">
|
|
||||||
<a class="btn btn-warning button-fixed button-sm"
|
|
||||||
th:href="@{/reader/edit/{id}(id=${reader.id})}">
|
|
||||||
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
|
||||||
</a>
|
|
||||||
<button type="button" class="btn btn-danger button-fixed button-sm"
|
|
||||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${reader.id}').click()|">
|
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<form th:action="@{/reader/delete/{id}(id=${reader.id})}" method="post">
|
|
||||||
<button th:id="'remove-' + ${reader.id}" type="submit" style="display: none">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
package com.LabWork.app;
|
package com.LabWork.app;
|
||||||
|
|
||||||
import com.LabWork.app.MangaStore.model.Default.Creator;
|
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||||
@ -103,6 +104,7 @@ public class ReMangaTest {
|
|||||||
creatorService.deleteAllCreators();
|
creatorService.deleteAllCreators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
/* @Test
|
/* @Test
|
||||||
void testCreatorAddManga() {
|
void testCreatorAddManga() {
|
||||||
readerService.deleteAllReaders();
|
readerService.deleteAllReaders();
|
||||||
@ -119,8 +121,10 @@ public class ReMangaTest {
|
|||||||
log.info(m1.getCreator().toString());
|
log.info(m1.getCreator().toString());
|
||||||
log.info(c1.toString());
|
log.info(c1.toString());
|
||||||
Assertions.assertEquals(c1.getCreatorName(), m1.getCreator().getCreatorName());
|
Assertions.assertEquals(c1.getCreatorName(), m1.getCreator().getCreatorName());
|
||||||
}*/
|
}*//*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
/* //бесполезня штука
|
/* //бесполезня штука
|
||||||
@Test
|
@Test
|
||||||
void testCreatorDeleteManga() {
|
void testCreatorDeleteManga() {
|
||||||
@ -147,8 +151,11 @@ public class ReMangaTest {
|
|||||||
|
|
||||||
Assertions.assertEquals(1, c1.getMangas().size());
|
Assertions.assertEquals(1, c1.getMangas().size());
|
||||||
|
|
||||||
}*/
|
}*//*
|
||||||
/*тестстим работоспособность гита*/
|
|
||||||
|
*/
|
||||||
|
/*тестстим работоспособность гита*//*
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCreatorUpdated() {
|
void testCreatorUpdated() {
|
||||||
readerService.deleteAllReaders();
|
readerService.deleteAllReaders();
|
||||||
@ -429,3 +436,4 @@ public class ReMangaTest {
|
|||||||
creatorService.deleteAllCreators();
|
creatorService.deleteAllCreators();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user