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

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.team.generator.api.pojo.generator.result.CommonGenerateResult;
import cn.stylefeng.team.meta.modular.pojo.request.BusinessGenerateRequest;
import cn.stylefeng.team.meta.modular.pojo.request.MetaModelRequest;
import cn.stylefeng.team.meta.modular.pojo.response.GenerateCreateTableSqlResult;
import cn.stylefeng.team.meta.modular.service.BusinessCodeGenerateService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiResource(name = "元数据SQL导出控制器")
public class BusinessCodeGenerateController {

    @Resource
    private BusinessCodeGenerateService businessCodeGenerateService;

    @GetResource(name = "汇总导出业务的所有数据库表", path = "/metaSqlExport/summaryCreateTableSql")
    public ResponseData<GenerateCreateTableSqlResult> summaryCreateTableSql(MetaModelRequest metaModelRequest) {
        GenerateCreateTableSqlResult result = businessCodeGenerateService.summaryCreateTableSql(metaModelRequest);
        return new SuccessResponseData<>(result);
    }

    @GetResource(name = "汇总导出项目字典insertSQL", path = "/metaSqlExport/summaryCreateDictSql")
    public ResponseData<CommonGenerateResult> summaryCreateDictSql(BusinessGenerateRequest businessGenerateRequest) {
        CommonGenerateResult result = businessCodeGenerateService.summaryCreateDictSql(businessGenerateRequest);
        return new SuccessResponseData<>(result);
    }

    @GetResource(name = "汇总导出项目的字典的java枚举", path = "/metaBusinessCode/javaEnums")
    public ResponseData<List<CommonGenerateResult>> javaEnums(BusinessGenerateRequest businessGenerateRequest) {
        List<CommonGenerateResult> result = businessCodeGenerateService.javaEnums(businessGenerateRequest);
        return new SuccessResponseData<>(result);
    }

}
