diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreCodeGenService.java b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreCodeGenService.java index 817b418d739a244caf79ab9d79660447d3369ab0..415d9fcd2bfe4980339c32392c0e25e346c357e7 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreCodeGenService.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreCodeGenService.java @@ -1,9 +1,10 @@ package com.ibeetl.admin.core.service; -import org.beetl.core.Configuration; -import org.beetl.core.GroupTemplate; -import org.beetl.core.Template; -import org.beetl.core.resource.ClasspathResourceLoader; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; + import org.beetl.sql.core.JavaType; import org.beetl.sql.core.NameConversion; import org.beetl.sql.core.SQLManager; @@ -11,20 +12,13 @@ import org.beetl.sql.core.db.ClassDesc; import org.beetl.sql.core.db.ColDesc; import org.beetl.sql.core.db.MetadataManager; import org.beetl.sql.core.db.TableDesc; -import org.beetl.sql.ext.gen.GenConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ibeetl.admin.core.entity.CoreFunction; import com.ibeetl.admin.core.gen.model.Attribute; import com.ibeetl.admin.core.gen.model.Entity; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - /** * 代码生成,用于根据表或者视图生成entity,mapper,service,conroller * 未来可以生成swagger api,界面 @@ -107,6 +101,22 @@ public class CoreCodeGenService { return e; } + public boolean insertFunction(Entity data,String urlBase){ + CoreFunction cf = new CoreFunction(); + cf.setAccessUrl("/"+urlBase+"/"+data.getCode()+"/index.do"); + Object o = sqlManager.templateOne(cf); + + if(o == null){ + cf.setName(data.getDisplayName()); + cf.setCode(data.getTableName().replace("_", ".")); + cf.setCreateTime(new Date()); + cf.setParentId(0L); + cf.setType("FN0"); + sqlManager.insert(cf); + } + return true; + } + //根据类名提供一个变量名 private String getEntityCode(String s) { //找到最后一个大写字母,以此为变量名 diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/web/CoreCodeGenController.java b/admin-core/src/main/java/com/ibeetl/admin/core/web/CoreCodeGenController.java index 58448726293fd90af4b10c158628a9deab5cd85b..cd1f3fc5344e259f8ca8a931f6c9fb9dbfccef3f 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/web/CoreCodeGenController.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/web/CoreCodeGenController.java @@ -208,6 +208,8 @@ public class CoreCodeGenController { MdGen mdGen = new MdGen(); mdGen.make(target, entity); + + codeGenService.insertFunction(data.entity,data.urlBase); return JsonResult.success(); }