军标库
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
package com.yj.earth.business.controller;
|
||||
|
||||
import com.yj.earth.annotation.CheckAuth;
|
||||
import com.yj.earth.business.domain.BusinessConfig;
|
||||
import com.yj.earth.business.service.BusinessConfigService;
|
||||
import com.yj.earth.common.util.ApiResponse;
|
||||
import com.yj.earth.dto.businessConfig.AddBusinessConfigDto;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Tag(name = "业务配置管理")
|
||||
@CheckAuth
|
||||
@RestController
|
||||
@RequestMapping("/businessConfig")
|
||||
public class BusinessConfigController {
|
||||
@Resource
|
||||
private BusinessConfigService businessConfigService;
|
||||
|
||||
@Operation(summary = "业务配置列表")
|
||||
@GetMapping("/list")
|
||||
public ApiResponse list() {
|
||||
return ApiResponse.success(businessConfigService.list());
|
||||
}
|
||||
|
||||
@PostMapping("/addBusinessConfig")
|
||||
@Operation(summary = "新增业务配置")
|
||||
public ApiResponse addBusinessConfig(@RequestBody AddBusinessConfigDto addBusinessConfigDto) {
|
||||
BusinessConfig businessConfig = new BusinessConfig();
|
||||
BeanUtils.copyProperties(addBusinessConfigDto, businessConfig);
|
||||
return ApiResponse.success(businessConfigService.save(businessConfig));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,396 @@
|
||||
package com.yj.earth.business.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.yj.earth.annotation.CheckAuth;
|
||||
import com.yj.earth.business.domain.IconLibrary;
|
||||
import com.yj.earth.business.domain.IconType;
|
||||
import com.yj.earth.business.service.FileInfoService;
|
||||
import com.yj.earth.business.service.IconLibraryService;
|
||||
import com.yj.earth.common.util.ApiResponse;
|
||||
import com.yj.earth.common.util.SQLiteUtil;
|
||||
import com.yj.earth.dto.iconLibrary.AddIconTypeDto;
|
||||
import com.yj.earth.dto.iconLibrary.CreateIconLibraryDto;
|
||||
import com.yj.earth.dto.iconLibrary.DragIconTypeDto;
|
||||
import com.yj.earth.dto.iconLibrary.UpdateIconTypeNameDto;
|
||||
import com.yj.earth.vo.IconTypeVo;
|
||||
import com.yj.earth.vo.IconVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "图标库管理")
|
||||
@CheckAuth
|
||||
@RestController
|
||||
@RequestMapping("/iconLibrary")
|
||||
public class IconLibraryController {
|
||||
@Resource
|
||||
private IconLibraryService iconLibraryService;
|
||||
@Resource
|
||||
private FileInfoService fileInfoService;
|
||||
|
||||
@Operation(summary = "创建图标库")
|
||||
@PostMapping("/createIconLibrary")
|
||||
public ApiResponse createIconLibrary(@RequestBody CreateIconLibraryDto createIconLibraryDto) {
|
||||
try {
|
||||
// 参数校验与路径处理
|
||||
String folderPath = createIconLibraryDto.getPath();
|
||||
String iconName = createIconLibraryDto.getName();
|
||||
File parentDir = new File(folderPath);
|
||||
File iconFile = new File(parentDir, iconName);
|
||||
String iconPath = iconFile.getAbsolutePath().replace("\\", "/");
|
||||
|
||||
// 检查父目录(不存在则创建)
|
||||
if (!parentDir.exists()) {
|
||||
boolean mkdirsSuccess = parentDir.mkdirs();
|
||||
if (!mkdirsSuccess) {
|
||||
return ApiResponse.failure("创建图标库父目录失败:" + folderPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查图标库文件是否已存在
|
||||
if (iconFile.exists()) {
|
||||
if (iconFile.isDirectory()) {
|
||||
return ApiResponse.failure("同名目录已存在、无法创建图标库文件:" + iconPath);
|
||||
}
|
||||
return ApiResponse.failure("图标库文件已存在:" + iconPath);
|
||||
}
|
||||
|
||||
// 创建图标库文件
|
||||
boolean createSuccess = iconFile.createNewFile();
|
||||
if (!createSuccess) {
|
||||
return ApiResponse.failure("创建图标库文件失败:" + iconPath);
|
||||
}
|
||||
|
||||
// 新增图标库记录并初始化SQLite表结构
|
||||
addIconLibrary(iconPath);
|
||||
SQLiteUtil.initializationIcon(iconPath);
|
||||
return ApiResponse.success(null);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.failure("创建图标库失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "导入图标库")
|
||||
@PostMapping("/importIconLibrary")
|
||||
public ApiResponse importIconLibrary(@RequestParam("iconPath") @Parameter(description = "图标库路径") String iconPath) {
|
||||
addIconLibrary(iconPath);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加图标类型")
|
||||
@PostMapping("/addIconType")
|
||||
public ApiResponse addIconType(@RequestBody AddIconTypeDto addIconTypeDto) throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 检查父级图标类型是否存在
|
||||
String parentId = addIconTypeDto.getParentId();
|
||||
if (parentId != null) {
|
||||
String sql = "SELECT * FROM icon_type WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(parentId);
|
||||
IconType iconType = SQLiteUtil.queryForObject(iconPath, sql, params, IconType.class);
|
||||
if (iconType == null) {
|
||||
return ApiResponse.failure("父级图标类型不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 插入图标类型
|
||||
String sql = "INSERT INTO icon_type " +
|
||||
"(id, name, parent_id, tree_index, created_at) " +
|
||||
"VALUES (?, ?, ?, ?, ?)";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(UUID.fastUUID().toString(true));
|
||||
params.add(addIconTypeDto.getName());
|
||||
params.add(addIconTypeDto.getParentId());
|
||||
params.add(0);
|
||||
params.add(LocalDateTime.now());
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除图标类型")
|
||||
@PostMapping("/deleteIconType")
|
||||
public ApiResponse deleteIconType(@Parameter(description = "图标类型ID") @RequestParam("iconTypeId") String iconTypeId) throws SQLException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 删除图标类型
|
||||
String sql = "DELETE FROM icon_type WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(iconTypeId);
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改图标类型名称")
|
||||
@PostMapping("/updateIconTypeName")
|
||||
public ApiResponse updateIconTypeName(@RequestBody UpdateIconTypeNameDto updateIconTypeNameDto) throws SQLException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 更新图标类型名称
|
||||
String sql = "UPDATE icon_type SET name = ? WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(updateIconTypeNameDto.getName());
|
||||
params.add(updateIconTypeNameDto.getId());
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "图标类型列表")
|
||||
@GetMapping("/iconTypeTree")
|
||||
public ApiResponse iconTypeTree() throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 查询所有图标类型
|
||||
String sql = """
|
||||
SELECT id, name, parent_id as parentId,
|
||||
tree_index as treeIndex, created_at as createdAt,
|
||||
updated_at as updatedAt FROM icon_type ORDER BY tree_index ASC
|
||||
""";
|
||||
List<IconType> iconTypes = SQLiteUtil.queryForList(iconPath, sql, null, IconType.class);
|
||||
|
||||
// 构建树形结构
|
||||
List<IconTypeVo> treeList = buildIconTypeTree(iconTypes);
|
||||
return ApiResponse.success(treeList);
|
||||
}
|
||||
|
||||
@Operation(summary = "拖动图标类型树")
|
||||
@PostMapping("/dragIconType")
|
||||
public ApiResponse dragIconType(@RequestBody DragIconTypeDto dragIconTypeDto) throws SQLException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 动态构建更新SQL
|
||||
List<String> updateFields = new ArrayList<>();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (dragIconTypeDto.getParentId() != null) {
|
||||
updateFields.add("parent_id = ?");
|
||||
params.add(dragIconTypeDto.getParentId());
|
||||
}
|
||||
if (dragIconTypeDto.getTreeIndex() != null) {
|
||||
updateFields.add("tree_index = ?");
|
||||
params.add(dragIconTypeDto.getTreeIndex());
|
||||
}
|
||||
|
||||
String sql = "UPDATE icon_type SET " + String.join(", ", updateFields) + " WHERE id = ?";
|
||||
params.add(dragIconTypeDto.getId());
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加图标文件")
|
||||
@PostMapping("/addIconFile")
|
||||
public ApiResponse addIconFile(@RequestParam("files") MultipartFile[] files,
|
||||
@Parameter(description = "图标类型ID") @RequestParam("iconTypeId") String iconTypeId)
|
||||
throws IOException, SQLException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 循环处理上传文件
|
||||
for (MultipartFile file : files) {
|
||||
if (file.isEmpty()) continue;
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (fileName == null) continue;
|
||||
|
||||
String fileSuffix = FileUtil.extName(fileName);
|
||||
String fileNameWithoutSuffix = FileUtil.mainName(fileName);
|
||||
|
||||
// 上传文件并获取访问URL
|
||||
String url = fileInfoService.uploadWithPreview(file);
|
||||
|
||||
// 插入图标记录
|
||||
String sql = "INSERT INTO icon " +
|
||||
"(id, icon_type_id, icon_name, icon_type, data, created_at) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(UUID.fastUUID().toString(true));
|
||||
params.add(iconTypeId);
|
||||
params.add(fileNameWithoutSuffix);
|
||||
params.add(fileSuffix);
|
||||
params.add(url);
|
||||
params.add(LocalDateTime.now());
|
||||
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
}
|
||||
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据图标类型查看图标列表")
|
||||
@PostMapping("/iconList")
|
||||
public ApiResponse iconList(@Parameter(description = "图标类型ID") @RequestParam("iconTypeId") String iconTypeId)
|
||||
throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 多表联查图标数据
|
||||
String sql = """
|
||||
SELECT
|
||||
icon.id,
|
||||
icon.icon_type_id as iconTypeId,
|
||||
icon.icon_name as iconName,
|
||||
icon.icon_type as iconType,
|
||||
icon.data,
|
||||
icon.view,
|
||||
icon.created_at as createdAt,
|
||||
icon.updated_at as updatedAt,
|
||||
icon_type.name as iconTypeName
|
||||
FROM icon
|
||||
JOIN icon_type ON icon.icon_type_id = icon_type.id
|
||||
WHERE icon.icon_type_id = ?
|
||||
""";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(iconTypeId);
|
||||
List<IconVo> iconVos = SQLiteUtil.queryForList(iconPath, sql, params, IconVo.class);
|
||||
return ApiResponse.success(iconVos);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新图标信息")
|
||||
@PostMapping("/updateIconInfo")
|
||||
public ApiResponse updateIconInfo(@Parameter(description = "图标ID") @RequestParam("iconId") String iconId,
|
||||
@Parameter(description = "图标名称") @RequestParam(value = "iconName", required = false) String iconName)
|
||||
throws SQLException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 无更新字段直接返回成功
|
||||
if (!StringUtils.hasText(iconName)) {
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
// 更新图标名称
|
||||
String sql = "UPDATE icon SET updated_at = ?, icon_name = ? WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(LocalDateTime.now());
|
||||
params.add(iconName);
|
||||
params.add(iconId);
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除图标")
|
||||
@PostMapping("/deleteIcon")
|
||||
public ApiResponse deleteIcon(@Parameter(description = "图标ID") @RequestParam("iconId") String iconId) throws SQLException {
|
||||
String iconPath = getIconLibrary();
|
||||
if (iconPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入图标库");
|
||||
}
|
||||
|
||||
// 删除图标
|
||||
String sql = "DELETE FROM icon WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(iconId);
|
||||
SQLiteUtil.executeUpdate(iconPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建图标类型树形结构
|
||||
*
|
||||
* @param iconTypes 图标类型列表
|
||||
* @return 树形结构列表
|
||||
*/
|
||||
private List<IconTypeVo> buildIconTypeTree(List<IconType> iconTypes) {
|
||||
// 转换为VO列表
|
||||
List<IconTypeVo> treeNodes = iconTypes.stream()
|
||||
.map(IconTypeVo::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建ID到VO的映射(便于快速查找父节点)
|
||||
Map<String, IconTypeVo> nodeMap = treeNodes.stream()
|
||||
.collect(Collectors.toMap(IconTypeVo::getId, node -> node));
|
||||
|
||||
// 组装树形结构
|
||||
List<IconTypeVo> rootNodes = new ArrayList<>();
|
||||
for (IconTypeVo node : treeNodes) {
|
||||
String parentId = node.getParentId();
|
||||
if (parentId == null || parentId.isEmpty()) {
|
||||
// 无父节点 → 根节点
|
||||
rootNodes.add(node);
|
||||
} else {
|
||||
// 有父节点 → 加入父节点的子列表
|
||||
IconTypeVo parentNode = nodeMap.get(parentId);
|
||||
if (parentNode != null) {
|
||||
parentNode.getChildren().add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rootNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前启用的图标库路径
|
||||
*
|
||||
* @return 图标库路径(null表示无启用的图标库)
|
||||
*/
|
||||
private String getIconLibrary() {
|
||||
LambdaQueryWrapper<IconLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(IconLibrary::getIsEnable, 1);
|
||||
IconLibrary iconLibrary = iconLibraryService.getOne(queryWrapper);
|
||||
return iconLibrary == null ? null : iconLibrary.getPath();
|
||||
}
|
||||
|
||||
private void addIconLibrary(String iconPath) {
|
||||
// 查询所有图标库并置为禁用
|
||||
List<IconLibrary> iconLibraries = iconLibraryService.list();
|
||||
for (IconLibrary iconLibrary : iconLibraries) {
|
||||
iconLibrary.setIsEnable(0);
|
||||
iconLibraryService.updateById(iconLibrary);
|
||||
}
|
||||
|
||||
// 检查路径是否已存在(存在则启用、不存在则新增)
|
||||
LambdaQueryWrapper<IconLibrary> pathWrapper = new LambdaQueryWrapper<>();
|
||||
pathWrapper.eq(IconLibrary::getPath, iconPath);
|
||||
IconLibrary existingIconLib = iconLibraryService.getOne(pathWrapper);
|
||||
|
||||
if (existingIconLib != null) {
|
||||
existingIconLib.setIsEnable(1);
|
||||
iconLibraryService.updateById(existingIconLib);
|
||||
} else {
|
||||
// 新增图标库记录
|
||||
IconLibrary newIconLib = new IconLibrary();
|
||||
File iconFile = FileUtil.file(iconPath);
|
||||
newIconLib.setId(UUID.fastUUID().toString(true));
|
||||
newIconLib.setPath(iconPath);
|
||||
newIconLib.setName(FileUtil.extName(iconFile));
|
||||
newIconLib.setIsEnable(1);
|
||||
iconLibraryService.save(newIconLib);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,387 @@
|
||||
package com.yj.earth.business.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.yj.earth.annotation.CheckAuth;
|
||||
import com.yj.earth.business.domain.MilitaryLibrary;
|
||||
import com.yj.earth.business.domain.MilitaryType;
|
||||
import com.yj.earth.business.service.FileInfoService;
|
||||
import com.yj.earth.business.service.MilitaryLibraryService;
|
||||
import com.yj.earth.common.util.ApiResponse;
|
||||
import com.yj.earth.common.util.SQLiteUtil;
|
||||
import com.yj.earth.dto.militaryLibrary.AddMilitaryTypeDto;
|
||||
import com.yj.earth.dto.militaryLibrary.CreateMilitaryLibraryDto;
|
||||
import com.yj.earth.dto.militaryLibrary.DragMilitaryTypeDto;
|
||||
import com.yj.earth.dto.militaryLibrary.UpdateMilitaryTypeNameDto;
|
||||
import com.yj.earth.vo.MilitaryTypeVo;
|
||||
import com.yj.earth.vo.MilitaryVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "军标库管理")
|
||||
@CheckAuth
|
||||
@RestController
|
||||
@RequestMapping("/militaryLibrary")
|
||||
public class MilitaryLibraryController {
|
||||
@Resource
|
||||
private MilitaryLibraryService militaryLibraryService;
|
||||
@Resource
|
||||
private FileInfoService fileInfoService;
|
||||
|
||||
@Operation(summary = "创建军标库")
|
||||
@PostMapping("/createMilitaryLibrary")
|
||||
public ApiResponse createMilitaryLibrary(@RequestBody CreateMilitaryLibraryDto createMilitaryLibraryDto) {
|
||||
try {
|
||||
// 参数校验
|
||||
String folderPath = createMilitaryLibraryDto.getPath();
|
||||
String militaryName = createMilitaryLibraryDto.getName();
|
||||
// 处理路径、组合为完整军标库文件路径
|
||||
File parentDir = new File(folderPath);
|
||||
File militaryFile = new File(parentDir, militaryName);
|
||||
String militaryPath = militaryFile.getAbsolutePath().replace("\\", "/");
|
||||
// 检查父目录是否存在、不存在则创建
|
||||
if (!parentDir.exists()) {
|
||||
boolean mkdirsSuccess = parentDir.mkdirs();
|
||||
if (!mkdirsSuccess) {
|
||||
return ApiResponse.failure("创建父目录失败:" + folderPath);
|
||||
}
|
||||
}
|
||||
// 检查军标库文件是否已存在
|
||||
if (militaryFile.exists()) {
|
||||
if (militaryFile.isDirectory()) {
|
||||
return ApiResponse.failure("同名目录已存在、无法创建文件:" + militaryPath);
|
||||
}
|
||||
return ApiResponse.failure("军标库文件已存在:" + militaryPath);
|
||||
}
|
||||
// 创建军标库文件
|
||||
boolean createSuccess = militaryFile.createNewFile();
|
||||
if (!createSuccess) {
|
||||
return ApiResponse.failure("创建军标库文件失败:" + militaryPath);
|
||||
}
|
||||
// 添加军标库信息
|
||||
addMilitaryLibrary(militaryPath);
|
||||
SQLiteUtil.initializationMilitary(militaryPath);
|
||||
return ApiResponse.success(null);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.failure("创建军标库失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "导入军标库")
|
||||
@PostMapping("/importMilitaryLibrary")
|
||||
public ApiResponse importMilitaryLibrary(@RequestParam("militaryPath") @Parameter(description = "军标库路径") String militaryPath) {
|
||||
addMilitaryLibrary(militaryPath);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加军标类型")
|
||||
@PostMapping("/addMilitaryType")
|
||||
public ApiResponse addMilitaryType(@RequestBody AddMilitaryTypeDto addMilitaryTypeDto) throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
// 检查父级是否存在
|
||||
String parentId = addMilitaryTypeDto.getParentId();
|
||||
if (parentId != null) {
|
||||
String sql = "SELECT * FROM military_type WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(parentId);
|
||||
MilitaryType militaryType = SQLiteUtil.queryForObject(militaryPath, sql, params, MilitaryType.class);
|
||||
if (militaryType == null) {
|
||||
return ApiResponse.failure("父级军标类型不存在");
|
||||
}
|
||||
}
|
||||
String sql = "INSERT INTO military_type " +
|
||||
"(id, name, parent_id, tree_index, created_at) " +
|
||||
"VALUES (?, ?, ?, ?, ?)";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(UUID.fastUUID().toString(true));
|
||||
params.add(addMilitaryTypeDto.getName());
|
||||
params.add(addMilitaryTypeDto.getParentId());
|
||||
params.add(0);
|
||||
params.add(LocalDateTime.now());
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除军标类型")
|
||||
@PostMapping("/deleteMilitaryType")
|
||||
public ApiResponse deleteMilitaryType(@Parameter(description = "军标类型ID") @RequestParam("militaryTypeId") String militaryTypeId) throws SQLException {
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
String sql = "DELETE FROM military_type WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(militaryTypeId);
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改军标类型名称")
|
||||
@PostMapping("/updateMilitaryTypeName")
|
||||
public ApiResponse updateMilitaryTypeName(@RequestBody UpdateMilitaryTypeNameDto updateMilitaryTypeNameDto) throws SQLException {
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
String sql = "UPDATE military_type SET name = ? WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(updateMilitaryTypeNameDto.getName());
|
||||
params.add(updateMilitaryTypeNameDto.getId());
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "军标类型列表")
|
||||
@GetMapping("/militaryTypeList")
|
||||
public ApiResponse militaryTypeTree() throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
// 查询所有军标类型
|
||||
String sql = """
|
||||
SELECT id, name, parent_id as parentId,
|
||||
tree_index as treeIndex, created_at as createdAt,
|
||||
updated_at as updatedAt FROM military_type ORDER BY tree_index ASC
|
||||
""";
|
||||
List<MilitaryType> militaryTypes = SQLiteUtil.queryForList(militaryPath, sql, null, MilitaryType.class);
|
||||
// 转换为树形结构
|
||||
List<MilitaryTypeVo> treeList = buildMilitaryTypeTree(militaryTypes);
|
||||
return ApiResponse.success(treeList);
|
||||
}
|
||||
|
||||
@Operation(summary = "拖动军标类型树")
|
||||
@PostMapping("/dragMilitaryType")
|
||||
public ApiResponse dragMilitaryType(@RequestBody DragMilitaryTypeDto dragMilitaryTypeDto) throws SQLException {
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
|
||||
// 动态构建SQL和参数
|
||||
List<String> updateFields = new ArrayList<>();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
// 判断 parentId 是否存在
|
||||
if (dragMilitaryTypeDto.getParentId() != null) {
|
||||
updateFields.add("parent_id = ?");
|
||||
params.add(dragMilitaryTypeDto.getParentId());
|
||||
}
|
||||
|
||||
// 判断 treeIndex 是否存在
|
||||
if (dragMilitaryTypeDto.getTreeIndex() != null) {
|
||||
updateFields.add("tree_index = ?");
|
||||
params.add(dragMilitaryTypeDto.getTreeIndex());
|
||||
}
|
||||
|
||||
// 构建完整 SQL
|
||||
String sql = "UPDATE military_type SET " + String.join(", ", updateFields) + " WHERE id = ?";
|
||||
params.add(dragMilitaryTypeDto.getId());
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加军标文件")
|
||||
@PostMapping("/addMilitaryFile")
|
||||
public ApiResponse addMilitaryFile(@RequestParam("files") MultipartFile[] files, @Parameter(description = "军标类型ID") @RequestParam("militaryTypeId") String militaryTypeId) throws IOException, SQLException {
|
||||
// 获取最新的军标库路径
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
// 循环处理每个上传的文件
|
||||
for (MultipartFile file : files) {
|
||||
// 跳过空文件
|
||||
if (file.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 获取文件信息
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (fileName == null) {
|
||||
continue;
|
||||
}
|
||||
String fileSuffix = FileUtil.extName(fileName);
|
||||
String fileNameWithoutSuffix = FileUtil.mainName(fileName);
|
||||
|
||||
// 构建插入SQL
|
||||
String sql = "INSERT INTO military " +
|
||||
"(id, military_type_id, military_name, military_type, data, created_at) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
|
||||
String url = fileInfoService.uploadWithPreview(file);
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(UUID.fastUUID().toString(true));
|
||||
params.add(militaryTypeId);
|
||||
params.add(fileNameWithoutSuffix);
|
||||
params.add(fileSuffix);
|
||||
params.add(url);
|
||||
params.add(LocalDateTime.now());
|
||||
|
||||
// 执行插入操作
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
}
|
||||
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据军标类型查看军标列表")
|
||||
@PostMapping("/militaryList")
|
||||
public ApiResponse militaryList(@Parameter(description = "军标类型ID") @RequestParam("militaryTypeId") String militaryTypeId) throws SQLException, IllegalAccessException, InstantiationException {
|
||||
// 获取最新的军标库
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
// 多表联查、查询所有的军标
|
||||
String sql = """
|
||||
SELECT
|
||||
military.id,
|
||||
military.military_type_id as militaryTypeId,
|
||||
military.military_name as militaryName,
|
||||
military.military_type as militaryType,
|
||||
military.data,
|
||||
military.view,
|
||||
military.created_at as createdAt,
|
||||
military.updated_at as updatedAt,
|
||||
military_type.name as militaryTypeName from
|
||||
military JOIN military_type ON military.military_type_id = military_type.id
|
||||
WHERE military.military_type_id = ?
|
||||
""";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(militaryTypeId);
|
||||
List<MilitaryVo> militaryVos = SQLiteUtil.queryForList(militaryPath, sql, params, MilitaryVo.class);
|
||||
return ApiResponse.success(militaryVos);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新军标信息")
|
||||
@PostMapping("/uploadMilitaryInfo")
|
||||
public ApiResponse uploadMilitaryInfo(
|
||||
@Parameter(description = "军标ID") @RequestParam("militaryId") String militaryId,
|
||||
@Parameter(description = "军标名称") @RequestParam(value = "militaryName", required = false) String militaryName)
|
||||
throws SQLException {
|
||||
|
||||
// 获取最新的军标库路径
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
|
||||
// 如果没有需要更新的字段、直接返回成功
|
||||
if (!StringUtils.hasText(militaryName)) {
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
// 构建更新SQL和参数
|
||||
String sql = "UPDATE military SET updated_at = ?, military_name = ? WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(LocalDateTime.now());
|
||||
params.add(militaryName);
|
||||
params.add(militaryId);
|
||||
|
||||
// 执行更新
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "删除军标")
|
||||
@PostMapping("/deleteMilitary")
|
||||
public ApiResponse deleteMilitary(@Parameter(description = "军标ID") @RequestParam("militaryId") String militaryId) throws SQLException {
|
||||
String militaryPath = getMilitaryLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入军标库");
|
||||
}
|
||||
String sql = "DELETE FROM military WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(militaryId);
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
private List<MilitaryTypeVo> buildMilitaryTypeTree(List<MilitaryType> militaryTypes) {
|
||||
List<MilitaryTypeVo> treeNodes = militaryTypes.stream()
|
||||
.map(militaryType -> new MilitaryTypeVo(militaryType))
|
||||
.collect(Collectors.toList());
|
||||
// 构建节点ID到节点的映射
|
||||
Map<String, MilitaryTypeVo> nodeMap = treeNodes.stream()
|
||||
.collect(Collectors.toMap(MilitaryTypeVo::getId, node -> node));
|
||||
// 根节点列表
|
||||
List<MilitaryTypeVo> rootNodes = new ArrayList<>();
|
||||
// 为每个节点添加子节点
|
||||
for (MilitaryTypeVo node : treeNodes) {
|
||||
String parentId = node.getParentId();
|
||||
if (parentId == null || parentId.isEmpty()) {
|
||||
// 没有父节点的是根节点
|
||||
rootNodes.add(node);
|
||||
} else {
|
||||
// 找到父节点并添加为子节点
|
||||
MilitaryTypeVo parentNode = nodeMap.get(parentId);
|
||||
if (parentNode != null) {
|
||||
parentNode.getChildren().add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rootNodes;
|
||||
}
|
||||
|
||||
private String getMilitaryLibrary() {
|
||||
// 获取启用的军标库
|
||||
LambdaQueryWrapper<MilitaryLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MilitaryLibrary::getIsEnable, 1);
|
||||
MilitaryLibrary militaryLibrary = militaryLibraryService.getOne(queryWrapper);
|
||||
if (militaryLibrary == null) {
|
||||
return null;
|
||||
}
|
||||
return militaryLibrary.getPath();
|
||||
}
|
||||
|
||||
private void addMilitaryLibrary(String militaryPath) {
|
||||
// 查询系统所有的军标库
|
||||
List<MilitaryLibrary> militaryLibraries = militaryLibraryService.list();
|
||||
// 遍历并更新状态
|
||||
for (MilitaryLibrary militaryLibrary : militaryLibraries) {
|
||||
// 设置启用状态为0
|
||||
militaryLibrary.setIsEnable(0);
|
||||
militaryLibraryService.updateById(militaryLibrary);
|
||||
}
|
||||
|
||||
// 检查相同路径的军标库是否已存在
|
||||
LambdaQueryWrapper<MilitaryLibrary> pathWrapper = new LambdaQueryWrapper<>();
|
||||
pathWrapper.eq(MilitaryLibrary::getPath, militaryPath);
|
||||
MilitaryLibrary existingMilitary = militaryLibraryService.getOne(pathWrapper);
|
||||
// 若存在相同路径的军标库、不做处理、仅仅更新状态为显示
|
||||
if (existingMilitary != null) {
|
||||
existingMilitary.setIsEnable(1);
|
||||
militaryLibraryService.updateById(existingMilitary);
|
||||
return;
|
||||
} else {
|
||||
// 新增军标库
|
||||
MilitaryLibrary newMilitary = new MilitaryLibrary();
|
||||
File file = FileUtil.file(militaryPath);
|
||||
newMilitary.setId(UUID.fastUUID().toString(true));
|
||||
newMilitary.setPath(militaryPath);
|
||||
newMilitary.setName(FileUtil.extName(file));
|
||||
newMilitary.setIsEnable(1);
|
||||
militaryLibraryService.save(newMilitary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,395 @@
|
||||
package com.yj.earth.business.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.yj.earth.annotation.CheckAuth;
|
||||
import com.yj.earth.business.domain.ModelLibrary;
|
||||
import com.yj.earth.business.domain.ModelType;
|
||||
import com.yj.earth.business.service.FileInfoService;
|
||||
import com.yj.earth.business.service.ModelLibraryService;
|
||||
import com.yj.earth.common.util.ApiResponse;
|
||||
import com.yj.earth.common.util.SQLiteUtil;
|
||||
import com.yj.earth.dto.militaryLibrary.DragMilitaryTypeDto;
|
||||
import com.yj.earth.dto.modelLibrary.AddModelTypeDto;
|
||||
import com.yj.earth.dto.modelLibrary.CreateModelLibraryDto;
|
||||
import com.yj.earth.dto.modelLibrary.DragModelTypeDto;
|
||||
import com.yj.earth.dto.modelLibrary.UpdateModelTypeNameDto;
|
||||
import com.yj.earth.vo.ModelTypeVo;
|
||||
import com.yj.earth.vo.ModelVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "模型库管理")
|
||||
@CheckAuth
|
||||
@RestController
|
||||
@RequestMapping("/modelLibrary")
|
||||
public class ModelLibraryController {
|
||||
@Resource
|
||||
private ModelLibraryService modelLibraryService;
|
||||
@Resource
|
||||
private FileInfoService fileInfoService;
|
||||
|
||||
@Operation(summary = "创建模型库")
|
||||
@PostMapping("/createModelLibrary")
|
||||
public ApiResponse createModelLibrary(@RequestBody CreateModelLibraryDto createModelLibraryDto) {
|
||||
try {
|
||||
// 参数校验
|
||||
String folderPath = createModelLibraryDto.getPath();
|
||||
String modelName = createModelLibraryDto.getName();
|
||||
// 处理路径、组合为完整模型库文件路径(.model后缀)
|
||||
File parentDir = new File(folderPath);
|
||||
File modelFile = new File(parentDir, modelName + ".model");
|
||||
String modelPath = modelFile.getAbsolutePath().replace("\\", "/");
|
||||
// 检查父目录是否存在、不存在则创建
|
||||
if (!parentDir.exists()) {
|
||||
boolean mkdirsSuccess = parentDir.mkdirs();
|
||||
if (!mkdirsSuccess) {
|
||||
return ApiResponse.failure("创建父目录失败:" + folderPath);
|
||||
}
|
||||
}
|
||||
// 检查模型库文件是否已存在
|
||||
if (modelFile.exists()) {
|
||||
if (modelFile.isDirectory()) {
|
||||
return ApiResponse.failure("同名目录已存在、无法创建文件:" + modelPath);
|
||||
}
|
||||
return ApiResponse.failure("模型库文件已存在:" + modelPath);
|
||||
}
|
||||
// 创建模型库文件(
|
||||
boolean createSuccess = modelFile.createNewFile();
|
||||
if (!createSuccess) {
|
||||
return ApiResponse.failure("创建模型库文件失败:" + modelPath);
|
||||
}
|
||||
// 添加模型库信息
|
||||
addModelLibrary(modelPath);
|
||||
SQLiteUtil.initializationModel(modelPath);
|
||||
return ApiResponse.success(null);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.failure("创建模型库失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "导入模型库")
|
||||
@PostMapping("/importModelLibrary")
|
||||
public ApiResponse importModelLibrary(@RequestParam("modelPath") @Parameter(description = "模型库路径") String modelPath) {
|
||||
addModelLibrary(modelPath);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加模型类型")
|
||||
@PostMapping("/addModelType")
|
||||
public ApiResponse addModelType(@RequestBody AddModelTypeDto addModelTypeDto) throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
// 检查父级是否存在
|
||||
String parentId = addModelTypeDto.getParentId();
|
||||
if (parentId != null) {
|
||||
String sql = "SELECT * FROM model_type WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(parentId);
|
||||
ModelType modelType = SQLiteUtil.queryForObject(modelPath, sql, params, ModelType.class);
|
||||
if (modelType == null) {
|
||||
return ApiResponse.failure("父级模型类型不存在");
|
||||
}
|
||||
}
|
||||
String sql = "INSERT INTO model_type " +
|
||||
"(id, name, parent_id, tree_index, created_at) " +
|
||||
"VALUES (?, ?, ?, ?, ?)";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(UUID.fastUUID().toString(true));
|
||||
params.add(addModelTypeDto.getName());
|
||||
params.add(addModelTypeDto.getParentId());
|
||||
params.add(0);
|
||||
params.add(LocalDateTime.now());
|
||||
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改模型类型名称")
|
||||
@PostMapping("/updateModelTypeName")
|
||||
public ApiResponse updateModelTypeName(@RequestBody UpdateModelTypeNameDto updateModelTypeNameDto) throws SQLException {
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
String sql = "UPDATE model_type SET name = ? WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(updateModelTypeNameDto.getName());
|
||||
params.add(updateModelTypeNameDto.getId());
|
||||
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除模型类型")
|
||||
@PostMapping("/deleteModelType")
|
||||
public ApiResponse deleteModelType(@Parameter(description = "模型类型ID") @RequestParam("modelTypeId") String modelTypeId) throws SQLException {
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
String sql = "DELETE FROM model_type WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(modelTypeId);
|
||||
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "模型类型列表")
|
||||
@GetMapping("/modelTypeList")
|
||||
public ApiResponse modelTypeTree() throws SQLException, IllegalAccessException, InstantiationException {
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
String sql = """
|
||||
SELECT id, name, parent_id as parentId,
|
||||
tree_index as treeIndex, created_at as createdAt,
|
||||
updated_at as updatedAt FROM model_type ORDER BY tree_index ASC
|
||||
""";
|
||||
// 查询所有模型类型
|
||||
List<ModelType> modelTypes = SQLiteUtil.queryForList(modelPath, sql, null, ModelType.class);
|
||||
// 转换为树形结构
|
||||
List<ModelTypeVo> treeList = buildModelTypeTree(modelTypes);
|
||||
return ApiResponse.success(treeList);
|
||||
}
|
||||
|
||||
@Operation(summary = "拖动模型类型树")
|
||||
@PostMapping("/dragModelType")
|
||||
public ApiResponse dragMilitaryType(@RequestBody DragModelTypeDto dragModelTypeDto) throws SQLException {
|
||||
String militaryPath = getModelLibrary();
|
||||
if (militaryPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
|
||||
// 动态构建SQL和参数
|
||||
List<String> updateFields = new ArrayList<>();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
// 判断 parentId 是否存在
|
||||
if (dragModelTypeDto.getParentId() != null) {
|
||||
updateFields.add("parent_id = ?");
|
||||
params.add(dragModelTypeDto.getParentId());
|
||||
}
|
||||
|
||||
// 判断 treeIndex 是否存在
|
||||
if (dragModelTypeDto.getTreeIndex() != null) {
|
||||
updateFields.add("tree_index = ?");
|
||||
params.add(dragModelTypeDto.getTreeIndex());
|
||||
}
|
||||
|
||||
// 构建完整 SQL
|
||||
String sql = "UPDATE model_type SET " + String.join(", ", updateFields) + " WHERE id = ?";
|
||||
params.add(dragModelTypeDto.getId());
|
||||
SQLiteUtil.executeUpdate(militaryPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "添加模型文件")
|
||||
@PostMapping("/addModelFile")
|
||||
public ApiResponse addModelFile(@RequestParam("files") MultipartFile[] files, @Parameter(description = "模型类型ID") @RequestParam("modelTypeId") String modelTypeId) throws IOException, SQLException {
|
||||
// 获取最新的模型库路径
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
// 循环处理每个上传的文件
|
||||
for (MultipartFile file : files) {
|
||||
// 跳过空文件
|
||||
if (file.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 获取文件信息
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (fileName == null) {
|
||||
continue;
|
||||
}
|
||||
String fileSuffix = FileUtil.extName(fileName);
|
||||
String fileNameWithoutSuffix = FileUtil.mainName(fileName);
|
||||
|
||||
// 构建插入SQL
|
||||
String sql = "INSERT INTO model " +
|
||||
"(id, model_type_id, model_name, model_type, data, created_at) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
|
||||
String url = fileInfoService.uploadWithPreview(file);
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(UUID.fastUUID().toString(true));
|
||||
params.add(modelTypeId);
|
||||
params.add(fileNameWithoutSuffix);
|
||||
params.add(fileSuffix);
|
||||
params.add(url);
|
||||
params.add(LocalDateTime.now());
|
||||
|
||||
// 执行插入操作
|
||||
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
||||
}
|
||||
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据模型类型查看模型列表")
|
||||
@PostMapping("/modelList")
|
||||
public ApiResponse modelList(@Parameter(description = "模型类型ID") @RequestParam("modelTypeId") String modelTypeId) throws SQLException, IllegalAccessException, InstantiationException {
|
||||
// 获取最新的模型库
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
// 多表联查、查询所有的模型
|
||||
String sql = """
|
||||
SELECT
|
||||
model.id,
|
||||
model.model_type_id as modelTypeId,
|
||||
model.model_name as modelName,
|
||||
model.model_type as modelType,
|
||||
model.poster_type as posterType,
|
||||
model.poster,
|
||||
model.data,
|
||||
model.view,
|
||||
model.created_at as createdAt,
|
||||
model.updated_at as updatedAt,
|
||||
model_type.name as modelTypeName from
|
||||
model JOIN model_type ON model.model_type_id = model_type.id
|
||||
WHERE model.model_type_id = ?
|
||||
""";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(modelTypeId);
|
||||
List<ModelVo> modelVos = SQLiteUtil.queryForList(modelPath, sql, params, ModelVo.class);
|
||||
return ApiResponse.success(modelVos);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新模型信息")
|
||||
@PostMapping("/uploadModelInfo")
|
||||
public ApiResponse uploadModelInfo(@Parameter(description = "模型封面文件") @RequestParam(value = "file", required = false) MultipartFile file, @Parameter(description = "模型ID") @RequestParam("modelId") String modelId, @Parameter(description = "模型名称") @RequestParam(value = "modelName", required = false) String modelName) throws IOException, SQLException {
|
||||
|
||||
// 获取最新的模型库路径
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
// 动态构建SQL更新语句和参数
|
||||
StringBuilder sql = new StringBuilder("UPDATE model SET updated_at = ? ");
|
||||
List<Object> params = new ArrayList<>();
|
||||
// 始终更新时间
|
||||
params.add(LocalDateTime.now());
|
||||
// 处理封面文件
|
||||
if (file != null && !file.isEmpty()) {
|
||||
String fileSuffix = FileUtil.extName(file.getOriginalFilename());
|
||||
String url = fileInfoService.uploadWithPreview(file);
|
||||
sql.append(", poster_type = ?, poster = ? ");
|
||||
params.add(fileSuffix);
|
||||
params.add(url);
|
||||
}
|
||||
|
||||
// 处理模型名称
|
||||
if (StringUtils.hasText(modelName)) {
|
||||
sql.append(", model_name = ? ");
|
||||
params.add(modelName);
|
||||
}
|
||||
// 拼接WHERE条件
|
||||
sql.append("WHERE id = ?");
|
||||
params.add(modelId);
|
||||
// 执行更新
|
||||
SQLiteUtil.executeUpdate(modelPath, sql.toString(), params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除模型")
|
||||
@PostMapping("/deleteModel")
|
||||
public ApiResponse deleteModel(@Parameter(description = "模型ID") @RequestParam("modelId") String modelId) throws SQLException {
|
||||
String modelPath = getModelLibrary();
|
||||
if (modelPath == null) {
|
||||
return ApiResponse.failure("请先创建或导入模型库");
|
||||
}
|
||||
String sql = "DELETE FROM model WHERE id = ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(modelId);
|
||||
SQLiteUtil.executeUpdate(modelPath, sql, params);
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
||||
private List<ModelTypeVo> buildModelTypeTree(List<ModelType> modelTypes) {
|
||||
List<ModelTypeVo> treeNodes = modelTypes.stream()
|
||||
.map(modelType -> new ModelTypeVo(modelType))
|
||||
.collect(Collectors.toList());
|
||||
// 构建节点ID到节点的映射
|
||||
Map<String, ModelTypeVo> nodeMap = treeNodes.stream()
|
||||
.collect(Collectors.toMap(ModelTypeVo::getId, node -> node));
|
||||
// 根节点列表
|
||||
List<ModelTypeVo> rootNodes = new ArrayList<>();
|
||||
// 为每个节点添加子节点
|
||||
for (ModelTypeVo node : treeNodes) {
|
||||
String parentId = node.getParentId();
|
||||
if (parentId == null || parentId.isEmpty()) {
|
||||
// 没有父节点的是根节点
|
||||
rootNodes.add(node);
|
||||
} else {
|
||||
// 找到父节点并添加为子节点
|
||||
ModelTypeVo parentNode = nodeMap.get(parentId);
|
||||
if (parentNode != null) {
|
||||
parentNode.getChildren().add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rootNodes;
|
||||
}
|
||||
|
||||
private String getModelLibrary() {
|
||||
// 获取启用的模型库
|
||||
LambdaQueryWrapper<ModelLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ModelLibrary::getIsEnable, 1);
|
||||
ModelLibrary modelLibrary = modelLibraryService.getOne(queryWrapper);
|
||||
if (modelLibrary == null) {
|
||||
return null;
|
||||
}
|
||||
return modelLibrary.getPath();
|
||||
}
|
||||
|
||||
private void addModelLibrary(String modelPath) {
|
||||
// 查询系统所有的模型库
|
||||
List<ModelLibrary> modelLibraries = modelLibraryService.list();
|
||||
// 遍历并更新状态
|
||||
for (ModelLibrary modelLibrary : modelLibraries) {
|
||||
// 设置启用状态为0
|
||||
modelLibrary.setIsEnable(0);
|
||||
modelLibraryService.updateById(modelLibrary);
|
||||
}
|
||||
|
||||
// 检查相同路径的模型库是否已存在
|
||||
LambdaQueryWrapper<ModelLibrary> pathWrapper = new LambdaQueryWrapper<>();
|
||||
pathWrapper.eq(ModelLibrary::getPath, modelPath);
|
||||
ModelLibrary existingModel = modelLibraryService.getOne(pathWrapper);
|
||||
// 若存在相同路径的模型库、不做处理、仅仅更新状态为显示
|
||||
if (existingModel != null) {
|
||||
existingModel.setIsEnable(1);
|
||||
modelLibraryService.updateById(existingModel);
|
||||
return;
|
||||
} else {
|
||||
// 新增模型库
|
||||
ModelLibrary newModel = new ModelLibrary();
|
||||
File file = FileUtil.file(modelPath);
|
||||
newModel.setId(UUID.fastUUID().toString(true));
|
||||
newModel.setPath(modelPath);
|
||||
newModel.setName(FileUtil.extName(file));
|
||||
newModel.setIsEnable(1);
|
||||
modelLibraryService.save(newModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package com.yj.earth.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
public class BusinessConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "键")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
53
src/main/java/com/yj/earth/business/domain/IconLibrary.java
Normal file
53
src/main/java/com/yj/earth/business/domain/IconLibrary.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.yj.earth.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-24
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("icon_library")
|
||||
@Schema(name = "IconLibrary", description = "")
|
||||
public class IconLibrary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "生成文件夹路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "图标库文件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Integer isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.yj.earth.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
public class MilitaryLibrary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "生成文件夹路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "军标库文件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Integer isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
42
src/main/java/com/yj/earth/business/domain/ModelLibrary.java
Normal file
42
src/main/java/com/yj/earth/business/domain/ModelLibrary.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.yj.earth.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
public class ModelLibrary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "生成文件夹路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "模型库文件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Integer isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.yj.earth.business.mapper;
|
||||
|
||||
import com.yj.earth.business.domain.BusinessConfig;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-22
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusinessConfigMapper extends BaseMapper<BusinessConfig> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.yj.earth.business.mapper;
|
||||
|
||||
import com.yj.earth.business.domain.IconLibrary;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-24
|
||||
*/
|
||||
@Mapper
|
||||
public interface IconLibraryMapper extends BaseMapper<IconLibrary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.yj.earth.business.mapper;
|
||||
|
||||
import com.yj.earth.business.domain.MilitaryLibrary;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-23
|
||||
*/
|
||||
@Mapper
|
||||
public interface MilitaryLibraryMapper extends BaseMapper<MilitaryLibrary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.yj.earth.business.mapper;
|
||||
|
||||
import com.yj.earth.business.domain.ModelLibrary;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-17
|
||||
*/
|
||||
@Mapper
|
||||
public interface ModelLibraryMapper extends BaseMapper<ModelLibrary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.yj.earth.business.service;
|
||||
|
||||
import com.yj.earth.business.domain.BusinessConfig;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-22
|
||||
*/
|
||||
public interface BusinessConfigService extends IService<BusinessConfig> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.yj.earth.business.service;
|
||||
|
||||
import com.yj.earth.business.domain.IconLibrary;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-24
|
||||
*/
|
||||
public interface IconLibraryService extends IService<IconLibrary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.yj.earth.business.service;
|
||||
|
||||
import com.yj.earth.business.domain.MilitaryLibrary;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-23
|
||||
*/
|
||||
public interface MilitaryLibraryService extends IService<MilitaryLibrary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.yj.earth.business.service;
|
||||
|
||||
import com.yj.earth.business.domain.ModelLibrary;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-17
|
||||
*/
|
||||
public interface ModelLibraryService extends IService<ModelLibrary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.yj.earth.business.service.impl;
|
||||
|
||||
import com.yj.earth.business.domain.BusinessConfig;
|
||||
import com.yj.earth.business.mapper.BusinessConfigMapper;
|
||||
import com.yj.earth.business.service.BusinessConfigService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-22
|
||||
*/
|
||||
@Service
|
||||
public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, BusinessConfig> implements BusinessConfigService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.yj.earth.business.service.impl;
|
||||
|
||||
import com.yj.earth.business.domain.IconLibrary;
|
||||
import com.yj.earth.business.mapper.IconLibraryMapper;
|
||||
import com.yj.earth.business.service.IconLibraryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-24
|
||||
*/
|
||||
@Service
|
||||
public class IconLibraryServiceImpl extends ServiceImpl<IconLibraryMapper, IconLibrary> implements IconLibraryService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.yj.earth.business.service.impl;
|
||||
|
||||
import com.yj.earth.business.domain.MilitaryLibrary;
|
||||
import com.yj.earth.business.mapper.MilitaryLibraryMapper;
|
||||
import com.yj.earth.business.service.MilitaryLibraryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-23
|
||||
*/
|
||||
@Service
|
||||
public class MilitaryLibraryServiceImpl extends ServiceImpl<MilitaryLibraryMapper, MilitaryLibrary> implements MilitaryLibraryService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.yj.earth.business.service.impl;
|
||||
|
||||
import com.yj.earth.business.domain.ModelLibrary;
|
||||
import com.yj.earth.business.mapper.ModelLibraryMapper;
|
||||
import com.yj.earth.business.service.ModelLibraryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 周志雄
|
||||
* @since 2025-09-17
|
||||
*/
|
||||
@Service
|
||||
public class ModelLibraryServiceImpl extends ServiceImpl<ModelLibraryMapper, ModelLibrary> implements ModelLibraryService {
|
||||
|
||||
}
|
||||
19
src/main/resources/mapper/BusinessConfigMapper.xml
Normal file
19
src/main/resources/mapper/BusinessConfigMapper.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yj.earth.business.mapper.BusinessConfigMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.yj.earth.business.domain.BusinessConfig">
|
||||
<id column="id" property="id" />
|
||||
<result column="key" property="key" />
|
||||
<result column="value" property="value" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="updated_at" property="updatedAt" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, key, value, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
20
src/main/resources/mapper/IconLibraryMapper.xml
Normal file
20
src/main/resources/mapper/IconLibraryMapper.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yj.earth.business.mapper.IconLibraryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.yj.earth.business.domain.IconLibrary">
|
||||
<id column="id" property="id" />
|
||||
<result column="path" property="path" />
|
||||
<result column="name" property="name" />
|
||||
<result column="is_enable" property="isEnable" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="updated_at" property="updatedAt" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, path, name, is_enable, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
20
src/main/resources/mapper/MilitaryLibraryMapper.xml
Normal file
20
src/main/resources/mapper/MilitaryLibraryMapper.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yj.earth.business.mapper.MilitaryLibraryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.yj.earth.business.domain.MilitaryLibrary">
|
||||
<id column="id" property="id" />
|
||||
<result column="path" property="path" />
|
||||
<result column="name" property="name" />
|
||||
<result column="is_enable" property="isEnable" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="updated_at" property="updatedAt" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, path, name, is_enable, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
20
src/main/resources/mapper/ModelLibraryMapper.xml
Normal file
20
src/main/resources/mapper/ModelLibraryMapper.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yj.earth.business.mapper.ModelLibraryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.yj.earth.business.domain.ModelLibrary">
|
||||
<id column="id" property="id" />
|
||||
<result column="path" property="path" />
|
||||
<result column="name" property="name" />
|
||||
<result column="is_enable" property="isEnable" />
|
||||
<result column="created_at" property="createdAt" />
|
||||
<result column="updated_at" property="updatedAt" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, path, name, is_enable, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user