com.fhs.pagex.service.PageXAutoJavaService Maven / Gradle / Ivy
The newest version!
package com.fhs.pagex.service;
import com.fhs.common.spring.SpringContextUtil;
import com.fhs.common.utils.CheckUtils;
import com.fhs.common.utils.ConverterUtils;
import com.fhs.common.utils.Logger;
import com.fhs.common.utils.StringUtil;
import com.fhs.config.BeetlConf;
import com.fhs.core.clazz.MemoryClassLoader;
import com.fhs.pagex.common.BeetlUtil;
import com.fhs.pagex.dto.PagexListSettDTO;
import com.mybatis.jpa.common.ColumnNameUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 根据js代码自动生成javabean
* @ProjectName: framework_v2_idea2
* @Package: com.fhs.pagex.service
* @ClassName: PageXAutoJavaService
* @Author: JackWang
* @CreateDate: 2018/12/10 0010 9:02
* @UpdateUser: JackWang
* @UpdateDate: 2018/12/10 0010 9:02
* @Version: 1.0
*/
@Service
public class PageXAutoJavaService {
private static final Logger LOG = Logger.getLogger(PageXAutoJavaService.class);
@Autowired
private PageXDBService pageXDBService;
public static final Set DEFAULT_FIELD_SET = new HashSet<>();
static
{
DEFAULT_FIELD_SET.add("create_user");
DEFAULT_FIELD_SET.add("update_user");
DEFAULT_FIELD_SET.add("create_time");
DEFAULT_FIELD_SET.add("update_time");
}
/**
* 翻译简写
*/
private static Map transAbbreviationMap = new HashMap<>();
static
{
transAbbreviationMap.put("book","wordbook");
transAbbreviationMap.put("user","sysUser");
transAbbreviationMap.put("type","classifyInfo");
transAbbreviationMap.put("fuser","ucenter:frontUser");
}
private BeetlConf beetlConf;
/**
*自动生成Java文件并编译为class
* @param js js内容
*/
public void autoJava(String js) throws Exception {
if(beetlConf == null){
beetlConf = SpringContextUtil.getBeanByName(BeetlConf.class);
}
PagexListSettDTO pagexListSettDTO = new PagexListSettDTO(js);
String namespace = ConverterUtils.toString(pagexListSettDTO.getModelConfig().get("namespace"));
if(ConverterUtils.toBoolean(pagexListSettDTO.getModelConfig().get("trans")))
{
pageXDBService.getNeedTransNamespaceSet().add(namespace);
}
String javaClassName = StringUtil.firstCharUpperCase(ColumnNameUtil.underlineToCamel(namespace));
//po对象
Map poMap = new HashMap<>();
poMap.put("className", javaClassName);
StringBuilder transTypes = new StringBuilder("\"wordbook\",\"sysUser\",\"classifyInfo\",\"ucenter:frontUser\"");
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy