| @@ -0,0 +1,84 @@ | |||||
| package com.ruoyi.platform.controller; | |||||
| import com.ruoyi.platform.domain.ImageVersion; | |||||
| import com.ruoyi.platform.service.ImageVersionService; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.http.ResponseEntity; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | |||||
| /** | |||||
| * (ImageVersion)表控制层 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 15:00:02 | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("imageVersion") | |||||
| public class ImageVersionController { | |||||
| /** | |||||
| * 服务对象 | |||||
| */ | |||||
| @Resource | |||||
| private ImageVersionService imageVersionService; | |||||
| /** | |||||
| * 分页查询 | |||||
| * | |||||
| * @param imageVersion 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | |||||
| */ | |||||
| @GetMapping | |||||
| public ResponseEntity<Page<ImageVersion>> queryByPage(ImageVersion imageVersion, PageRequest pageRequest) { | |||||
| return ResponseEntity.ok(this.imageVersionService.queryByPage(imageVersion, pageRequest)); | |||||
| } | |||||
| /** | |||||
| * 通过主键查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 单条数据 | |||||
| */ | |||||
| @GetMapping("{id}") | |||||
| public ResponseEntity<ImageVersion> queryById(@PathVariable("id") Integer id) { | |||||
| return ResponseEntity.ok(this.imageVersionService.queryById(id)); | |||||
| } | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param imageVersion 实体 | |||||
| * @return 新增结果 | |||||
| */ | |||||
| @PostMapping | |||||
| public ResponseEntity<ImageVersion> add(ImageVersion imageVersion) { | |||||
| return ResponseEntity.ok(this.imageVersionService.insert(imageVersion)); | |||||
| } | |||||
| /** | |||||
| * 编辑数据 | |||||
| * | |||||
| * @param imageVersion 实体 | |||||
| * @return 编辑结果 | |||||
| */ | |||||
| @PutMapping | |||||
| public ResponseEntity<ImageVersion> edit(ImageVersion imageVersion) { | |||||
| return ResponseEntity.ok(this.imageVersionService.update(imageVersion)); | |||||
| } | |||||
| /** | |||||
| * 删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 删除是否成功 | |||||
| */ | |||||
| @DeleteMapping | |||||
| public ResponseEntity<Boolean> deleteById(Integer id) { | |||||
| return ResponseEntity.ok(this.imageVersionService.deleteById(id)); | |||||
| } | |||||
| } | |||||
| @@ -65,7 +65,7 @@ public class ComponentController { | |||||
| @GetMapping("{id}") | @GetMapping("{id}") | ||||
| @ApiOperation("根据id查询") | @ApiOperation("根据id查询") | ||||
| public AjaxResult queryById(@PathVariable("id") Integer id) { | public AjaxResult queryById(@PathVariable("id") Integer id) { | ||||
| return AjaxResult.success(this.componentService.queryById(id)); | |||||
| return AjaxResult.success(this.componentService.queryById(id)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -113,6 +113,7 @@ public class DatasetController { | |||||
| * @param dataset_version_id ps:这里的id是dataset_version表的主键 | * @param dataset_version_id ps:这里的id是dataset_version表的主键 | ||||
| * @return 单条数据 | * @return 单条数据 | ||||
| */ | */ | ||||
| @GetMapping("/download/{dataset_version_id}") | @GetMapping("/download/{dataset_version_id}") | ||||
| @ApiOperation(value = "下载数据集", notes = "根据数据集版本表id下载数据集文件") | @ApiOperation(value = "下载数据集", notes = "根据数据集版本表id下载数据集文件") | ||||
| public ResponseEntity<InputStreamResource> downloadDataset(@PathVariable("dataset_version_id") Integer dataset_version_id) { | public ResponseEntity<InputStreamResource> downloadDataset(@PathVariable("dataset_version_id") Integer dataset_version_id) { | ||||
| @@ -0,0 +1,90 @@ | |||||
| package com.ruoyi.platform.controller.image; | |||||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||||
| import com.ruoyi.platform.domain.Image; | |||||
| import com.ruoyi.platform.domain.Models; | |||||
| import com.ruoyi.platform.service.ImageService; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.http.ResponseEntity; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | |||||
| /** | |||||
| * (Image)表控制层 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 14:46:47 | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("image") | |||||
| public class ImageController { | |||||
| /** | |||||
| * 服务对象 | |||||
| */ | |||||
| @Resource | |||||
| private ImageService imageService; | |||||
| /** | |||||
| * 分页查询 | |||||
| * | |||||
| * @param image 筛选条件 | |||||
| * @param page 分页对象 | |||||
| * @param size 分页对象 | |||||
| * @return 查询结果 | |||||
| */ | |||||
| @GetMapping | |||||
| @ApiOperation("分页查询") | |||||
| public AjaxResult queryByPage(Image image, int page, int size) { | |||||
| PageRequest pageRequest = PageRequest.of(page,size); | |||||
| return AjaxResult.success(this.imageService.queryByPage(image, pageRequest)); | |||||
| } | |||||
| /** | |||||
| * 通过主键查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 单条数据 | |||||
| */ | |||||
| @GetMapping("{id}") | |||||
| public AjaxResult queryById(@PathVariable("id") Integer id) { | |||||
| return AjaxResult.success(this.imageService.queryById(id)); | |||||
| } | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param image 实体 | |||||
| * @return 新增结果 | |||||
| */ | |||||
| @PostMapping | |||||
| public AjaxResult add(Image image) { | |||||
| return AjaxResult.success(this.imageService.insert(image)); | |||||
| } | |||||
| /** | |||||
| * 编辑数据 | |||||
| * | |||||
| * @param image 实体 | |||||
| * @return 编辑结果 | |||||
| */ | |||||
| @PutMapping | |||||
| public AjaxResult edit(Image image) { | |||||
| return AjaxResult.success(this.imageService.update(image)); | |||||
| } | |||||
| /** | |||||
| * 删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 删除是否成功 | |||||
| */ | |||||
| @DeleteMapping | |||||
| public AjaxResult deleteById(Integer id) { | |||||
| return AjaxResult.success(this.imageService.removeById(id)); | |||||
| } | |||||
| } | |||||
| @@ -74,7 +74,7 @@ public class ModelsController { | |||||
| @PostMapping | @PostMapping | ||||
| @ApiOperation("添加模型") | @ApiOperation("添加模型") | ||||
| public AjaxResult add(@RequestBody Models models) { | public AjaxResult add(@RequestBody Models models) { | ||||
| return AjaxResult.success(this.modelsService.insert(models)); | |||||
| return AjaxResult.success(this.modelsService.insert(models)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -106,8 +106,9 @@ public class ModelsController { | |||||
| * | * | ||||
| * | * | ||||
| * | * | ||||
| * @param file 文件 | |||||
| * @param models_version_id 模型版本表主键 | |||||
| * @param files 文件 | |||||
| * @param modelsId 模型表主键 | |||||
| * @param version 模型版本表主键 | |||||
| * @return 上传结果 | * @return 上传结果 | ||||
| */ | */ | ||||
| @@ -0,0 +1,125 @@ | |||||
| package com.ruoyi.platform.domain; | |||||
| import java.util.Date; | |||||
| import java.io.Serializable; | |||||
| /** | |||||
| * (Image)实体类 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 14:45:48 | |||||
| */ | |||||
| public class Image implements Serializable { | |||||
| private static final long serialVersionUID = 179166185018853959L; | |||||
| /** | |||||
| * 主键 | |||||
| */ | |||||
| private Integer id; | |||||
| /** | |||||
| * 镜像名称 | |||||
| */ | |||||
| private String name; | |||||
| /** | |||||
| * 镜像描述 | |||||
| */ | |||||
| private String description; | |||||
| /** | |||||
| * 镜像类型 | |||||
| */ | |||||
| private Integer imageType; | |||||
| /** | |||||
| * 创建者 | |||||
| */ | |||||
| private String createBy; | |||||
| /** | |||||
| * 创建时间 | |||||
| */ | |||||
| private Date createTime; | |||||
| /** | |||||
| * 更新者 | |||||
| */ | |||||
| private String updateBy; | |||||
| /** | |||||
| * 更新时间 | |||||
| */ | |||||
| private Date updateTime; | |||||
| /** | |||||
| * 状态,0失效,1生效 | |||||
| */ | |||||
| private Integer state; | |||||
| public Integer getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Integer id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| this.name = name; | |||||
| } | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| public void setDescription(String description) { | |||||
| this.description = description; | |||||
| } | |||||
| public Integer getImageType() { | |||||
| return imageType; | |||||
| } | |||||
| public void setImageType(Integer imageType) { | |||||
| this.imageType = imageType; | |||||
| } | |||||
| public String getCreateBy() { | |||||
| return createBy; | |||||
| } | |||||
| public void setCreateBy(String createBy) { | |||||
| this.createBy = createBy; | |||||
| } | |||||
| public Date getCreateTime() { | |||||
| return createTime; | |||||
| } | |||||
| public void setCreateTime(Date createTime) { | |||||
| this.createTime = createTime; | |||||
| } | |||||
| public String getUpdateBy() { | |||||
| return updateBy; | |||||
| } | |||||
| public void setUpdateBy(String updateBy) { | |||||
| this.updateBy = updateBy; | |||||
| } | |||||
| public Date getUpdateTime() { | |||||
| return updateTime; | |||||
| } | |||||
| public void setUpdateTime(Date updateTime) { | |||||
| this.updateTime = updateTime; | |||||
| } | |||||
| public Integer getState() { | |||||
| return state; | |||||
| } | |||||
| public void setState(Integer state) { | |||||
| this.state = state; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,161 @@ | |||||
| package com.ruoyi.platform.domain; | |||||
| import java.util.Date; | |||||
| import java.io.Serializable; | |||||
| /** | |||||
| * (ImageVersion)实体类 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 15:00:02 | |||||
| */ | |||||
| public class ImageVersion implements Serializable { | |||||
| private static final long serialVersionUID = 251017725389874890L; | |||||
| /** | |||||
| * 主键 | |||||
| */ | |||||
| private Integer id; | |||||
| /** | |||||
| * 对应的镜像id | |||||
| */ | |||||
| private Integer imageId; | |||||
| /** | |||||
| * 镜像版本 | |||||
| */ | |||||
| private String version; | |||||
| /** | |||||
| * 镜像推送地址 | |||||
| */ | |||||
| private String url; | |||||
| /** | |||||
| * 镜像tag名称 | |||||
| */ | |||||
| private String tagName; | |||||
| /** | |||||
| * 镜像文件大小 | |||||
| */ | |||||
| private String fileSize; | |||||
| /** | |||||
| * 镜像构建状态 | |||||
| */ | |||||
| private String status; | |||||
| /** | |||||
| * 创建者 | |||||
| */ | |||||
| private String createBy; | |||||
| /** | |||||
| * 创建时间 | |||||
| */ | |||||
| private Date createTime; | |||||
| /** | |||||
| * 更新者 | |||||
| */ | |||||
| private String updateBy; | |||||
| /** | |||||
| * 更新时间 | |||||
| */ | |||||
| private Date updateTime; | |||||
| /** | |||||
| * 状态,0失效,1生效 | |||||
| */ | |||||
| private Integer state; | |||||
| public Integer getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Integer id) { | |||||
| this.id = id; | |||||
| } | |||||
| public Integer getImageId() { | |||||
| return imageId; | |||||
| } | |||||
| public void setImageId(Integer imageId) { | |||||
| this.imageId = imageId; | |||||
| } | |||||
| public String getVersion() { | |||||
| return version; | |||||
| } | |||||
| public void setVersion(String version) { | |||||
| this.version = version; | |||||
| } | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| public String getTagName() { | |||||
| return tagName; | |||||
| } | |||||
| public void setTagName(String tagName) { | |||||
| this.tagName = tagName; | |||||
| } | |||||
| public String getFileSize() { | |||||
| return fileSize; | |||||
| } | |||||
| public void setFileSize(String fileSize) { | |||||
| this.fileSize = fileSize; | |||||
| } | |||||
| public String getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(String status) { | |||||
| this.status = status; | |||||
| } | |||||
| public String getCreateBy() { | |||||
| return createBy; | |||||
| } | |||||
| public void setCreateBy(String createBy) { | |||||
| this.createBy = createBy; | |||||
| } | |||||
| public Date getCreateTime() { | |||||
| return createTime; | |||||
| } | |||||
| public void setCreateTime(Date createTime) { | |||||
| this.createTime = createTime; | |||||
| } | |||||
| public String getUpdateBy() { | |||||
| return updateBy; | |||||
| } | |||||
| public void setUpdateBy(String updateBy) { | |||||
| this.updateBy = updateBy; | |||||
| } | |||||
| public Date getUpdateTime() { | |||||
| return updateTime; | |||||
| } | |||||
| public void setUpdateTime(Date updateTime) { | |||||
| this.updateTime = updateTime; | |||||
| } | |||||
| public Integer getState() { | |||||
| return state; | |||||
| } | |||||
| public void setState(Integer state) { | |||||
| this.state = state; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,83 @@ | |||||
| package com.ruoyi.platform.mapper; | |||||
| import com.ruoyi.platform.domain.Image; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import org.springframework.data.domain.Pageable; | |||||
| import java.util.List; | |||||
| /** | |||||
| * (Image)表数据库访问层 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 14:46:47 | |||||
| */ | |||||
| public interface ImageDao { | |||||
| /** | |||||
| * 通过ID查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| Image queryById(Integer id); | |||||
| /** | |||||
| * 查询指定行数据 | |||||
| * | |||||
| * @param image 查询条件 | |||||
| * @param pageable 分页对象 | |||||
| * @return 对象列表 | |||||
| */ | |||||
| List<Image> queryAllByLimit(@Param("image") Image image, @Param("pageable") Pageable pageable); | |||||
| /** | |||||
| * 统计总行数 | |||||
| * | |||||
| * @param image 查询条件 | |||||
| * @return 总行数 | |||||
| */ | |||||
| long count(@Param("image") Image image); | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param image 实例对象 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int insert(@Param("image") Image image); | |||||
| /** | |||||
| * 批量新增数据(MyBatis原生foreach方法) | |||||
| * | |||||
| * @param entities List<Image> 实例对象列表 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int insertBatch(@Param("entities") List<Image> entities); | |||||
| /** | |||||
| * 批量新增或按主键更新数据(MyBatis原生foreach方法) | |||||
| * | |||||
| * @param entities List<Image> 实例对象列表 | |||||
| * @return 影响行数 | |||||
| * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 | |||||
| */ | |||||
| int insertOrUpdateBatch(@Param("entities") List<Image> entities); | |||||
| /** | |||||
| * 修改数据 | |||||
| * | |||||
| * @param image 实例对象 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int update(@Param("image") Image image); | |||||
| /** | |||||
| * 通过主键删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int deleteById(Integer id); | |||||
| } | |||||
| @@ -0,0 +1,85 @@ | |||||
| package com.ruoyi.platform.mapper; | |||||
| import com.ruoyi.platform.domain.ImageVersion; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import org.springframework.data.domain.Pageable; | |||||
| import java.util.List; | |||||
| /** | |||||
| * (ImageVersion)表数据库访问层 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 15:00:02 | |||||
| */ | |||||
| public interface ImageVersionDao { | |||||
| /** | |||||
| * 通过ID查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| ImageVersion queryById(Integer id); | |||||
| /** | |||||
| * 查询指定行数据 | |||||
| * | |||||
| * @param imageVersion 查询条件 | |||||
| * @param pageable 分页对象 | |||||
| * @return 对象列表 | |||||
| */ | |||||
| List<ImageVersion> queryAllByLimit(ImageVersion imageVersion, @Param("pageable") Pageable pageable); | |||||
| /** | |||||
| * 统计总行数 | |||||
| * | |||||
| * @param imageVersion 查询条件 | |||||
| * @return 总行数 | |||||
| */ | |||||
| long count(ImageVersion imageVersion); | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param imageVersion 实例对象 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int insert(ImageVersion imageVersion); | |||||
| /** | |||||
| * 批量新增数据(MyBatis原生foreach方法) | |||||
| * | |||||
| * @param entities List<ImageVersion> 实例对象列表 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int insertBatch(@Param("entities") List<ImageVersion> entities); | |||||
| /** | |||||
| * 批量新增或按主键更新数据(MyBatis原生foreach方法) | |||||
| * | |||||
| * @param entities List<ImageVersion> 实例对象列表 | |||||
| * @return 影响行数 | |||||
| * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 | |||||
| */ | |||||
| int insertOrUpdateBatch(@Param("entities") List<ImageVersion> entities); | |||||
| /** | |||||
| * 修改数据 | |||||
| * | |||||
| * @param imageVersion 实例对象 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int update(ImageVersion imageVersion); | |||||
| /** | |||||
| * 通过主键删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 影响行数 | |||||
| */ | |||||
| int deleteById(Integer id); | |||||
| List<ImageVersion> queryByImageId(Integer imageId); | |||||
| } | |||||
| @@ -0,0 +1,61 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import com.ruoyi.platform.domain.Image; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import java.util.Collection; | |||||
| /** | |||||
| * (Image)表服务接口 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 14:46:58 | |||||
| */ | |||||
| public interface ImageService { | |||||
| /** | |||||
| * 通过ID查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| Image queryById(Integer id); | |||||
| /** | |||||
| * 分页查询 | |||||
| * | |||||
| * @param image 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | |||||
| */ | |||||
| Page<Image> queryByPage(Image image, PageRequest pageRequest); | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param image 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| Image insert(Image image); | |||||
| /** | |||||
| * 修改数据 | |||||
| * | |||||
| * @param image 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| Image update(Image image); | |||||
| /** | |||||
| * 通过主键删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 是否成功 | |||||
| */ | |||||
| boolean deleteById(Integer id); | |||||
| String removeById(Integer id); | |||||
| } | |||||
| @@ -0,0 +1,65 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import com.ruoyi.platform.domain.ImageVersion; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * (ImageVersion)表服务接口 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 15:00:02 | |||||
| */ | |||||
| public interface ImageVersionService { | |||||
| /** | |||||
| * 通过ID查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| ImageVersion queryById(Integer id); | |||||
| /** | |||||
| * 分页查询 | |||||
| * | |||||
| * @param imageVersion 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | |||||
| */ | |||||
| Page<ImageVersion> queryByPage(ImageVersion imageVersion, PageRequest pageRequest); | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param imageVersion 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| ImageVersion insert(ImageVersion imageVersion); | |||||
| /** | |||||
| * 修改数据 | |||||
| * | |||||
| * @param imageVersion 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| ImageVersion update(ImageVersion imageVersion); | |||||
| /** | |||||
| * 通过主键删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 是否成功 | |||||
| */ | |||||
| boolean deleteById(Integer id); | |||||
| List<ImageVersion> queryByImageId(Integer id); | |||||
| } | |||||
| @@ -0,0 +1,124 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||||
| import com.ruoyi.platform.domain.Image; | |||||
| import com.ruoyi.platform.domain.ImageVersion; | |||||
| import com.ruoyi.platform.domain.Models; | |||||
| import com.ruoyi.platform.mapper.ImageDao; | |||||
| import com.ruoyi.platform.mapper.ImageVersionDao; | |||||
| import com.ruoyi.platform.service.ImageService; | |||||
| import com.ruoyi.platform.service.ImageVersionService; | |||||
| import com.ruoyi.system.api.model.LoginUser; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageImpl; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import javax.annotation.Resource; | |||||
| /** | |||||
| * (Image)表服务实现类 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 14:46:58 | |||||
| */ | |||||
| @Service("imageService") | |||||
| public class ImageServiceImpl implements ImageService { | |||||
| @Resource | |||||
| private ImageDao imageDao; | |||||
| @Resource | |||||
| private ImageVersionService imageVersionService; | |||||
| @Resource | |||||
| private ImageVersionDao imageVersionDao; | |||||
| /** | |||||
| * 通过ID查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| @Override | |||||
| public Image queryById(Integer id) { | |||||
| return this.imageDao.queryById(id); | |||||
| } | |||||
| /** | |||||
| * 分页查询 | |||||
| * | |||||
| * @param image 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | |||||
| */ | |||||
| @Override | |||||
| public Page<Image> queryByPage(Image image, PageRequest pageRequest) { | |||||
| long total = this.imageDao.count(image); | |||||
| return new PageImpl<>(this.imageDao.queryAllByLimit(image, pageRequest), pageRequest, total); | |||||
| } | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param image 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| @Override | |||||
| public Image insert(Image image) { | |||||
| this.imageDao.insert(image); | |||||
| return image; | |||||
| } | |||||
| /** | |||||
| * 修改数据 | |||||
| * | |||||
| * @param image 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| @Override | |||||
| public Image update(Image image) { | |||||
| this.imageDao.update(image); | |||||
| return this.queryById(image.getId()); | |||||
| } | |||||
| /** | |||||
| * 通过主键删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 是否成功 | |||||
| */ | |||||
| @Override | |||||
| public boolean deleteById(Integer id) { | |||||
| return this.imageDao.deleteById(id) > 0; | |||||
| } | |||||
| @Override | |||||
| public String removeById(Integer id) { | |||||
| Image image = this.imageDao.queryById(id); | |||||
| if (image == null){ | |||||
| return "模型不存在"; | |||||
| } | |||||
| //判断权限,只有admin和创建者本身可以删除该数据集 | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||||
| String username = loginUser.getUsername(); | |||||
| String createdBy = image.getCreateBy(); | |||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | |||||
| return "无权限删除该镜像"; | |||||
| } | |||||
| if (!imageVersionService.queryByImageId(id).isEmpty()){ | |||||
| return "请先删除该镜像下的版本文件"; | |||||
| } | |||||
| image.setState(0); | |||||
| return this.imageDao.update(image)>0?"删除成功":"删除失败"; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,89 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.platform.domain.ImageVersion; | |||||
| import com.ruoyi.platform.mapper.ImageVersionDao; | |||||
| import com.ruoyi.platform.domain.ModelsVersion; | |||||
| import com.ruoyi.platform.service.ImageVersionService; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageImpl; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import javax.annotation.Resource; | |||||
| import java.util.List; | |||||
| /** | |||||
| * (ImageVersion)表服务实现类 | |||||
| * | |||||
| * @author Xidaray | |||||
| * @since 2024-03-05 15:00:02 | |||||
| */ | |||||
| @Service("imageVersionService") | |||||
| public class ImageVersionServiceImpl implements ImageVersionService { | |||||
| @Resource | |||||
| private ImageVersionDao imageVersionDao; | |||||
| /** | |||||
| * 通过ID查询单条数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| @Override | |||||
| public ImageVersion queryById(Integer id) { | |||||
| return this.imageVersionDao.queryById(id); | |||||
| } | |||||
| /** | |||||
| * 分页查询 | |||||
| * | |||||
| * @param imageVersion 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | |||||
| */ | |||||
| @Override | |||||
| public Page<ImageVersion> queryByPage(ImageVersion imageVersion, PageRequest pageRequest) { | |||||
| long total = this.imageVersionDao.count(imageVersion); | |||||
| return new PageImpl<>(this.imageVersionDao.queryAllByLimit(imageVersion, pageRequest), pageRequest, total); | |||||
| } | |||||
| @Override | |||||
| public List<ImageVersion> queryByImageId(Integer imageId){ | |||||
| return imageVersionDao.queryByImageId(imageId); | |||||
| } | |||||
| /** | |||||
| * 新增数据 | |||||
| * | |||||
| * @param imageVersion 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| @Override | |||||
| public ImageVersion insert(ImageVersion imageVersion) { | |||||
| this.imageVersionDao.insert(imageVersion); | |||||
| return imageVersion; | |||||
| } | |||||
| /** | |||||
| * 修改数据 | |||||
| * | |||||
| * @param imageVersion 实例对象 | |||||
| * @return 实例对象 | |||||
| */ | |||||
| @Override | |||||
| public ImageVersion update(ImageVersion imageVersion) { | |||||
| this.imageVersionDao.update(imageVersion); | |||||
| return this.queryById(imageVersion.getId()); | |||||
| } | |||||
| /** | |||||
| * 通过主键删除数据 | |||||
| * | |||||
| * @param id 主键 | |||||
| * @return 是否成功 | |||||
| */ | |||||
| @Override | |||||
| public boolean deleteById(Integer id) { | |||||
| return this.imageVersionDao.deleteById(id) > 0; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,159 @@ | |||||
| <?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.platform.mapper.ImageDao"> | |||||
| <resultMap type="com.ruoyi.platform.domain.Image" id="ImageMap"> | |||||
| <result property="id" column="id" jdbcType="INTEGER"/> | |||||
| <result property="name" column="name" jdbcType="VARCHAR"/> | |||||
| <result property="description" column="description" jdbcType="VARCHAR"/> | |||||
| <result property="imageType" column="image_type" jdbcType="INTEGER"/> | |||||
| <result property="createBy" column="create_by" jdbcType="VARCHAR"/> | |||||
| <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> | |||||
| <result property="updateBy" column="update_by" jdbcType="VARCHAR"/> | |||||
| <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> | |||||
| <result property="state" column="state" jdbcType="INTEGER"/> | |||||
| </resultMap> | |||||
| <!--查询单个--> | |||||
| <select id="queryById" resultMap="ImageMap"> | |||||
| select | |||||
| idnamedescriptionimage_typecreate_bycreate_timeupdate_byupdate_timestate | |||||
| from image | |||||
| where id = #{id} | |||||
| </select> | |||||
| <!--查询指定行数据--> | |||||
| <select id="queryAllByLimit" resultMap="ImageMap"> | |||||
| select | |||||
| idnamedescriptionimage_typecreate_bycreate_timeupdate_byupdate_timestate | |||||
| from image | |||||
| <where> | |||||
| <if test="id != null"> | |||||
| and id = #{id} | |||||
| </if> | |||||
| <if test="name != null and name != ''"> | |||||
| and name = #{name} | |||||
| </if> | |||||
| <if test="description != null and description != ''"> | |||||
| and description = #{description} | |||||
| </if> | |||||
| <if test="imageType != null"> | |||||
| and image_type = #{imageType} | |||||
| </if> | |||||
| <if test="createBy != null and createBy != ''"> | |||||
| and create_by = #{createBy} | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| and create_time = #{createTime} | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| and update_by = #{updateBy} | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| and update_time = #{updateTime} | |||||
| </if> | |||||
| <if test="state != null and state != ''"> | |||||
| and state = #{state} | |||||
| </if> | |||||
| </where> | |||||
| limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | |||||
| <!--统计总行数--> | |||||
| <select id="count" resultType="java.lang.Long"> | |||||
| select count(1) | |||||
| from image | |||||
| <where> | |||||
| <if test="id != null"> | |||||
| and id = #{id} | |||||
| </if> | |||||
| <if test="name != null and name != ''"> | |||||
| and name = #{name} | |||||
| </if> | |||||
| <if test="description != null and description != ''"> | |||||
| and description = #{description} | |||||
| </if> | |||||
| <if test="imageType != null"> | |||||
| and image_type = #{imageType} | |||||
| </if> | |||||
| <if test="createBy != null and createBy != ''"> | |||||
| and create_by = #{createBy} | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| and create_time = #{createTime} | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| and update_by = #{updateBy} | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| and update_time = #{updateTime} | |||||
| </if> | |||||
| <if test="state != null and state != ''"> | |||||
| and state = #{state} | |||||
| </if> | |||||
| </where> | |||||
| </select> | |||||
| <!--新增所有列--> | |||||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into image(namedescriptionimage_typecreate_bycreate_timeupdate_byupdate_timestate) | |||||
| values (#{name}#{description}#{imageType}#{createBy}#{createTime}#{updateBy}#{updateTime}#{state}) | |||||
| </insert> | |||||
| <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into image(namedescriptionimage_typecreate_bycreate_timeupdate_byupdate_timestate) | |||||
| values | |||||
| <foreach collection="entities" item="entity" separator=","> | |||||
| (#{entity.name}#{entity.description}#{entity.imageType}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||||
| </foreach> | |||||
| </insert> | |||||
| <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into image(namedescriptionimage_typecreate_bycreate_timeupdate_byupdate_timestate) | |||||
| values | |||||
| <foreach collection="entities" item="entity" separator=","> | |||||
| (#{entity.name}#{entity.description}#{entity.imageType}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||||
| </foreach> | |||||
| on duplicate key update | |||||
| name = values(name)description = values(description)image_type = values(image_type)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state) | |||||
| </insert> | |||||
| <!--通过主键修改数据--> | |||||
| <update id="update"> | |||||
| update image | |||||
| <set> | |||||
| <if test="name != null and name != ''"> | |||||
| name = #{name}, | |||||
| </if> | |||||
| <if test="description != null and description != ''"> | |||||
| description = #{description}, | |||||
| </if> | |||||
| <if test="imageType != null"> | |||||
| image_type = #{imageType}, | |||||
| </if> | |||||
| <if test="createBy != null and createBy != ''"> | |||||
| create_by = #{createBy}, | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| create_time = #{createTime}, | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| update_by = #{updateBy}, | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| update_time = #{updateTime}, | |||||
| </if> | |||||
| <if test="state != null and state != ''"> | |||||
| state = #{state}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{id} | |||||
| </update> | |||||
| <!--通过主键删除--> | |||||
| <delete id="deleteById"> | |||||
| delete from image where id = #{id} | |||||
| </delete> | |||||
| </mapper> | |||||
| @@ -0,0 +1,194 @@ | |||||
| <?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.platform.dao.ImageVersionDao"> | |||||
| <resultMap type="com.ruoyi.platform.domain.ImageVersion" id="ImageVersionMap"> | |||||
| <result property="id" column="id" jdbcType="INTEGER"/> | |||||
| <result property="imageId" column="image_id" jdbcType="INTEGER"/> | |||||
| <result property="version" column="version" jdbcType="VARCHAR"/> | |||||
| <result property="url" column="url" jdbcType="VARCHAR"/> | |||||
| <result property="tagName" column="tag_name" jdbcType="VARCHAR"/> | |||||
| <result property="fileSize" column="file_size" jdbcType="VARCHAR"/> | |||||
| <result property="status" column="status" jdbcType="VARCHAR"/> | |||||
| <result property="createBy" column="create_by" jdbcType="VARCHAR"/> | |||||
| <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> | |||||
| <result property="updateBy" column="update_by" jdbcType="VARCHAR"/> | |||||
| <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> | |||||
| <result property="state" column="state" jdbcType="INTEGER"/> | |||||
| </resultMap> | |||||
| <!--根据模型id返回版本列表--> | |||||
| <select id="queryByModelsId" resultMap="ModelsVersionMap"> | |||||
| select * | |||||
| from image_version | |||||
| where image_id = #{imageId} and state = 1 | |||||
| </select> | |||||
| <!--查询单个--> | |||||
| <select id="queryById" resultMap="ImageVersionMap"> | |||||
| select * | |||||
| from image_version | |||||
| where id = #{id} | |||||
| </select> | |||||
| <!--查询指定行数据--> | |||||
| <select id="queryAllByLimit" resultMap="ImageVersionMap"> | |||||
| select * | |||||
| from image_version | |||||
| <where> | |||||
| <if test="id != null"> | |||||
| and id = #{id} | |||||
| </if> | |||||
| <if test="imageId != null"> | |||||
| and image_id = #{imageId} | |||||
| </if> | |||||
| <if test="version != null and version != ''"> | |||||
| and version = #{version} | |||||
| </if> | |||||
| <if test="url != null and url != ''"> | |||||
| and url = #{url} | |||||
| </if> | |||||
| <if test="tagName != null and tagName != ''"> | |||||
| and tag_name = #{tagName} | |||||
| </if> | |||||
| <if test="fileSize != null and fileSize != ''"> | |||||
| and file_size = #{fileSize} | |||||
| </if> | |||||
| <if test="status != null and status != ''"> | |||||
| and status = #{status} | |||||
| </if> | |||||
| <if test="createBy != null and createBy != ''"> | |||||
| and create_by = #{createBy} | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| and create_time = #{createTime} | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| and update_by = #{updateBy} | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| and update_time = #{updateTime} | |||||
| </if> | |||||
| <if test="state != null"> | |||||
| and state = #{state} | |||||
| </if> | |||||
| </where> | |||||
| limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | |||||
| <!--统计总行数--> | |||||
| <select id="count" resultType="java.lang.Long"> | |||||
| select count(1) | |||||
| from image_version | |||||
| <where> | |||||
| <if test="id != null"> | |||||
| and id = #{id} | |||||
| </if> | |||||
| <if test="imageId != null"> | |||||
| and image_id = #{imageId} | |||||
| </if> | |||||
| <if test="version != null and version != ''"> | |||||
| and version = #{version} | |||||
| </if> | |||||
| <if test="url != null and url != ''"> | |||||
| and url = #{url} | |||||
| </if> | |||||
| <if test="tagName != null and tagName != ''"> | |||||
| and tag_name = #{tagName} | |||||
| </if> | |||||
| <if test="fileSize != null and fileSize != ''"> | |||||
| and file_size = #{fileSize} | |||||
| </if> | |||||
| <if test="status != null and status != ''"> | |||||
| and status = #{status} | |||||
| </if> | |||||
| <if test="createBy != null and createBy != ''"> | |||||
| and create_by = #{createBy} | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| and create_time = #{createTime} | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| and update_by = #{updateBy} | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| and update_time = #{updateTime} | |||||
| </if> | |||||
| <if test="state != null"> | |||||
| and state = #{state} | |||||
| </if> | |||||
| </where> | |||||
| </select> | |||||
| <!--新增所有列--> | |||||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into image_version(image_idversionurltag_namefile_sizestatuscreate_bycreate_timeupdate_byupdate_timestate) | |||||
| values (#{imageId}#{version}#{url}#{tagName}#{fileSize}#{status}#{createBy}#{createTime}#{updateBy}#{updateTime}#{state}) | |||||
| </insert> | |||||
| <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into image_version(image_idversionurltag_namefile_sizestatuscreate_bycreate_timeupdate_byupdate_timestate) | |||||
| values | |||||
| <foreach collection="entities" item="entity" separator=","> | |||||
| (#{entity.imageId}#{entity.version}#{entity.url}#{entity.tagName}#{entity.fileSize}#{entity.status}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||||
| </foreach> | |||||
| </insert> | |||||
| <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into image_version(image_idversionurltag_namefile_sizestatuscreate_bycreate_timeupdate_byupdate_timestate) | |||||
| values | |||||
| <foreach collection="entities" item="entity" separator=","> | |||||
| (#{entity.imageId}#{entity.version}#{entity.url}#{entity.tagName}#{entity.fileSize}#{entity.status}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state}) | |||||
| </foreach> | |||||
| on duplicate key update | |||||
| image_id = values(image_id)version = values(version)url = values(url)tag_name = values(tag_name)file_size = values(file_size)status = values(status)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state) | |||||
| </insert> | |||||
| <!--通过主键修改数据--> | |||||
| <update id="update"> | |||||
| update image_version | |||||
| <set> | |||||
| <if test="imageId != null"> | |||||
| image_id = #{imageId}, | |||||
| </if> | |||||
| <if test="version != null and version != ''"> | |||||
| version = #{version}, | |||||
| </if> | |||||
| <if test="url != null and url != ''"> | |||||
| url = #{url}, | |||||
| </if> | |||||
| <if test="tagName != null and tagName != ''"> | |||||
| tag_name = #{tagName}, | |||||
| </if> | |||||
| <if test="fileSize != null and fileSize != ''"> | |||||
| file_size = #{fileSize}, | |||||
| </if> | |||||
| <if test="status != null and status != ''"> | |||||
| status = #{status}, | |||||
| </if> | |||||
| <if test="createBy != null and createBy != ''"> | |||||
| create_by = #{createBy}, | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| create_time = #{createTime}, | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | |||||
| update_by = #{updateBy}, | |||||
| </if> | |||||
| <if test="updateTime != null"> | |||||
| update_time = #{updateTime}, | |||||
| </if> | |||||
| <if test="state != null"> | |||||
| state = #{state}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{id} | |||||
| </update> | |||||
| <!--通过主键删除--> | |||||
| <delete id="deleteById"> | |||||
| delete from image_version where id = #{id} | |||||
| </delete> | |||||
| </mapper> | |||||
| @@ -17,7 +17,7 @@ | |||||
| <!--查询单个--> | <!--查询单个--> | ||||
| <select id="queryById" resultMap="ModelsMap"> | <select id="queryById" resultMap="ModelsMap"> | ||||
| select | select | ||||
| id, name, description, model_type, create_by, create_time, update_by, update_time, state | |||||
| id, name, description, model_type, create_by, create_time, update_by, update_time, state | |||||
| from models | from models | ||||
| where id = #{id} and state = 1 | where id = #{id} and state = 1 | ||||
| </select> | </select> | ||||