package com.th.demo.controller.develop;

import com.th.demo.service.develop.CodeMachineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping(value = "/CodeMachine")
public class CodeMachineController {

    @Autowired
    CodeMachineService codeMachineService;
    @RequestMapping(value = "/query.do")
    public String query(int page ,int rows,String queryTableName) throws IOException {
        return codeMachineService.query( page , rows,queryTableName);
    }
    @RequestMapping(value = "/queryTableProperty.do")
    public String queryTableProperty(String bussinessName) throws IOException {
        return codeMachineService.queryTableProperty(bussinessName);
    }
    @RequestMapping(value = "/queryTableName.do")
    public String queryTableName() throws IOException {
        return codeMachineService.queryTableName();
    }

    @RequestMapping(value = "/queryProcessName.do")
    public String queryProcessName() throws IOException {
        return codeMachineService.queryProcessName();
    }
    @RequestMapping(value = "/queryBussiness.do")
    public String queryBussiness(String processDefinitionId)  {
        return codeMachineService.queryBussiness(processDefinitionId);
    }

  //  http://localhost:8080/thdemo/CodeMachine/generate.do?id=&bussinessName=&dbTableName=T_TEST_COST&bussinessName=&processName=&patchName=&userId=
    @RequestMapping(value = "/generate.do", method = RequestMethod.POST)
    public String generate(String id ,
                           String bussinessName,
                           String dbTableName,
                           String processName,
                           String packageName,
                           String moduleName,
                           String userId) throws IOException {


        return codeMachineService.generate(id,bussinessName,
                dbTableName,
                processName,
                packageName,moduleName,userId);
    }

    @RequestMapping(value = "/remove.do", method = RequestMethod.POST)
    public String remove(String id,
                       String userId) throws IOException {

        return  codeMachineService.remove(id,userId);

    }

}
