全部
This commit is contained in:
@ -25,7 +25,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
public class AuthAspect {
|
public class AuthAspect {
|
||||||
|
|
||||||
// 授权文件路径
|
// 授权文件路径
|
||||||
private static final String LICENSE_FILE_PATH = "license/yjearth.lic";
|
private static final String LICENSE_FILE_PATH = "license/yjearth.yj";
|
||||||
|
|
||||||
@Pointcut("@annotation(com.yj.earth.annotation.CheckAuth)")
|
@Pointcut("@annotation(com.yj.earth.annotation.CheckAuth)")
|
||||||
public void authPointCut() {
|
public void authPointCut() {
|
||||||
|
|||||||
@ -79,8 +79,8 @@ public class AuthGenerator {
|
|||||||
// 生成加密的授权字符串
|
// 生成加密的授权字符串
|
||||||
String authContent = generateAuth("标准版", 1000, 365, "196CB2226A5D5334B9C065ECFC77F4B9");
|
String authContent = generateAuth("标准版", 1000, 365, "196CB2226A5D5334B9C065ECFC77F4B9");
|
||||||
|
|
||||||
// 定义授权文件路径(当前目录下的 yjearth.lic)
|
// 定义授权文件路径(当前目录下的 yjearth.yj)
|
||||||
Path licPath = Paths.get("yjearth.lic");
|
Path licPath = Paths.get("yjearth.yj");
|
||||||
|
|
||||||
// 将授权字符串写入文件
|
// 将授权字符串写入文件
|
||||||
Files.write(licPath, authContent.getBytes(StandardCharsets.UTF_8));
|
Files.write(licPath, authContent.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import java.nio.file.Paths;
|
|||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
// 授权文件存储路径、项目根目录下的 license 目录
|
// 授权文件存储路径、项目根目录下的 license 目录
|
||||||
private static final String AUTH_FILE_PATH = "license/yjearth.lic";
|
private static final String AUTH_FILE_PATH = "license/yjearth.yj";
|
||||||
|
|
||||||
@GetMapping("/info")
|
@GetMapping("/info")
|
||||||
@Operation(summary = "获取系统授权码")
|
@Operation(summary = "获取系统授权码")
|
||||||
@ -37,10 +37,10 @@ public class AuthController {
|
|||||||
return ApiResponse.failure("请选择授权文件");
|
return ApiResponse.failure("请选择授权文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证文件名是否为 yjearth.lic
|
// 验证文件名是否为 yjearth.yj
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
if (fileName == null || !fileName.equals("yjearth.lic")) {
|
if (fileName == null || !fileName.equals("yjearth.yj")) {
|
||||||
return ApiResponse.failure("请上传 yjearth.lic");
|
return ApiResponse.failure("请上传 yjearth.yj");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -4,18 +4,24 @@ import cn.hutool.core.io.FileUtil;
|
|||||||
import cn.hutool.core.lang.UUID;
|
import cn.hutool.core.lang.UUID;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.yj.earth.annotation.CheckAuth;
|
import com.yj.earth.annotation.CheckAuth;
|
||||||
|
import com.yj.earth.business.domain.Model;
|
||||||
import com.yj.earth.business.domain.ModelLibrary;
|
import com.yj.earth.business.domain.ModelLibrary;
|
||||||
import com.yj.earth.business.domain.ModelType;
|
import com.yj.earth.business.domain.ModelType;
|
||||||
|
import com.yj.earth.business.domain.Source;
|
||||||
import com.yj.earth.business.service.FileInfoService;
|
import com.yj.earth.business.service.FileInfoService;
|
||||||
import com.yj.earth.business.service.ModelLibraryService;
|
import com.yj.earth.business.service.ModelLibraryService;
|
||||||
|
import com.yj.earth.business.service.SourceService;
|
||||||
import com.yj.earth.common.util.ApiResponse;
|
import com.yj.earth.common.util.ApiResponse;
|
||||||
import com.yj.earth.common.util.FileCommonUtil;
|
import com.yj.earth.common.util.FileCommonUtil;
|
||||||
|
import com.yj.earth.common.util.JsonUtil;
|
||||||
import com.yj.earth.common.util.SQLiteUtil;
|
import com.yj.earth.common.util.SQLiteUtil;
|
||||||
import com.yj.earth.dto.militaryLibrary.DragMilitaryTypeDto;
|
import com.yj.earth.dto.militaryLibrary.DragMilitaryTypeDto;
|
||||||
import com.yj.earth.dto.modelLibrary.AddModelTypeDto;
|
import com.yj.earth.dto.modelLibrary.AddModelTypeDto;
|
||||||
import com.yj.earth.dto.modelLibrary.CreateModelLibraryDto;
|
import com.yj.earth.dto.modelLibrary.CreateModelLibraryDto;
|
||||||
import com.yj.earth.dto.modelLibrary.DragModelTypeDto;
|
import com.yj.earth.dto.modelLibrary.DragModelTypeDto;
|
||||||
import com.yj.earth.dto.modelLibrary.UpdateModelTypeNameDto;
|
import com.yj.earth.dto.modelLibrary.UpdateModelTypeNameDto;
|
||||||
|
import com.yj.earth.params.ModelParam;
|
||||||
|
import com.yj.earth.params.Point;
|
||||||
import com.yj.earth.vo.IconDataVo;
|
import com.yj.earth.vo.IconDataVo;
|
||||||
import com.yj.earth.vo.ModelDataVo;
|
import com.yj.earth.vo.ModelDataVo;
|
||||||
import com.yj.earth.vo.ModelTypeVo;
|
import com.yj.earth.vo.ModelTypeVo;
|
||||||
@ -24,6 +30,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@ -51,7 +58,13 @@ public class ModelLibraryController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ModelLibraryService modelLibraryService;
|
private ModelLibraryService modelLibraryService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private SourceService sourceService;
|
||||||
|
@Resource
|
||||||
private FileInfoService fileInfoService;
|
private FileInfoService fileInfoService;
|
||||||
|
@Value("${server.host}")
|
||||||
|
private String serverHost;
|
||||||
|
@Value("${server.port}")
|
||||||
|
private int serverPort;
|
||||||
|
|
||||||
@Operation(summary = "创建模型库")
|
@Operation(summary = "创建模型库")
|
||||||
@PostMapping("/createModelLibrary")
|
@PostMapping("/createModelLibrary")
|
||||||
@ -372,11 +385,41 @@ public class ModelLibraryController {
|
|||||||
if (modelPath == null) {
|
if (modelPath == null) {
|
||||||
return ApiResponse.failure("请先创建或导入模型库");
|
return ApiResponse.failure("请先创建或导入模型库");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 存储被删除的Source ID列表
|
||||||
|
List<String> deletedSourceIds = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取URL
|
||||||
|
String modelDataUrlByModelId = getModelDataUrlByModelId(modelId);
|
||||||
|
// 查询资源
|
||||||
|
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
// 查询类型为 model 的
|
||||||
|
queryWrapper.eq(Source::getSourceType, "model");
|
||||||
|
// 查询列表
|
||||||
|
List<Source> sourceList = sourceService.list(queryWrapper);
|
||||||
|
// 遍历数据
|
||||||
|
for (Source source : sourceList) {
|
||||||
|
// 取出 params 字段
|
||||||
|
String dataParams = source.getParams();
|
||||||
|
if (dataParams != null) {
|
||||||
|
// 转换为 Model 对象
|
||||||
|
ModelParam modelParam = JsonUtil.jsonToObject(dataParams, ModelParam.class);
|
||||||
|
if (modelDataUrlByModelId.equals(modelParam.getUrl())) {
|
||||||
|
// 删除这个资源
|
||||||
|
sourceService.removeById(source.getId());
|
||||||
|
// 添加到被删除的ID列表
|
||||||
|
deletedSourceIds.add(source.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String sql = "DELETE FROM model WHERE id = ?";
|
String sql = "DELETE FROM model WHERE id = ?";
|
||||||
List<Object> params = new ArrayList<>();
|
List<Object> params = new ArrayList<>();
|
||||||
params.add(modelId);
|
params.add(modelId);
|
||||||
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
||||||
return ApiResponse.success(null);
|
|
||||||
|
// 返回被删除的Source ID列表
|
||||||
|
return ApiResponse.success(deletedSourceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "拖动层级")
|
@Operation(summary = "拖动层级")
|
||||||
@ -573,6 +616,32 @@ public class ModelLibraryController {
|
|||||||
return existTypes != null && !existTypes.isEmpty();
|
return existTypes != null && !existTypes.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据模型ID获取模型数据访问URL
|
||||||
|
*/
|
||||||
|
private String getModelDataUrlByModelId(String modelId) {
|
||||||
|
try {
|
||||||
|
// 获取当前启用的模型库路径
|
||||||
|
String modelPath = getModelLibrary();
|
||||||
|
if (modelPath == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询模型对应的类型后缀
|
||||||
|
String sql = "SELECT model_type FROM model WHERE id = ?";
|
||||||
|
List<Object> params = new ArrayList<>();
|
||||||
|
params.add(modelId);
|
||||||
|
Model model = SQLiteUtil.queryForObject(modelPath, sql, params, Model.class);
|
||||||
|
// 得到类型ID
|
||||||
|
String modelType = model.getModelType();
|
||||||
|
// 拼接完整URL
|
||||||
|
return "http://" + serverHost + ":" + serverPort + "/modelLibrary/data/model/" + modelId + "/" + modelType;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String trimDot(String str) {
|
private String trimDot(String str) {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@SourceType("model")
|
@SourceType("model")
|
||||||
public class Model {
|
public class ModelParam {
|
||||||
private String id;
|
private String id;
|
||||||
private Position position;
|
private Position position;
|
||||||
private String name;
|
private String name;
|
||||||
Reference in New Issue
Block a user