package cn.stylefeng.team.meta.modular.service;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.team.generator.api.pojo.generator.result.CommonGenerateResult;
import cn.stylefeng.team.meta.api.MetaModelServiceApi;
import cn.stylefeng.team.meta.api.entity.MetaDefinition;
import cn.stylefeng.team.meta.api.entity.MetaModel;
import cn.stylefeng.team.meta.modular.pojo.CategoryInfo;
import cn.stylefeng.team.meta.modular.pojo.request.MetaModelRequest;
import cn.stylefeng.team.meta.modular.pojo.request.TableUpdateOperateRequest;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

public interface MetaModelService extends IService<MetaModel>, MetaModelServiceApi {

    void add(MetaModelRequest metaModelRequest);

    void del(MetaModelRequest metaModelRequest);

    void edit(MetaModelRequest metaModelRequest);

    MetaModel detail(MetaModelRequest metaModelRequest);

    PageResult<MetaModel> findPage(MetaModelRequest metaModelRequest);

    void updateModelVersion(MetaDefinition newMetaDefinition);

    List<MetaModel> findList(MetaModelRequest metaModelRequest);

    MetaDefinition quickAddModelAndDefinition(Long businessCategoryId, Long businessId, String metaModelName, String metaModelCode);

    void batchDelete(MetaModelRequest metaModelRequest);

    MetaDefinition upgradeModel(MetaModelRequest metaModelRequest);

    String getMetaModelNameById(Long metaModelId);

    Long getModelIdByModelCode(String modelCode);

    List<CommonGenerateResult> generateCreateTable(Long metaModelId);

    List<CommonGenerateResult> generateCreateTable(MetaModel metaModel, Long definitionId);

    List<MetaModel> getTotalTableList(MetaModelRequest metaModelRequest);

    MetaModel getBusinessMainModel(Long businessId);

    List<MetaModel> getTotalModelAndFieldList(MetaModelRequest metaModelRequest);

    void createTableIntoDb(Long metaDefinitionId);

    void updateTableIntoDb(TableUpdateOperateRequest tableUpdateOperateRequest);

    List<CategoryInfo> getCategoryModelList(MetaModelRequest metaModelRequest);

    String generateAlterSql(MetaModel metaModel, TableUpdateOperateRequest tableUpdateOperateRequest);

    Boolean validateTableExisted(String tableName);

}