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

[数据模型] 修改model的bug。

上级 ebc68b1e
......@@ -111,36 +111,30 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<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>
</resources>
<!-- <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>-->
<!-- </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>
......
......@@ -4,6 +4,8 @@ package com.tykj.workflowcore.model_layer.dao;
import com.tykj.workflowcore.model_layer.entity.ColumnInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -21,4 +23,12 @@ public interface ColumnInfoDao extends JpaRepository<ColumnInfo, Integer>, JpaSp
* @return
*/
List<ColumnInfo> findAllByDbId(int id);
/**
* 根据dbID删除
* @param id
*/
@Transactional(rollbackFor = Exception.class)
@Modifying
void deleteAllByDbId(Integer id);
}
......@@ -4,6 +4,10 @@ package com.tykj.workflowcore.model_layer.dao;
import com.tykj.workflowcore.model_layer.entity.TableInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @ClassName TableInfoDao
......@@ -19,4 +23,14 @@ public interface TableInfoDao extends JpaRepository<TableInfo, Integer>, JpaSpec
* @return
*/
TableInfo findByModelName(String name);
/**
* 删除modelType是0的数据
* @param type
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Modifying
List<TableInfo> deleteAllByModelType(Integer type);
}
......@@ -25,8 +25,6 @@ import java.io.Serializable;
@Data
@NoArgsConstructor
@Entity
@SQLDelete(sql = "update column_info set deleted = 1 where id = ?")
@Where(clause = "deleted = 0")
public class ColumnInfo extends BaseEntity {
/**
......
......@@ -48,7 +48,7 @@ public class AggregationImpl implements AggregationService {
SessionUtil sessionUtil;
@Override
@Transactional
@Transactional(rollbackOn = Exception.class)
public void addAggregation(AggregationVO aggregationVO) {
Document mainTableDocument;
//获取主表XML
......
......@@ -11,7 +11,7 @@ import com.tykj.workflowcore.model_layer.entity.vo.*;
import com.tykj.workflowcore.model_layer.entity.*;
import com.tykj.workflowcore.model_layer.myEnum.ModelType;
import com.tykj.workflowcore.model_layer.service.ModelService;
import com.tykj.workflowcore.model_layer.utils.CreateTableUtil;
import com.tykj.workflowcore.model_layer.utils.SessionUtil;
import com.tykj.workflowcore.model_layer.utils.SqlUtil;
import io.swagger.annotations.ApiModel;
......@@ -268,6 +268,8 @@ public class ModelImpl implements ModelService {
*/
@Override
public void swaggerScan(List<Class<?>> classList) {
/* 扫描前先删除原数据*/
delTableAndColumnInfo();
for (Class<?> aClass : classList) {
//不扫描自己
TableInfo tableInfo = new TableInfo();
......@@ -279,12 +281,11 @@ public class ModelImpl implements ModelService {
if (aClass.isAnnotationPresent(Table.class)) {
Table table = aClass.getAnnotation(Table.class);
if (!"".equals(table.name()) && table.name() != null) {
realName=table.name();
realName = table.name();
}
}
else {
} else {
String className = getClassName(aClass.toString());
realName=className;
realName = className;
}
tableVO.setModelName(realName);
//获得类中文描述
......@@ -308,7 +309,7 @@ public class ModelImpl implements ModelService {
List<ColumnVO> list = new ArrayList<>();
for (Field declaredField : declaredFields) {
ColumnVO columnVO = new ColumnVO();
if (declaredField.isAnnotationPresent(Transient.class)){
if (declaredField.isAnnotationPresent(Transient.class)) {
continue;
}
//获得类型
......@@ -604,4 +605,15 @@ public class ModelImpl implements ModelService {
tableAndColumnInfoVO.setColumnInfos(allColumnInfos);
return tableAndColumnInfoVO;
}
public void delTableAndColumnInfo() {
/* 先删除上次扫描的基础类型*/
List<TableInfo> tableInfos = tableInfoDao.deleteAllByModelType(ModelType.BASICS);
for (TableInfo tableInfo : tableInfos) {
/*删除columnInfo*/
columnInfoDao.deleteAllByDbId(tableInfo.getId());
}
}
}
......@@ -2,7 +2,7 @@ spring:
datasource:
username: root
password: Huang123+
url: jdbc:mysql://47.106.142.73:3306/www3?useSSL=false&serverTimezone=GMT%2b8&characterEncoding=utf-8&nullCatalogMeansCurrent=true
url: jdbc:mysql://47.106.142.73:3306/www_hxh?useSSL=false&serverTimezone=GMT%2b8&characterEncoding=utf-8&nullCatalogMeansCurrent=true
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
show-sql: true
......
......@@ -3,8 +3,10 @@ package com.tykj.workflowcore;
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;
import com.tykj.workflowcore.model_layer.myEnum.ModelType;
......@@ -88,6 +90,9 @@ class WorkflowCoreApplicationTests {
@Autowired
TableInfoExDao tableInfoExDao;
@Autowired
ColumnInfoDao columnInfoDao;
@Before("")
public void setUp() {
mockMvc = MockMvcBuilders.standaloneSetup(modelController).build();
......@@ -489,4 +494,14 @@ class WorkflowCoreApplicationTests {
// System.out.println(jsonExample);
StringUtils.hasLength(xml);
}
@Test
public void testDelete(){
List<TableInfo> tableInfos = tableInfoDao.deleteAllByModelType(0);
for (TableInfo tableInfo : tableInfos) {
System.out.println(tableInfo.getId());
columnInfoDao.deleteAllByDbId(tableInfo.getId());
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论