提交导入实体vo类

dev
mqh 1 year ago
parent 0fc1d68d85
commit 83d5672603
  1. 143
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java
  2. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/mapper/TablexMapper.java
  3. 18
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/mapper/TablexVoMapper.java
  4. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/mapper/xml/TablexMapper.xml
  5. 5
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/mapper/xml/TablexVoMapper.xml
  6. 15
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/ITablexVoService.java
  7. 22
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/impl/TablexVoServiceImpl.java
  8. 331
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java
  9. 4
      jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml
  10. 4
      jeecg-boot/jeecg-boot-module-system/src/main/resources/application-prod.yml
  11. 2
      jeecg-boot/jeecg-boot-module-system/src/main/resources/application-test.yml
  12. 2
      package-lock.json

@ -1,6 +1,9 @@
package org.jeecg.modules.tablex.controller;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@ -9,8 +12,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.fieldx.controller.FieldxController;
import org.jeecg.modules.fieldx.entity.Fieldx;
@ -25,6 +31,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.tablex.service.ITablexVoService;
import org.jeecg.modules.tablex.vo.TablexVo;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -63,6 +71,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@Autowired
private FieldxController fieldxController;
@Autowired
private ITablexVoService tablexVoService;
/**
* 分页列表查询
*
@ -84,22 +95,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
IPage<Tablex> pageList = tablexService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "实体管理-通过模块查询实体")
@ApiOperation(value="实体管理-通过模块查询实体", notes="实体管理-通过模块查询实体")
@GetMapping(value = "/getTableByModuleId")
public Result<?> getTableByModuleId(@RequestParam(name="moduleId",required=true) String moduleId){
if (moduleId!=null){
List<Tablex> tablexList = tablexService.list(new QueryWrapper<Tablex>().eq("module_id", moduleId));
ArrayList<HashMap> hashMaps = new ArrayList<>();
for (Tablex tablex:tablexList){
HashMap<Object, Object> hashMap = new HashMap<>();
hashMap.put("text",tablex.getTableName());
hashMap.put("value",tablex.getId());
hashMaps.add(hashMap);
}
return Result.OK(hashMaps);
}else return Result.error("未找到数据,请重试");
}
/**
* 添加
*
@ -140,12 +136,12 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody Tablex tablex) {
tablex.setVerison(tablex.getVerison()+1);
// List<Tablex> tablexList = tablexService.list();
// for (Tablex tablex1 : tablexList){
// if (tablex1.getModuleId().equals(tablex.getModuleId())){
// return Result.error("该模块已有实体,编辑失败");
// }
// }
List<Tablex> tablexList = tablexService.list();
for (Tablex tablex1 : tablexList){
if (tablex1.getModuleId().equals(tablex.getModuleId())){
return Result.error("该模块已有实体,编辑失败");
}
}
if (tablex.getModuleId() != null){
Modulex modulex = modulexService.getById(tablex.getModuleId());
tablex.setTableName(modulex.getModuleName());
@ -230,7 +226,106 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Tablex.class);
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
for (Map.Entry<String, MultipartFile> entry : fileMap.entrySet()) {
//获取上传文件对象
MultipartFile file = entry.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);//表格标题行数,默认0
params.setHeadRows(1);//表头行数,默认1
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
// 判断文件是否是表格
String originalFilename = file.getOriginalFilename();
if (StringUtils.isBlank(originalFilename) ||
(!originalFilename.endsWith("xls") &&
!originalFilename.endsWith("xlsx"))) {
return Result.error("文件格式不正确");
}
List<Tablex> list = null;
try {
//读取excel数据
list = ExcelImportUtil.importExcel(file.getInputStream(), Tablex.class, params);
} catch (Exception e) {
return Result.error("文件读取失败");
}
//判断文件中是否存在数据
if (list == null || list.size() == 0) {
return Result.error("Excel数据为空");
}
for (int i = 0; i < list.size(); i++) {
//判断当前存入行是否为空值
if (list.size() > 0 &&
list.get(i).getId() == null &&
list.get(i).getModuleId() == null &&
list.get(i).getTableName() == null &&
list.get(i).getTableEnName() == null &&
list.get(i).getTableStructure() == null &&
list.get(i).getStructuralDiagram() == null &&
list.get(i).getStatus() == null &&
list.get(i).getVerisonStatus() == null &&
list.get(i).getVerison() == null) continue;
//存入临时表中
tablexVoService.save((TablexVo) list.get(i));
}
//从临时表中取出数据
List<TablexVo> voList = tablexVoService.list();
if (voList == null) {
return Result.error("数据为空");
}
List<Tablex> tablexList = new ArrayList<>();
for (int i = 0; i < voList.size(); i++) {
//判断对应模块
if (voList.get(i).getModuleId() != null || !voList.get(i).getModuleId().equals("")) {
//判断中文名称
if (voList.get(i).getTableName() != null || !voList.get(i).getTableName().equals("")) {
//判断英文名称
if (voList.get(i).getTableEnName() != null || !voList.get(i).getTableEnName().equals("")) {
//判断表结构SQL
if (voList.get(i).getTableStructure() != null || !voList.get(i).getTableStructure().equals("")) {
//判断结构图
if (voList.get(i).getStructuralDiagram() != null || !voList.get(i).getStructuralDiagram().equals("")) {
//判断实体状态
if (voList.get(i).getStatus() != null || !voList.get(i).getStatus().equals("")) {
//判断版本状态
if (voList.get(i).getVerisonStatus() != null || !voList.get(i).getVerisonStatus().equals("")){
//判断版本号
if (voList.get(i).getVerison() != null || !voList.get(i).getVerison().equals("")){
} else {
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的结构图填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的表结构SQL填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!");
}
} else {
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!");
}
}
}
return super.importExcel(request, response, Tablex.class);
}

@ -2,6 +2,7 @@ package org.jeecg.modules.tablex.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.checkerframework.checker.guieffect.qual.UI;
@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Date: 2023-04-10
* @Version: V1.0
*/
@Mapper
public interface TablexMapper extends BaseMapper<Tablex> {
@Update("update tablex set table_structure = #{sql} where id = #{tableId}")

@ -0,0 +1,18 @@
package org.jeecg.modules.tablex.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.vo.TablexVo;
/**
* @Description: 实体表
* @Author: jeecg-boot
* @Date: 2023-04-10
* @Version: V1.0
*/
@Mapper
public interface TablexVoMapper extends BaseMapper<TablexVo> {
}

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace=".tablex.mapper.TablexMapper">
<mapper namespace="org.jeecg.modules.tablex.mapper.TablexMapper">
</mapper>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.tablex.mapper.TablexVoMapper">
</mapper>

@ -0,0 +1,15 @@
package org.jeecg.modules.tablex.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.vo.TablexVo;
/**
* @Description: 实体表
* @Author: jeecg-boot
* @Date: 2023-04-10
* @Version: V1.0
*/
public interface ITablexVoService extends IService<TablexVo> {
}

@ -0,0 +1,22 @@
package org.jeecg.modules.tablex.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.mapper.TablexMapper;
import org.jeecg.modules.tablex.mapper.TablexVoMapper;
import org.jeecg.modules.tablex.service.ITablexService;
import org.jeecg.modules.tablex.service.ITablexVoService;
import org.jeecg.modules.tablex.vo.TablexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Description: 实体表
* @Author: jeecg-boot
* @Date: 2023-04-10
* @Version: V1.0
*/
@Service
public class TablexVoServiceImpl extends ServiceImpl<TablexVoMapper, TablexVo> implements ITablexVoService {
}

@ -0,0 +1,331 @@
package org.jeecg.modules.tablex.vo;
import org.jeecg.modules.tablex.entity.Tablex;
import java.io.Serializable;
/**
*
* @TableName tablex_vo
*/
public class TablexVo extends Tablex implements Serializable {
/**
*
*/
private String id;
/**
* 对应模块id
*/
private String moduleId;
/**
* 中文名称
*/
private String tableName;
/**
* 英文名称
*/
private String tableEnName;
/**
* 表结构SQL
*/
private String tableStructure;
/**
* 结构图
*/
private String structuralDiagram;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private String createTime;
/**
* 修改人
*/
private String updateBy;
/**
* 修改时间
*/
private String updateTime;
/**
* 实体状态
*/
private String status;
/**
* 版本状态
*/
private String verisonStatus;
/**
* 版本号
*/
private String verison;
private static final long serialVersionUID = 1L;
/**
*
*/
public String getId() {
return id;
}
/**
*
*/
public void setId(String id) {
this.id = id;
}
/**
* 对应模块id
*/
public String getModuleId() {
return moduleId;
}
/**
* 对应模块id
*/
public void setModuleId(String moduleId) {
this.moduleId = moduleId;
}
/**
* 中文名称
*/
public String getTableName() {
return tableName;
}
/**
* 中文名称
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* 英文名称
*/
public String getTableEnName() {
return tableEnName;
}
/**
* 英文名称
*/
public void setTableEnName(String tableEnName) {
this.tableEnName = tableEnName;
}
/**
* 表结构SQL
*/
public String getTableStructure() {
return tableStructure;
}
/**
* 表结构SQL
*/
public void setTableStructure(String tableStructure) {
this.tableStructure = tableStructure;
}
/**
* 结构图
*/
public String getStructuralDiagram() {
return structuralDiagram;
}
/**
* 结构图
*/
public void setStructuralDiagram(String structuralDiagram) {
this.structuralDiagram = structuralDiagram;
}
/**
* 创建人
*/
public String getCreateBy() {
return createBy;
}
/**
* 创建人
*/
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
/**
* 创建时间
*/
public String getCreateTime() {
return createTime;
}
/**
* 创建时间
*/
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
/**
* 修改人
*/
public String getUpdateBy() {
return updateBy;
}
/**
* 修改人
*/
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
/**
* 修改时间
*/
public String getUpdateTime() {
return updateTime;
}
/**
* 修改时间
*/
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
/**
* 实体状态
*/
public String getStatus() {
return status;
}
/**
* 实体状态
*/
public void setStatus(String status) {
this.status = status;
}
/**
* 版本状态
*/
public String getVerisonStatus() {
return verisonStatus;
}
/**
* 版本状态
*/
public void setVerisonStatus(String verisonStatus) {
this.verisonStatus = verisonStatus;
}
/**
* 版本号
*/
public String getVerison() {
return verison;
}
/**
* 版本号
*/
public void setVerison(String verison) {
this.verison = verison;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TablexVo other = (TablexVo) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getModuleId() == null ? other.getModuleId() == null : this.getModuleId().equals(other.getModuleId()))
&& (this.getTableName() == null ? other.getTableName() == null : this.getTableName().equals(other.getTableName()))
&& (this.getTableEnName() == null ? other.getTableEnName() == null : this.getTableEnName().equals(other.getTableEnName()))
&& (this.getTableStructure() == null ? other.getTableStructure() == null : this.getTableStructure().equals(other.getTableStructure()))
&& (this.getStructuralDiagram() == null ? other.getStructuralDiagram() == null : this.getStructuralDiagram().equals(other.getStructuralDiagram()))
&& (this.getCreateBy() == null ? other.getCreateBy() == null : this.getCreateBy().equals(other.getCreateBy()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateBy() == null ? other.getUpdateBy() == null : this.getUpdateBy().equals(other.getUpdateBy()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getVerisonStatus() == null ? other.getVerisonStatus() == null : this.getVerisonStatus().equals(other.getVerisonStatus()))
&& (this.getVerison() == null ? other.getVerison() == null : this.getVerison().equals(other.getVerison()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getModuleId() == null) ? 0 : getModuleId().hashCode());
result = prime * result + ((getTableName() == null) ? 0 : getTableName().hashCode());
result = prime * result + ((getTableEnName() == null) ? 0 : getTableEnName().hashCode());
result = prime * result + ((getTableStructure() == null) ? 0 : getTableStructure().hashCode());
result = prime * result + ((getStructuralDiagram() == null) ? 0 : getStructuralDiagram().hashCode());
result = prime * result + ((getCreateBy() == null) ? 0 : getCreateBy().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateBy() == null) ? 0 : getUpdateBy().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getVerisonStatus() == null) ? 0 : getVerisonStatus().hashCode());
result = prime * result + ((getVerison() == null) ? 0 : getVerison().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", moduleId=").append(moduleId);
sb.append(", tableName=").append(tableName);
sb.append(", tableEnName=").append(tableEnName);
sb.append(", tableStructure=").append(tableStructure);
sb.append(", structuralDiagram=").append(structuralDiagram);
sb.append(", createBy=").append(createBy);
sb.append(", createTime=").append(createTime);
sb.append(", updateBy=").append(updateBy);
sb.append(", updateTime=").append(updateTime);
sb.append(", status=").append(status);
sb.append(", verisonStatus=").append(verisonStatus);
sb.append(", verison=").append(verison);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -137,9 +137,9 @@ spring:
# driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
url: jdbc:mysql://182.92.169.222:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: ycwl2022.
password: 157189
driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置
redis:

@ -132,9 +132,9 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://182.92.169.222:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: ycwl2022.
password: 157189
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:

@ -133,7 +133,7 @@ spring:
master:
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: root
password: 157189
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:

2
package-lock.json generated

@ -1,5 +1,5 @@
{
"name": "education",
"name": "projectManagement",
"lockfileVersion": 2,
"requires": true,
"packages": {}

Loading…
Cancel
Save