代码生成 - 编辑
This commit is contained in:
parent
b08bf59e63
commit
19d4bf34ec
|
|
@ -4,6 +4,7 @@ import com.hxkj.common.core.AjaxResult;
|
|||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import com.hxkj.generator.service.IGenerateService;
|
||||
import com.hxkj.generator.validate.GenParam;
|
||||
import com.hxkj.generator.validate.PageParam;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -78,8 +79,8 @@ public class GenController {
|
|||
* @return Object
|
||||
*/
|
||||
@PostMapping("/editTable")
|
||||
public Object editTable(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
iGenerateService.editTable(id);
|
||||
public Object editTable(@Validated() @RequestBody GenParam genParam) {
|
||||
iGenerateService.editTable(genParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class GenTable implements Serializable {
|
|||
private String functionName;
|
||||
private String functionAuthor;
|
||||
private String genTpl;
|
||||
private String genType;
|
||||
private Integer genType;
|
||||
private String genPath;
|
||||
private String remarks;
|
||||
private Long createTime;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hxkj.generator.service;
|
||||
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.generator.validate.GenParam;
|
||||
import com.hxkj.generator.validate.PageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -50,7 +51,7 @@ public interface IGenerateService {
|
|||
*
|
||||
* @author fzr
|
||||
*/
|
||||
void editTable(Integer id);
|
||||
void editTable(GenParam genParam);
|
||||
|
||||
/**
|
||||
* 删除表结构
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.hxkj.generator.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.hxkj.common.constant.GenConstants;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
|
@ -14,11 +15,13 @@ import com.hxkj.generator.mapper.GenTableMapper;
|
|||
import com.hxkj.generator.service.IGenerateService;
|
||||
import com.hxkj.generator.util.GenUtil;
|
||||
import com.hxkj.generator.util.VelocityUtil;
|
||||
import com.hxkj.generator.validate.GenParam;
|
||||
import com.hxkj.generator.validate.PageParam;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.StringWriter;
|
||||
|
|
@ -156,6 +159,7 @@ public class GenerateServiceImpl implements IGenerateService {
|
|||
* @param tableNames 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void importTable(String[] tableNames) {
|
||||
List<Map<String, String>> tables = genTableMapper.selectDbTableListByNames(tableNames);
|
||||
|
||||
|
|
@ -266,11 +270,45 @@ public class GenerateServiceImpl implements IGenerateService {
|
|||
* 编辑表结构
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @param genParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void editTable(Integer id) {
|
||||
@Transactional
|
||||
public void editTable(GenParam genParam) {
|
||||
GenTable model = genTableMapper.selectById(genParam.getId());
|
||||
Assert.notNull(model, "数据已丢失");
|
||||
|
||||
model.setTableName(genParam.getTableName());
|
||||
model.setEntityName(genParam.getEntityName());
|
||||
model.setTableComment(genParam.getTableComment());
|
||||
model.setFunctionAuthor(genParam.getFunctionAuthor());
|
||||
model.setRemarks(genParam.getRemarks());
|
||||
model.setGenTpl(genParam.getGenTpl());
|
||||
model.setModuleName(genParam.getModuleName());
|
||||
model.setPackageName(genParam.getPackageName());
|
||||
model.setBusinessName(genParam.getBusinessName());
|
||||
model.setFunctionName(genParam.getFunctionName());
|
||||
model.setGenType(genParam.getGenType());
|
||||
model.setGenPath(genParam.getGenPath());
|
||||
genTableMapper.updateById(model);
|
||||
|
||||
for (Map<String, String> item : genParam.getColumns()) {
|
||||
Integer id = Integer.parseInt(item.get("id"));
|
||||
GenTableColumn column = genTableColumnMapper.selectById(id);
|
||||
column.setColumnComment(item.get("columnComment"));
|
||||
column.setJavaField(item.get("javaField"));
|
||||
column.setIsPk(Integer.parseInt(item.get("isPK")));
|
||||
column.setIsIncrement(Integer.parseInt(item.get("isIncrement")));
|
||||
column.setIsRequired(Integer.parseInt(item.get("isRequired")));
|
||||
column.setIsInsert(Integer.parseInt(item.get("isInsert")));
|
||||
column.setIsEdit(Integer.parseInt(item.get("isEdit")));
|
||||
column.setIsList(Integer.parseInt(item.get("isList")));
|
||||
column.setIsQuery(Integer.parseInt(item.get("isQuery")));
|
||||
column.setQueryType(item.get("queryType"));
|
||||
column.setHtmlType(item.get("htmlType"));
|
||||
column.setDictType(item.get("dictType"));
|
||||
genTableColumnMapper.updateById(column);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import org.hibernate.validator.constraints.Length;
|
|||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 生成参数
|
||||
|
|
@ -78,4 +80,6 @@ public class GenParam implements Serializable {
|
|||
@Length(max = 200, message = "生成代码路径不能大于200个字符")
|
||||
private String genPath;
|
||||
|
||||
private List<Map<String, String>> columns;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue