import com.taauav.admin.controller.BaseController; | import com.taauav.admin.controller.BaseController; | ||||
import com.taauav.common.bean.Response; | import com.taauav.common.bean.Response; | ||||
import com.taauav.tool.service.IGenTableService; | import com.taauav.tool.service.IGenTableService; | ||||
import org.apache.ibatis.annotations.Param; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
* 导入表结构(保存) | * 导入表结构(保存) | ||||
*/ | */ | ||||
@GetMapping("/importTable") | @GetMapping("/importTable") | ||||
public Response importTableSave(String tables) | |||||
public Response importTableSave(@RequestParam("tableName") String tableName) | |||||
{ | { | ||||
genTableService.importGenTable(tables); | |||||
genTableService.importGenTable(tableName); | |||||
return response.success("操作成功"); | return response.success("操作成功"); | ||||
} | } | ||||
@GetMapping("genCode") | @GetMapping("genCode") | ||||
public Response genCode(@Param("tableName") String tableName) | |||||
public Response genCode(@RequestParam("tableName") String tableName) | |||||
{ | { | ||||
genTableService.generatorCode(tableName); | genTableService.generatorCode(tableName); | ||||
return response.success("操作成功"); | return response.success("操作成功"); |
//查询列信息 | //查询列信息 | ||||
List<GenTableColumn> colums = table.getColumns(); | List<GenTableColumn> colums = table.getColumns(); | ||||
setPkColumn(table, colums); | setPkColumn(table, colums); | ||||
//过滤不需要生成的字段 | |||||
setIgnoreColumn(table, colums); | |||||
VelocityInitializer.initVelocity(); | VelocityInitializer.initVelocity(); | ||||
VelocityContext context = VelocityUtils.prepareContext(table); | VelocityContext context = VelocityUtils.prepareContext(table); | ||||
//获取模板列表 | //获取模板列表 |
String funcationName = genTable.getFunctionName(); | String funcationName = genTable.getFunctionName(); | ||||
List<GenTableColumn> columnList = genTable.getColumns(); | List<GenTableColumn> columnList = genTable.getColumns(); | ||||
for (int i=0; i < columnList.size(); i++) { | |||||
GenTableColumn column = columnList.get(i); | |||||
if (null == column) { | |||||
continue; | |||||
} | |||||
if (column.getColumnName().equals("status") || column.getColumnName().equals("create_user") || | |||||
column.getColumnName().equals("create_time") || column.getColumnName().equals("update_user") || | |||||
column.getColumnName().equals("update_time") || column.getColumnName().equals("mark")) { | |||||
columnList.remove(i); | |||||
} | |||||
} | |||||
VelocityContext velocityContext = new VelocityContext(); | VelocityContext velocityContext = new VelocityContext(); | ||||
velocityContext.put("tplCategory", tplCategory); | velocityContext.put("tplCategory", tplCategory); |