update minecraft server/client
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package com.imyeyu.api.modules.forevermc.bean;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.Server;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ -17,6 +19,8 @@ import java.util.List;
|
||||
@Data
|
||||
public class ServerStatus implements Cloneable {
|
||||
|
||||
@Valid
|
||||
@NotBlank
|
||||
private String id;
|
||||
|
||||
/** true 为维护中 */
|
||||
@ -60,7 +64,7 @@ public class ServerStatus implements Cloneable {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class BaseInfo extends Server implements Cloneable {
|
||||
public static class BaseInfo extends Server {
|
||||
|
||||
/** 核心 */
|
||||
private String core;
|
||||
@ -76,14 +80,6 @@ public class ServerStatus implements Cloneable {
|
||||
|
||||
/** 游戏版本 */
|
||||
private String version;
|
||||
|
||||
// @Override
|
||||
// protected BaseInfo clone() throws CloneNotSupportedException {
|
||||
// BaseInfo clone = (BaseInfo) super.clone();
|
||||
// clone.core = core;
|
||||
// clone.bootAt = bootAt;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
package com.imyeyu.api.modules.forevermc.controller;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPackSrc;
|
||||
import com.imyeyu.api.modules.forevermc.service.ClientPackService;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-07-24 21:43
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/fmc/client")
|
||||
public class ClientPackController {
|
||||
|
||||
private final ClientPackService service;
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequestMapping("/list")
|
||||
public PageResult<ClientPack> listClientPack(@RequestBody Page page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequestMapping("/src/{clientId}")
|
||||
public List<ClientPackSrc> listClientPackSrc(@PathVariable("clientId") long clientId) {
|
||||
return service.listClientPackSrc(clientId);
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,19 @@
|
||||
package com.imyeyu.api.modules.forevermc.controller;
|
||||
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.api.modules.forevermc.bean.ServerStatus;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.api.modules.forevermc.service.ClientPackService;
|
||||
import com.imyeyu.api.modules.forevermc.service.ServerService;
|
||||
import com.imyeyu.api.modules.minecraft.annotation.RequiredFMCServerToken;
|
||||
import com.imyeyu.api.modules.minecraft.vo.server.ReportRequest;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.utils.Decoder;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -44,6 +48,7 @@ import java.util.List;
|
||||
public class ServerController {
|
||||
|
||||
private final ServerService service;
|
||||
private final ClientPackService clientService;
|
||||
|
||||
/**
|
||||
* 服务器状态报告,由 FMCServer 服务端插件发送
|
||||
@ -88,6 +93,13 @@ public class ServerController {
|
||||
}
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@GetMapping("/client/{serverId}")
|
||||
public List<ClientPack> listClientPack(@PathVariable("serverId") String serverId) {
|
||||
return service.listClientPack(serverId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器状态列表
|
||||
*
|
||||
@ -112,4 +124,10 @@ public class ServerController {
|
||||
result.sort(Comparator.comparingInt(o -> o.getBaseInfo().getOrder()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestRateLimit
|
||||
@PostMapping("/client/list")
|
||||
public PageResult<ClientPack> listClient(@RequestBody Page page) {
|
||||
return clientService.page(page);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.imyeyu.api.modules.forevermc.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.Column;
|
||||
import com.imyeyu.spring.entity.Entity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 服务器客户端
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-01-27 20:40
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ClientPack extends Entity {
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 说明 */
|
||||
private String description;
|
||||
|
||||
/** 游戏 ID */
|
||||
private String gameId;
|
||||
|
||||
/** 游戏版本 */
|
||||
private String gameVersion;
|
||||
|
||||
/** 客户端版本 */
|
||||
private String version;
|
||||
|
||||
/** 需要运行时版本 */
|
||||
private String runtimeVersion;
|
||||
|
||||
/** 文件大小 */
|
||||
private Long size;
|
||||
|
||||
/** true 为支持 FMC 授权验证 */
|
||||
@Column("can_fmc_auth")
|
||||
private Boolean canFMCAuth;
|
||||
|
||||
/** true 为已过时 */
|
||||
private boolean isDeprecated;
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package com.imyeyu.api.modules.forevermc.entity;
|
||||
|
||||
import com.imyeyu.spring.entity.Entity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.imyeyu.spring.entity.Entity;
|
||||
|
||||
/**
|
||||
* 服务器客户端下载源
|
||||
@ -12,7 +12,7 @@ import com.imyeyu.spring.entity.Entity;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ServerClientSrc extends Entity {
|
||||
public class ClientPackSrc extends Entity {
|
||||
|
||||
/**
|
||||
* 下载源类型
|
||||
@ -32,12 +32,9 @@ public class ServerClientSrc extends Entity {
|
||||
URL
|
||||
}
|
||||
|
||||
/** 客户端 ID,关联 {@link ServerClient#getId()} */
|
||||
/** 客户端 ID,关联 {@link ClientPack#getId()} */
|
||||
private Long clientId;
|
||||
|
||||
/** 服务器 ID,关联 {@link Server#getId()} */
|
||||
private String serverId;
|
||||
|
||||
/** 下载源类型 */
|
||||
private BizType bizType;
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
package com.imyeyu.api.modules.forevermc.entity;
|
||||
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.Destroyable;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器
|
||||
*
|
||||
@ -36,6 +33,9 @@ public class Server extends UUIDEntity implements Destroyable {
|
||||
/** 上级服务器 ID */
|
||||
protected String pid;
|
||||
|
||||
/** 类型 */
|
||||
protected Type type;
|
||||
|
||||
/** 标题 */
|
||||
protected String title;
|
||||
|
||||
@ -45,13 +45,6 @@ public class Server extends UUIDEntity implements Destroyable {
|
||||
/** 地址 */
|
||||
protected String host;
|
||||
|
||||
/** 类型 */
|
||||
protected Type type;
|
||||
|
||||
/** 排序 */
|
||||
protected int order;
|
||||
|
||||
/** 客户端列表 */
|
||||
@Transient
|
||||
protected List<ServerClient> clientList;
|
||||
}
|
||||
|
||||
@ -1,40 +1,15 @@
|
||||
package com.imyeyu.api.modules.forevermc.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.Entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器客户端
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-01-27 20:40
|
||||
* @since 2025-07-23 21:54
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ServerClient extends Entity {
|
||||
public class ServerClient {
|
||||
|
||||
/** 服务器 ID,关联 {@link Server#getId()} */
|
||||
private String serverId;
|
||||
|
||||
/** 文件名 */
|
||||
private String fileName;
|
||||
|
||||
/** 客户端版本 */
|
||||
private String version;
|
||||
|
||||
/** 默认配置 */
|
||||
private String defOption;
|
||||
|
||||
/** 文件大小 */
|
||||
private Long size;
|
||||
|
||||
/** true 为已过时 */
|
||||
private boolean isDeprecated;
|
||||
|
||||
@Transient
|
||||
private List<ServerClientSrc> srcList;
|
||||
private Long clientId;
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.imyeyu.api.modules.forevermc.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-02-07 17:03
|
||||
*/
|
||||
public interface ClientPackMapper extends BaseMapper<ClientPack, Long> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.imyeyu.api.modules.forevermc.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPackSrc;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-02-07 17:20
|
||||
*/
|
||||
public interface ClientPackSrcMapper extends BaseMapper<ClientPackSrc, Long> {
|
||||
|
||||
@Select("SELECT * FROM client_pack_src WHERE client_id = #{clientId}" + NOT_DELETE + " ORDER BY `order` ASC")
|
||||
List<ClientPackSrc> selectByClientId(long clientId);
|
||||
}
|
||||
@ -1,17 +1,14 @@
|
||||
package com.imyeyu.api.modules.forevermc.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ServerClient;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-02-07 17:03
|
||||
* @since 2025-07-23 22:03
|
||||
*/
|
||||
public interface ServerClientMapper extends BaseMapper<ServerClient, Long> {
|
||||
public interface ServerClientMapper {
|
||||
|
||||
@Select("SELECT * FROM server_client WHERE server_id = #{serverId}" + NOT_DELETE)
|
||||
List<ServerClient> selectByServerId(String serverId);
|
||||
List<ClientPack> selectByServerId(String serverId);
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package com.imyeyu.api.modules.forevermc.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ServerClientSrc;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-02-07 17:20
|
||||
*/
|
||||
public interface ServerClientSrcMapper extends BaseMapper<ServerClientSrc, Long> {
|
||||
|
||||
@Select("SELECT * FROM server_client_src WHERE client_id = #{clientId}" + NOT_DELETE + " ORDER BY order ASC")
|
||||
List<ServerClientSrc> selectByClientId(Long clientId);
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.imyeyu.api.modules.forevermc.service;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPackSrc;
|
||||
import com.imyeyu.spring.service.DeletableService;
|
||||
import com.imyeyu.spring.service.GettableService;
|
||||
import com.imyeyu.spring.service.PageableService;
|
||||
import com.imyeyu.spring.service.UpdatableService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-07-23 16:59
|
||||
*/
|
||||
public interface ClientPackService extends PageableService<ClientPack>, GettableService<ClientPack, Long>, UpdatableService<ClientPack>, DeletableService<Long> {
|
||||
|
||||
List<ClientPackSrc> listClientPackSrc(long clientId);
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
package com.imyeyu.api.modules.forevermc.service;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.bean.ServerStatus;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.api.modules.minecraft.vo.server.ReportRequest;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.api.modules.forevermc.bean.ServerStatus;
|
||||
import com.imyeyu.api.modules.minecraft.vo.server.ReportRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -23,6 +24,8 @@ public interface ServerService extends TimiJava {
|
||||
*/
|
||||
void report(ReportRequest request);
|
||||
|
||||
List<ClientPack> listClientPack(String serverId);
|
||||
|
||||
String getIcon(String serverId);
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.imyeyu.api.modules.forevermc.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPackSrc;
|
||||
import com.imyeyu.api.modules.forevermc.mapper.ClientPackMapper;
|
||||
import com.imyeyu.api.modules.forevermc.mapper.ClientPackSrcMapper;
|
||||
import com.imyeyu.api.modules.forevermc.service.ClientPackService;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2025-07-23 16:59
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ClientPackServiceImplement extends AbstractEntityService<ClientPack, Long> implements ClientPackService {
|
||||
|
||||
private final ClientPackMapper mapper;
|
||||
private final ClientPackSrcMapper srcMapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<ClientPack, Long> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClientPackSrc> listClientPackSrc(long clientId) {
|
||||
return srcMapper.selectByClientId(clientId);
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,15 @@
|
||||
package com.imyeyu.api.modules.forevermc.service.implement;
|
||||
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.api.modules.forevermc.bean.ServerStatus;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ClientPack;
|
||||
import com.imyeyu.api.modules.forevermc.entity.Server;
|
||||
import com.imyeyu.api.modules.forevermc.entity.ServerClient;
|
||||
import com.imyeyu.api.modules.forevermc.mapper.ServerClientMapper;
|
||||
import com.imyeyu.api.modules.forevermc.mapper.ServerClientSrcMapper;
|
||||
import com.imyeyu.api.modules.forevermc.mapper.ServerMapper;
|
||||
import com.imyeyu.api.modules.forevermc.service.ServerService;
|
||||
import com.imyeyu.api.modules.minecraft.vo.server.ReportRequest;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -36,7 +35,6 @@ public class ServerServiceImplement implements ServerService {
|
||||
|
||||
private final ServerMapper serverMapper;
|
||||
private final ServerClientMapper serverClientMapper;
|
||||
private final ServerClientSrcMapper serverClientSrcMapper;
|
||||
|
||||
private final Map<String, ServerStatus> serverMap = new HashMap<>();
|
||||
|
||||
@ -50,13 +48,6 @@ public class ServerServiceImplement implements ServerService {
|
||||
}
|
||||
Server server = serverMapper.select(item.getKey());
|
||||
TimiException.required(server, "not found server");
|
||||
|
||||
List<ServerClient> clientList = serverClientMapper.selectByServerId(server.getId());
|
||||
for (int i = 0; i < clientList.size(); i++) {
|
||||
ServerClient client = clientList.get(i);
|
||||
client.setSrcList(serverClientSrcMapper.selectByClientId(client.getId()));
|
||||
}
|
||||
server.setClientList(clientList);
|
||||
BeanUtils.copyProperties(server, item.getValue().getBaseInfo());
|
||||
}
|
||||
}
|
||||
@ -74,6 +65,11 @@ public class ServerServiceImplement implements ServerService {
|
||||
serverMap.put(request.getId(), request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClientPack> listClientPack(String serverId) {
|
||||
return serverClientMapper.selectByServerId(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIcon(String serverId) {
|
||||
ServerStatus status = serverMap.get(serverId);
|
||||
|
||||
Reference in New Issue
Block a user