feat(video): 新增模型管理与MinIO对象存储功能
- 新增算法模型实体类VModel及对应CRUD接口和实现 - 新增MinIO对象记录实体类VMinioObject及对应CRUD接口和实现 - 实现模型下载重定向功能 - 扩展MinioService支持指定文件名上传和删除对象 - 在CommonController中增加上传后持久化MinIO对象记录逻辑 - 新增ModelController用于模型管理RESTful接口- 新增VMinioObjectController用于MinIO对象记录管理接口 - 添加相关Mapper XML配置和DAO接口 - 更新pom.xml引入必要依赖
This commit is contained in:
@@ -62,6 +62,14 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.framework.config.ServerConfig;
|
||||
import com.ruoyi.framework.config.MinioProperties;
|
||||
import com.ruoyi.framework.service.MinioService;
|
||||
import com.ruoyi.video.service.IVMinioObjectService;
|
||||
import com.ruoyi.video.domain.VMinioObject;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
|
||||
/**
|
||||
* 通用请求处理
|
||||
@@ -43,6 +46,9 @@ public class CommonController
|
||||
@Autowired(required = false)
|
||||
private MinioProperties minioProperties;
|
||||
|
||||
@Autowired
|
||||
private IVMinioObjectService vMinioObjectService;
|
||||
|
||||
private static final String FILE_DELIMETER = ",";
|
||||
|
||||
/**
|
||||
@@ -87,9 +93,18 @@ public class CommonController
|
||||
{
|
||||
if (minioProperties != null && minioProperties.isEnabled())
|
||||
{
|
||||
MinioService.UploadResult result = minioService.upload(file);
|
||||
String fileName = result.getObjectName();
|
||||
// 先生成唯一文件名(含扩展名),再用该名称上传
|
||||
String uniqueObjectName = FileUploadUtils.extractFilename(file);
|
||||
MinioService.UploadResult result = minioService.uploadWithName(file, uniqueObjectName);
|
||||
String fileName = result.getObjectName(); // 即 uniqueObjectName
|
||||
String url = result.getUrl();
|
||||
// persist to v_minio_object
|
||||
VMinioObject record = new VMinioObject();
|
||||
record.setObjectName(fileName);
|
||||
record.setUrl(url);
|
||||
record.setOriginalName(file.getOriginalFilename());
|
||||
try { record.setCreateBy(SecurityUtils.getUsername()); } catch (Exception ignored) {}
|
||||
vMinioObjectService.insert(record);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("url", url);
|
||||
ajax.put("fileName", fileName);
|
||||
@@ -132,13 +147,21 @@ public class CommonController
|
||||
{
|
||||
for (MultipartFile file : files)
|
||||
{
|
||||
MinioService.UploadResult result = minioService.upload(file);
|
||||
String fileName = result.getObjectName();
|
||||
String uniqueObjectName = FileUploadUtils.extractFilename(file);
|
||||
MinioService.UploadResult result = minioService.uploadWithName(file, uniqueObjectName);
|
||||
String fileName = result.getObjectName(); // 即 uniqueObjectName
|
||||
String url = result.getUrl();
|
||||
urls.add(url);
|
||||
fileNames.add(fileName);
|
||||
newFileNames.add(FileUtils.getName(fileName));
|
||||
originalFilenames.add(file.getOriginalFilename());
|
||||
// persist each to v_minio_object
|
||||
VMinioObject record = new VMinioObject();
|
||||
record.setObjectName(fileName);
|
||||
record.setUrl(url);
|
||||
record.setOriginalName(file.getOriginalFilename());
|
||||
try { record.setCreateBy(SecurityUtils.getUsername()); } catch (Exception ignored) {}
|
||||
vMinioObjectService.insert(record);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.service.MinioService;
|
||||
import com.ruoyi.video.domain.VMinioObject;
|
||||
import com.ruoyi.video.service.IVMinioObjectService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/system/minio-object")
|
||||
public class VMinioObjectController {
|
||||
|
||||
private final IVMinioObjectService vMinioObjectService;
|
||||
private final MinioService minioService;
|
||||
|
||||
public VMinioObjectController(IVMinioObjectService vMinioObjectService,
|
||||
MinioService minioService) {
|
||||
this.vMinioObjectService = vMinioObjectService;
|
||||
this.minioService = minioService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询:根据主键ID查询一条记录
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult getById(@PathVariable("id") Long id) {
|
||||
VMinioObject obj = vMinioObjectService.selectById(id);
|
||||
if (obj == null) {
|
||||
return AjaxResult.error("记录不存在");
|
||||
}
|
||||
return AjaxResult.success(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询:根据唯一对象名查询
|
||||
*/
|
||||
@GetMapping("/name/{objectName}")
|
||||
public AjaxResult getByObjectName(@PathVariable("objectName") String objectName) {
|
||||
VMinioObject obj = vMinioObjectService.selectByObjectName(objectName);
|
||||
if (obj == null) {
|
||||
return AjaxResult.error("记录不存在");
|
||||
}
|
||||
return AjaxResult.success(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除:根据主键ID删除(先删 MinIO,后删数据库)
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult deleteById(@PathVariable("id") Long id) {
|
||||
VMinioObject obj = vMinioObjectService.selectById(id);
|
||||
if (obj == null) {
|
||||
return AjaxResult.error("记录不存在或已删除");
|
||||
}
|
||||
String objectName = obj.getObjectName();
|
||||
if (StringUtils.isEmpty(objectName)) {
|
||||
return AjaxResult.error("对象名为空,无法删除 MinIO 对象");
|
||||
}
|
||||
try {
|
||||
// 先删除 MinIO 中的对象,确保不留悬挂数据
|
||||
minioService.deleteObject(objectName);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("删除 MinIO 对象失败: " + e.getMessage());
|
||||
}
|
||||
// 再删除数据库记录
|
||||
int rows = vMinioObjectService.deleteById(id);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("删除数据库记录失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除:根据唯一对象名删除(先 MinIO,再 DB)
|
||||
*/
|
||||
@DeleteMapping("/name/{objectName}")
|
||||
public AjaxResult deleteByObjectName(@PathVariable("objectName") String objectName) {
|
||||
VMinioObject obj = vMinioObjectService.selectByObjectName(objectName);
|
||||
if (obj == null) {
|
||||
return AjaxResult.error("记录不存在或已删除");
|
||||
}
|
||||
try {
|
||||
minioService.deleteObject(objectName);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("删除 MinIO 对象失败: " + e.getMessage());
|
||||
}
|
||||
int rows = vMinioObjectService.deleteByObjectName(objectName);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("删除数据库记录失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.web.controller.video;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.video.domain.VModel;
|
||||
import com.ruoyi.video.service.IVModelService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/video/model")
|
||||
public class ModelController {
|
||||
|
||||
private final IVModelService modelService;
|
||||
|
||||
public ModelController(IVModelService modelService) {
|
||||
this.modelService = modelService;
|
||||
}
|
||||
|
||||
/** 新增模型(JSON) */
|
||||
@PostMapping
|
||||
public AjaxResult create(@RequestBody VModel model) {
|
||||
if (StringUtils.isEmpty(model.getModelName())) {
|
||||
return AjaxResult.error("模型名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(model.getUrl())) {
|
||||
return AjaxResult.error("模型URL不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(model.getFramework())) {
|
||||
model.setFramework("onnx");
|
||||
}
|
||||
int rows = modelService.insert(model);
|
||||
return rows > 0 ? AjaxResult.success(model) : AjaxResult.error("新增失败");
|
||||
}
|
||||
|
||||
/** 根据ID查询 */
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult get(@PathVariable("id") Long id) {
|
||||
VModel model = modelService.selectById(id);
|
||||
return model != null ? AjaxResult.success(model) : AjaxResult.error("未找到记录");
|
||||
}
|
||||
|
||||
/** 列表查询(可选条件) */
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(@RequestParam(value = "modelName", required = false) String modelName,
|
||||
@RequestParam(value = "framework", required = false) String framework,
|
||||
@RequestParam(value = "enabled", required = false) Integer enabled,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("modelName", modelName);
|
||||
params.put("framework", framework);
|
||||
params.put("enabled", enabled);
|
||||
params.put("keyword", keyword);
|
||||
List<VModel> list = modelService.selectList(params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult delete(@PathVariable("id") Long id) {
|
||||
int rows = modelService.deleteById(id);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
/** 启用/禁用 */
|
||||
@PutMapping("/{id}/enable")
|
||||
public AjaxResult enable(@PathVariable("id") Long id,
|
||||
@RequestParam("enabled") Integer enabled) {
|
||||
if (enabled == null || (enabled != 0 && enabled != 1)) {
|
||||
return AjaxResult.error("enabled 仅支持 0 或 1");
|
||||
}
|
||||
int rows = modelService.updateEnabled(id, enabled);
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error("更新失败");
|
||||
}
|
||||
|
||||
/** 下载:直接 302 重定向到模型URL,确保可点击下载 */
|
||||
@GetMapping("/download/{id}")
|
||||
public void download(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
|
||||
VModel model = modelService.selectById(id);
|
||||
if (model == null || StringUtils.isEmpty(model.getUrl())) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "模型或URL不存在");
|
||||
return;
|
||||
}
|
||||
// 302 跳转到真实URL
|
||||
String target = model.getUrl();
|
||||
response.setStatus(HttpServletResponse.SC_FOUND);
|
||||
response.setHeader("Location", target);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(model.getModelName(), StandardCharsets.UTF_8) + ".onnx\"");
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.ruoyi.framework.config.MinioProperties;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import io.minio.BucketExistsArgs;
|
||||
import io.minio.MakeBucketArgs;
|
||||
import io.minio.RemoveObjectArgs;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectArgs;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -44,6 +45,25 @@ public class MinioService {
|
||||
return new UploadResult(objectName, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload using the provided unique objectName.
|
||||
*/
|
||||
public UploadResult uploadWithName(MultipartFile file, String objectName) throws Exception {
|
||||
ensureBucket();
|
||||
try (InputStream is = file.getInputStream()) {
|
||||
minioClient.putObject(
|
||||
PutObjectArgs.builder()
|
||||
.bucket(properties.getBucket())
|
||||
.object(objectName)
|
||||
.stream(is, file.getSize(), -1)
|
||||
.contentType(file.getContentType())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
String url = buildObjectUrl(objectName);
|
||||
return new UploadResult(objectName, url);
|
||||
}
|
||||
|
||||
public String buildObjectUrl(String objectName) {
|
||||
String endpoint = properties.getEndpoint();
|
||||
if (endpoint.endsWith("/")) {
|
||||
@@ -63,6 +83,18 @@ public class MinioService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an object from MinIO by its object name (key).
|
||||
*/
|
||||
public void deleteObject(String objectName) throws Exception {
|
||||
minioClient.removeObject(
|
||||
RemoveObjectArgs.builder()
|
||||
.bucket(properties.getBucket())
|
||||
.object(objectName)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
public static class UploadResult {
|
||||
private final String objectName;
|
||||
private final String url;
|
||||
|
||||
@@ -95,6 +95,10 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.video.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* MinIO 返回结果记录实体,对应表 v_minio_object
|
||||
*/
|
||||
public class VMinioObject extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long objectId;
|
||||
/** MinIO 对象名(Key) */
|
||||
private String objectName;
|
||||
/** 访问URL */
|
||||
private String url;
|
||||
/** 原始文件名(上传时的文件名) */
|
||||
private String originalName;
|
||||
/** 删除标志(0存在 2删除) */
|
||||
private String delFlag;
|
||||
|
||||
public Long getObjectId() { return objectId; }
|
||||
public void setObjectId(Long objectId) { this.objectId = objectId; }
|
||||
|
||||
public String getObjectName() { return objectName; }
|
||||
public void setObjectName(String objectName) { this.objectName = objectName; }
|
||||
|
||||
public String getUrl() { return url; }
|
||||
public void setUrl(String url) { this.url = url; }
|
||||
|
||||
public String getOriginalName() { return originalName; }
|
||||
public void setOriginalName(String originalName) { this.originalName = originalName; }
|
||||
|
||||
public String getDelFlag() { return delFlag; }
|
||||
public void setDelFlag(String delFlag) { this.delFlag = delFlag; }
|
||||
}
|
||||
47
ruoyi-video/src/main/java/com/ruoyi/video/domain/VModel.java
Normal file
47
ruoyi-video/src/main/java/com/ruoyi/video/domain/VModel.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.ruoyi.video.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 算法模型(ONNX等)记录表 v_model
|
||||
*/
|
||||
public class VModel extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long modelId;
|
||||
private String modelName;
|
||||
private String version;
|
||||
private String framework; // e.g., onnx
|
||||
private String url; // OSS/MinIO 直链
|
||||
private Long fileSize; // bytes
|
||||
private String checksum; // e.g., sha256
|
||||
private Integer enabled; // 1启用 0禁用
|
||||
private String delFlag; // 0存在 2删除
|
||||
|
||||
public Long getModelId() { return modelId; }
|
||||
public void setModelId(Long modelId) { this.modelId = modelId; }
|
||||
|
||||
public String getModelName() { return modelName; }
|
||||
public void setModelName(String modelName) { this.modelName = modelName; }
|
||||
|
||||
public String getVersion() { return version; }
|
||||
public void setVersion(String version) { this.version = version; }
|
||||
|
||||
public String getFramework() { return framework; }
|
||||
public void setFramework(String framework) { this.framework = framework; }
|
||||
|
||||
public String getUrl() { return url; }
|
||||
public void setUrl(String url) { this.url = url; }
|
||||
|
||||
public Long getFileSize() { return fileSize; }
|
||||
public void setFileSize(Long fileSize) { this.fileSize = fileSize; }
|
||||
|
||||
public String getChecksum() { return checksum; }
|
||||
public void setChecksum(String checksum) { this.checksum = checksum; }
|
||||
|
||||
public Integer getEnabled() { return enabled; }
|
||||
public void setEnabled(Integer enabled) { this.enabled = enabled; }
|
||||
|
||||
public String getDelFlag() { return delFlag; }
|
||||
public void setDelFlag(String delFlag) { this.delFlag = delFlag; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.video.mapper;
|
||||
|
||||
import com.ruoyi.video.domain.VMinioObject;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface VMinioObjectMapper {
|
||||
int insertVMinioObject(VMinioObject obj);
|
||||
VMinioObject selectVMinioObjectById(@Param("id") Long id);
|
||||
int deleteVMinioObjectById(@Param("id") Long id);
|
||||
|
||||
VMinioObject selectVMinioObjectByObjectName(@Param("objectName") String objectName);
|
||||
int deleteVMinioObjectByObjectName(@Param("objectName") String objectName);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.video.mapper;
|
||||
|
||||
import com.ruoyi.video.domain.VModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface VModelMapper {
|
||||
int insertModel(VModel model);
|
||||
VModel selectModelById(@Param("id") Long id);
|
||||
int deleteModelById(@Param("id") Long id);
|
||||
int updateEnabled(@Param("id") Long id, @Param("enabled") Integer enabled);
|
||||
|
||||
List<VModel> selectModelList(Map<String, Object> params);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.video.service;
|
||||
|
||||
|
||||
import com.ruoyi.video.domain.VMinioObject;
|
||||
|
||||
public interface IVMinioObjectService {
|
||||
int insert(VMinioObject obj);
|
||||
VMinioObject selectById(Long id);
|
||||
int deleteById(Long id);
|
||||
|
||||
VMinioObject selectByObjectName(String objectName);
|
||||
int deleteByObjectName(String objectName);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.video.service;
|
||||
|
||||
import com.ruoyi.video.domain.VModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IVModelService {
|
||||
int insert(VModel model);
|
||||
VModel selectById(Long id);
|
||||
int deleteById(Long id);
|
||||
int updateEnabled(Long id, Integer enabled);
|
||||
List<VModel> selectList(Map<String, Object> params);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.video.service.impl;
|
||||
|
||||
import com.ruoyi.video.domain.VMinioObject;
|
||||
import com.ruoyi.video.mapper.VMinioObjectMapper;
|
||||
import com.ruoyi.video.service.IVMinioObjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class VMinioObjectServiceImpl implements IVMinioObjectService {
|
||||
|
||||
@Autowired
|
||||
private VMinioObjectMapper mapper;
|
||||
|
||||
|
||||
@Override
|
||||
public int insert(VMinioObject obj) {
|
||||
if (obj.getDelFlag() == null) {
|
||||
obj.setDelFlag("0");
|
||||
}
|
||||
return mapper.insertVMinioObject(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMinioObject selectById(Long id) {
|
||||
return mapper.selectVMinioObjectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return mapper.deleteVMinioObjectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMinioObject selectByObjectName(String objectName) {
|
||||
return mapper.selectVMinioObjectByObjectName(objectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByObjectName(String objectName) {
|
||||
return mapper.deleteVMinioObjectByObjectName(objectName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.video.service.impl;
|
||||
|
||||
import com.ruoyi.video.domain.VModel;
|
||||
import com.ruoyi.video.mapper.VModelMapper;
|
||||
import com.ruoyi.video.service.IVModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class VModelServiceImpl implements IVModelService {
|
||||
|
||||
private final VModelMapper mapper;
|
||||
|
||||
public VModelServiceImpl(VModelMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(VModel model) {
|
||||
if (model.getEnabled() == null) model.setEnabled(1);
|
||||
if (model.getDelFlag() == null) model.setDelFlag("0");
|
||||
return mapper.insertModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VModel selectById(Long id) {
|
||||
return mapper.selectModelById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return mapper.deleteModelById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateEnabled(Long id, Integer enabled) {
|
||||
return mapper.updateEnabled(id, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VModel> selectList(Map<String, Object> params) {
|
||||
return mapper.selectModelList(params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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.ruoyi.video.mapper.VMinioObjectMapper">
|
||||
|
||||
<resultMap id="VMinioObjectResult" type="com.ruoyi.video.domain.VMinioObject">
|
||||
<id property="objectId" column="object_id" />
|
||||
<result property="objectName" column="object_name" />
|
||||
<result property="url" column="url" />
|
||||
<result property="originalName" column="original_name" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insertVMinioObject" parameterType="com.ruoyi.video.domain.VMinioObject" useGeneratedKeys="true" keyProperty="objectId">
|
||||
INSERT INTO v_minio_object (
|
||||
object_name,
|
||||
url,
|
||||
original_name,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
del_flag
|
||||
) VALUES (
|
||||
#{objectName},
|
||||
#{url},
|
||||
#{originalName},
|
||||
#{createBy},
|
||||
NOW(),
|
||||
#{updateBy},
|
||||
NOW(),
|
||||
#{remark},
|
||||
#{delFlag}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectVMinioObjectById" parameterType="long" resultMap="VMinioObjectResult">
|
||||
SELECT * FROM v_minio_object WHERE object_id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteVMinioObjectById" parameterType="long">
|
||||
DELETE FROM v_minio_object WHERE object_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="selectVMinioObjectByObjectName" parameterType="string" resultMap="VMinioObjectResult">
|
||||
SELECT * FROM v_minio_object WHERE object_name = #{objectName}
|
||||
</select>
|
||||
|
||||
<delete id="deleteVMinioObjectByObjectName" parameterType="string">
|
||||
DELETE FROM v_minio_object WHERE object_name = #{objectName}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
67
ruoyi-video/src/main/resources/mapper/video/VModelMapper.xml
Normal file
67
ruoyi-video/src/main/resources/mapper/video/VModelMapper.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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.ruoyi.video.mapper.VModelMapper">
|
||||
|
||||
<resultMap id="VModelResult" type="com.ruoyi.video.domain.VModel">
|
||||
<id property="modelId" column="model_id" />
|
||||
<result property="modelName" column="model_name" />
|
||||
<result property="version" column="version" />
|
||||
<result property="framework" column="framework" />
|
||||
<result property="url" column="url" />
|
||||
<result property="fileSize" column="file_size" />
|
||||
<result property="checksum" column="checksum" />
|
||||
<result property="enabled" column="enabled" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insertModel" parameterType="com.ruoyi.video.domain.VModel" useGeneratedKeys="true" keyProperty="modelId">
|
||||
INSERT INTO v_model (
|
||||
model_name, version, framework, url, file_size, checksum, enabled,
|
||||
create_by, create_time, update_by, update_time, remark, del_flag
|
||||
) VALUES (
|
||||
#{modelName}, #{version}, #{framework}, #{url}, #{fileSize}, #{checksum}, #{enabled},
|
||||
#{createBy}, NOW(), #{updateBy}, NOW(), #{remark}, #{delFlag}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectModelById" parameterType="long" resultMap="VModelResult">
|
||||
SELECT * FROM v_model WHERE model_id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteModelById" parameterType="long">
|
||||
DELETE FROM v_model WHERE model_id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateEnabled">
|
||||
UPDATE v_model SET enabled = #{enabled}, update_time = NOW() WHERE model_id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectModelList" parameterType="map" resultMap="VModelResult">
|
||||
SELECT * FROM v_model
|
||||
<where>
|
||||
<if test="modelName != null and modelName != ''">
|
||||
AND model_name LIKE CONCAT('%', #{modelName}, '%')
|
||||
</if>
|
||||
<if test="framework != null and framework != ''">
|
||||
AND framework = #{framework}
|
||||
</if>
|
||||
<if test="enabled != null">
|
||||
AND enabled = #{enabled}
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (
|
||||
model_name LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR version LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR url LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user