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

[数据模型] 删除tableInfoEx

上级 656eef29
...@@ -114,26 +114,26 @@ ...@@ -114,26 +114,26 @@
<build> <build>
<resources> <resources>
<resource> <!-- <resource>-->
<directory>src/main/java</directory> <!-- <directory>src/main/java</directory>-->
<includes> <!-- <includes>-->
<include>**/*</include> <!-- <include>**/*</include>-->
</includes> <!-- </includes>-->
<excludes> <!-- <excludes>-->
<exclude>**/.svn/*</exclude> <!-- <exclude>**/.svn/*</exclude>-->
</excludes> <!-- </excludes>-->
<filtering>false</filtering> <!-- <filtering>false</filtering>-->
</resource> <!-- </resource>-->
<resource> <!-- <resource>-->
<directory>${project.basedir}/src/main/resources</directory> <!-- <directory>${project.basedir}/src/main/resources</directory>-->
<targetPath>META-INF/resources/</targetPath> <!-- <targetPath>META-INF/resources/</targetPath>-->
</resource> <!-- </resource>-->
</resources> </resources>
<plugins> <plugins>
<!-- <plugin>--> <plugin>
<!-- <groupId>org.springframework.boot</groupId>--> <groupId>org.springframework.boot</groupId>
<!-- <artifactId>spring-boot-maven-plugin</artifactId>--> <artifactId>spring-boot-maven-plugin</artifactId>
<!-- </plugin>--> </plugin>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
......
...@@ -35,6 +35,8 @@ public class WebMvcConfig { ...@@ -35,6 +35,8 @@ public class WebMvcConfig {
.addResourceLocations("file:" + System.getProperty("user.dir") + "\\xml\\"); .addResourceLocations("file:" + System.getProperty("user.dir") + "\\xml\\");
registry.addResourceHandler("/xml/**") registry.addResourceHandler("/xml/**")
.addResourceLocations("file:" + System.getProperty("user.dir") + "\\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 { ...@@ -49,6 +49,12 @@ public class TableInfo extends BaseEntity {
@ApiModelProperty("父表名称") @ApiModelProperty("父表名称")
private String parentTable; private String parentTable;
/**
* 聚合对象主表id
*/
@ApiModelProperty("主表id")
private Integer mainTableId;
@Lob @Lob
@ApiModelProperty("表对应hbm.xml") @ApiModelProperty("表对应hbm.xml")
private String 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; ...@@ -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.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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -23,10 +24,10 @@ import java.util.List; ...@@ -23,10 +24,10 @@ import java.util.List;
public class AggregationVO { public class AggregationVO {
@ApiModelProperty("名称") @ApiModelProperty("名称")
private String name; private String modelName;
@ApiModelProperty("描述") @ApiModelProperty("描述")
private String chineseName; private String modelTitle;
@ApiModelProperty("描述") @ApiModelProperty("描述")
private String description; private String description;
...@@ -37,9 +38,9 @@ public class AggregationVO { ...@@ -37,9 +38,9 @@ public class AggregationVO {
@ApiModelProperty("关系集合") @ApiModelProperty("关系集合")
private List<Aggregation> aggregations; private List<Aggregation> aggregations;
public TableInfoEx getTableInfoEx(){ public TableInfo getTableInfo(){
TableInfoEx tableInfoEx = new TableInfoEx(); TableInfo tableInfo= new TableInfo();
BeanUtils.copyProperties(this,tableInfoEx); BeanUtils.copyProperties(this,tableInfo);
return tableInfoEx; return tableInfo;
} }
} }
package com.tykj.workflowcore.model_layer.service; 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 com.tykj.workflowcore.model_layer.entity.vo.AggregationVO;
import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @ClassName Aggregation * @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; ...@@ -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.AggregationDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao; 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.Aggregation;
import com.tykj.workflowcore.model_layer.entity.TableInfo; 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.entity.vo.AggregationVO;
import com.tykj.workflowcore.model_layer.myEnum.AggregationType; import com.tykj.workflowcore.model_layer.myEnum.AggregationType;
import com.tykj.workflowcore.model_layer.service.AggregationService; import com.tykj.workflowcore.model_layer.service.AggregationService;
...@@ -40,8 +39,7 @@ public class AggregationImpl implements AggregationService { ...@@ -40,8 +39,7 @@ public class AggregationImpl implements AggregationService {
@Autowired @Autowired
TableInfoDao tableInfoDao; TableInfoDao tableInfoDao;
@Autowired
TableInfoExDao tableInfoExDao;
@Autowired @Autowired
AggregationDao aggregationRelationshipDao; AggregationDao aggregationRelationshipDao;
@Autowired @Autowired
...@@ -60,16 +58,16 @@ public class AggregationImpl implements AggregationService { ...@@ -60,16 +58,16 @@ public class AggregationImpl implements AggregationService {
throw new ApiException("主表不存在"); throw new ApiException("主表不存在");
} }
//改CLASS名字 //改CLASS名字
AggregationUtil.changeClassName(aggregationVO.getName(),mainTableDocument ); AggregationUtil.changeClassName(aggregationVO.getModelName(),mainTableDocument );
// save TableInfoEx (name des mainTableId) // save TableInfoEx (name des mainTableId)
TableInfoEx tableInfoEx = tableInfoExDao.save(aggregationVO.getTableInfoEx()); TableInfo tableInfoEx = tableInfoDao.save(aggregationVO.getTableInfo());
try { try {
createAggregationObjectXml(aggregationVO.getAggregations(), null, tableInfoEx.getId(), mainTableById.get(), mainTableDocument.getRootElement()); createAggregationObjectXml(aggregationVO.getAggregations(), null, tableInfoEx.getId(), mainTableById.get(), mainTableDocument.getRootElement());
tableInfoEx.setXml(mainTableDocument.asXML()); tableInfoEx.setXml(mainTableDocument.asXML());
} catch (DocumentException e) { } catch (DocumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
tableInfoExDao.save(tableInfoEx); tableInfoDao.save(tableInfoEx);
} }
//假设获得的是一份XML //假设获得的是一份XML
......
...@@ -6,11 +6,10 @@ import com.tykj.workflowcore.base.result.ApiException; ...@@ -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.AggregationDao;
import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao; import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao; 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.Aggregation;
import com.tykj.workflowcore.model_layer.entity.ColumnInfo; import com.tykj.workflowcore.model_layer.entity.ColumnInfo;
import com.tykj.workflowcore.model_layer.entity.TableInfo; 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 com.tykj.workflowcore.model_layer.entity.vo.ColumnEXVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -30,8 +29,7 @@ public class ModelHelper { ...@@ -30,8 +29,7 @@ public class ModelHelper {
private TableInfoDao tableInfoDao; private TableInfoDao tableInfoDao;
@Autowired @Autowired
private ColumnInfoDao columnInfoDao; private ColumnInfoDao columnInfoDao;
@Autowired
private TableInfoExDao tableInfoExDao;
@Autowired @Autowired
private AggregationDao aggregationDao; private AggregationDao aggregationDao;
...@@ -66,7 +64,7 @@ public class ModelHelper { ...@@ -66,7 +64,7 @@ public class ModelHelper {
*/ */
public String getExJsonExample(Integer tableInfoExId) { public String getExJsonExample(Integer tableInfoExId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
TableInfoEx tableInfoEX = tableInfoExDao.findById(tableInfoExId) TableInfo tableInfoEX = tableInfoDao.findById(tableInfoExId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId))); .orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId)));
//根据主表id查出主表部分字段信息 并加入Map结果 //根据主表id查出主表部分字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId()); List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId());
...@@ -127,7 +125,7 @@ public class ModelHelper { ...@@ -127,7 +125,7 @@ public class ModelHelper {
*/ */
public List<ColumnEXVO> getColumnEXVOs(Integer tableInfoExId) { public List<ColumnEXVO> getColumnEXVOs(Integer tableInfoExId) {
List<ColumnEXVO> result = new ArrayList<>(); List<ColumnEXVO> result = new ArrayList<>();
TableInfoEx tableInfoEX = tableInfoExDao.findById(tableInfoExId) TableInfo tableInfoEX = tableInfoDao.findById(tableInfoExId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId))); .orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId)));
//根据主表id查出主表部分字段信息 并加入Map结果 //根据主表id查出主表部分字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId()); 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; ...@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.tykj.workflowcore.model_layer.controller.ModelController; import com.tykj.workflowcore.model_layer.controller.ModelController;
import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao; import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao; 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.ColumnInfo;
import com.tykj.workflowcore.model_layer.entity.TableInfo; import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.model_layer.entity.vo.TableAndColumnInfoVO; import com.tykj.workflowcore.model_layer.entity.vo.TableAndColumnInfoVO;
...@@ -89,8 +89,6 @@ class WorkflowCoreApplicationTests { ...@@ -89,8 +89,6 @@ class WorkflowCoreApplicationTests {
@Autowired @Autowired
ModelHelper modelHelper; ModelHelper modelHelper;
@Autowired
TableInfoExDao tableInfoExDao;
@Autowired @Autowired
ColumnInfoDao columnInfoDao; ColumnInfoDao columnInfoDao;
...@@ -486,7 +484,7 @@ class WorkflowCoreApplicationTests { ...@@ -486,7 +484,7 @@ class WorkflowCoreApplicationTests {
// } // }
@Test @Test
public void testJSON() { public void testJSON() {
String xml = tableInfoExDao.findById(32).get().getXml(); String xml = tableInfoDao.findById(32).get().getXml();
sessionUtil.addXml(xml); sessionUtil.addXml(xml);
Session session = sessionUtil.getSession(); Session session = sessionUtil.getSession();
List list = session.createQuery("from test_obj").list(); List list = session.createQuery("from test_obj").list();
...@@ -507,7 +505,9 @@ class WorkflowCoreApplicationTests { ...@@ -507,7 +505,9 @@ class WorkflowCoreApplicationTests {
} }
@Test @Test
public void testType(){ 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论