提交 b457b716 编写于 作者: sq3536's avatar sq3536

提交

上级 e94fd7f2
......@@ -100,7 +100,7 @@
<dependency>
<groupId>net.ibizsys.model</groupId>
<artifactId>ibizlab-model</artifactId>
<version>1.2.2</version>
<version>1.2.4</version>
</dependency>
</dependencies>
......
......@@ -237,7 +237,7 @@ public class DOModel extends EntityBase implements Serializable {
else if(keyMap.size()>1)
{
String key=DataObject.getStringValue(keyValue,"");
String[] keys=key.split("||");
String[] keys=key.split("\\|\\|");
if(keyMap.size()!=keys.length)
return null;
int i=0;
......
package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Getter
@Setter
......@@ -21,10 +38,136 @@ public class DstSystemModel {
@JSONField(name = "pssystemid")
@JsonProperty("pssystemid")
private String pssystemid;
/**
* 系统名称
*/
@JSONField(name = "pssystemname")
@JsonProperty("pssystemname")
private String pssystemname;
/**
* 结构
*/
@JSONField(name = "sysstructure")
@JsonProperty("sysstructure")
private Map sysstructure;
/**
* 应用
*/
@JSONField(name = "apps")
@JsonProperty("apps")
private List<App> apps;
public DstSystemModel addApp(App app)
{
if(apps==null)
apps=new ArrayList<>();
apps.add(app.setSystemid(this.pssystemid));
return this;
}
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class App{
private String id;
private String label;
private String systemid;
private String fullname;
private String type;
private String group;
private String icon;
private Integer visabled;
private String addr;
}
/**
* 校验
*/
@JSONField(name = "md5check")
@JsonProperty("md5check")
private String md5check;
/**
* 排序
*/
@JSONField(name = "showorder")
@JsonProperty("showorder")
private Integer showorder;
private Map<String,Object> extensionparams;
public DstSystemModel setDynamicModelPath(String dynamic_model_path)
{
if(extensionparams==null)
extensionparams=new HashMap<String,Object>();
extensionparams.put("dynamic_model_path",dynamic_model_path);
return this;
}
@JSONField(serialize = false)
@JsonIgnore
public String getDynamicModelPath()
{
if(extensionparams!=null&&extensionparams.get("dynamic_model_path")!=null)
return extensionparams.get("dynamic_model_path").toString();
return null;
}
public DstSystemModel setLastModify(Long lastModify)
{
if(extensionparams==null)
extensionparams=new HashMap<String,Object>();
extensionparams.put("last_modify",lastModify);
return this;
}
@JSONField(serialize = false)
@JsonIgnore
public Long getLastModify()
{
if(extensionparams!=null&&extensionparams.get("last_modify")!=null)
return DataObject.getLongValue(extensionparams.get("last_modify"),0L);
return 0L;
}
public DstSystemModel fromPath(Path path)
{
try {
if(!Files.exists(path))
throw new BadRequestAlertException("读取文件失败","DstSystem",path.toString());
JSONObject jo=JSON.parseObject(new String(Files.readAllBytes(path), StandardCharsets.UTF_8));
this.setPssystemid(jo.getString("codeName"));
this.setPssystemname(jo.getString("logicName"));
this.setLastModify(path.toFile().lastModified());
if(jo.containsKey("getAllPSApps"))
{
JSONArray array=jo.getJSONArray("getAllPSApps");
array.forEach(obj->{
JSONObject app=(JSONObject)obj;
String appPath=app.getString("path");
if(!StringUtils.isEmpty(appPath))
{
String[] args=appPath.split("/");
if(args.length==3)
{
String appId=args[1];
this.addApp(new App().setId(appId).setLabel(appId));
}
}
});
}
this.setDynamicModelPath(path.getParent().toAbsolutePath().toString());
} catch (IOException e) {
throw new BadRequestAlertException("读取文件失败","DstSystem",path.toString());
}
return this;
}
}
......@@ -58,7 +58,15 @@ public class EntityModel {
private MetaEntityModel entity;
private List<Map> dataSets;
private List<MetaDataSetModel> dataSets;
public EntityModel addDataSet(MetaDataSetModel dataSet)
{
if(dataSets==null)
dataSets=new ArrayList<>();
dataSets.add(dataSet);
return this;
}
private List<FieldModel> fields;
......
......@@ -19,11 +19,11 @@ public interface LiteModelFeignClient {
String defaultToken="Bearer eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpYnphZG1pbiIsImV4cCI6MTkzMzI0MTkzNywiaWF0IjoxNjE3ODgxOTM3fQ.dFmy-Sx0SlKQcDhbbAs9_bPkbAfy8eRLlGdtl-YZhfU82bCuS4n56ESK8fE0xQqqNJJM87X7U9CnWxRk9z9Xh_dqch-GW8qPj5s25cFsR96V2Ke-6XirCnS-fTRfY9ZIcqVT2gvFUE1MiSbEC-7SPgxcGrNZv0bLzmlW3drlSyQ";
@GetMapping( "/lite/{system}/entitys/{entity}")
@GetMapping( "/lite/{system}/entities/{entity}")
@Cacheable( value="entitymodel",key = "'row:'+#p0+'.'+#p1")
EntityModel getProxyEntityModel(@PathVariable("system") String system, @PathVariable("entity") String entity);
@GetMapping("/lite/{system}/entitys")
@GetMapping("/lite/{system}/entities")
List<EntityModel> getEntityModel(@PathVariable("system") String system);
@GetMapping( "/lite/sysapps")
......
package cn.ibizlab.core.data.lite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.File;
@Component
public class LiteStorage {
public static String MODEL_PATH;
private static LiteModelFeignClient liteModelFeignClient;
private static DynamicModelService dynamicModelService;
......@@ -18,6 +23,11 @@ public class LiteStorage {
LiteStorage.dynamicModelService=service;
}
public static DynamicModelService getDynamicModelService()
{
return dynamicModelService;
}
public static void setLiteModelService(LiteModelFeignClient service)
{
if(LiteStorage.liteModelFeignClient==null)
......@@ -29,10 +39,6 @@ public class LiteStorage {
return liteModelFeignClient;
}
public static DynamicModelService getDynamicModelService()
{
return dynamicModelService;
}
public static EntityModel getEntityModel(String system,String entity)
{
......@@ -59,10 +65,21 @@ public class LiteStorage {
private DynamicModelService dynamicService;
@Value("${ibiz.model.path:/app/file/model/}")
private String modelPath;
public String getModelPath()
{
if(modelPath.equals(File.separator))
return modelPath.substring(0,modelPath.length()-1);
return modelPath;
}
@PostConstruct
public void init(){
LiteStorage.setLiteModelService(liteService);
LiteStorage.setDynamicModelService(dynamicService);
LiteStorage.MODEL_PATH=getModelPath();
}
......
package cn.ibizlab.core.data.lite;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* 实体[数据集]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("数据集")
public class MetaDataSetModel {
/**
* 标识
*/
@JSONField(name = "dataset_id")
@JsonProperty("dataset_id")
@ApiModelProperty("标识")
private String datasetId;
/**
* 名称
*/
@JSONField(name = "dataset_name")
@JsonProperty("dataset_name")
@ApiModelProperty("名称")
private String datasetName;
/**
* 实体标识
*/
@JSONField(name = "entity_id")
@JsonProperty("entity_id")
@ApiModelProperty("实体标识")
private String entityId;
/**
* 实体
*/
@JSONField(name = "entity_name")
@JsonProperty("entity_name")
@ApiModelProperty("实体")
private String entityName;
/**
* 代码名称
*/
@JSONField(name = "code_name")
@JsonProperty("code_name")
@ApiModelProperty("代码名称")
private String codeName;
/**
* 代码
*/
@JSONField(name = "ds_code")
@JsonProperty("ds_code")
@ApiModelProperty("代码")
private String dsCode;
/**
* 模型
*/
@JSONField(name = "ds_model")
@JsonProperty("ds_model")
@ApiModelProperty("模型")
private String dsModel;
}
package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
......@@ -10,6 +13,9 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 实体[实体]
......@@ -116,8 +122,30 @@ public class MetaEntityModel{
private Timestamp updatedate;
@JSONField(serialize = false)
@JsonIgnore
private Map<String,Object> extensionparams;
public Object get(String key)
{
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
return extensionparams.get(key);
}
public MetaEntityModel set(String key,Object value)
{
if(value==null)
return this;
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String,Object> entry:extensionparams.entrySet())
settingList.add(new Setting().setProperty(key).setValue(DataObject.getStringValue(value,"")));
return setExtParams(JSON.toJSONString(settingList));
}
}
......
package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
......@@ -12,6 +15,9 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 实体[属性]
......@@ -260,7 +266,37 @@ public class MetaFieldModel {
private Timestamp updatedate;
/**
* 扩展参数
*/
@JSONField(name = "ext_params")
@JsonProperty("ext_params")
private String extParams;
@JSONField(serialize = false)
@JsonIgnore
private Map<String,Object> extensionparams;
public Object get(String key)
{
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
return extensionparams.get(key);
}
public MetaFieldModel set(String key,Object value)
{
if(value==null)
return this;
if(extensionparams==null)
extensionparams=Setting.getMap(extParams);
extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String,Object> entry:extensionparams.entrySet())
settingList.add(new Setting().setProperty(key).setValue(DataObject.getStringValue(value,"")));
return setExtParams(JSON.toJSONString(settingList));
}
}
......
package cn.ibizlab.core.data.model;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
......@@ -12,7 +13,11 @@ import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.*;
@Getter
......@@ -128,6 +133,28 @@ public class PojoSchema {
@JsonIgnore
public PojoSchema build()
{
if((!built)&&Type.object.getCode().equalsIgnoreCase(this.getType()))
{
if(properties!=null)
{
properties.values().forEach(prop->{
PojoSchema item=null;
if(Type.object.getCode().equalsIgnoreCase(prop.getType())&&(!StringUtils.isEmpty(prop.getRef())))
item=prop;
else if(Type.array.getCode().equalsIgnoreCase(prop.getType())
&&prop.getItems()!=null&&Type.object.getCode().equalsIgnoreCase(prop.getItems().getType())
&&(!StringUtils.isEmpty(prop.getItems().getRef())))
item=prop.getItems();
else
return;
});
}
built=true;
}
return this;
}
......@@ -279,14 +306,31 @@ public class PojoSchema {
private Integer multipleOf;
public PojoSchema writeTo(Path path)
{
return writeTo(this,path);
}
public static PojoSchema fromPath(Path path)
{
try {
if(!Files.exists(path))
throw new BadRequestAlertException("读取文件失败","PojoSchema",path.toString());
return JSON.parseObject(Files.readAllBytes(path),PojoSchema.class);
public static void main(String[] args) {
PojoSchema schema=new PojoSchema().setType("object").setRef("#/definitions/entity");
PojoSchema def=new PojoSchema();
def.setType("object").setTitle("部门").addProperty("deptCode",new PojoSchema().setType("string").setTitle("部门编码"))
.addProperty("deptName",new PojoSchema().setType("string").setTitle("部门名称")).addProperty("parent",def);
} catch (Exception e) {
throw new BadRequestAlertException("解析文件失败","PojoSchema",path.toString());
}
}
System.out.println(JSON.toJSONString(schema));
public static PojoSchema writeTo(PojoSchema pojoSchema,Path path)
{
try {
Files.write(path, JSON.toJSONBytes(pojoSchema), StandardOpenOption.CREATE);
} catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","PojoSchema",path.toString());
}
return pojoSchema;
}
......
......@@ -116,7 +116,7 @@ public class TransUtils {
return pojoModel;
}
public static PojoSchema LiteEntityModelModel2Schema(EntityModel entityModel)
public static PojoSchema EntityModelModel2Schema(EntityModel entityModel)
{
PojoSchema pojoSchema=new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
.setOptions(new PojoOption().setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
......@@ -294,6 +294,41 @@ public class TransUtils {
return poSchema;
}
//
// public static PojoSchema EntityModelModel2PO(EntityModel entityModel,String dbType) {
//
// POSchema poSchema=new POSchema().setName(pojoSchema.getDefaultTableName()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce()).setRemarks(pojoSchema.getTitle()).setLogicVal(pojoSchema.getOptions().getLogicVal()).setLogicDelVal(pojoSchema.getOptions().getLogicDelVal());
//
//
// PojoSchema pojoSchema = new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
// .setOptions(new PojoOption().setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
// pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity())));
//
// int order = 1;
//
// for (FieldModel fieldModel : entityModel.getFields()) {
// String propType = fieldModel.getPropType();
// PojoSchema sub = null;
// if ("date".equals(propType))
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date");
// else if ("date-time".equals(propType))
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date-time");
// else
// sub = new PojoSchema().setType(propType);
// sub.setName(fieldModel.getCodeName()).setTitle(fieldModel.getField().getFieldLogicName()).setPropertyOrder(order).setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField()))));
// if ("PICKUP".equals(fieldModel.getField().getFieldType()) && fieldModel.isPhysicalField()) {
// if (!StringUtils.isEmpty(sub.getOptions().getRelationCodeName())) {
// RelationshipModel relationshipModel = entityModel.getRefMaps().get(sub.getOptions().getRelationCodeName());
// if (relationshipModel != null && (!StringUtils.isEmpty(relationshipModel.getTableName())))
// sub.getOptions().setRefTableName(relationshipModel.getTableName());
// }
//
// }
// pojoSchema.addProperty(sub.getName(), sub);
// order++;
// }
//
// }
public static void main(String[] args) {
String str="{\"code\":\"CaseInfo\",\"name\":\"案件基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_id\",\"name\":\"请求ID标识\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"req_type\",\"name\":\"业务请求类型\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajbh\",\"name\":\"公共案件编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajmc\",\"name\":\"公共案件名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ab\",\"name\":\"案由代码\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"案由\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"gajgysrdh\",\"name\":\"移送人电话\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"case_status\",\"name\":\"案件状态\",\"required\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"CaseSuspect_List\",\"name\":\"嫌疑人自然人信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSuspect\",\"name\":\"嫌疑人自然人信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"rybh\",\"name\":\"人员编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"rybs\",\"name\":\"公安人员标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"xm\",\"name\":\"姓名\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"SuspectCoercive_List\",\"name\":\"嫌疑人强制措施信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCoercive\",\"name\":\"嫌疑人强制措施信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"cslb\",\"name\":\"强制措施种类代码\",\"required\":false,\"uniqueKeys\":true,\"dict\":\"强制措施种类\",\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}],\"extensions\":{}}},{\"code\":\"SuspectCompany_List\",\"name\":\"涉案单位信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCompany\",\"name\":\"涉案人单位信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"dwmc\",\"name\":\"单位名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSHR_List\",\"name\":\"受害人列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSHR\",\"name\":\"受害人基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"xm\",\"name\":\"姓名\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSAWP_List\",\"name\":\"涉案物品列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSAWP\",\"name\":\"涉案物品信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"sawpmc\",\"name\":\"名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseStatus_List\",\"name\":\"案件移送记录列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"object\",\"model\":{\"code\":\"CaseStatus\",\"name\":\"提请逮捕移送记录\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_dept\",\"name\":\"发送部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_deptname\",\"name\":\"发送部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_dept\",\"name\":\"接收部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_deptname\",\"name\":\"接收部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_time\",\"name\":\"发送时间\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"date\"},{\"code\":\"send_type\",\"name\":\"移送状态\",\"required\":true,\"uniqueKeys\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_type_zh\",\"name\":\"移送状态名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh_zh\",\"name\":\"文书名称\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh\",\"name\":\"移送文书文号\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}]}";
......
package cn.ibizlab.core.data.service.impl;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import cn.ibizlab.core.data.lite.EntityModel;
import cn.ibizlab.core.data.lite.LiteStorage;
......@@ -25,13 +14,9 @@ import cn.ibizlab.core.data.model.TransUtils;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.util.errors.BadRequestAlertException;
import org.springframework.transaction.annotation.Transactional;
......@@ -40,9 +25,6 @@ import cn.ibizlab.core.data.domain.DOModel;
import cn.ibizlab.core.data.filter.DOModelSearchContext;
import cn.ibizlab.core.data.service.IDOModelService;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.helper.DEFieldCacheMap;
/**
* 实体[业务实体] 无存储服务对象接口实现
......@@ -87,42 +69,26 @@ public class DOModelServiceImpl implements IDOModelService {
String[] args=key.split("[.]");
String system=args[0];
String entity=args[2];
File domainDir = new File(modelPath+system+File.separator+"domain");
if(!domainDir.exists())
domainDir.mkdirs();
File schemaJson=new File(domainDir,entity+".json");
if(!schemaJson.exists())
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo","domain",entity+".json");
if(!Files.exists(storePath))
{
EntityModel entityModel= LiteStorage.getEntityModel(system,entity);
if(entityModel!=null) {
schema=TransUtils.LiteEntityModelModel2Schema(entityModel);
schema=TransUtils.EntityModelModel2Schema(entityModel);
if(schema!=null)
schema.writeTo(storePath);
}
}
else
{
try {
String schemaJSON=new String(Files.readAllBytes(Paths.get(domainDir.getAbsolutePath(),entity+".json")),StandardCharsets.UTF_8);
schema=JSON.parseObject(schemaJSON,PojoSchema.class);
} catch (IOException e) {
schema=PojoSchema.fromPath(storePath);
}
}
if(schema!=null)
{
doModel.setSchema(schema);
try {
Files.write(Paths.get(domainDir.getAbsolutePath(),entity+".json"), JSON.toJSONString(schema).getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
} catch (IOException e) {
}
}
else
{
throw new BadRequestAlertException("未找到对应的模型","DOModel",key);
}
return doModel;
}
......
package cn.ibizlab.core.data.service.impl;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import cn.ibizlab.core.data.domain.DOModel;
import cn.ibizlab.core.data.lite.EntityModel;
import cn.ibizlab.core.data.lite.LiteStorage;
import cn.ibizlab.core.data.model.PojoSchema;
import cn.ibizlab.core.data.model.TransUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.util.errors.BadRequestAlertException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import cn.ibizlab.core.data.domain.DTOModel;
import cn.ibizlab.core.data.filter.DTOModelSearchContext;
import cn.ibizlab.core.data.service.IDTOModelService;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.helper.DEFieldCacheMap;
/**
* 实体[数据传输对象] 无存储服务对象接口实现
......@@ -89,46 +67,29 @@ public class DTOModelServiceImpl implements IDTOModelService {
String[] args=key.split("[.]");
String system=args[0];
String dto=args[2];
File domainDir = new File(modelPath+system+File.separator+"dto");
if(!domainDir.exists())
domainDir.mkdirs();
File schemaJson=new File(domainDir,dto+".json");
if(!schemaJson.exists())
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo","dto",dto+".json");
if(!Files.exists(storePath))
{
String entity=dto;
if(entity.endsWith("DTO"))
entity=entity.substring(0,entity.length()-3);
EntityModel entityModel= LiteStorage.getEntityModel(system,entity);
if(entityModel!=null) {
schema= JSONObject.parseObject(JSON.toJSONString(TransUtils.LiteEntityModelModel2Schema(entityModel)),PojoSchema.class);
schema= TransUtils.EntityModelModel2Schema(entityModel);
schema.setName(dto);
schema.setId(key);
if(schema!=null)
schema.writeTo(storePath);
}
}
else
{
try {
String schemaJSON=new String(Files.readAllBytes(Paths.get(domainDir.getAbsolutePath(),dto+".json")), StandardCharsets.UTF_8);
schema= JSON.parseObject(schemaJSON,PojoSchema.class);
} catch (IOException e) {
}
}
schema=PojoSchema.fromPath(storePath);
if(schema!=null)
{
dtoModel.setSchema(schema);
try {
Files.write(Paths.get(domainDir.getAbsolutePath(),dto+".json"), JSON.toJSONString(schema).getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
} catch (IOException e) {
}
}
else
{
throw new BadRequestAlertException("未找到对应的模型","DOModel",key);
}
throw new BadRequestAlertException("未找到对应的模型","DTOModel",key);
return dtoModel;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册