From 1db0e84d891f7eec99e4602b24d65d3e716e3c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=AF=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=B2?= Date: Sun, 12 May 2024 18:20:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data.mv.db | Bin 49152 -> 49152 bytes data.trace.db | 108 ++++++++++++++++++ .../demo/games/api/GameController.java | 93 ++++++++++++--- .../com/example/demo/games/api/GameDto.java | 2 +- .../example/demo/games/model/GameEntity.java | 50 ++++---- .../demo/games/service/GameService.java | 7 +- .../com/example/demo/genres/api/GenreDto.java | 15 +-- .../orders/repository/OrderRepository.java | 1 + .../demo/orders/service/OrderService.java | 1 - .../demo/users/api/UserCartController.java | 20 ++-- .../demo/users/api/UserProfileController.java | 22 ++-- src/main/resources/templates/cart.html | 9 +- src/main/resources/templates/default.html | 2 - src/main/resources/templates/game-edit.html | 31 ++++- src/main/resources/templates/orders.html | 14 ++- src/main/resources/templates/profile.html | 2 +- 16 files changed, 291 insertions(+), 86 deletions(-) create mode 100644 data.trace.db diff --git a/data.mv.db b/data.mv.db index ef94f3ebadd0082f26a6811da9b03b48e58174b6..6819e849f31056a0d65973c86ad7564def917182 100644 GIT binary patch literal 49152 zcmeG_TWlT2b$c%_r4>z5jvd>HB|BHwvL)IKz3-i6l2&|NidW)8zP!|A{BoH z1_}%m7$`7MV4%Q2fq?=81qKQX6c{KlP+*|Iz(O3=|kBFi>Eiz(9e40s{pG_8J3;kbfiCoK`1q;48t-v^{wpzdMaQ1W3O%bT`Mzq(g{M3>;>qyHiO z)w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fD< zrGt5ewH;@!QFtgxhkhu1qgZ@ZiiI&5!D=O5b0i78oQD%+ah@h%2^11^wO9rbLifW! zlToNewiEg?w?2$Js-u7q0tZ#~kuN*88R>ceXOQPwrfJ9yq>u)Zh7-721oD;aL?+k_ zOjmXl$MOOgd@FPm!*ygIX^IV3Wgo5u zo*qI1!9t`J$bMviWC~IrB-}_*Z8^r;my~0YL z;6Og}OWlntyZOTJJ5_mwd!ICO9_Bm*)mPLKM)}s}!zLd#`LM~~l+^XJd~(?PFQ zTp;m+%fTwF;=mSo;FWW17VPR^OAj~04L>}F=kI-I`)i}nungM{lIBNw8L+AQ$*0G} z05z#0P`T0D5jIWvq?o#$;buf;>K6C7>$4iirtTpCcO0Q6W4}9bTfX#Ao!1n zktwF`aBP!~n7@kIw?$G@W@e$0GI1lDZIKoW)!S90!IuH7g+yAfDZP*@_Ze${w z(PR9-1|N~od#Lt*@bpS-q>_dIr@NXaT)SYOd)O$oN4TA^|3ld4o(X?XDT@Dpj^h7+ z`5wjpzu!A1@c;jn{4^CTB{1-7>xNG|DWUk$*72993-&T zIsTu%Gb6=1NQDQd;;wW2e~$lOSymjAZcWgKR;NKn$a^>#b7S#R)5!7vWXjqBv){+j zj|TtWqWFJUMj-fqIQHZJ@8-(Bjn zkb-62d0fI~NjNS=|GvA#DT10u`Bt$>rwDqDjmi)Qqm{XYQv KfACQ3|NjqH`7(R} diff --git a/data.trace.db b/data.trace.db new file mode 100644 index 0000000..3b6df68 --- /dev/null +++ b/data.trace.db @@ -0,0 +1,108 @@ +2024-05-12 15:36:55.285977+04:00 database: wrong user or password; user: "SA" +org.h2.message.DbException: Неверное имя пользователя или пароль +Wrong user name or password [28000-224] + at org.h2.message.DbException.get(DbException.java:223) + at org.h2.message.DbException.get(DbException.java:199) + at org.h2.message.DbException.get(DbException.java:188) + at org.h2.engine.Engine.openSession(Engine.java:154) + at org.h2.engine.Engine.openSession(Engine.java:222) + at org.h2.engine.Engine.createSession(Engine.java:201) + at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343) + at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:125) + at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288) + at org.h2.server.web.WebServer.getConnection(WebServer.java:811) + at org.h2.server.web.WebApp.login(WebApp.java:1039) + at org.h2.server.web.WebApp.process(WebApp.java:227) + at org.h2.server.web.WebApp.processRequest(WebApp.java:177) + at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129) + at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166) + at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590) + at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:206) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:150) + at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:175) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:150) + at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108) + at org.springframework.security.web.FilterChainProxy.lambda$doFilterInternal$3(FilterChainProxy.java:231) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:365) + at org.springframework.security.web.access.intercept.AuthorizationFilter.doFilter(AuthorizationFilter.java:100) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126) + at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:110) + at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:101) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:179) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:227) + at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:221) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:107) + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:93) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) + at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:82) + at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:69) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:62) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:233) + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:191) + at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113) + at org.springframework.web.servlet.handler.HandlerMappingIntrospector.lambda$createCacheFilter$3(HandlerMappingIntrospector.java:195) + at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113) + at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74) + at org.springframework.security.config.annotation.web.configuration.WebMvcSecurityConfiguration$CompositeFilterChainProxy.doFilter(WebMvcSecurityConfiguration.java:230) + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:352) + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:268) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:175) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:150) + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:175) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:150) + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:175) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:150) + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:175) + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:150) + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) + at java.base/java.lang.Thread.run(Thread.java:1623) +Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль +Wrong user name or password [28000-224] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:522) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) + ... 100 more diff --git a/src/main/java/com/example/demo/games/api/GameController.java b/src/main/java/com/example/demo/games/api/GameController.java index e72cc73..f7045ed 100644 --- a/src/main/java/com/example/demo/games/api/GameController.java +++ b/src/main/java/com/example/demo/games/api/GameController.java @@ -6,21 +6,24 @@ import java.util.Map; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.example.demo.core.api.PageAttributesMapper; import com.example.demo.core.configuration.Constants; import com.example.demo.games.model.GameEntity; import com.example.demo.games.service.GameService; +import com.example.demo.genres.api.GenreDto; import com.example.demo.genres.model.GenreEntity; import com.example.demo.genres.service.GenreService; +import com.example.demo.types.api.TypeDto; +import com.example.demo.types.model.TypeEntity; import com.example.demo.types.service.TypeService; import jakarta.validation.Valid; @@ -60,6 +63,14 @@ public class GameController { return dto; } + private TypeDto toTypeDto(TypeEntity entity) { + return modelMapper.map(entity, TypeDto.class); + } + + private GenreDto toGenreDto(GenreEntity entity) { + return modelMapper.map(entity, GenreDto.class); + } + private GameEntity toEntity(GameDto dto) { // return modelMapper.map(dto, GameEntity.class); final GameEntity entity = modelMapper.map(dto, GameEntity.class); @@ -83,23 +94,75 @@ public class GameController { return GAME_VIEW; } - @GetMapping("/{id}") - public GameDto get(@PathVariable(name = "id") Long id) { - return toDto(gameService.get(id)); + @GetMapping("/edit/") + public String create( + @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, + Model model) { + model.addAttribute(GAME_ATTRIBUTE, new GameDto()); + model.addAttribute("types", typeService.getAll().stream().map(this::toTypeDto).toList()); + model.addAttribute("genresCheck", genreService.getAll().stream().map(this::toGenreDto).toList()); + model.addAttribute(PAGE_ATTRIBUTE, page); + return GAME_EDIT_VIEW; } - @PostMapping - public GameDto create(@RequestBody @Valid GameDto dto) { - return toDto(gameService.create(toEntity(dto))); + @PostMapping("/edit/") + public String create( + @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, + @ModelAttribute(name = GAME_ATTRIBUTE) @Valid GameDto game, + BindingResult bindingResult, + Model model, + RedirectAttributes redirectAttributes) { + if (bindingResult.hasErrors()) { + model.addAttribute(PAGE_ATTRIBUTE, page); + return GAME_EDIT_VIEW; + } + redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page); + gameService.create(toEntity(game)); + return Constants.REDIRECT_VIEW + URL; } - @PutMapping("/{id}") - public GameDto update(@PathVariable(name = "id") Long id, @RequestBody GameDto dto) { - return toDto(gameService.update(id, toEntity(dto))); + @GetMapping("/edit/{id}") + public String update( + @PathVariable(name = "id") Long id, + @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, + Model model) { + if (id <= 0) { + throw new IllegalArgumentException(); + } + model.addAttribute(GAME_ATTRIBUTE, toDto(gameService.get(id))); + model.addAttribute(PAGE_ATTRIBUTE, page); + model.addAttribute("types", typeService.getAll().stream().map(this::toTypeDto).toList()); + model.addAttribute("genresCheck", genreService.getAll().stream().map(this::toGenreDto).toList()); + return GAME_EDIT_VIEW; } - @DeleteMapping("/{id}") - public GameDto delete(@PathVariable(name = "id") Long id) { - return toDto(gameService.delete(id)); + @PostMapping("/edit/{id}") + public String update( + @PathVariable(name = "id") Long id, + @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, + @ModelAttribute(name = GAME_ATTRIBUTE) @Valid GameDto game, + BindingResult bindingResult, + Model model, + RedirectAttributes redirectAttributes) { + if (bindingResult.hasErrors()) { + model.addAttribute(PAGE_ATTRIBUTE, page); + return GAME_EDIT_VIEW; + } + if (id <= 0) { + throw new IllegalArgumentException(); + } + redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page); + gameService.update(id, toEntity(game)); + return Constants.REDIRECT_VIEW + URL; + } + + @PostMapping("/delete/{id}") + public String delete( + @PathVariable(name = "id") Long id, + @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, + RedirectAttributes redirectAttributes) { + redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page); + gameService.delete(id); + return Constants.REDIRECT_VIEW + URL; } } diff --git a/src/main/java/com/example/demo/games/api/GameDto.java b/src/main/java/com/example/demo/games/api/GameDto.java index 1a6e39f..a71abb3 100644 --- a/src/main/java/com/example/demo/games/api/GameDto.java +++ b/src/main/java/com/example/demo/games/api/GameDto.java @@ -15,7 +15,7 @@ public class GameDto { @NotNull private final List genres = new ArrayList<>(); @NotNull - @Min(1) + @Min(100) private Double price; @NotBlank private String name; diff --git a/src/main/java/com/example/demo/games/model/GameEntity.java b/src/main/java/com/example/demo/games/model/GameEntity.java index ff75593..a3573b0 100644 --- a/src/main/java/com/example/demo/games/model/GameEntity.java +++ b/src/main/java/com/example/demo/games/model/GameEntity.java @@ -12,12 +12,12 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToMany; -import jakarta.persistence.OneToOne; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; @Entity @Table(name = "games") -public class GameEntity extends BaseEntity{ +public class GameEntity extends BaseEntity { @Column(nullable = false) private String name; @Column(nullable = false) @@ -27,14 +27,14 @@ public class GameEntity extends BaseEntity{ @ManyToMany() @Column(unique = false) private final List genres = new ArrayList<>(); - @OneToOne + @ManyToOne @JoinColumn(name = "typeId", nullable = false, unique = false) private TypeEntity type; - public GameEntity(){ + public GameEntity() { } - public GameEntity(TypeEntity type, String name, Double price, String description, List genres){ + public GameEntity(TypeEntity type, String name, Double price, String description, List genres) { this.type = type; this.name = name; this.price = price; @@ -43,63 +43,67 @@ public class GameEntity extends BaseEntity{ this.genres.addAll(genres); } - public TypeEntity getType(){ + public TypeEntity getType() { return type; } - public void setType(TypeEntity type){ + public void setType(TypeEntity type) { this.type = type; } - public Double getPrice(){ + public Double getPrice() { return price; } - public void setPrice(Double price){ + public void setPrice(Double price) { this.price = price; } - public String getName(){ + public String getName() { return name; } - public void setName(String name){ + public void setName(String name) { this.name = name; } - public String getDescription(){ + public String getDescription() { return description; } - public void setDescription(String description){ + public void setDescription(String description) { this.description = description; } - public List getGenres(){ + public List getGenres() { return genres; } - public void setGenres(GenreEntity genre){ + public void setGenres(GenreEntity genre) { this.genres.add(genre); } + public void delGenres() { + this.genres.clear(); + } + @Override public int hashCode() { return Objects.hash(id, type, price, genres, description, name); } @Override - public boolean equals(Object obj){ - if(this == obj) + public boolean equals(Object obj) { + if (this == obj) return true; - if(obj == null || getClass() != obj.getClass()) + if (obj == null || getClass() != obj.getClass()) return false; final GameEntity other = (GameEntity) obj; return Objects.equals(other.getId(), id) - && Objects.equals(other.getType(), type) - && Objects.equals(other.getPrice(), price) - && Objects.equals(other.getGenres(), genres) - && Objects.equals(other.getDescription(), description) - && Objects.equals(other.getName(), name); + && Objects.equals(other.getType(), type) + && Objects.equals(other.getPrice(), price) + && Objects.equals(other.getGenres(), genres) + && Objects.equals(other.getDescription(), description) + && Objects.equals(other.getName(), name); } } diff --git a/src/main/java/com/example/demo/games/service/GameService.java b/src/main/java/com/example/demo/games/service/GameService.java index 3bafb07..cf79b52 100644 --- a/src/main/java/com/example/demo/games/service/GameService.java +++ b/src/main/java/com/example/demo/games/service/GameService.java @@ -86,8 +86,11 @@ public class GameService { existEntity.setDescription(entity.getDescription()); existEntity.setType(entity.getType()); var genres = entity.getGenres(); - for (var genre : genres) { - existEntity.setGenres(genre); + if (genres.size() != 0) { + existEntity.delGenres(); + for (var genre : genres) { + existEntity.setGenres(genre); + } } return repository.save(existEntity); } diff --git a/src/main/java/com/example/demo/genres/api/GenreDto.java b/src/main/java/com/example/demo/genres/api/GenreDto.java index 5f3c6e0..343b96c 100644 --- a/src/main/java/com/example/demo/genres/api/GenreDto.java +++ b/src/main/java/com/example/demo/genres/api/GenreDto.java @@ -1,30 +1,27 @@ package com.example.demo.genres.api; -import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; public class GenreDto { - @JsonProperty(access = JsonProperty.Access.READ_ONLY) private Long id; @NotBlank @Size(min = 1, max = 50) private String name; - public Long getId(){ + public Long getId() { return id; } - - public void setId(Long id){ + + public void setId(Long id) { this.id = id; } - public String getName(){ + public String getName() { return name; } - - public void setName(String name){ + + public void setName(String name) { this.name = name; } } diff --git a/src/main/java/com/example/demo/orders/repository/OrderRepository.java b/src/main/java/com/example/demo/orders/repository/OrderRepository.java index 9015a75..fa7cbab 100644 --- a/src/main/java/com/example/demo/orders/repository/OrderRepository.java +++ b/src/main/java/com/example/demo/orders/repository/OrderRepository.java @@ -15,6 +15,7 @@ public interface OrderRepository extends CrudRepository, PagingAndSortingRepository { Optional findOneByUserIdAndId(long userId, long id); + @Query("select o from OrderEntity o join fetch o.games where o.user.id = ?1") List findByUserId(long userId); @Query("select o from OrderEntity o join fetch o.games where o.user.id = ?1") diff --git a/src/main/java/com/example/demo/orders/service/OrderService.java b/src/main/java/com/example/demo/orders/service/OrderService.java index 780152f..ea6f109 100644 --- a/src/main/java/com/example/demo/orders/service/OrderService.java +++ b/src/main/java/com/example/demo/orders/service/OrderService.java @@ -1,7 +1,6 @@ package com.example.demo.orders.service; import java.util.List; -import java.util.stream.StreamSupport; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; diff --git a/src/main/java/com/example/demo/users/api/UserCartController.java b/src/main/java/com/example/demo/users/api/UserCartController.java index 5499f2a..572fb10 100644 --- a/src/main/java/com/example/demo/users/api/UserCartController.java +++ b/src/main/java/com/example/demo/users/api/UserCartController.java @@ -2,9 +2,7 @@ package com.example.demo.users.api; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; import org.modelmapper.ModelMapper; @@ -43,7 +41,6 @@ public class UserCartController { private final GameService gameService; private final OrderService orderService; private final SessionCart cart; - private final ModelMapper modelMapper; public UserCartController( GameService gameService, @@ -53,7 +50,6 @@ public class UserCartController { this.gameService = gameService; this.orderService = orderService; this.cart = cart; - this.modelMapper = modelMapper; } private GameDto toGameDto(GameEntity entity) { @@ -68,14 +64,14 @@ public class UserCartController { } // private List toGameEntities(Collection dtos){ - // final GameEntity entity = modelMapper.map(dto, GameEntity.class); - // entity.setType(typeService.get(dto.getTypeId())); - // var genres = dto.getGenres(); - // List genresList = genreService.getAllById(genres); - // for (var genre : genresList) { - // entity.setGenres(genre); - // } - // return entity; + // final GameEntity entity = modelMapper.map(dto, GameEntity.class); + // entity.setType(typeService.get(dto.getTypeId())); + // var genres = dto.getGenres(); + // List genresList = genreService.getAllById(genres); + // for (var genre : genresList) { + // entity.setGenres(genre); + // } + // return entity; // } private OrderEntity toOrderEntities(Collection dtos) { diff --git a/src/main/java/com/example/demo/users/api/UserProfileController.java b/src/main/java/com/example/demo/users/api/UserProfileController.java index f480f40..82b5db1 100644 --- a/src/main/java/com/example/demo/users/api/UserProfileController.java +++ b/src/main/java/com/example/demo/users/api/UserProfileController.java @@ -5,7 +5,10 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.example.demo.core.api.PageAttributesMapper; import com.example.demo.core.configuration.Constants; @@ -24,13 +27,9 @@ public class UserProfileController { private static final String PROFILE_VIEW = "profile"; private static final String PAGE_ATTRIBUTE = "page"; - private static final String TYPEID_ATTRIBUTE = "gameId"; - private static final String PROFILE_ATTRIBUTE = "profile"; private final OrderService orderService; private final GameService gameService; - private final UserService userService; - private final ModelMapper modelMapper; public UserProfileController( OrderService orderService, @@ -39,8 +38,6 @@ public class UserProfileController { ModelMapper modelMapper) { this.orderService = orderService; this.gameService = gameService; - this.userService = userService; - this.modelMapper = modelMapper; } private OrderDto toDto(OrderEntity entity) { @@ -64,12 +61,10 @@ public class UserProfileController { @GetMapping public String getProfile( @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, - @RequestParam(name = TYPEID_ATTRIBUTE, defaultValue = "0") int typeId, Model model, @AuthenticationPrincipal UserPrincipal principal) { final long userId = principal.getId(); model.addAttribute(PAGE_ATTRIBUTE, page); - model.addAttribute(TYPEID_ATTRIBUTE, typeId); model.addAllAttributes(PageAttributesMapper.toAttributes( orderService.getAll(userId, page, Constants.DEFAULT_PAGE_SIZE), this::toDto)); @@ -79,4 +74,15 @@ public class UserProfileController { .toList()); return PROFILE_VIEW; } + + @PostMapping("/delete/{id}") + public String deleteOrder( + @PathVariable(name = "id") Long id, + @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, + RedirectAttributes redirectAttributes, + @AuthenticationPrincipal UserPrincipal principal) { + redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page); + orderService.delete(principal.getId(), id); + return Constants.REDIRECT_VIEW + "/"; + } } diff --git a/src/main/resources/templates/cart.html b/src/main/resources/templates/cart.html index a19c372..c595b07 100644 --- a/src/main/resources/templates/cart.html +++ b/src/main/resources/templates/cart.html @@ -17,12 +17,15 @@ -

+
-
- [[${cartItem.gameName}]] +
+ Название: [[${cartItem.gameName}]]
+
+ Цена: [[${cartItem.Price}]] +
diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html index 2be9f25..0e7b41c 100644 --- a/src/main/resources/templates/default.html +++ b/src/main/resources/templates/default.html @@ -47,8 +47,6 @@ Консоль H2 - Ошибка 1 - Ошибка 2