文档库--列表,文件上传

This commit is contained in:
zhn
2022-02-14 16:43:48 +08:00
parent d2d9fe50c1
commit fa1f3f3d5f
12 changed files with 585 additions and 401 deletions
@@ -1,11 +1,14 @@
package com.jero.modules.oss.entity; package com.jero.modules.oss.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.system.base.entity.JeroEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import com.jero.common.system.base.entity.JeroEntity;
import org.jeecgframework.poi.excel.annotation.Excel; import java.util.Date;
@Data @Data
@TableName("oss_file") @TableName("oss_file")
@@ -15,10 +18,30 @@ public class OSSFile extends JeroEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Excel(name = "文件名称") @ApiModelProperty(value = "文件名称")
private String fileName; private String fileName;
@Excel(name = "文件地址") @ApiModelProperty(value = "文件路径")
private String url; private String url;
@ApiModelProperty(value = "关联ID")
private String connectId;
@ApiModelProperty(value = "创建人登录名称")
private String createBy;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "创建日期")
private Date createTime;
@ApiModelProperty(value = "更新人登录名称")
private String updateBy;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
} }
@@ -1,6 +1,7 @@
package com.jero.modules.oss.service; package com.jero.modules.oss.service;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.entity.OSSFile;
@@ -9,7 +10,21 @@ import org.springframework.web.multipart.MultipartFile;
public interface IOSSFileService extends IService<OSSFile> { public interface IOSSFileService extends IService<OSSFile> {
void upload(MultipartFile multipartFile) throws IOException; void upload(MultipartFile multipartFile) throws IOException;
/**
* 本地文件上传
*
* @param mf 文件
* @param bizPath 自定义路径
* @return
*/
public OSSFile uploadLocal(MultipartFile mf, String bizPath);
boolean delete(OSSFile ossFile); boolean delete(OSSFile ossFile);
/**
* 批量修改
* @param ossFileList
*/
void updateFileInfo(List<OSSFile> ossFileList);
} }
@@ -1,19 +1,33 @@
package com.jero.modules.oss.service.impl; package com.jero.modules.oss.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.CommonUtils; import com.jero.common.util.CommonUtils;
import com.jero.common.util.oConvertUtils;
import com.jero.common.util.oss.OssBootUtil; import com.jero.common.util.oss.OssBootUtil;
import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.mapper.OSSFileMapper; import com.jero.modules.oss.mapper.OSSFileMapper;
import com.jero.modules.oss.service.IOSSFileService; import com.jero.modules.oss.service.IOSSFileService;
import me.zhyd.oauth.utils.UuidUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Date;
import java.util.List;
@Service("ossFileService") @Service("ossFileService")
public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> implements IOSSFileService { public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> implements IOSSFileService {
@Value(value = "${jero.path.upload}")
private String uploadpath;
@Override @Override
public void upload(MultipartFile multipartFile) throws IOException { public void upload(MultipartFile multipartFile) throws IOException {
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
@@ -27,6 +41,83 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
//update-end--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败------------------- //update-end--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------
this.save(ossFile); this.save(ossFile);
} }
/**
* 本地文件上传
*
* @param mf 文件
* @param bizPath 自定义路径
* @return
*/
@Override
public OSSFile uploadLocal(MultipartFile mf, String bizPath) {
//处理文件大小,大于100M抛出异常
long fileSize = mf.getSize() / 1024 / 1024;
String originalFilename = mf.getOriginalFilename();
if (fileSize >= 100) {
throw new JeroBootException(originalFilename + "文件大小超出100MB限制, 请压缩或降低文件质量!");
}
OSSFile oSSFile = new OSSFile();
try {
String ctxPath = uploadpath;
String fileName = null;
String fileType = null;
File file = new File(ctxPath + File.separator + bizPath + File.separator);
if (!file.exists()) {
file.mkdirs();// 创建文件根目录
}
String orgName = mf.getOriginalFilename();// 获取文件名
orgName = CommonUtils.getFileName(orgName);
if (orgName.indexOf(".") != -1) {
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
} else {
fileName = orgName + "_" + System.currentTimeMillis();
}
fileType = orgName.substring(orgName.lastIndexOf("."));
//判断文件类型
if (StringUtils.isNotEmpty(fileType)) {
String[] fileTypeArr = {".doc", ".docx", ".xls", ".xlsx", ".pdf", ".png", ".jfif", ".pjpeg", ".jpeg", ".pjp", ".jpg", ".swf", ".bmp",".rar",".zip"};
boolean flag = true;
for (String fileTypeTemp : fileTypeArr) {
if (fileTypeTemp.equalsIgnoreCase(fileType)) {
flag = false;
}
}
if (flag) {
throw new JeroBootException("只能够上传Word、Excel、PDF、静态图片类型的文件。请重新选择文件!");
}
}
String savePath = file.getPath() + File.separator + fileName;
File savefile = new File(savePath);
FileCopyUtils.copy(mf.getBytes(), savefile);
String dbpath = null;
if (oConvertUtils.isNotEmpty(bizPath)) {
dbpath = bizPath + File.separator + fileName;
} else {
dbpath = fileName;
}
if (dbpath.contains("\\")) {
dbpath = dbpath.replace("\\", "/");
}
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//存入文件表
oSSFile.setFileName(orgName);
oSSFile.setId(UuidUtils.getUUID());
oSSFile.setUrl(file.getPath());
oSSFile.setCreateBy(loginUser.getUsername());
oSSFile.setCreateTime(new Date());
this.save(oSSFile);
return oSSFile;
} catch (IOException e) {
log.error(e.getMessage(), e);
}
return oSSFile;
}
@Override @Override
public boolean delete(OSSFile ossFile) { public boolean delete(OSSFile ossFile) {
@@ -40,4 +131,9 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
return true; return true;
} }
@Override
public void updateFileInfo(List<OSSFile> ossFileList) {
this.updateBatchById(ossFileList);
}
} }
@@ -72,48 +72,80 @@ public class CommonController {
return Result.error("没有权限,请联系管理员授权"); return Result.error("没有权限,请联系管理员授权");
} }
// /**
// * 文件上传统一方法
// * @param request
// * @param response
// * @return
// */
// @PostMapping(value = "/upload")
// public Result<OSSFile> upload(HttpServletRequest request, HttpServletResponse response) {
// Result<OSSFile> result = new Result<>();
// String savePath = "";
// String bizPath = request.getParameter("biz");
// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
// // 获取上传文件对象
// MultipartFile file = multipartRequest.getFile("file");
// // 文件类型是否处于黑名单
// if(CommonUtils.limitFileSuffix(file.getOriginalFilename(),fileSuffixLimits)){
// result.setMessage("该文件类型不允许上传");
// result.setSuccess(false);
// result.setCode(0);
// return result;
// }
// if(oConvertUtils.isEmpty(bizPath)){
// bizPath = "";
// }
// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
// // 本地上传
// savePath = CommonUtils.uploadLocal(file,bizPath,uploadpath);
// }else{
// // minio上传
// savePath = CommonUtils.upload(file, bizPath, uploadType);
// }
// if(oConvertUtils.isNotEmpty(savePath)){
// //上传成功 进行数据库存储
// OSSFile ossFile = new OSSFile();
// // 文件名
// String fileName = file.getOriginalFilename();
// fileName = CommonUtils.getFileName(fileName);
// ossFile.setFileName(fileName);
// ossFile.setUrl(savePath);
// ossFileService.save(ossFile);
// result.setMessage(savePath);
// result.setResult(ossFile);
// result.setSuccess(true);
// }else {
// result.setMessage("上传失败!");
// result.setSuccess(false);
// }
// return result;
// }
/** /**
* 文件上传统一方法 * 文件上传统一方法
*
* @param request * @param request
* @param response * @param response
* @return * @return
*/ */
@PostMapping(value = "/upload") @PostMapping(value = "/upload")
public Result<OSSFile> upload(HttpServletRequest request, HttpServletResponse response) { public Result<?> upload(HttpServletRequest request, HttpServletResponse response) {
Result<OSSFile> result = new Result<>(); Result<OSSFile> result = new Result<>();
String savePath = "";
String bizPath = request.getParameter("biz"); String bizPath = request.getParameter("biz");
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
// 获取上传文件对象 MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
MultipartFile file = multipartRequest.getFile("file");
// 文件类型是否处于黑名单
if(CommonUtils.limitFileSuffix(file.getOriginalFilename(),fileSuffixLimits)){
result.setMessage("该文件类型不允许上传");
result.setSuccess(false);
result.setCode(0);
return result;
}
if (oConvertUtils.isEmpty(bizPath)) { if (oConvertUtils.isEmpty(bizPath)) {
if (CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)) {
//未指定目录,则用阿里云默认目录 upload
bizPath = "upload";
} else {
bizPath = ""; bizPath = "";
} }
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
// 本地上传
savePath = CommonUtils.uploadLocal(file,bizPath,uploadpath);
}else{
// minio上传
savePath = CommonUtils.upload(file, bizPath, uploadType);
} }
if(oConvertUtils.isNotEmpty(savePath)){ OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath);
//上传成功 进行数据库存储 if (oConvertUtils.isNotEmpty(oSSFile)) {
OSSFile ossFile = new OSSFile(); result.setResult(oSSFile);
// 文件名
String fileName = file.getOriginalFilename();
fileName = CommonUtils.getFileName(fileName);
ossFile.setFileName(fileName);
ossFile.setUrl(savePath);
ossFileService.save(ossFile);
result.setMessage(savePath);
result.setResult(ossFile);
result.setSuccess(true); result.setSuccess(true);
} else { } else {
result.setMessage("上传失败!"); result.setMessage("上传失败!");
+34
View File
@@ -47,6 +47,40 @@
<artifactId>jero-boot-base-generater</artifactId> <artifactId>jero-boot-base-generater</artifactId>
<version>${jero.version}</version> <version>${jero.version}</version>
</dependency> </dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.2.3</version>
<classifier>jdk15</classifier>
<!-- jdk版本 -->
</dependency>
</dependencies> </dependencies>
</project> </project>
@@ -1,5 +1,6 @@
package com.jero.modules.document.controller; package com.jero.modules.document.controller;
import cn.hutool.json.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import net.sf.json.JSONObject;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -67,9 +69,12 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
@AutoLog(value = "分页查询") @AutoLog(value = "分页查询")
@ApiOperation(value="分页查询", notes="分页查询") @ApiOperation(value="分页查询", notes="分页查询")
@GetMapping(value = "/queryPageInfo") @GetMapping(value = "/queryPageInfo")
public Result<?> queryPageInfo(@RequestParam(name="parameter",required=false) Map<String,Object> parameter) { @ResponseBody
bussDocumentLibraryEOService.getInfoPage(parameter); public JSONObject queryPageInfo(@RequestParam(name="parameter",required=false) Map<String,Object> parameter) {
return Result.OK(); IPage infoPage = bussDocumentLibraryEOService.getInfoPage(parameter);
Result<IPage> ok = Result.OK(infoPage);
JSONObject jsonResult = JSONObject.fromObject(ok);
return jsonResult;
} }
/** /**
@@ -17,7 +17,8 @@ public interface BussDocumentLibraryEOMapper extends BaseMapper<BussDocumentLibr
int insertInfo(@Param("insertField") String insertField, int insertInfo(@Param("insertField") String insertField,
@Param("insertValue") String insertValue); @Param("insertValue") String insertValue);
IPage getInfoPage(@Param("page") Page page, IPage getInfoPage(@Param("page") IPage page,
@Param("field") String field,
@Param("condition") String condition); @Param("condition") String condition);
@@ -40,8 +40,8 @@
values (${insertValue}) values (${insertValue})
</insert> </insert>
<select id="getInfoPage" resultType="com.baomidou.mybatisplus.core.metadata.IPage"> <select id="getInfoPage" resultType="java.util.LinkedHashMap">
select * from buss_document_library select ${field} from buss_document_library
${condition} ${condition}
</select> </select>
@@ -1,5 +1,6 @@
package com.jero.modules.document.service; package com.jero.modules.document.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.document.entity.BussDocumentLibraryEO; import com.jero.modules.document.entity.BussDocumentLibraryEO;
@@ -85,7 +86,7 @@ public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibr
*/ */
void updateInfo(Map<String,Object> map); void updateInfo(Map<String,Object> map);
void getInfoPage(Map<String,Object> parameter); IPage getInfoPage(Map<String,Object> parameter);
} }
@@ -13,6 +13,8 @@ import com.jero.modules.document.entity.BussDocumentLibraryEO;
import com.jero.modules.document.enums.FieldTypeEnum; import com.jero.modules.document.enums.FieldTypeEnum;
import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper; import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper;
import com.jero.modules.document.service.IBussDocumentLibraryEOService; import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.tag.entity.OnlCgformArea; import com.jero.modules.tag.entity.OnlCgformArea;
import com.jero.modules.tag.service.impl.OnlCgformAreaServiceImpl; import com.jero.modules.tag.service.impl.OnlCgformAreaServiceImpl;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
@@ -22,7 +24,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -40,6 +47,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
private OnlCgformAreaServiceImpl onlCgformAreaServiceImpl; private OnlCgformAreaServiceImpl onlCgformAreaServiceImpl;
@Autowired @Autowired
private BussDocumentLibraryEOMapper bussDocumentLibraryEOMapper; private BussDocumentLibraryEOMapper bussDocumentLibraryEOMapper;
@Autowired
private IOSSFileService iOSSFileService;
/** /**
@@ -87,6 +96,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* 查询条件 * 查询条件
*
* @return * @return
*/ */
@Override @Override
@@ -111,6 +121,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* 列表表头 * 列表表头
*
* @return * @return
*/ */
@Override @Override
@@ -133,6 +144,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* 新增表单 * 新增表单
*
* @return * @return
*/ */
@Override @Override
@@ -168,6 +180,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* 详情,编辑数据查询 * 详情,编辑数据查询
*
* @param id * @param id
* @return * @return
*/ */
@@ -212,6 +225,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* 新增数据 * 新增数据
*
* @param map * @param map
*/ */
public void addInfo(Map<String, Object> map) { public void addInfo(Map<String, Object> map) {
@@ -251,24 +265,28 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
valuesBuilder.append("," + value); valuesBuilder.append("," + value);
} else { } else {
valuesBuilder.append("," + "'" + value + "'");
}
fieldsBuilder.append("," + key);
// }
//处理文件类型 //处理文件类型
List<OnlCgformField> fieldFile = fieldFileList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList()); List<OnlCgformField> fieldFile = fieldFileList.stream().filter(e -> entry.getKey().equals(e.getDbFieldName())).collect(Collectors.toList());
if (fieldFile.size() != 0 && ObjectUtils.isNotEmpty(value)) { if (fieldFile.size() != 0 && ObjectUtils.isNotEmpty(value)) {
String valueTemp = UUID.randomUUID().toString().replace("-", ""); String valueTemp = UUID.randomUUID().toString().replace("-", "");
value = valueTemp;
//修改文件表关联信息connect_id //修改文件表关联信息connect_id
List<OSSFile> oSSFileList = new ArrayList<>();
for (String fileId : value.toString().split(",")) {
OSSFile ossFile = new OSSFile();
ossFile.setId(fileId);
ossFile.setConnectId(valueTemp);
oSSFileList.add(ossFile);
}
iOSSFileService.updateFileInfo(oSSFileList);
}
valuesBuilder.append("," + "'" + value + "'");
}
fieldsBuilder.append("," + key);
// }
} }
}
String insertField = mustFields + fieldsBuilder.toString(); String insertField = mustFields + fieldsBuilder.toString();
String insertValue = mustValues + valuesBuilder.toString(); String insertValue = mustValues + valuesBuilder.toString();
@@ -278,6 +296,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
/** /**
* 编辑数据 * 编辑数据
*
* @param map * @param map
*/ */
public void updateInfo(Map<String, Object> map) { public void updateInfo(Map<String, Object> map) {
@@ -337,6 +356,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
bussDocumentLibraryEOMapper.insertInfo(insertField, insertValue); bussDocumentLibraryEOMapper.insertInfo(insertField, insertValue);
} }
private String getMustValues() { private String getMustValues() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -346,30 +366,34 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
return mustValue; return mustValue;
} }
public void getInfoPage(Map<String,Object> parameter){ public IPage getInfoPage(Map<String, Object> parameter) {
//过滤查询条件字段类型使用 //过滤查询条件字段类型使用
List<Map<String, Object>> mapList = queryCondition("1"); List<Map<String, Object>> mapList = queryCondition("1");
//测试数据(查询条件, 暂时使用mapTemp, 提交代码的时候使用parameter)
Map<String,Object> mapTemp = new HashMap<>();
// mapTemp.put("orderByField","issue_time");//测试数据
// mapTemp.put("orderBy","1");//测试数据
for (Map<String, Object> map : mapList) { //需要查询的字段
for (Map.Entry<String, Object> entry : map.entrySet()) { List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList("1");
String key = entry.getKey(); if (fieldList.size() != 0) {
String value = (String) entry.getValue(); //过滤列表字段(is_show_list-->列表是否显示0否 1是)
int a= 0; fieldList = fieldList.stream().filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowList()))).collect(Collectors.toList());
if("db_field_name".equals(key)){
mapTemp.put(value,"aaa");//测试数据
} }
List<String> fieldListTemp = fieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
List<String> fieldListNew = new ArrayList<>();
fieldListNew.add("id");
//转时间格式
for (String field : fieldListTemp) {
if ("issue_time".equals(field) || "implement_time".equals(field)) {
fieldListNew.add("date_format(" + field + ", '%Y-%m-%d %H:%i:%s')");
} else {
fieldListNew.add(field);
} }
} }
//查询条件 //查询条件
StringBuilder conditionSb = new StringBuilder("where 1 = 1"); StringBuilder conditionSb = new StringBuilder("where 1 = 1");
for (Map.Entry<String, Object> entry : mapTemp.entrySet()) { if (ObjectUtils.isNotEmpty(parameter)) {
for (Map.Entry<String, Object> entry : parameter.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String value = (String) entry.getValue(); String value = (String) entry.getValue();
if (StringUtils.isNotBlank(value)) { if (StringUtils.isNotBlank(value)) {
@@ -408,74 +432,26 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
} }
} }
//处理列表表头排序 //处理列表表头排序
if(StringUtils.isNotBlank((String) mapTemp.get("orderByField"))){ if (StringUtils.isNotBlank((String) parameter.get("orderByField"))) {
conditionSb.append(" order by " + (String) mapTemp.get("orderByField")); conditionSb.append(" order by " + (String) parameter.get("orderByField"));
if("1".equals((String) mapTemp.get("orderBy"))){ if ("1".equals((String) parameter.get("orderBy"))) {
conditionSb.append(" asc");//正序 conditionSb.append(" asc");//正序
}else if("2".equals((String) mapTemp.get("orderBy"))){ } else if ("2".equals((String) parameter.get("orderBy"))) {
conditionSb.append(" desc");//倒序 conditionSb.append(" desc");//倒序
} }
} else { } else {
conditionSb.append(" order by create_time desc"); conditionSb.append(" order by create_time desc");
} }
}
int pageNo = 1; int pageNo = 1;
int pageSize = 10; int pageSize = 10;
// int pageNo = Integer.parseInt(mapTemp.get("pageNo").toString()); // int pageNo = Integer.parseInt(mapTemp.get("pageNo").toString());
// int pageSize = Integer.parseInt(mapTemp.get("pageSize").toString()); // int pageSize = Integer.parseInt(mapTemp.get("pageSize").toString());
Page page = new Page(pageNo, pageSize); IPage page = new Page(pageNo, pageSize);
IPage infoPage = bussDocumentLibraryEOMapper.getInfoPage(page, conditionSb.toString());
int a = 0;
// for (Map<String, Object> map : mapList) {
//
//
// String key = (String) map.get("db_field_name");//字段名
//// String value = (String) map.get("value");//字段值
// String value = "qqqqqq,wwww";//字段值
// String fieldType = (String) map.get("field_show_type");//字段类型
//
// if(StringUtils.isNotBlank(value)){
// if(FieldTypeEnum.TEXT.getValue().equals(fieldType)){
// //输入框
// conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%')");
//// conditionSb.append(" and " + key +"='"+value+"' ");
//
//
// }else if(FieldTypeEnum.LIST.getValue().equals(fieldType)
// || FieldTypeEnum.LIST_MULTI.getValue().equals(fieldType)){
// StringBuilder valueSb = new StringBuilder();
// for (String valueTemp : value.split(",")) {
// valueSb.append("'" + valueTemp + "',");
// }
// String substring = valueSb.substring(0, valueSb.length() - 1);
// //下拉单选或下拉多选
// conditionSb.append(" and " + key + " in("+substring+")");
//
//
// }else if(FieldTypeEnum.DATE.getValue().equals(fieldType)){
// value = "2022-01-24,2022-01-24";
// //日期
// if(value.contains(",")){
// conditionSb.append(" and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
// + " and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value.split(",")[1] + "'");
// }else{
// conditionSb.append(" and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value + "'");
// }
//
//
//
// }
// }
//
// }
IPage infoPage = bussDocumentLibraryEOMapper.getInfoPage(page, " " + StringUtils.join(fieldListNew, ","), conditionSb.toString());
return infoPage;
// bussDocumentLibraryEOMapper.getInfoPage();
} }
@@ -135,7 +135,8 @@ spring:
# username: root # username: root
# password: 123456 # password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://121.36.69.172:3307/laws_weilai?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://121.36.69.172:3307/laws_weilai?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
# url: jdbc:mysql://121.36.69.172:3307/laws_weilai?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root username: root
password: hzwlsoft.com password: hzwlsoft.com
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
@@ -180,7 +181,7 @@ jero :
uploadType: local uploadType: local
path : path :
#文件上传根目录 设置 #文件上传根目录 设置
upload: D://opt//upFiles upload: E://opt//upFiles
#webapp文件路径 #webapp文件路径
webapp: D://opt//webapp webapp: D://opt//webapp
shiro: shiro:
+1 -1
View File
@@ -124,7 +124,7 @@
} }
getAction(this.url.tableList, params).then((res) => { getAction(this.url.tableList, params).then((res) => {
if (res.success) { if (res.success) {
this.jsonBody = res.result || [] this.jsonBody = res.result.records
} }
}) })
}, },