Locations added to control panel
This commit is contained in:
parent
95f3eb887d
commit
679ed915bf
@ -6,6 +6,8 @@ import com.alterdekim.game.message.amf.*;
|
|||||||
import com.alterdekim.game.message.serializer.BinaryMessageSerializer;
|
import com.alterdekim.game.message.serializer.BinaryMessageSerializer;
|
||||||
import com.alterdekim.game.utils.StringUtils;
|
import com.alterdekim.game.utils.StringUtils;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.javatuples.Pair;
|
import org.javatuples.Pair;
|
||||||
|
|
||||||
@ -13,10 +15,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ConnectedProcessor extends ConnectionProcessor {
|
public class ConnectedProcessor extends ConnectionProcessor {
|
||||||
@ -186,4 +185,35 @@ public class ConnectedProcessor extends ConnectionProcessor {
|
|||||||
return Unknown;
|
return Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RTMPSession {
|
||||||
|
private int windowBytesRead;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int acknowledgementWindowSize = Integer.MAX_VALUE;
|
||||||
|
private int totalBytesRead = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int chunkSize = 128;
|
||||||
|
|
||||||
|
private Map<Byte, ChunkStreamInfo> chunkStreams = new HashMap<>();
|
||||||
|
|
||||||
|
public ChunkStreamInfo getChunkStreamInfo(byte chunkStreamId) {
|
||||||
|
ChunkStreamInfo chunkStreamInfo = chunkStreams.get(chunkStreamId);
|
||||||
|
if (chunkStreamInfo == null) {
|
||||||
|
chunkStreamInfo = new ChunkStreamInfo();
|
||||||
|
chunkStreams.put(chunkStreamId, chunkStreamInfo);
|
||||||
|
}
|
||||||
|
return chunkStreamInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChunkStreamInfo {
|
||||||
|
private static final byte RTMP_STREAM_CHANNEL = 0x08;
|
||||||
|
private static final byte RTMP_COMMAND_CHANNEL = 0x03;
|
||||||
|
private static final byte CONTROL_CHANNEL = 0x02;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,11 @@ import com.alterdekim.game.controller.result.api.ApiResult;
|
|||||||
import com.alterdekim.game.controller.result.api.PreloaderResult;
|
import com.alterdekim.game.controller.result.api.PreloaderResult;
|
||||||
import com.alterdekim.game.controller.result.api.PromotionBannerResult;
|
import com.alterdekim.game.controller.result.api.PromotionBannerResult;
|
||||||
import com.alterdekim.game.controller.result.api.PromotionResult;
|
import com.alterdekim.game.controller.result.api.PromotionResult;
|
||||||
|
import com.alterdekim.game.entity.Location;
|
||||||
import com.alterdekim.game.entity.Preloader;
|
import com.alterdekim.game.entity.Preloader;
|
||||||
import com.alterdekim.game.entity.Promotion;
|
import com.alterdekim.game.entity.Promotion;
|
||||||
import com.alterdekim.game.entity.PromotionBanner;
|
import com.alterdekim.game.entity.PromotionBanner;
|
||||||
import com.alterdekim.game.service.PreloaderService;
|
import com.alterdekim.game.service.*;
|
||||||
import com.alterdekim.game.service.PromotionBannerService;
|
|
||||||
import com.alterdekim.game.service.PromotionService;
|
|
||||||
import com.alterdekim.game.service.UserService;
|
|
||||||
import com.alterdekim.game.utils.DateUtils;
|
import com.alterdekim.game.utils.DateUtils;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@ -67,12 +65,16 @@ public class ApiController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PromotionBannerService promotionBannerService;
|
private PromotionBannerService promotionBannerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LocationService locationService;
|
||||||
|
|
||||||
@PostMapping("/delete_row")
|
@PostMapping("/delete_row")
|
||||||
public ResponseEntity deleteRow(@RequestParam("table") APITable table, @RequestParam("row") Long rowId) {
|
public ResponseEntity deleteRow(@RequestParam("table") APITable table, @RequestParam("row") Long rowId) {
|
||||||
switch (table) {
|
switch (table) {
|
||||||
case Preloaders -> preloaderService.removeById(rowId);
|
case Preloaders -> preloaderService.removeById(rowId);
|
||||||
case Promotions -> promotionService.removeById(rowId);
|
case Promotions -> promotionService.removeById(rowId);
|
||||||
case Banners -> promotionBannerService.removeById(rowId);
|
case Banners -> promotionBannerService.removeById(rowId);
|
||||||
|
case Locations -> locationService.removeById(rowId);
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@ -101,7 +103,8 @@ public class ApiController {
|
|||||||
public enum APITable {
|
public enum APITable {
|
||||||
Preloaders("preloaders", Preloader.class, StaticController.PanelSection.Preloaders),
|
Preloaders("preloaders", Preloader.class, StaticController.PanelSection.Preloaders),
|
||||||
Promotions("promotions", Promotion.class, StaticController.PanelSection.Preloaders),
|
Promotions("promotions", Promotion.class, StaticController.PanelSection.Preloaders),
|
||||||
Banners("promotion_banners", PromotionBanner.class, StaticController.PanelSection.Preloaders);
|
Banners("promotion_banners", PromotionBanner.class, StaticController.PanelSection.Preloaders),
|
||||||
|
Locations("locations", Location.class, StaticController.PanelSection.Locations);
|
||||||
|
|
||||||
private final String val;
|
private final String val;
|
||||||
private final Class<?> cl;
|
private final Class<?> cl;
|
||||||
@ -147,6 +150,7 @@ public class ApiController {
|
|||||||
case Preloaders -> preloaderService.getAll();
|
case Preloaders -> preloaderService.getAll();
|
||||||
case Promotions -> promotionService.getAll();
|
case Promotions -> promotionService.getAll();
|
||||||
case Banners -> promotionBannerService.getAll();
|
case Banners -> promotionBannerService.getAll();
|
||||||
|
case Locations -> locationService.getAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.alterdekim.game.controller.result.api;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LocationResult {
|
||||||
|
@JsonProperty
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private Long locationId;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private Long mediaResourceId;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private Double x;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private Double y;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private Boolean isDefault;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private Boolean isEnabled;
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package com.alterdekim.game.entity;
|
package com.alterdekim.game.entity;
|
||||||
|
|
||||||
|
import com.alterdekim.game.controller.result.api.ApiResult;
|
||||||
|
import com.alterdekim.game.controller.result.api.LocationResult;
|
||||||
|
import com.alterdekim.game.controller.result.api.PreloaderResult;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -11,7 +14,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@Getter
|
@Getter
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "locations")
|
@Table(name = "locations")
|
||||||
public class Location {
|
public class Location implements ApiResult {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@ -46,4 +49,9 @@ public class Location {
|
|||||||
this.isDefault = isDefault;
|
this.isDefault = isDefault;
|
||||||
this.isEnabled = isEnabled;
|
this.isEnabled = isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocationResult toAPIResult() {
|
||||||
|
return new LocationResult(this.id, this.locationId, this.mediaResourceId, this.x, this.y, this.name, this.isDefault, this.isEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -27,4 +28,12 @@ public class LocationService {
|
|||||||
public void addLocation(Location location) {
|
public void addLocation(Location location) {
|
||||||
this.repository.save(location);
|
this.repository.save(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> getAll() {
|
||||||
|
return repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeById(Long id) {
|
||||||
|
this.repository.deleteById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,15 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</th:block>
|
</th:block>
|
||||||
|
<th:block th:case="Locations">
|
||||||
|
<h2>Locations<a href="?section=Add&table=Locations"><img src="/file/svg/plus-square.svg" class="add-btn"></a></h2>
|
||||||
|
<table id="locations" aria-busy="true">
|
||||||
|
<thead>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</th:block>
|
||||||
<th:block th:case="Add">
|
<th:block th:case="Add">
|
||||||
<blockquote id="error_response" style="display: none">
|
<blockquote id="error_response" style="display: none">
|
||||||
An internal server error occurred
|
An internal server error occurred
|
||||||
|
Loading…
x
Reference in New Issue
Block a user