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

[数据模型] 版本类相关

上级 1df7f9d9
...@@ -148,5 +148,14 @@ ...@@ -148,5 +148,14 @@
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.6.0" level="project" /> <orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.6.0" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.3" level="project" /> <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.0.1" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.18" level="project" />
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.05" level="project" />
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.0.2" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -5,6 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -5,6 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author HASEE
*/
@SpringBootApplication @SpringBootApplication
@EnableSwagger2 @EnableSwagger2
public class DataApplication { public class DataApplication {
......
...@@ -2,9 +2,13 @@ package com.tykj.model_layer.controller; ...@@ -2,9 +2,13 @@ package com.tykj.model_layer.controller;
import com.tykj.base.result.ResultUtil; import com.tykj.base.result.ResultUtil;
import com.tykj.model_layer.entity.TableInfo; import com.tykj.model_layer.dao.QuoteDao;
import com.tykj.model_layer.entity.*;
import com.tykj.model_layer.entity.vo.*; import com.tykj.model_layer.entity.vo.*;
import com.tykj.model_layer.service.ModelService; import com.tykj.model_layer.service.ModelService;
import com.tykj.model_layer.service.QuoteService;
import com.tykj.model_layer.service.VersionBackupService;
import com.tykj.model_layer.service.VersionService;
import com.tykj.model_layer.service.impl.ModelHelper; import com.tykj.model_layer.service.impl.ModelHelper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -15,6 +19,7 @@ import org.springframework.http.ResponseEntity; ...@@ -15,6 +19,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -37,6 +42,16 @@ public class ModelController { ...@@ -37,6 +42,16 @@ public class ModelController {
@Autowired @Autowired
private ModelHelper modelHelper; private ModelHelper modelHelper;
@Autowired
private QuoteDao quoteDao;
@Autowired
private VersionService versionService;
@Autowired
private VersionBackupService versionBackupService;
/** /**
* @param * @param
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo> * @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
...@@ -62,7 +77,13 @@ public class ModelController { ...@@ -62,7 +77,13 @@ public class ModelController {
@ApiOperation("根据表名或者id查询表中所有字段") @ApiOperation("根据表名或者id查询表中所有字段")
@PostMapping("/getAllField") @PostMapping("/getAllField")
public ResponseEntity getFields(@RequestBody SearchColumnInfoVo searchColumnInfoVo) { public ResponseEntity getFields(@RequestBody SearchColumnInfoVo searchColumnInfoVo) {
return ResultUtil.success(modelService.showModelFields(searchColumnInfoVo), "数据查询成功!");
List<ColumnInfo> columnInfos = modelService.showModelFields(searchColumnInfoVo);
for (ColumnInfo columnInfo : columnInfos) {
List<Quote> allByColumnId = quoteDao.findAllByColumnId(columnInfo.getId());
columnInfo.setQuoteList(allByColumnId);
}
return ResultUtil.success(columnInfos, "数据查询成功!");
} }
/** /**
...@@ -84,8 +105,9 @@ public class ModelController { ...@@ -84,8 +105,9 @@ public class ModelController {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
modelService.newTable(tableVO); modelService.newTable(tableVO);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
log.warn("创建总用时为:{}秒", (end - start) / 1000.0); log.warn("创建总用时为:{}秒", (end - start) / 1000.0);
// versionService.addVersion(new Version("1.0","这是初始版本",""));
// versionBackupService.addVersion(new VersionBackup("1.0","这是初始备份版本",""));
return ResultUtil.success("", "新建成功!"); return ResultUtil.success("", "新建成功!");
} }
......
package com.tykj.model_layer.controller;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/17 15:57
*/
public class QuoteControler {
}
package com.tykj.model_layer.controller;
import com.tykj.base.result.ResultUtil;
import com.tykj.model_layer.entity.vo.UpdateQuoteVO;
import com.tykj.model_layer.service.QuoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/17 15:57
*/
@Api(tags = "引用接口")
@RestController
@RequestMapping("/quote")
public class QuoteController {
@Autowired
private QuoteService quoteService;
@ApiModelProperty("引用删除")
@GetMapping("/delete")
public ResponseEntity deleteQuote(Integer id) {
return ResultUtil.success(quoteService.delQuote(id), "删除成功!");
}
@ApiModelProperty("引用更新")
@PostMapping("/update")
public ResponseEntity UpdateQuote(@RequestBody UpdateQuoteVO updateQuoteVO) {
return ResultUtil.success(quoteService.updateQuote(updateQuoteVO), "查询成功!");
}
}
package com.tykj.model_layer.controller;
import com.tykj.base.result.ResultUtil;
import com.tykj.model_layer.dao.VersionDao;
import com.tykj.model_layer.entity.Version;
import com.tykj.model_layer.entity.vo.VersionVO;
import com.tykj.model_layer.service.VersionService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 14:47
*/
@Api(tags = "版本接口")
@RestController
@RequestMapping("/version")
public class VersionController {
@Autowired
private VersionService versionService;
@RequestMapping("/delVersion")
public ResponseEntity delVersion(){
versionService.delVersion();
return ResultUtil.success("删除成功!");
}
@RequestMapping("/addVersion")
public ResponseEntity addVersion(VersionVO versionVO){
return ResultUtil.success(versionService.addVersion(versionVO),"保存成功!");
}
}
package com.tykj.model_layer.dao;
import com.tykj.model_layer.entity.MyIndex;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 14:34
*/
public interface IndexDao extends JpaRepository<MyIndex,Integer>, JpaSpecificationExecutor<MyIndex> {
}
package com.tykj.model_layer.dao;
import com.tykj.model_layer.entity.VersionBackup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:51
*/
public interface VersionBackupDao extends JpaRepository<VersionBackup,Integer>, JpaSpecificationExecutor<VersionBackup> {
}
package com.tykj.model_layer.dao;
import com.tykj.model_layer.entity.Version;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:21
*/
public interface VersionDao extends JpaRepository<Version,Integer>, JpaSpecificationExecutor<Version> {
}
...@@ -9,6 +9,8 @@ import lombok.NoArgsConstructor; ...@@ -9,6 +9,8 @@ import lombok.NoArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/** /**
* @ClassName ColumnInfo * @ClassName ColumnInfo
...@@ -46,6 +48,10 @@ public class ColumnInfo extends BaseEntity { ...@@ -46,6 +48,10 @@ public class ColumnInfo extends BaseEntity {
@ApiModelProperty("详细描述") @ApiModelProperty("详细描述")
private String description; private String description;
@ApiModelProperty("引用对象")
@Transient
private List<Quote> quoteList;
public ColumnInfo(Integer primaryKey, String fieldName, String fieldTitle, String fieldType, Integer fieldLength, String dbName, Integer dbId, String description) { public ColumnInfo(Integer primaryKey, String fieldName, String fieldTitle, String fieldType, Integer fieldLength, String dbName, Integer dbId, String description) {
this.primaryKey = primaryKey; this.primaryKey = primaryKey;
this.fieldName = fieldName; this.fieldName = fieldName;
......
package com.tykj.model_layer.entity;
import com.tykj.base.entity.BaseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 14:28
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table
public class MyIndex extends BaseEntity {
@ApiModelProperty("版本")
private String versionId;
@ApiModelProperty("索引")
private String ids;
}
package com.tykj.model_layer.entity;
import com.tykj.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:07
*/
@Entity
@Table
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("版本控制表")
public class Version extends BaseEntity {
@ApiModelProperty("版本号")
private String versionId;
@ApiModelProperty("版本号")
private String versionDesc;
@Lob
@ApiModelProperty("版本对应数据")
private String content;
}
package com.tykj.model_layer.entity;
import com.tykj.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:18
*/
@Entity
@Table
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("版本备份控制表")
public class VersionBackup extends BaseEntity {
@ApiModelProperty("版本号")
private String versionId;
@ApiModelProperty("版本号")
private String versionDesc;
@Lob
@ApiModelProperty("版本对应数据")
private String content;
}
package com.tykj.model_layer.entity.vo;
import com.tykj.model_layer.entity.ColumnInfo;
import com.tykj.model_layer.entity.Quote;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;
import java.util.List;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/18 14:19
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ColumnWithQuoteVO {
private ColumnInfo columnInfo;
private List<Quote> quotes;
}
package com.tykj.model_layer.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 15:53
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IndexVO {
@ApiModelProperty("tableId")
private Integer dbId;
@ApiModelProperty("版本")
private String versionId;
@ApiModelProperty("索引")
private String ids;
}
package com.tykj.model_layer.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/18 13:19
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SearchQuoteVO {
private Integer[] columnIds;
private Integer[] ids;
private String value;
private String[] values;
}
package com.tykj.model_layer.entity.vo;
import com.tykj.model_layer.entity.Quote;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/18 15:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateQuoteVO {
@ApiModelProperty("id")
private Integer id;
private List<Quote> quoteList;
}
package com.tykj.model_layer.entity.vo; package com.tykj.model_layer.entity.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -18,13 +19,12 @@ import lombok.NoArgsConstructor; ...@@ -18,13 +19,12 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@ApiModel("更新表VO") @ApiModel("更新表VO")
public class UpdateTableInfoVO { public class UpdateTableInfoVO {
@ApiModelProperty("表id") @ApiModelProperty("表id")
private Integer dbId; private Integer dbId;
@ApiModelProperty("表名称") @ApiModelProperty("表名称")
private String dbName; private String dbName;
@ApiModelProperty("TableVO") @ApiModelProperty("TableVO")
private TableVO tableVO; private TableVO tableVO;
} }
package com.tykj.model_layer.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Lob;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 15:42
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VersionVO {
@ApiModelProperty("tableInfoID")
private Integer dbId;
@ApiModelProperty("版本号")
private String versionId;
@ApiModelProperty("版本号")
private String versionDesc;
@Lob
@ApiModelProperty("版本对应数据")
private String content;
}
...@@ -62,7 +62,7 @@ public class Template { ...@@ -62,7 +62,7 @@ public class Template {
fileReader.close(); fileReader.close();
} }
} }
System.out.println("读取出来的文件内容是:"+"\r\n"+result); // System.out.println("读取出来的文件内容是:"+"\r\n"+result);
return result; return result;
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
......
package com.tykj.model_layer.service;
import com.tykj.model_layer.entity.vo.IndexVO;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 14:36
*/
public interface IndexService {
/**
* 增加索引
*/
void addIndex(IndexVO indexVO);
}
package com.tykj.model_layer.service; package com.tykj.model_layer.service;
import com.tykj.model_layer.entity.Quote; import com.tykj.model_layer.entity.Quote;
import com.tykj.model_layer.entity.vo.SearchQuoteVO;
import com.tykj.model_layer.entity.vo.UpdateQuoteVO;
import java.util.List; import java.util.List;
...@@ -13,14 +15,19 @@ public interface QuoteService { ...@@ -13,14 +15,19 @@ public interface QuoteService {
/** /**
* 更新quote * 更新quote
* @param id * @param updateQuoteVO
*/ */
void updateQuote(Integer id); List<Quote> updateQuote(UpdateQuoteVO updateQuoteVO);
List<Quote> getAllQuote(); /**
* 条件查询引用
* @param searchQuoteVO
* @return
*/
List<Quote> getAllQuote(SearchQuoteVO searchQuoteVO);
Quote saveQuote(Quote quote); Quote saveQuote(Quote quote);
void delQuote(Integer id); Integer delQuote(Integer id);
} }
package com.tykj.model_layer.service;
import com.tykj.model_layer.entity.VersionBackup;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:59
*/
public interface VersionBackupService {
/**
*
*/
void addVersion(VersionBackup versionBackup);
}
package com.tykj.model_layer.service;
import com.tykj.model_layer.entity.Version;
import com.tykj.model_layer.entity.vo.VersionVO;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:53
*/
public interface VersionService {
/**
* 增加version
* @param versionVO
* @return
*/
Version addVersion(VersionVO versionVO);
/**
* 删除
*/
void delVersion();
void Synchronize();
}
package com.tykj.model_layer.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tykj.model_layer.dao.ColumnInfoDao;
import com.tykj.model_layer.dao.IndexDao;
import com.tykj.model_layer.entity.ColumnInfo;
import com.tykj.model_layer.entity.MyIndex;
import com.tykj.model_layer.entity.vo.IndexVO;
import com.tykj.model_layer.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 14:37
*/
@Service
public class IndexServiceImpl implements IndexService {
@Autowired
private IndexDao indexDao;
@Autowired
private ColumnInfoDao columnInfoDao;
@Override
public void addIndex(IndexVO indexVO) {
MyIndex index =new MyIndex();
index.setVersionId(indexVO.getVersionId());
List<Integer> collect = columnInfoDao
.findAllByDbId(indexVO.getDbId()).stream()
.map(ColumnInfo::getId)
.collect(Collectors.toList());
index.setIds(JSONArray.toJSONString(collect));
indexDao.save(index);
}
}
...@@ -124,7 +124,8 @@ public class ModelImpl implements ModelService { ...@@ -124,7 +124,8 @@ public class ModelImpl implements ModelService {
public List<ColumnInfo> showModelFields(SearchColumnInfoVo searchColumnInfoVo) { public List<ColumnInfo> showModelFields(SearchColumnInfoVo searchColumnInfoVo) {
PredicateBuilder<ColumnInfo> and = Specifications.and(); PredicateBuilder<ColumnInfo> and = Specifications.and();
and.eq(searchColumnInfoVo.getDbId() != null, "dbId", searchColumnInfoVo.getDbId()); and.eq(searchColumnInfoVo.getDbId() != null, "dbId", searchColumnInfoVo.getDbId());
and.eq(searchColumnInfoVo.getDbName() != null && StringUtils.isNotEmpty(searchColumnInfoVo.getDbName()), "dbName", searchColumnInfoVo.getDbName()); and.eq(searchColumnInfoVo.getDbName() != null && StringUtils.isNotEmpty(searchColumnInfoVo.getDbName()),
"dbName", searchColumnInfoVo.getDbName());
return columnInfoDao.findAll(and.build()); return columnInfoDao.findAll(and.build());
} }
...@@ -139,15 +140,9 @@ public class ModelImpl implements ModelService { ...@@ -139,15 +140,9 @@ public class ModelImpl implements ModelService {
@Override @Override
public TableInfo newTable(TableVO tableVO) { public TableInfo newTable(TableVO tableVO) {
String xmlMapping = createTable(tableVO); String xmlMapping = createTable(tableVO);
Integer modelType = tableVO.getModelType();
String parentTable = null;
//扫描新建类型
if (modelType.equals(ModelType.VIRTUAL)) {
parentTable = tableVO.getParentTable();
tableVO.setModelType(ModelType.VIRTUAL);
} else {
tableVO.setModelType(ModelType.VIRTUAL);
}
sessionUtil.addXml(xmlMapping); sessionUtil.addXml(xmlMapping);
Session session = sessionUtil.getSession(); Session session = sessionUtil.getSession();
List<ColumnVO> dataList = tableVO.getDataList(); List<ColumnVO> dataList = tableVO.getDataList();
...@@ -164,7 +159,6 @@ public class ModelImpl implements ModelService { ...@@ -164,7 +159,6 @@ public class ModelImpl implements ModelService {
tableInfo.setXml(xmlMapping); tableInfo.setXml(xmlMapping);
tableInfo.setModelType(tableVO.getModelType()); tableInfo.setModelType(tableVO.getModelType());
tableInfo.setDescription(tableVO.getDescription()); tableInfo.setDescription(tableVO.getDescription());
tableInfo.setParentTable(parentTable);
tableInfoDao.save(tableInfo); tableInfoDao.save(tableInfo);
//默认存储ID字段 //默认存储ID字段
if (tableInfo.getModelType().equals(ModelType.VIRTUAL)) { if (tableInfo.getModelType().equals(ModelType.VIRTUAL)) {
...@@ -184,8 +178,10 @@ public class ModelImpl implements ModelService { ...@@ -184,8 +178,10 @@ public class ModelImpl implements ModelService {
ColumnInfo save = columnInfoDao.save(columnInfo); ColumnInfo save = columnInfoDao.save(columnInfo);
List<Quote> quoteList = columnVO.getQuoteList(); List<Quote> quoteList = columnVO.getQuoteList();
for (Quote quote : quoteList) { for (Quote quote : quoteList) {
quote.setColumnId(save.getId()); if (StringUtils.isNotEmpty(quote.getValue())){
quoteDao.save(quote); quote.setColumnId(save.getId());
quoteDao.save(quote);
}
} }
} }
//关闭会话 //关闭会话
...@@ -419,9 +415,9 @@ public class ModelImpl implements ModelService { ...@@ -419,9 +415,9 @@ public class ModelImpl implements ModelService {
tableInfo.setDescription(tableVO.getDescription()); tableInfo.setDescription(tableVO.getDescription());
tableInfo.setModelTitle(tableVO.getModelTitle()); tableInfo.setModelTitle(tableVO.getModelTitle());
tableInfo.setModelType(tableVO.getModelType()); tableInfo.setModelType(tableVO.getModelType());
// String xml = createTable(tableVO); String xml = createTable(tableVO);
//重新存xml //重新存xml
// tableInfo.setXml(xml); tableInfo.setXml(xml);
tableInfoDao.save(tableInfo); tableInfoDao.save(tableInfo);
//原来的字段信息 //原来的字段信息
...@@ -474,9 +470,9 @@ public class ModelImpl implements ModelService { ...@@ -474,9 +470,9 @@ public class ModelImpl implements ModelService {
columnInfoDao.save(columnInfo); columnInfoDao.save(columnInfo);
} }
tableInfo.setUpdatedTime(new Date()); tableInfo.setUpdatedTime(new Date());
// String xml = createTable(tableVO); String xml = createTable(tableVO);
//重新存xml // 重新存xml
// tableInfo.setXml(xml); tableInfo.setXml(xml);
tableInfoDao.save(tableInfo); tableInfoDao.save(tableInfo);
return 1; return 1;
} }
......
package com.tykj.model_layer.service.impl; package com.tykj.model_layer.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.base.result.ApiException; import com.tykj.base.result.ApiException;
import com.tykj.model_layer.dao.ColumnInfoDao;
import com.tykj.model_layer.dao.QuoteDao; import com.tykj.model_layer.dao.QuoteDao;
import com.tykj.model_layer.entity.Quote; import com.tykj.model_layer.entity.Quote;
import com.tykj.model_layer.entity.TableInfo;
import com.tykj.model_layer.entity.vo.SearchQuoteVO;
import com.tykj.model_layer.entity.vo.UpdateQuoteVO;
import com.tykj.model_layer.service.QuoteService; import com.tykj.model_layer.service.QuoteService;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.sql.Update;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -20,34 +32,55 @@ public class QuoteServiceImpl implements QuoteService { ...@@ -20,34 +32,55 @@ public class QuoteServiceImpl implements QuoteService {
@Autowired @Autowired
private QuoteDao quoteDao; private QuoteDao quoteDao;
@Override @Override
public void updateQuote(Integer id) { public List<Quote> updateQuote(UpdateQuoteVO updateQuoteVO) {
List<Quote> quoteList = updateQuoteVO.getQuoteList();
for (Quote quote : quoteList) {
quote.setColumnId(updateQuoteVO.getId());
quoteDao.save(quote);
}
return null;
} }
@Override @Override
public List<Quote> getAllQuote() { public List<Quote> getAllQuote(SearchQuoteVO searchQuoteVO) {
return quoteDao.findAll(); PredicateBuilder<Quote> and = Specifications.and();
if (searchQuoteVO!=null){
and.like(searchQuoteVO.getValue() != null && StringUtils.isNotEmpty(searchQuoteVO.getValue()),
"value", "%" + searchQuoteVO.getValue() + "%");
and.in(searchQuoteVO.getColumnIds()!=null && searchQuoteVO.getColumnIds().length>0,
"columnId",searchQuoteVO.getColumnIds());
and.in(searchQuoteVO.getValues()!=null && searchQuoteVO.getValues().length>0,
"value", searchQuoteVO.getValues());
}
return quoteDao.findAll(and.build());
} }
@Override @Override
public Quote saveQuote(Quote quote) { public Quote saveQuote(Quote quote) {
if (existValue(quote.getColumnId(), quote.getValue())) {
return quoteDao.save(quote); return quoteDao.save(quote);
}
throw new ApiException("插入错误!");
} }
@Override @Override
public void delQuote(Integer id) { public Integer delQuote(Integer id) {
quoteDao.deleteById(id); quoteDao.deleteById(id);
return 1;
} }
public boolean existValue(Integer cId, String value){ public boolean existValue(Integer cId, String value) {
List<String> collect = quoteDao.findAllByColumnId(cId) List<String> collect = quoteDao.findAllByColumnId(cId)
.stream() .stream()
.map(Quote::getValue) .map(Quote::getValue)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (collect.contains(value)){ if (collect.contains(value)) {
return true; return true;
} }
return false; return false;
......
package com.tykj.model_layer.service.impl;
import com.tykj.model_layer.dao.VersionBackupDao;
import com.tykj.model_layer.entity.VersionBackup;
import com.tykj.model_layer.service.VersionBackupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 14:00
*/
@Service
public class VersionBackupServiceImpl implements VersionBackupService {
@Autowired
private VersionBackupDao versionBackupDao;
@Override
public void addVersion(VersionBackup versionBackup) {
VersionBackup save = versionBackupDao.save(versionBackup);
}
}
package com.tykj.model_layer.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.tykj.model_layer.dao.ColumnInfoDao;
import com.tykj.model_layer.dao.VersionDao;
import com.tykj.model_layer.entity.ColumnInfo;
import com.tykj.model_layer.entity.Version;
import com.tykj.model_layer.entity.vo.VersionVO;
import com.tykj.model_layer.service.VersionService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:57
*/
@Service
public class VersionServiceImpl implements VersionService {
@Autowired
VersionDao versionDao;
@Autowired
ColumnInfoDao columnInfoDao;
@Override
public Version addVersion(VersionVO versionVO) {
Version version = new Version();
version.setVersionId(versionVO.getVersionId());
version.setVersionDesc(versionVO.getVersionDesc());
List<Integer> collect = columnInfoDao
.findAllByDbId(versionVO.getDbId()).stream()
.map(ColumnInfo::getId)
.collect(Collectors.toList());
version.setContent(JSONArray.toJSONString(collect));
return versionDao.save(version);
}
@Override
public void delVersion() {
versionDao.deleteAll();
}
@Override
public void Synchronize() {
}
}
package com.tykj.model_layer.utils;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 17:46
*/
public class GetIndexUtil {
public static String getIndex(Integer id){
return "";
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论