Browse Source

'代码生成'

master
dongyuangong 4 years ago
parent
commit
3b0160bac5
3 changed files with 16 additions and 5 deletions
  1. +3
    -4
      src/main/java/com/taauav/tool/controller/GenController.java
  2. +2
    -1
      src/main/java/com/taauav/tool/service/GenTableServiceImpl.java
  3. +11
    -0
      src/main/java/com/taauav/tool/util/VelocityUtils.java

+ 3
- 4
src/main/java/com/taauav/tool/controller/GenController.java View File

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("操作成功");

+ 2
- 1
src/main/java/com/taauav/tool/service/GenTableServiceImpl.java View File

//查询列信息 //查询列信息
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);
//获取模板列表 //获取模板列表

+ 11
- 0
src/main/java/com/taauav/tool/util/VelocityUtils.java View File

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);

Loading…
Cancel
Save