Commit 0c282664 authored by xiandafu's avatar xiandafu
Browse files

add menu auto gen

parent 71995bc5
...@@ -19,6 +19,8 @@ public class Entity { ...@@ -19,6 +19,8 @@ public class Entity {
boolean attachment=false; boolean attachment=false;
//是否生成代码,也同时生成功能点 //是否生成代码,也同时生成功能点
boolean autoAddFunction = false; boolean autoAddFunction = false;
boolean autoAddMenu = false;
public String getName() { public String getName() {
return name; return name;
} }
...@@ -106,5 +108,11 @@ public class Entity { ...@@ -106,5 +108,11 @@ public class Entity {
public void setAutoAddFunction(boolean autoAddFunction) { public void setAutoAddFunction(boolean autoAddFunction) {
this.autoAddFunction = autoAddFunction; this.autoAddFunction = autoAddFunction;
} }
public boolean isAutoAddMenu() {
return autoAddMenu;
}
public void setAutoAddMenu(boolean autoAddMenu) {
this.autoAddMenu = autoAddMenu;
}
} }
...@@ -5,6 +5,8 @@ import java.util.Date; ...@@ -5,6 +5,8 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.beetl.sql.core.JavaType; import org.beetl.sql.core.JavaType;
import org.beetl.sql.core.NameConversion; import org.beetl.sql.core.NameConversion;
import org.beetl.sql.core.SQLManager; import org.beetl.sql.core.SQLManager;
...@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ibeetl.admin.core.entity.CoreFunction; import com.ibeetl.admin.core.entity.CoreFunction;
import com.ibeetl.admin.core.entity.CoreMenu;
import com.ibeetl.admin.core.gen.model.Attribute; import com.ibeetl.admin.core.gen.model.Attribute;
import com.ibeetl.admin.core.gen.model.Entity; import com.ibeetl.admin.core.gen.model.Entity;
...@@ -31,6 +34,8 @@ public class CoreCodeGenService { ...@@ -31,6 +34,8 @@ public class CoreCodeGenService {
@Autowired @Autowired
CorePlatformService platformService; CorePlatformService platformService;
Log log = LogFactory.getLog(CoreCodeGenService.class);
public List<Entity> getAllEntityInfo(){ public List<Entity> getAllEntityInfo(){
MetadataManager meta = sqlManager.getMetaDataManager(); MetadataManager meta = sqlManager.getMetaDataManager();
Set<String> set = meta.allTable(); Set<String> set = meta.allTable();
...@@ -103,7 +108,7 @@ public class CoreCodeGenService { ...@@ -103,7 +108,7 @@ public class CoreCodeGenService {
return e; return e;
} }
public boolean insertFunction(Entity data,String urlBase){ public Long insertFunction(Entity data,String urlBase){
String preffix = urlBase.replace('/', '.'); String preffix = urlBase.replace('/', '.');
String functionCode = preffix+"."+data.getCode(); String functionCode = preffix+"."+data.getCode();
String indexFunctonCode = functionCode+".query"; String indexFunctonCode = functionCode+".query";
...@@ -111,10 +116,10 @@ public class CoreCodeGenService { ...@@ -111,10 +116,10 @@ public class CoreCodeGenService {
query.setCode(indexFunctonCode); query.setCode(indexFunctonCode);
Object o = sqlManager.templateOne(query); Object o = sqlManager.templateOne(query);
if(o != null){ if(o != null){
return true; return -1l;
} }
//设置功能点 //设置功能点
CoreFunction rootFunction = new CoreFunction(); CoreFunction rootFunction = new CoreFunction();
rootFunction.setName(data.getDisplayName()); rootFunction.setName(data.getDisplayName());
rootFunction.setCode(functionCode); rootFunction.setCode(functionCode);
...@@ -167,6 +172,27 @@ public class CoreCodeGenService { ...@@ -167,6 +172,27 @@ public class CoreCodeGenService {
//刷新缓存 //刷新缓存
platformService.clearFunctionCache(); platformService.clearFunctionCache();
return indexFunction.getId();
}
public boolean insertMenu(Long functionId,Entity data,String urlBase){
CoreMenu query = new CoreMenu();
query.setCode("代码生成导航");
CoreMenu menu = this.sqlManager.templateOne(query);
if(menu==null) {
log.warn("未找到对应的父菜单:"+query.getCode());
return false ;
}
Long parentId = query.getId();
CoreMenu newMenu = new CoreMenu();
newMenu.setCode(data.getName()+".Manager");
newMenu.setName(data.getName()+"管理");
newMenu.setParentMenuId(parentId);
newMenu.setFunctionId(functionId);
newMenu.setType("MENU_M");
this.sqlManager.insert(newMenu);
this.platformService.clearMenuCache();
return true; return true;
} }
......
...@@ -284,6 +284,10 @@ public class CoreCodeGenController { ...@@ -284,6 +284,10 @@ public class CoreCodeGenController {
String code = entry.getValue(); String code = entry.getValue();
content.put(gen.getName(), code); content.put(gen.getName(), code);
} }
return JsonResult.success(content); return JsonResult.success(content);
} }
...@@ -320,6 +324,7 @@ public class CoreCodeGenController { ...@@ -320,6 +324,7 @@ public class CoreCodeGenController {
entity.setAttachment(data.entity.isAttachment()); entity.setAttachment(data.entity.isAttachment());
entity.setIncludeExcel(data.entity.isIncludeExcel()); entity.setIncludeExcel(data.entity.isIncludeExcel());
entity.setAutoAddFunction(info.isAutoAddFunction()); entity.setAutoAddFunction(info.isAutoAddFunction());
entity.setAutoAddMenu(info.isAutoAddFunction());
for (int i = 0; i < entity.getList().size(); i++) { for (int i = 0; i < entity.getList().size(); i++) {
Attribute attr = entity.getList().get(i); Attribute attr = entity.getList().get(i);
attr.setDisplayName(info.getList().get(i).getDisplayName()); attr.setDisplayName(info.getList().get(i).getDisplayName());
......
...@@ -145,10 +145,19 @@ ...@@ -145,10 +145,19 @@
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="checkbox" <input type="checkbox"
name="entity.autoAddFunction" name="entity.autoAddFunction"
lay-skin="primary" value="true" title="自动配置到功能点"/> lay-skin="primary" value="true" title=" 自动配置功能点"/>
</div>
<div class="layui-input-inline">
<input type="checkbox"
name="entity.autoAddMenu"
lay-skin="primary" value="true" title="自动添加到菜单"/>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment