提交 f629e10c authored 作者: ww1xhqc's avatar ww1xhqc

[数据模型] 删除tableInfoEx

上级 656eef29
......@@ -114,26 +114,26 @@
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>**/.svn/*</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>META-INF/resources/</targetPath>
</resource>
<!-- <resource>-->
<!-- <directory>src/main/java</directory>-->
<!-- <includes>-->
<!-- <include>**/*</include>-->
<!-- </includes>-->
<!-- <excludes>-->
<!-- <exclude>**/.svn/*</exclude>-->
<!-- </excludes>-->
<!-- <filtering>false</filtering>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>${project.basedir}/src/main/resources</directory>-->
<!-- <targetPath>META-INF/resources/</targetPath>-->
<!-- </resource>-->
</resources>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
......
......@@ -35,6 +35,8 @@ public class WebMvcConfig {
.addResourceLocations("file:" + System.getProperty("user.dir") + "\\xml\\");
registry.addResourceHandler("/xml/**")
.addResourceLocations("file:" + System.getProperty("user.dir") + "\\xml\\");
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/workflow/");
}
};
}
......
package com.tykj.workflowcore.model_layer.controller;
import com.tykj.workflowcore.model_layer.service.TableInfoExService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName TableInfoExController
* @Description TODO
* @Author WWW
* @Date 2021/4/6 10:37
* @Version 1.0
*/
@RestController
public class TableInfoExController {
@Autowired
TableInfoExService tableInfoExService;
}
package com.tykj.workflowcore.model_layer.dao;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @ClassName TableInfoExDao
* @Description TODO
* @Author WWW
* @Date 2021/4/1 17:00
* @Version 1.0
*/
public interface TableInfoExDao extends JpaRepository<TableInfoEx, Integer>, JpaSpecificationExecutor<TableInfoEx> {
/**
* 根据表名查询name
* @param name
* @return
*/
TableInfoEx findByName(String name);
}
......@@ -49,6 +49,12 @@ public class TableInfo extends BaseEntity {
@ApiModelProperty("父表名称")
private String parentTable;
/**
* 聚合对象主表id
*/
@ApiModelProperty("主表id")
private Integer mainTableId;
@Lob
@ApiModelProperty("表对应hbm.xml")
private String xml;
......
package com.tykj.workflowcore.model_layer.entity;
import com.tykj.workflowcore.base.entity.BaseEntity;
import com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.Entity;
import javax.persistence.Lob;
/**
* @ClassName TableInfoEX
* @Description TODO 聚合对象
* @Author WWW
* @Date 2021/4/1 16:45
* @Version 1.0
*/
@WorkFlowCoreNoScan
@Data
@NoArgsConstructor
@Entity
@SQLDelete(sql = "update column_info set deleted = 1 where id = ?")
@Where(clause = "deleted = 0")
public class TableInfoEx extends BaseEntity {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("主表id")
private Integer mainTableId;
@Lob
@ApiModelProperty("聚合对象xml")
private String xml;
}
......@@ -3,7 +3,8 @@ package com.tykj.workflowcore.model_layer.entity.vo;
import com.tykj.workflowcore.model_layer.entity.Aggregation;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import com.tykj.workflowcore.model_layer.entity.TableInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -23,10 +24,10 @@ import java.util.List;
public class AggregationVO {
@ApiModelProperty("名称")
private String name;
private String modelName;
@ApiModelProperty("描述")
private String chineseName;
private String modelTitle;
@ApiModelProperty("描述")
private String description;
......@@ -37,9 +38,9 @@ public class AggregationVO {
@ApiModelProperty("关系集合")
private List<Aggregation> aggregations;
public TableInfoEx getTableInfoEx(){
TableInfoEx tableInfoEx = new TableInfoEx();
BeanUtils.copyProperties(this,tableInfoEx);
return tableInfoEx;
public TableInfo getTableInfo(){
TableInfo tableInfo= new TableInfo();
BeanUtils.copyProperties(this,tableInfo);
return tableInfo;
}
}
package com.tykj.workflowcore.model_layer.service;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import com.tykj.workflowcore.model_layer.entity.vo.AggregationVO;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName Aggregation
......
package com.tykj.workflowcore.model_layer.service;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import java.util.List;
/**
* @Author WWW
* @Description
* @Date 14:06 2021/4/6
* @return
**/
public interface TableInfoExService {
/**
* 查询所有
* @return
*/
List<TableInfoEx> findAll();
/**
* 根据id获取tableInfoExXML
* @param id
* @return
*/
String findXml(Integer id);
}
......@@ -4,11 +4,10 @@ import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.model_layer.dao.AggregationDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoExDao;
import com.tykj.workflowcore.model_layer.entity.Aggregation;
import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import com.tykj.workflowcore.model_layer.entity.vo.AggregationVO;
import com.tykj.workflowcore.model_layer.myEnum.AggregationType;
import com.tykj.workflowcore.model_layer.service.AggregationService;
......@@ -40,8 +39,7 @@ public class AggregationImpl implements AggregationService {
@Autowired
TableInfoDao tableInfoDao;
@Autowired
TableInfoExDao tableInfoExDao;
@Autowired
AggregationDao aggregationRelationshipDao;
@Autowired
......@@ -60,16 +58,16 @@ public class AggregationImpl implements AggregationService {
throw new ApiException("主表不存在");
}
//改CLASS名字
AggregationUtil.changeClassName(aggregationVO.getName(),mainTableDocument );
AggregationUtil.changeClassName(aggregationVO.getModelName(),mainTableDocument );
// save TableInfoEx (name des mainTableId)
TableInfoEx tableInfoEx = tableInfoExDao.save(aggregationVO.getTableInfoEx());
TableInfo tableInfoEx = tableInfoDao.save(aggregationVO.getTableInfo());
try {
createAggregationObjectXml(aggregationVO.getAggregations(), null, tableInfoEx.getId(), mainTableById.get(), mainTableDocument.getRootElement());
tableInfoEx.setXml(mainTableDocument.asXML());
} catch (DocumentException e) {
e.printStackTrace();
}
tableInfoExDao.save(tableInfoEx);
tableInfoDao.save(tableInfoEx);
}
//假设获得的是一份XML
......
......@@ -6,11 +6,10 @@ import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.model_layer.dao.AggregationDao;
import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoExDao;
import com.tykj.workflowcore.model_layer.entity.Aggregation;
import com.tykj.workflowcore.model_layer.entity.ColumnInfo;
import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import com.tykj.workflowcore.model_layer.entity.vo.ColumnEXVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -30,8 +29,7 @@ public class ModelHelper {
private TableInfoDao tableInfoDao;
@Autowired
private ColumnInfoDao columnInfoDao;
@Autowired
private TableInfoExDao tableInfoExDao;
@Autowired
private AggregationDao aggregationDao;
......@@ -66,7 +64,7 @@ public class ModelHelper {
*/
public String getExJsonExample(Integer tableInfoExId) {
Map<String, Object> result = new HashMap<>();
TableInfoEx tableInfoEX = tableInfoExDao.findById(tableInfoExId)
TableInfo tableInfoEX = tableInfoDao.findById(tableInfoExId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId)));
//根据主表id查出主表部分字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId());
......@@ -127,7 +125,7 @@ public class ModelHelper {
*/
public List<ColumnEXVO> getColumnEXVOs(Integer tableInfoExId) {
List<ColumnEXVO> result = new ArrayList<>();
TableInfoEx tableInfoEX = tableInfoExDao.findById(tableInfoExId)
TableInfo tableInfoEX = tableInfoDao.findById(tableInfoExId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId)));
//根据主表id查出主表部分字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId());
......
package com.tykj.workflowcore.model_layer.service.impl;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.model_layer.dao.TableInfoExDao;
import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import com.tykj.workflowcore.model_layer.service.TableInfoExService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.rmi.runtime.NewThreadAction;
import java.util.List;
import java.util.Optional;
/**
* @ClassName TableInfoExImpl
* @Description TODO
* @Author WWW
* @Date 2021/4/6 9:58
* @Version 1.0
*/
@Service
public class TableInfoExImpl implements TableInfoExService {
@Autowired
TableInfoExDao tableInfoExDao;
@Override
public List<TableInfoEx> findAll() {
return tableInfoExDao.findAll() ;
}
@Override
public String findXml(Integer id) {
Optional<TableInfoEx> byId = tableInfoExDao.findById(id);
if (byId.isPresent()){
return byId.get().getXml();
}
throw new ApiException("id错误!");
}
}
......@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.tykj.workflowcore.model_layer.controller.ModelController;
import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoExDao;
import com.tykj.workflowcore.model_layer.entity.ColumnInfo;
import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.model_layer.entity.vo.TableAndColumnInfoVO;
......@@ -89,8 +89,6 @@ class WorkflowCoreApplicationTests {
@Autowired
ModelHelper modelHelper;
@Autowired
TableInfoExDao tableInfoExDao;
@Autowired
ColumnInfoDao columnInfoDao;
......@@ -486,7 +484,7 @@ class WorkflowCoreApplicationTests {
// }
@Test
public void testJSON() {
String xml = tableInfoExDao.findById(32).get().getXml();
String xml = tableInfoDao.findById(32).get().getXml();
sessionUtil.addXml(xml);
Session session = sessionUtil.getSession();
List list = session.createQuery("from test_obj").list();
......@@ -507,7 +505,9 @@ class WorkflowCoreApplicationTests {
}
@Test
public void testType(){
System.out.println(getTypeName(Integer.class.toString()));
// System.out.println(getTypeName(Integer.class.toString()));
String exJsonExample = modelHelper.getExJsonExample(5);
System.out.println(exJsonExample);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论