Commit 18144407 authored by trumansdo's avatar trumansdo
Browse files

应用codestyle


千万千万要用vscode打开前端项目,或者关闭eslint,移除它
Signed-off-by: default avatartrumansdo <1012243881@qq.com>
parent 9b3d96a6
......@@ -3,46 +3,46 @@ package com.ibeetl.admin.core.file;
import java.io.OutputStream;
public abstract class FileItem {
protected Long id;
protected String name;
protected String path;
boolean isTemp = false;
public abstract OutputStream openOutpuStream();
public abstract void copy(OutputStream os);
public abstract boolean delete();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public boolean isTemp() {
return isTemp;
}
public void setTemp(boolean isTemp) {
this.isTemp = isTemp;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
protected Long id;
protected String name;
protected String path;
boolean isTemp = false;
public abstract OutputStream openOutpuStream();
public abstract void copy(OutputStream os);
public abstract boolean delete();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public boolean isTemp() {
return isTemp;
}
public void setTemp(boolean isTemp) {
this.isTemp = isTemp;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
......@@ -4,54 +4,63 @@ import java.io.OutputStream;
import java.util.List;
/**
* 文件持久化,默认为文件系统,可以扩展到fastfds等
* @author xiandafu
*
* @author xiandafu
*/
public interface FileService {
/**
* 得到一个临时文件操作
* @param name
* @return
*/
public FileItem createFileTemp(String name);
/**
* 创建一个持久的文档
* @param name
* @param bizType
* @param bizId
* @param userId
* @param orgId
* @param tags
* @return
*/
public FileItem createFileItem(String name,String bizType,String bizId,Long userId,Long orgId,String fileBatchId,List<FileTag> tags);
public FileItem loadFileItemByPath(String path);
public FileItem getFileItemById(Long id);
public FileItem getFileItemById(Long id,String batchFileId);
public List<FileItem> queryByUserId(Long userId,List<FileTag> tags);
public List<FileItem> queryByBiz(String bizType,String bizId);
public List<FileItem> queryByBatchId(String fileBatchId);
/**
* 删除某个文件
* @param id
* @param fileBatchId,用于验证
*/
public void removeFile(Long id,String fileBatchId);
/**
* 完善附件信息
* @param fileBatchId
* @param bizType
* @param bizId
*/
public void updateFile(String fileBatchId,String bizType,String bizId);
/**
* 得到一个临时文件操作
*
* @param name
* @return
*/
public FileItem createFileTemp(String name);
/**
* 创建一个持久的文档
*
* @param name
* @param bizType
* @param bizId
* @param userId
* @param orgId
* @param tags
* @return
*/
public FileItem createFileItem(
String name,
String bizType,
String bizId,
Long userId,
Long orgId,
String fileBatchId,
List<FileTag> tags);
public FileItem loadFileItemByPath(String path);
public FileItem getFileItemById(Long id);
public FileItem getFileItemById(Long id, String batchFileId);
public List<FileItem> queryByUserId(Long userId, List<FileTag> tags);
public List<FileItem> queryByBiz(String bizType, String bizId);
public List<FileItem> queryByBatchId(String fileBatchId);
/**
* 删除某个文件
*
* @param id
* @param fileBatchId,用于验证
*/
public void removeFile(Long id, String fileBatchId);
/**
* 完善附件信息
*
* @param fileBatchId
* @param bizType
* @param bizId
*/
public void updateFile(String fileBatchId, String bizType, String bizId);
}
package com.ibeetl.admin.core.file;
public class FileTag {
String name;
String value;
Long fileId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Long getFileId() {
return fileId;
}
public void setFileId(Long fileId) {
this.fileId = fileId;
}
String name;
String value;
Long fileId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Long getFileId() {
return fileId;
}
public void setFileId(Long fileId) {
this.fileId = fileId;
}
}
......@@ -9,67 +9,61 @@ import java.io.OutputStream;
import com.ibeetl.admin.core.util.PlatformException;
/**
* 本地文件系统
* @author xiandafu
*
* @author xiandafu
*/
class LocalFileItem extends PersistFileItem{
String root = null;
public LocalFileItem(String root) {
this.root = root;
}
public OutputStream openOutpuStream() {
File file = new File(root + File.separator + path);
try {
if(!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(file);
return fos;
} catch (IOException e) {
throw new PlatformException("Open stream error "+path);
}
class LocalFileItem extends PersistFileItem {
String root = null;
public LocalFileItem(String root) {
this.root = root;
}
public OutputStream openOutpuStream() {
File file = new File(root + File.separator + path);
try {
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(file);
return fos;
} catch (IOException e) {
throw new PlatformException("Open stream error " + path);
}
}
@Override
public void copy(OutputStream os) {
File file = new File(root + File.separator + path);
FileInputStream input = null;
try {
input = new FileInputStream(file);
byte[] buf = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buf)) > 0) {
os.write(buf, 0, bytesRead);
}
}catch(Exception ex) {
throw new PlatformException("下载文件失败"+ex);
}
finally {
try {
input.close();
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void copy(OutputStream os) {
File file = new File(root + File.separator + path);
FileInputStream input = null;
try {
input = new FileInputStream(file);
byte[] buf = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buf)) > 0) {
os.write(buf, 0, bytesRead);
}
if(path.startsWith("temp")) {
this.delete();
}
} catch (Exception ex) {
throw new PlatformException("下载文件失败" + ex);
} finally {
try {
input.close();
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public boolean delete() {
File file = new File(root + File.separator + path);
return file.delete();
if (path.startsWith("temp")) {
this.delete();
}
}
}
@Override
public boolean delete() {
File file = new File(root + File.separator + path);
return file.delete();
}
}
......@@ -16,160 +16,154 @@ import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.util.UUIDUtil;
/**
* 一个本地文件系统,管理临时文件和用户文件
* @author xiandafu
*
* @author xiandafu
*/
public class LocalFileService implements FileService {
Log log = LogFactory.getLog(this.getClass());
DBIndexHelper dbHelper = null;
String root = null;
public LocalFileService(ApplicationContext ctx,String root) {
this.root = root;
new File(root,"temp").mkdir();
dbHelper = new DBIndexHelper(ctx.getBean(CoreFileDao.class));
}
@Override
public FileItem loadFileItemByPath(String path) {
CoreFile coreFile = dbHelper.getFileItemByPath(path);
if(coreFile!=null) {
return getFileItem(coreFile);
}
LocalFileItem item = new LocalFileItem(root);
item.setPath(path);
item.setName(parseTempFileName(path));
item.setTemp(true);
return item;
}
@Override
public FileItem createFileTemp(String name) {
FileItem item = new LocalFileItem(root);
String fileName = "temp"+File.separator+name + "." + this.suffix();
item.setPath(fileName);
item.setName(name);
item.setTemp(true);
return item;
}
@Override
public FileItem createFileItem(String name, String bizType, String bizId, Long userId, Long orgId, String fileBatchId,List<FileTag> tags) {
CoreFile coreFile = new CoreFile();
coreFile.setBizId(bizId);
coreFile.setBizType(bizType);
coreFile.setUserId(userId);
coreFile.setOrgId(orgId);
coreFile.setName(name);
coreFile.setCreateTime(new Date());
coreFile.setFileBatchId(fileBatchId);
String dir = DateUtil.now("yyyyMMdd");
File dirFile = new File(root + File.separator + dir);
if(!dirFile.exists()) {
dirFile.mkdirs();
}
String fileName = name+"."+UUIDUtil.uuid();
String path = dir+File.separator+fileName;
coreFile.setPath(path);
//目前忽略tags
dbHelper.createFileItem(coreFile,tags);
return this.getFileItem(coreFile);
}
private String suffix() {
// TODO,改成唯一算法
return DateUtil.now("yyyyMMddhhmm")+ "-" + UUIDUtil.uuid();
}
private String parseTempFileName(String path) {
File file = new File(path);
String name = file.getName();
//去掉最后的临时标记
int index = name.lastIndexOf(".");
return name.substring(0, index);
}
protected FileItem getFileItem(CoreFile file) {
LocalFileItem item = new LocalFileItem(root);
item.setName(file.getName());
item.setPath(file.getPath());
item.setBizId(file.getBizId());
item.setBizType(file.getBizType());
item.setId(file.getId());
item.setOrgId(file.getOrgId());
item.setId(file.getId());
return item;
}
protected List<FileItem> getFileItem(List<CoreFile> files) {
List<FileItem> items = new ArrayList<>(files.size());
for(CoreFile file:files) {
items.add(this.getFileItem(file));
}
return items;
}
@Override
public FileItem getFileItemById(Long id) {
return this.getFileItem(dbHelper.getFileItemById(id));
}
@Override
public List<FileItem> queryByUserId(Long userId, List<FileTag> tags) {
return this.getFileItem(dbHelper.queryByUserId(userId, tags));
public class LocalFileService implements FileService {
Log log = LogFactory.getLog(this.getClass());
DBIndexHelper dbHelper = null;
String root = null;
public LocalFileService(ApplicationContext ctx, String root) {
this.root = root;
new File(root, "temp").mkdir();
dbHelper = new DBIndexHelper(ctx.getBean(CoreFileDao.class));
}
@Override
public FileItem loadFileItemByPath(String path) {
CoreFile coreFile = dbHelper.getFileItemByPath(path);
if (coreFile != null) {
return getFileItem(coreFile);
}
@Override
public List<FileItem> queryByBiz(String bizType, String bizId) {
return this.getFileItem(dbHelper.queryByBiz(bizType, bizId));
LocalFileItem item = new LocalFileItem(root);
item.setPath(path);
item.setName(parseTempFileName(path));
item.setTemp(true);
return item;
}
@Override
public FileItem createFileTemp(String name) {
FileItem item = new LocalFileItem(root);
String fileName = "temp" + File.separator + name + "." + this.suffix();
item.setPath(fileName);
item.setName(name);
item.setTemp(true);
return item;
}
@Override
public FileItem createFileItem(
String name,
String bizType,
String bizId,
Long userId,
Long orgId,
String fileBatchId,
List<FileTag> tags) {
CoreFile coreFile = new CoreFile();
coreFile.setBizId(bizId);
coreFile.setBizType(bizType);
coreFile.setUserId(userId);
coreFile.setOrgId(orgId);
coreFile.setName(name);
coreFile.setCreateTime(new Date());
coreFile.setFileBatchId(fileBatchId);
String dir = DateUtil.now("yyyyMMdd");
File dirFile = new File(root + File.separator + dir);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
@Override
public List<FileItem> queryByBatchId(String fileBatchId) {
return this.getFileItem(dbHelper.queryByBatchId(fileBatchId));
String fileName = name + "." + UUIDUtil.uuid();
String path = dir + File.separator + fileName;
coreFile.setPath(path);
// 目前忽略tags
dbHelper.createFileItem(coreFile, tags);
return this.getFileItem(coreFile);
}
private String suffix() {
// TODO,改成唯一算法
return DateUtil.now("yyyyMMddhhmm") + "-" + UUIDUtil.uuid();
}
private String parseTempFileName(String path) {
File file = new File(path);
String name = file.getName();
// 去掉最后的临时标记
int index = name.lastIndexOf(".");
return name.substring(0, index);
}
protected FileItem getFileItem(CoreFile file) {
LocalFileItem item = new LocalFileItem(root);
item.setName(file.getName());
item.setPath(file.getPath());
item.setBizId(file.getBizId());
item.setBizType(file.getBizType());
item.setId(file.getId());
item.setOrgId(file.getOrgId());
item.setId(file.getId());
return item;
}
protected List<FileItem> getFileItem(List<CoreFile> files) {
List<FileItem> items = new ArrayList<>(files.size());
for (CoreFile file : files) {
items.add(this.getFileItem(file));
}
@Override
public void removeFile(Long id, String fileBatchId) {
CoreFile file = dbHelper.getFileItemById(id);
if(!file.getFileBatchId().equals(fileBatchId)){
return ;
}
FileItem item = this.getFileItem(file);
boolean success = item.delete();
if(!success) {
log.warn("删除文件失败 "+file.getName()+ ",id="+file.getId()+" path="+file.getPath());
throw new PlatformException("删除文件失败 "+file.getName());
}
dbHelper.fileDao.deleteById(id);
return ;
return items;
}
@Override
public FileItem getFileItemById(Long id) {
return this.getFileItem(dbHelper.getFileItemById(id));
}
@Override
public List<FileItem> queryByUserId(Long userId, List<FileTag> tags) {
return this.getFileItem(dbHelper.queryByUserId(userId, tags));
}
@Override
public List<FileItem> queryByBiz(String bizType, String bizId) {
return this.getFileItem(dbHelper.queryByBiz(bizType, bizId));
}
@Override
public List<FileItem> queryByBatchId(String fileBatchId) {
return this.getFileItem(dbHelper.queryByBatchId(fileBatchId));
}
@Override
public void removeFile(Long id, String fileBatchId) {
CoreFile file = dbHelper.getFileItemById(id);
if (!file.getFileBatchId().equals(fileBatchId)) {
return;
}
@Override
public void updateFile(String fileBatchId, String bizType, String bizId) {
dbHelper.fileDao.updateBatchIdInfo(bizType, bizId, fileBatchId);
FileItem item = this.getFileItem(file);
boolean success = item.delete();
if (!success) {
log.warn("删除文件失败 " + file.getName() + ",id=" + file.getId() + " path=" + file.getPath());
throw new PlatformException("删除文件失败 " + file.getName());
}
@Override
public FileItem getFileItemById(Long id, String fileBatchId) {
CoreFile file = dbHelper.getFileItemById(id);
if(!file.getFileBatchId().equals(fileBatchId)){
return null;
}
return this.getFileItem(file);
dbHelper.fileDao.deleteById(id);
return;
}
@Override
public void updateFile(String fileBatchId, String bizType, String bizId) {
dbHelper.fileDao.updateBatchIdInfo(bizType, bizId, fileBatchId);
}
@Override
public FileItem getFileItemById(Long id, String fileBatchId) {
CoreFile file = dbHelper.getFileItemById(id);
if (!file.getFileBatchId().equals(fileBatchId)) {
return null;
}
return this.getFileItem(file);
}
}
......@@ -3,52 +3,62 @@ package com.ibeetl.admin.core.file;
import java.io.OutputStream;
public abstract class PersistFileItem extends FileItem {
protected Long id;
protected Long userId;
protected Long orgId;
protected String bizType;
protected String bizId;
FileTag[] tags;
public PersistFileItem() {
this.isTemp = false;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getOrgId() {
return orgId;
}
public void setOrgId(Long orgId) {
this.orgId = orgId;
}
public FileTag[] getTags() {
return tags;
}
public void setTags(FileTag[] tags) {
this.tags = tags;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
protected Long id;
protected Long userId;
protected Long orgId;
protected String bizType;
protected String bizId;
FileTag[] tags;
public PersistFileItem() {
this.isTemp = false;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getOrgId() {
return orgId;
}
public void setOrgId(Long orgId) {
this.orgId = orgId;
}
public FileTag[] getTags() {
return tags;
}
public void setTags(FileTag[] tags) {
this.tags = tags;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
}
......@@ -5,6 +5,7 @@ import java.io.Writer;
import com.ibeetl.admin.core.gen.model.Entity;
public interface AutoGen {
public void make(Target target,Entity entity);
public String getName();
public void make(Target target, Entity entity);
public String getName();
}
......@@ -11,76 +11,72 @@ import org.beetl.core.resource.ClasspathResourceLoader;
import com.ibeetl.admin.core.util.beetl.VerifyForamtFunction;
public abstract class BaseTarget implements Target {
protected GroupTemplate gt = null;
protected String urlBase = null;
@Override
public void flush(AutoGen gen, String content) {
// TODO Auto-generated method stub
}
@Override
public GroupTemplate getGroupTemplate() {
if(gt!=null) {
return gt;
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
ClasspathResourceLoader rs = new ClasspathResourceLoader(loader,"codeTemplate");
try {
Configuration cfg = Configuration.defaultConfiguration();
cfg.setStatementStart("@");
cfg.setStatementEnd(null);
cfg.setHtmlTagSupport(false);
cfg.build();
gt = new GroupTemplate(rs,cfg);
gt.registerFunction("verifyFormat", new VerifyForamtFunction());
gt.registerFunction("upperFirst", new Function() {
@Override
public Object call(Object[] paras, Context ctx) {
String s = (String)paras[0];
return upperFirst(s);
}
});
} catch (IOException e) {
throw new RuntimeException(e);
}
return gt;
}
public static String upperFirst(String s) {
if (Character.isUpperCase(s.charAt(0)))
return s;
else
return (new StringBuilder())
.append(Character.toUpperCase(s.charAt(0)))
.append(s.substring(1)).toString();
}
public GroupTemplate getGt() {
return gt;
}
public void setGt(GroupTemplate gt) {
this.gt = gt;
}
public String getUrlBase() {
return urlBase;
}
public void setUrlBase(String urlBase) {
this.urlBase = urlBase;
}
protected GroupTemplate gt = null;
protected String urlBase = null;
@Override
public void flush(AutoGen gen, String content) {
// TODO Auto-generated method stub
}
@Override
public GroupTemplate getGroupTemplate() {
if (gt != null) {
return gt;
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
ClasspathResourceLoader rs = new ClasspathResourceLoader(loader, "codeTemplate");
try {
Configuration cfg = Configuration.defaultConfiguration();
cfg.setStatementStart("@");
cfg.setStatementEnd(null);
cfg.setHtmlTagSupport(false);
cfg.build();
gt = new GroupTemplate(rs, cfg);
gt.registerFunction("verifyFormat", new VerifyForamtFunction());
gt.registerFunction(
"upperFirst",
new Function() {
@Override
public Object call(Object[] paras, Context ctx) {
String s = (String) paras[0];
return upperFirst(s);
}
});
} catch (IOException e) {
throw new RuntimeException(e);
}
return gt;
}
public static String upperFirst(String s) {
if (Character.isUpperCase(s.charAt(0))) return s;
else
return (new StringBuilder())
.append(Character.toUpperCase(s.charAt(0)))
.append(s.substring(1))
.toString();
}
public GroupTemplate getGt() {
return gt;
}
public void setGt(GroupTemplate gt) {
this.gt = gt;
}
public String getUrlBase() {
return urlBase;
}
public void setUrlBase(String urlBase) {
this.urlBase = urlBase;
}
}
package com.ibeetl.admin.core.gen;
/**
* 用于代码生成
* @author xiandafu
*
* @author xiandafu
*/
public class ConsoleTarget extends BaseTarget {
public ConsoleTarget() {}
public class ConsoleTarget extends BaseTarget {
public ConsoleTarget() {
}
@Override
public void flush(AutoGen gen, String content) {
System.out.println("=========="+gen.getClass().getSimpleName()+"=============");
System.out.println(content);
}
@Override
public void flush(AutoGen gen, String content) {
System.out.println("==========" + gen.getClass().getSimpleName() + "=============");
System.out.println(content);
}
}
......@@ -5,84 +5,77 @@ import org.beetl.core.Template;
import com.ibeetl.admin.core.gen.model.Entity;
public class HtmlGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
HtmlIndexGen indexGen = new HtmlIndexGen();
indexGen.make(target, entity);
HtmlEditGen editGen = new HtmlEditGen();
editGen.make(target, entity);
HtmlAddGen addGen = new HtmlAddGen();
addGen.make(target, entity);
}
@Override
public String getName() {
return "";
}
}
public class HtmlGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
class HtmlIndexGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/html/index.html");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "index.html";
}
}
HtmlIndexGen indexGen = new HtmlIndexGen();
indexGen.make(target, entity);
HtmlEditGen editGen = new HtmlEditGen();
editGen.make(target, entity);
class HtmlEditGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/html/edit.html");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "edit.html";
}
HtmlAddGen addGen = new HtmlAddGen();
addGen.make(target, entity);
}
@Override
public String getName() {
return "";
}
}
class HtmlAddGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/html/add.html");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "add.html";
}
class HtmlIndexGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/html/index.html");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "index.html";
}
}
class HtmlEditGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/html/edit.html");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "edit.html";
}
}
class HtmlAddGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/html/add.html");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "add.html";
}
}
......@@ -5,124 +5,117 @@ import org.beetl.core.Template;
import com.ibeetl.admin.core.gen.model.Entity;
public class JSGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
JSDelGen delGen = new JSDelGen();
delGen.make(target, entity);
JSAddGen addGen = new JSAddGen();
addGen.make(target, entity);
JSEditGen editGen = new JSEditGen();
editGen.make(target, entity);
JSApiGen apiGen = new JSApiGen();
apiGen.make(target, entity);
JSIndexGen indexGen = new JSIndexGen();
indexGen.make(target, entity);
}
@Override
public String getName() {
return "";
}
}
public class JSGen implements AutoGen {
class JSDelGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/del.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "del.js";
}
}
class JSAddGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/add.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "add.js";
}
@Override
public void make(Target target, Entity entity) {
JSDelGen delGen = new JSDelGen();
delGen.make(target, entity);
JSAddGen addGen = new JSAddGen();
addGen.make(target, entity);
JSEditGen editGen = new JSEditGen();
editGen.make(target, entity);
JSApiGen apiGen = new JSApiGen();
apiGen.make(target, entity);
JSIndexGen indexGen = new JSIndexGen();
indexGen.make(target, entity);
}
@Override
public String getName() {
return "";
}
}
class JSApiGen implements AutoGen{
Entity entity;
@Override
public void make(Target target, Entity entity) {
this.entity =entity;
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/entityApi.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return entity.getCode()+"Api.js";
}
class JSDelGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/del.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "del.js";
}
}
class JSAddGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/add.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
class JSEditGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/edit.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "edit.js";
}
@Override
public String getName() {
return "add.js";
}
}
class JSIndexGen implements AutoGen{
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/index.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "index.js";
}
class JSApiGen implements AutoGen {
Entity entity;
@Override
public void make(Target target, Entity entity) {
this.entity = entity;
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/entityApi.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return entity.getCode() + "Api.js";
}
}
class JSEditGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/edit.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "edit.js";
}
}
class JSIndexGen implements AutoGen {
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/js/index.js");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return "index.js";
}
}
......@@ -11,206 +11,196 @@ import org.beetl.core.Template;
import com.ibeetl.admin.core.gen.model.Attribute;
import com.ibeetl.admin.core.gen.model.Entity;
public class JavaCodeGen implements AutoGen{
String basePackage;
Entity entity;
String basicFunctionCode = null;
static String CR = System.getProperty("line.separator");
public JavaCodeGen(String basePackage,Entity entity,String basicFunctionCode) {
this.basePackage =basePackage;
this.entity = entity;
this.basicFunctionCode =basicFunctionCode;
}
@Override
public void make(Target target, Entity entity) {
JavaEntityGen entityGen = new JavaEntityGen(this);
entityGen.make(target, entity);
JavaDaoGen daoGen = new JavaDaoGen(this);
daoGen.make(target, entity);
JavaServiceGen serviceGen = new JavaServiceGen(this);
serviceGen.make(target, entity);
JavaControllerGen webGen = new JavaControllerGen(this);
webGen.make(target, entity);
JavaQueryGen queryGen = new JavaQueryGen(this);
queryGen.make(target, entity);
}
@Override
public String getName() {
return "";
}
}
public class JavaCodeGen implements AutoGen {
String basePackage;
Entity entity;
String basicFunctionCode = null;
static String CR = System.getProperty("line.separator");
public JavaCodeGen(String basePackage, Entity entity, String basicFunctionCode) {
this.basePackage = basePackage;
this.entity = entity;
this.basicFunctionCode = basicFunctionCode;
}
class JavaEntityGen implements AutoGen{
JavaCodeGen gen;
public JavaEntityGen(JavaCodeGen gen){
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/pojo.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage+".entity");
template.binding("className", entity.getName());
List<Map<String,Object>> attrs = new ArrayList<Map<String,Object>>();
for(Attribute attr:entity.getList()) {
Map<String,Object> map = new HashMap<String,Object>();
map.put("comment", attr.getComment());
map.put("type", attr.getJavaType());
map.put("name", attr.getName());
map.put("methodName", BaseTarget.upperFirst(attr.getName()));
map.put("isId", attr.isId());
map.put("dictType", attr.getDictType());
attrs.add(map);
}
template.binding("attrs", attrs);
String srcHead ="";
srcHead+="import java.math.*;"+JavaCodeGen.CR;
srcHead+="import java.util.Date;"+JavaCodeGen.CR;
srcHead+="import java.sql.Timestamp;"+JavaCodeGen.CR;
template.binding("imports", srcHead);
template.binding("comment", entity.getComment());
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName()+".java";
}
}
@Override
public void make(Target target, Entity entity) {
JavaEntityGen entityGen = new JavaEntityGen(this);
entityGen.make(target, entity);
class JavaDaoGen implements AutoGen{
JavaCodeGen gen;
public JavaDaoGen(JavaCodeGen gen){
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/dao.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage+".dao");
template.binding("basePackage", gen.basePackage);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName()+"Dao.java";
}
}
JavaDaoGen daoGen = new JavaDaoGen(this);
daoGen.make(target, entity);
JavaServiceGen serviceGen = new JavaServiceGen(this);
serviceGen.make(target, entity);
class JavaServiceGen implements AutoGen{
JavaCodeGen gen;
public JavaServiceGen(JavaCodeGen gen){
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/service.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage+".service");
template.binding("basePackage", gen.basePackage);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName()+"Service.java";
}
}
JavaControllerGen webGen = new JavaControllerGen(this);
webGen.make(target, entity);
JavaQueryGen queryGen = new JavaQueryGen(this);
queryGen.make(target, entity);
}
class JavaControllerGen implements AutoGen{
JavaCodeGen gen;
public JavaControllerGen(JavaCodeGen gen){
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/controller.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage+".web");
template.binding("basePackage", gen.basePackage);
template.binding("basicfunctionCode",gen.basicFunctionCode);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName()+"Controller.java";
}
@Override
public String getName() {
return "";
}
}
class JavaQueryGen implements AutoGen{
JavaCodeGen gen;
public JavaQueryGen(JavaCodeGen gen){
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/query.java");
List<Attribute> list = new ArrayList<Attribute>();
for(Attribute attr:entity.getList()) {
if(attr.isShowInQuery()) {
list.add(attr);
}
}
if(list.isEmpty()) {
list.add(entity.getIdAttribute());
}
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage+".web.query");
template.binding("basePackage", gen.basePackage);
template.binding("attrs", list);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName()+"Query.java";
}
class JavaEntityGen implements AutoGen {
JavaCodeGen gen;
public JavaEntityGen(JavaCodeGen gen) {
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/pojo.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage + ".entity");
template.binding("className", entity.getName());
List<Map<String, Object>> attrs = new ArrayList<Map<String, Object>>();
for (Attribute attr : entity.getList()) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("comment", attr.getComment());
map.put("type", attr.getJavaType());
map.put("name", attr.getName());
map.put("methodName", BaseTarget.upperFirst(attr.getName()));
map.put("isId", attr.isId());
map.put("dictType", attr.getDictType());
attrs.add(map);
}
template.binding("attrs", attrs);
String srcHead = "";
srcHead += "import java.math.*;" + JavaCodeGen.CR;
srcHead += "import java.util.Date;" + JavaCodeGen.CR;
srcHead += "import java.sql.Timestamp;" + JavaCodeGen.CR;
template.binding("imports", srcHead);
template.binding("comment", entity.getComment());
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName() + ".java";
}
}
class JavaDaoGen implements AutoGen {
JavaCodeGen gen;
public JavaDaoGen(JavaCodeGen gen) {
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/dao.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage + ".dao");
template.binding("basePackage", gen.basePackage);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName() + "Dao.java";
}
}
class JavaServiceGen implements AutoGen {
JavaCodeGen gen;
public JavaServiceGen(JavaCodeGen gen) {
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/service.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage + ".service");
template.binding("basePackage", gen.basePackage);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName() + "Service.java";
}
}
class JavaControllerGen implements AutoGen {
JavaCodeGen gen;
public JavaControllerGen(JavaCodeGen gen) {
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/controller.java");
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage + ".web");
template.binding("basePackage", gen.basePackage);
template.binding("basicfunctionCode", gen.basicFunctionCode);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName() + "Controller.java";
}
}
class JavaQueryGen implements AutoGen {
JavaCodeGen gen;
public JavaQueryGen(JavaCodeGen gen) {
this.gen = gen;
}
@Override
public void make(Target target, Entity entity) {
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/java/query.java");
List<Attribute> list = new ArrayList<Attribute>();
for (Attribute attr : entity.getList()) {
if (attr.isShowInQuery()) {
list.add(attr);
}
}
if (list.isEmpty()) {
list.add(entity.getIdAttribute());
}
template.binding("entity", entity);
template.binding("target", target);
template.binding("package", gen.basePackage + ".web.query");
template.binding("basePackage", gen.basePackage);
template.binding("attrs", list);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return gen.entity.getName() + "Query.java";
}
}
......@@ -7,114 +7,116 @@ import java.io.IOException;
import com.ibeetl.admin.core.gen.model.Entity;
public class MavenProjectTarget extends BaseTarget {
Entity entity;
String basePackage;
String basePackagePath = null;
String targetPath = null;
public MavenProjectTarget(Entity entity,String basePackage) {
this.entity = entity;
this.basePackage = basePackage;
this.basePackagePath = basePackage.replace('.', '/');
}
@Override
public void flush(AutoGen gen, String content) {
String name = gen.getName();
String target = null;
if (gen instanceof JSDelGen) {
target = getResourcePath()+"/static/js/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof JSEditGen) {
target = getResourcePath()+"/static/js/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof JSAddGen) {
target = getResourcePath()+"/static/js/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof JSApiGen) {
target = getResourcePath()+"/static/js/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof JSIndexGen) {
target = getResourcePath()+"/static/js/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof HtmlIndexGen) {
target = getResourcePath()+"/templates/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof HtmlEditGen) {
target = getResourcePath()+"/templates/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof HtmlAddGen) {
target = getResourcePath()+"/templates/"+this.urlBase+"/"+entity.getCode()+"/"+name;
}else if (gen instanceof MdGen) {
target = getResourcePath()+"/sql/"+entity.getSystem()+"/"+name;
}else if (gen instanceof JavaEntityGen) {
target = getSrcPath()+"/"+basePackagePath+"/entity/"+name;
}else if (gen instanceof JavaDaoGen) {
target = getSrcPath()+"/"+basePackagePath+"/dao/"+name;
}else if (gen instanceof JavaQueryGen) {
target = getSrcPath()+"/"+basePackagePath+"/web/query/"+name;
}else if (gen instanceof JavaServiceGen) {
target = getSrcPath()+"/"+basePackagePath+"/service/"+name;
}else if (gen instanceof JavaControllerGen) {
target = getSrcPath()+"/"+basePackagePath+"/web/"+name;
}
if(target==null) {
return ;
}
flush(target,content);
}
protected void flush(String path, String content) {
FileWriter fw;
try {
File file = new File(path);
if(!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fw = new FileWriter(new File(path));
fw.write(content);
fw.close();
System.out.println(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getTargetPath() {
return targetPath;
Entity entity;
String basePackage;
String basePackagePath = null;
String targetPath = null;
public MavenProjectTarget(Entity entity, String basePackage) {
this.entity = entity;
this.basePackage = basePackage;
this.basePackagePath = basePackage.replace('.', '/');
}
@Override
public void flush(AutoGen gen, String content) {
String name = gen.getName();
String target = null;
if (gen instanceof JSDelGen) {
target =
getResourcePath() + "/static/js/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof JSEditGen) {
target =
getResourcePath() + "/static/js/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof JSAddGen) {
target =
getResourcePath() + "/static/js/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof JSApiGen) {
target =
getResourcePath() + "/static/js/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof JSIndexGen) {
target =
getResourcePath() + "/static/js/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof HtmlIndexGen) {
target =
getResourcePath() + "/templates/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof HtmlEditGen) {
target =
getResourcePath() + "/templates/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof HtmlAddGen) {
target =
getResourcePath() + "/templates/" + this.urlBase + "/" + entity.getCode() + "/" + name;
} else if (gen instanceof MdGen) {
target = getResourcePath() + "/sql/" + entity.getSystem() + "/" + name;
} else if (gen instanceof JavaEntityGen) {
target = getSrcPath() + "/" + basePackagePath + "/entity/" + name;
} else if (gen instanceof JavaDaoGen) {
target = getSrcPath() + "/" + basePackagePath + "/dao/" + name;
} else if (gen instanceof JavaQueryGen) {
target = getSrcPath() + "/" + basePackagePath + "/web/query/" + name;
} else if (gen instanceof JavaServiceGen) {
target = getSrcPath() + "/" + basePackagePath + "/service/" + name;
} else if (gen instanceof JavaControllerGen) {
target = getSrcPath() + "/" + basePackagePath + "/web/" + name;
}
if (target == null) {
return;
}
flush(target, content);
}
protected void flush(String path, String content) {
FileWriter fw;
try {
File file = new File(path);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fw = new FileWriter(new File(path));
fw.write(content);
fw.close();
System.out.println(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setTargetPath(String targetPath) {
this.targetPath = targetPath;
public String getTargetPath() {
return targetPath;
}
public void setTargetPath(String targetPath) {
this.targetPath = targetPath;
}
private String getSrcPath() {
return getRootPath() + File.separator + "src/main/java";
}
private String getResourcePath() {
return getRootPath() + File.separator + "src/main/resources";
}
public String getRootPath() {
if (targetPath != null) {
return targetPath;
} else {
return detectRootPath();
}
}
private String getSrcPath() {
return getRootPath() + File.separator + "src/main/java";
}
private String getResourcePath() {
return getRootPath() + File.separator + "src/main/resources";
}
public String getRootPath() {
if(targetPath!=null) {
return targetPath;
}else {
return detectRootPath();
}
}
public static String detectRootPath() {
String srcPath;
String userDir = System.getProperty("user.dir");
if (userDir == null) {
throw new NullPointerException("用户目录未找到");
}
return userDir;
}
public static String detectRootPath() {
String srcPath;
String userDir = System.getProperty("user.dir");
if (userDir == null) {
throw new NullPointerException("用户目录未找到");
}
return userDir;
}
}
......@@ -11,30 +11,26 @@ import org.beetl.core.Template;
import com.ibeetl.admin.core.gen.model.Attribute;
import com.ibeetl.admin.core.gen.model.Entity;
public class MdGen implements AutoGen{
static String CR = System.getProperty("line.separator");
Entity entity = null;
public MdGen() {
}
@Override
public void make(Target target, Entity entity) {
this.entity = entity;
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/md/entity.md");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return entity.getCode()+".md";
}
}
public class MdGen implements AutoGen {
static String CR = System.getProperty("line.separator");
Entity entity = null;
public MdGen() {}
@Override
public void make(Target target, Entity entity) {
this.entity = entity;
GroupTemplate gt = target.getGroupTemplate();
Template template = gt.getTemplate("/md/entity.md");
template.binding("entity", entity);
template.binding("target", target);
String content = template.render();
target.flush(this, content);
}
@Override
public String getName() {
return entity.getCode() + ".md";
}
}
......@@ -4,10 +4,11 @@ import org.beetl.core.GroupTemplate;
/**
* 描述如何输出代码,有打印后台,页面输出,或者直接生成到项目里
* @author lijiazhi
*
* @author lijiazhi
*/
public interface Target {
public void flush(AutoGen gen,String content);
public GroupTemplate getGroupTemplate();
public void flush(AutoGen gen, String content);
public GroupTemplate getGroupTemplate();
}
......@@ -5,20 +5,16 @@ import java.util.Map;
import com.ibeetl.admin.core.gen.model.Entity;
public class WebTarget extends MavenProjectTarget {
public Map<Object,String> map = new HashMap<Object,String>();
public WebTarget(Entity entity,String basePackage) {
super(entity,basePackage);
}
@Override
public void flush(AutoGen gen, String content) {
map.put(gen, content);
public class WebTarget extends MavenProjectTarget {
}
public Map<Object, String> map = new HashMap<Object, String>();
public WebTarget(Entity entity, String basePackage) {
super(entity, basePackage);
}
@Override
public void flush(AutoGen gen, String content) {
map.put(gen, content);
}
}
......@@ -4,106 +4,123 @@ import java.util.ArrayList;
import java.util.List;
public class Attribute {
private String name;
private String colName;
private String javaType;
private String displayName;
private boolean isId;
private boolean showInQuery =false;
//数据字典
private String dictType;
private String comment;
// 是否范围
private boolean isDateRange;
private boolean isDateTimeRange;
//校验对象
private List<Verify> verifyList = new ArrayList<>();
public Attribute() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getColName() {
return colName;
}
public void setColName(String colName) {
this.colName = colName;
}
public String getJavaType() {
return javaType;
}
public void setJavaType(String javaType) {
this.javaType = javaType;
}
public String getDisplayName() {
if(displayName==null) {
return this.name;
}
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public boolean isId() {
return isId;
}
public void setId(boolean isId) {
this.isId = isId;
}
public boolean isShowInQuery() {
return showInQuery;
}
public void setShowInQuery(boolean showInQuery) {
this.showInQuery = showInQuery;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getDictType() {
return dictType;
private String name;
private String colName;
private String javaType;
private String displayName;
private boolean isId;
private boolean showInQuery = false;
// 数据字典
private String dictType;
private String comment;
// 是否范围
private boolean isDateRange;
private boolean isDateTimeRange;
// 校验对象
private List<Verify> verifyList = new ArrayList<>();
public Attribute() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getColName() {
return colName;
}
public void setColName(String colName) {
this.colName = colName;
}
public String getJavaType() {
return javaType;
}
public void setJavaType(String javaType) {
this.javaType = javaType;
}
public String getDisplayName() {
if (displayName == null) {
return this.name;
}
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public boolean isId() {
return isId;
}
public void setId(boolean isId) {
this.isId = isId;
}
public boolean isShowInQuery() {
return showInQuery;
}
public void setShowInQuery(boolean showInQuery) {
this.showInQuery = showInQuery;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getDictType() {
return dictType;
}
public void setDictType(String dictType) {
this.dictType = dictType;
}
public List<Verify> getVerifyList() {
return verifyList;
}
public void setVerifyList(List<Verify> verifyList) {
this.verifyList = verifyList;
}
public boolean isDateRange() {
for (Verify verify : verifyList) {
if (verify.getName().equals("dateRange")) {
return true;
}
}
public void setDictType(String dictType) {
this.dictType = dictType;
return false;
}
public void setDateRange(boolean dateRange) {
isDateRange = dateRange;
}
public boolean isDateTimeRange() {
for (Verify verify : verifyList) {
if (verify.getName().equals("datetimeRange")) {
return true;
}
}
public List<Verify> getVerifyList() {
return verifyList;
}
public void setVerifyList(List<Verify> verifyList) {
this.verifyList = verifyList;
}
public boolean isDateRange() {
for(Verify verify: verifyList) {
if(verify.getName().equals("dateRange")) {
return true;
}
}
return false;
}
public void setDateRange(boolean dateRange) {
isDateRange = dateRange;
}
public boolean isDateTimeRange() {
for(Verify verify: verifyList) {
if(verify.getName().equals("datetimeRange")) {
return true;
}
}
return false;
}
public void setDateTimeRange(boolean dateTimeRange) {
isDateTimeRange = dateTimeRange;
}
return false;
}
public void setDateTimeRange(boolean dateTimeRange) {
isDateTimeRange = dateTimeRange;
}
}
......@@ -4,115 +4,138 @@ import java.util.ArrayList;
import java.util.List;
public class Entity {
String name;
String tableName;
String code;
String displayName;
ArrayList<Attribute> list = new ArrayList<Attribute>();
Attribute idAttribute;
Attribute nameAttribute;
String comment;
String system;
//是否生成excel导入导出按钮
boolean includeExcel =false;
//是否包含附件信息
boolean attachment=false;
//是否生成代码,也同时生成功能点
boolean autoAddFunction = false;
boolean autoAddMenu = false;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDisplayName() {
if(displayName==null) {
return this.displayName;
}
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public ArrayList<Attribute> getList() {
return list;
}
public void setList(ArrayList<Attribute> list) {
this.list = list;
}
public Attribute getIdAttribute() {
return idAttribute;
}
public void setIdAttribute(Attribute idAttribute) {
this.idAttribute = idAttribute;
}
public Attribute getNameAttribute() {
return nameAttribute;
}
public void setNameAttribute(Attribute nameAttribute) {
this.nameAttribute = nameAttribute;
}
public String getSystem() {
return system;
}
public void setSystem(String system) {
this.system = system;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public List<Attribute> getGeneralList(){
List<Attribute> newList = new ArrayList<Attribute>();
for(Attribute attr:list) {
if(attr.getName().equals(this.idAttribute.getName())) {
continue;
}
newList.add(attr);
}
return newList;
}
public boolean isIncludeExcel() {
return includeExcel;
}
public void setIncludeExcel(boolean includeExcel) {
this.includeExcel = includeExcel;
}
public boolean isAttachment() {
return attachment;
String name;
String tableName;
String code;
String displayName;
ArrayList<Attribute> list = new ArrayList<Attribute>();
Attribute idAttribute;
Attribute nameAttribute;
String comment;
String system;
// 是否生成excel导入导出按钮
boolean includeExcel = false;
// 是否包含附件信息
boolean attachment = false;
// 是否生成代码,也同时生成功能点
boolean autoAddFunction = false;
boolean autoAddMenu = false;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDisplayName() {
if (displayName == null) {
return this.displayName;
}
public void setAttachment(boolean attachment) {
this.attachment = attachment;
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public ArrayList<Attribute> getList() {
return list;
}
public void setList(ArrayList<Attribute> list) {
this.list = list;
}
public Attribute getIdAttribute() {
return idAttribute;
}
public void setIdAttribute(Attribute idAttribute) {
this.idAttribute = idAttribute;
}
public Attribute getNameAttribute() {
return nameAttribute;
}
public void setNameAttribute(Attribute nameAttribute) {
this.nameAttribute = nameAttribute;
}
public String getSystem() {
return system;
}
public void setSystem(String system) {
this.system = system;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public List<Attribute> getGeneralList() {
List<Attribute> newList = new ArrayList<Attribute>();
for (Attribute attr : list) {
if (attr.getName().equals(this.idAttribute.getName())) {
continue;
}
newList.add(attr);
}
public boolean isAutoAddFunction() {
return autoAddFunction;
}
public void setAutoAddFunction(boolean autoAddFunction) {
this.autoAddFunction = autoAddFunction;
}
public boolean isAutoAddMenu() {
return autoAddMenu;
}
public void setAutoAddMenu(boolean autoAddMenu) {
this.autoAddMenu = autoAddMenu;
}
return newList;
}
public boolean isIncludeExcel() {
return includeExcel;
}
public void setIncludeExcel(boolean includeExcel) {
this.includeExcel = includeExcel;
}
public boolean isAttachment() {
return attachment;
}
public void setAttachment(boolean attachment) {
this.attachment = attachment;
}
public boolean isAutoAddFunction() {
return autoAddFunction;
}
public void setAutoAddFunction(boolean autoAddFunction) {
this.autoAddFunction = autoAddFunction;
}
public boolean isAutoAddMenu() {
return autoAddMenu;
}
public void setAutoAddMenu(boolean autoAddMenu) {
this.autoAddMenu = autoAddMenu;
}
}
package com.ibeetl.admin.core.gen.model;
/**
* 添加表单属性的校验
*/
/** 添加表单属性的校验 */
public class Verify {
private String name;//校验规则名称
private String name; // 校验规则名称
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -2,15 +2,18 @@ package com.ibeetl.admin.core.rbac;
/**
* 数据权限算法结果
* @author xiandafu
*
* @author xiandafu
*/
public enum AccessType {
OnlyUser(1), OnlyOrg(2), AllOrg(3), NoneOrg(4);
OnlyUser(1),
OnlyOrg(2),
AllOrg(3),
NoneOrg(4);
private int value;
private int value;
AccessType(int value) {
this.value = value;
}
AccessType(int value) {
this.value = value;
}
}
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