package com.boman.gen.controller;

import com.boman.common.core.web.controller.BaseController;
import com.boman.domain.dto.AjaxResult;
import com.boman.domain.TableSql;
import com.boman.gen.service.ITableSqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author tjf
 * @Date: 2021/04/14/10:27
 */
@RequestMapping("/tableSql")
@RestController
public class TableSqlController extends BaseController {


    @Autowired
    private ITableSqlService tableSqlService;


    /**
     * @Description 新增建表sql语句
     * @author tjf
     * @Date 2021/3/24
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody TableSql tableSql) {
        return tableSqlService.insertTableSql(tableSql);
    }

    /**
     * @Description 刷新建表sql语句
     * @author tjf
     * @Date 2021/3/24
     */
    @PostMapping("/reload")
    public AjaxResult reload(@Validated @RequestBody TableSql tableSql) {
        return tableSqlService.reloadTableSql(tableSql);
    }


    /**
     * 执行创建语句
     * @param tableSql
     * @return
     */
    @PostMapping("/implement")
    public AjaxResult implementSql(@Validated @RequestBody TableSql tableSql) {
        return tableSqlService.implementSql(tableSql);
    }

    /**
     * 查询
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return tableSqlService.selectTableSqlByTableId(id);
    }
}
