package com.ruoyi.platform.service;


import com.ruoyi.platform.domain.ModelDependency1;
import com.ruoyi.platform.domain.Models;
import com.ruoyi.platform.domain.ModelsVersion;
import com.ruoyi.platform.vo.ModelDependency1TreeVo;
import com.ruoyi.platform.vo.ModelsVo;
import com.ruoyi.platform.vo.QueryModelMetricsVo;
import org.springframework.core.io.InputStreamResource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * (Models)表服务接口
 *
 * @author Xidaray
 * @since 2023-11-28 16:26:07
 */
public interface ModelsService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    Models queryById(Integer id);

    /**
     * 分页查询
     *
     * @param models      筛选条件
     * @param pageRequest 分页对象
     * @return 查询结果
     */
    Page<Models> queryByPage(Models models, PageRequest pageRequest);

    /**
     * 新增数据
     *
     * @param models 实例对象
     * @return 实例对象
     */
    Models insert(Models models) throws Exception;

    /**
     * 修改数据
     *
     * @param models 实例对象
     * @return 实例对象
     */
    Models update(Models models);


    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    boolean deleteById(Integer id);

    String removeById(Integer id) throws Exception;

    ResponseEntity<InputStreamResource> downloadModels(Integer id) throws Exception;

    ResponseEntity<InputStreamResource> downloadDatasetlocal(String filePath) throws Exception;

    List<Map<String, String>> uploadModels(MultipartFile[] files, String uuid) throws Exception;

    Map uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception;

    ResponseEntity<InputStreamResource> downloadAllModelFiles(Integer modelsId, String version) throws Exception;

    List<String> getModelVersions(Integer modelId) throws Exception;

    String insertModelAndVersion(ModelsVo modelsVo) throws Exception;

    String readFileContent(Integer modelsId, String version) throws Exception;

    public void checkDeclaredName(Models insert) throws Exception;

    List<Map<String, String>> exportModels(String path, String uuid) throws Exception;

    String newCreateModel(ModelsVo modelsVo);

    String newCreateVersion(ModelsVo modelsVo) throws Exception;

    List<Map<String, String>> uploadModelLocal(MultipartFile[] files, String uuid) throws Exception;

    ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String name, String identifier, Integer id, String version, Boolean isPublic) throws IOException, Exception;

    Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception;

    Page<ModelsVo> newPersonalQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception;

    Page<Map<String, Object>> queryVersions(PageRequest pageRequest, String identifier, String owner, String type) throws Exception;

    Map<String, Object> queryVersionsMetrics(QueryModelMetricsVo queryModelMetricsVo) throws Exception;

    List<Map<String, Object>> getVersionList(String identifier, String owner) throws Exception;

    ModelsVo getModelDetail(Integer id, String identifier, String owner, String version, Boolean isPublic) throws Exception;

    ModelDependency1TreeVo getModelDependencyTree(Integer repoId, String identifier, String version) throws Exception;

    void deleteModel(Integer repoId, String identifier, String owner, Boolean isPublic) throws Exception;

    void deleteVersion(Integer repoId, String identifier, String owner, String version, String relativePath) throws Exception;

    Map<String, Object> getVersionsCompare(QueryModelMetricsVo queryModelMetricsVo) throws Exception;

    String praise(Integer id) throws Exception;

    String unpraise(Integer id) throws Exception;

    List<ModelsVo> convert(List<Map<String, Object>> lst, String modelTopic, String modelTagName, String modelTypeName);

}
