package com.tofly.codegen.controller;

import com.tofly.codegen.entity.TableGen;
import com.tofly.codegen.service.GeneratorService;
import com.tofly.codegen.service.TableProcessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author tuonbed
 * @date 2020/1/2  14:47
 * 表处理
 */
@Controller
@Slf4j
@CrossOrigin
public class TableProcessController {


    @Autowired
    private GeneratorService generatorService;

    @Autowired
    private TableProcessService tableProcessService;

    @GetMapping("/queryColumns")
    @ResponseBody
    public List<Map> queryColumns(String tableName){
        return generatorService.queryColumns(tableName);
    }

    @PostMapping("/insertTableGen")
    @ResponseBody
    public int insertTableGen(@RequestBody TableGen tableGen){
        return tableProcessService.insertTableGen(tableGen);
    }
}
