Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.invms.x.services.basis.ManageService Maven / Gradle / Ivy
package com.invms.x.services.basis;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.invms.x.builders.ArgsBuilder;
import com.invms.x.components.GenerateHandler;
import com.invms.x.entities.IFieldEntity;
import com.invms.x.filters.EntityFilter;
import com.invms.x.filters.FieldFilter;
import com.invms.x.models.EntityModel;
import com.invms.x.services.BaseService;
import com.invms.x.utils.ComUtils;
import com.invms.x.utils.XUtils;
@SuppressWarnings("rawtypes")
@Service
public class ManageService extends BaseService {
@Autowired
private ObjectMapper objectMapper;
@Autowired
private ResourceLoader resourceLoader;
@Autowired
private GenerateHandler generateHandler;
@Autowired
private FieldService fieldService;
public String buildJs(EntityModel entityModel) throws Exception {
String entityCode = entityModel.getCode();
String text = "(function(window, undefined) {\r\n";
text += "\tvar managePanel = x.managePanel, options = {\r\n";
text += "\t\tcode : '" + entityCode + "'\r\n";
text += "\t};\r\n";
text += "\tmanagePanel.render(options);\r\n";
text += "})(window);";
return text;
}
public String buildHtml(EntityModel entityModel, boolean entityScript) throws Exception {
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, String[].class);
String entityCode = entityModel.getCode();
List fieldModels = entityModel.getFieldModels();
String webRoot;
if (entityScript) {
webRoot = "{webRoot}/dist/js/entity/entity";
} else {
webRoot = "{webRoot}/dist/js/" + entityModel.getCodePath() + "/" + entityModel.getCodeLast();
}
String text = "\r\n";
if (entityModel.isHierarchic()) {
text += "\t
\r\n";
text += "\t\t
\r\n";
text += "\t
\r\n";
}
text += "\t
\r\n";
text += "\t\t
\r\n";
text += "\t\t\t
详情 \r\n";
text += "\t\t\t
新增 \r\n";
text += "\t\t\t
修改 \r\n";
text += "\t\t\t
删除 \r\n";
text += "\t\t\t
清除 \r\n";
text += "\t\t\t
\r\n";
text += "\t\t\t
导出 \r\n";
text += "\t\t\t
设置查询列 \r\n";
text += "\t\t\t
设置列表列 \r\n";
text += "\t\t\t
保存排序列 \r\n";
text += "\t\t\t
\r\n";
text += "\t\t\t\t
清空 \r\n";
text += "\t\t\t\t
搜索 \r\n";
text += "\t\t\t
\r\n";
text += "\t\t
\r\n";
text += "\t\t
\r\n";
if (ComUtils.empty(entityModel.getSortOptions())) {
text += "\t\t
\r\n";
} else {
text += "\t\t\r\n";
}
text += "\t\t\t\r\n";
text += "\t\t\t\t\r\n";
for (IFieldEntity item : fieldModels) {
if (item.isListEnable()) {
String itemCode = item.getCode();
String itemName = item.getName();
String itemColumn = item.getColumn();
String dataOptions = "field:'" + itemColumn + "',title:'" + itemName + "'";
dataOptions += ",hidden:" + (item.isListVisible() ? "false" : "true");
dataOptions += ",sortable:" + (item.isSortEnable() ? "true" : "false");
if (!ComUtils.empty(item.getListOptions())) {
dataOptions += "," + item.getListOptions();
}
if (!ComUtils.empty(item.getSortOptions())) {
dataOptions += "," + item.getSortOptions();
}
text += "\t\t\t\t\t \r\n";
}
}
text += "\t\t\t\t \r\n";
text += "\t\t\t \r\n";
text += "\t\t
\r\n";
text += "\t\t
\r\n";
text += "\t\r\n";
text += "\r\n";
text += "";
return text;
}
public String buildDetailHtml(EntityModel entityModel) throws Exception {
List fieldModels = entityModel.getFieldModels();
String apiRoot = "{apiRoot}/entity/" + entityModel.getCodePath();
String text = "\r\n";
text += "\t
\r\n";
text += "\t\t
返回 \r\n";
text += "\t\t
重置 \r\n";
text += "\t
\r\n";
text += "\t