Bans implemented

This commit is contained in:
Michael Wain 2025-02-03 03:42:42 +03:00
parent 5c2ffca131
commit 95f3eb887d
3 changed files with 21 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -114,8 +115,12 @@ public class AsyncController {
List<ServerActionCData> cdatas = new ArrayList<>(); List<ServerActionCData> cdatas = new ArrayList<>();
cdatas.add(new ServerActionConfig(items)); cdatas.add(new ServerActionConfig(items));
cdatas.add(new ServerActionSystem(1, "cache/resources.swf")); // swf/cache/rus/resources[19].swf cdatas.add(new ServerActionSystem(1, "cache/resources.swf")); // swf/cache/rus/resources[19].swf
cdatas.add(new ServerActionUser(user.getId(), AuthenticationUtil.getToken(user), AuthenticationUtil.getToken(user), 2)); if( !user.getIsBanned() ) {
cdatas.add(new ServerActionUser(user.getId(), AuthenticationUtil.getToken(user), AuthenticationUtil.getToken(user), 2, null, null));
cdatas.add(new ServerActionServers(s_items)); cdatas.add(new ServerActionServers(s_items));
} else {
cdatas.add(new ServerActionUser(user.getId(), null, null, 0, LocalDateTime.now(), 162L));
}
serverActionResult.setCdata(cdatas); serverActionResult.setCdata(cdatas);
return ResponseEntity.ok() return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_XML) .contentType(MediaType.APPLICATION_XML)

View File

@ -1,11 +1,15 @@
package com.alterdekim.game.controller.result.async; package com.alterdekim.game.controller.result.async;
import com.alterdekim.game.xml.LocalDateTimeSerializer;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDateTime;
@Setter @Setter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ -23,4 +27,11 @@ public class ServerActionUser extends ServerActionCData {
@JacksonXmlProperty(isAttribute = true, localName = "RoleFlags") @JacksonXmlProperty(isAttribute = true, localName = "RoleFlags")
private Integer roleFlags; private Integer roleFlags;
@JacksonXmlProperty(isAttribute = true, localName = "BanDateExpired")
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime banDateExpired;
@JacksonXmlProperty(isAttribute = true, localName = "BanTextResourceID")
private Long banTextResourceID;
} }

View File

@ -46,6 +46,9 @@ public class User {
inverseJoinColumns={@JoinColumn(name="ROLE_ID", referencedColumnName="ID")}) inverseJoinColumns={@JoinColumn(name="ROLE_ID", referencedColumnName="ID")})
private List<Role> roles = new ArrayList<>(); private List<Role> roles = new ArrayList<>();
@Column(nullable = false)
private Boolean isBanned = false;
public User(Long id, String username) { public User(Long id, String username) {
this.id = id; this.id = id;
this.username = username; this.username = username;