Browse Source

发布查询1

chenc 3 năm trước cách đây
mục cha
commit
74491681f4

+ 71 - 3
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/common/system/controller/CommonController.java

@@ -8,6 +8,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -72,7 +74,8 @@ public class CommonController {
 	 * @return
 	 */
 	@PostMapping(value = "/upload")
-	public Result<?> upload(HttpServletRequest request, HttpServletResponse response) {
+	public Map<String,Object> upload(HttpServletRequest request, HttpServletResponse response) {
+		Map<String,Object> map=new HashMap<>();
 		Result<?> result = new Result<>();
 		String savePath = "";
 		String bizPath = request.getParameter("biz");
@@ -82,7 +85,7 @@ public class CommonController {
 			if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){
 				result.setMessage("使用阿里云文件上传时,必须添加目录!");
 				result.setSuccess(false);
-				return result;
+				return map;
 			}else{
 				bizPath = "";
 			}
@@ -99,7 +102,11 @@ public class CommonController {
 			result.setMessage("上传失败!");
 			result.setSuccess(false);
 		}
-		return result;
+		map.put("code",0);
+		Map<String,Object> map1=new HashMap<>();
+		map1.put("url","http://localhost:3000/jeecg-boot/sys/common/upload/");
+		map.put("data",map1);
+		return map;
 	}
 
 	/**
@@ -374,6 +381,13 @@ public class CommonController {
 	}
 
 
+	/**
+	* @Author chenchuang
+	* @Description //TODO 常用文件上传下载
+	* @Date 2021/6/23 15:42
+	* @Param [request, response]
+	* @return org.jeecg.common.api.vo.Result
+	*/
 	@PostMapping(value = "/uploadFile")
 	public Result uploadFile(HttpServletRequest request, HttpServletResponse response) {
 		Result result = new Result<>();
@@ -388,6 +402,9 @@ public class CommonController {
 			}
 			MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
 			MultipartFile mf = multipartRequest.getFile("file");// 获取上传文件对象
+			if(mf==null){
+				mf = multipartRequest.getFile("image");// 获取上传文件对象
+			}
 			String orgName = mf.getOriginalFilename();// 获取文件名
 			fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
 			String savePath = file.getPath() + File.separator + fileName;
@@ -407,4 +424,55 @@ public class CommonController {
 		return result;
 	}
 
+	/**
+	* @Author chenchuang
+	* @Description //TODO 自定义表单文件上传下载
+	* @Date 2021/6/23 15:42
+	* @Param [request, response]
+	* @return java.lang.Object
+	*/
+	@PostMapping(value = "/uploadFile2")
+	public Object uploadFile2(HttpServletRequest request, HttpServletResponse response) {
+		Map<String,Object> map =new HashMap<>();
+		Result result = new Result<>();
+		try {
+			String ctxPath = uploadpath;
+			String fileName = null;
+			String bizPath = "file";
+			String nowday = new SimpleDateFormat("yyyyMMdd").format(new Date());
+			File file = new File(ctxPath + File.separator + bizPath + File.separator + nowday);
+			if (!file.exists()) {
+				file.mkdirs();// 创建文件根目录
+			}
+			MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+			MultipartFile mf = multipartRequest.getFile("file");// 获取上传文件对象
+			if(mf==null){
+				mf = multipartRequest.getFile("image");// 获取上传文件对象
+			}
+			String orgName = mf.getOriginalFilename();// 获取文件名
+			fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
+			String savePath = file.getPath() + File.separator + fileName;
+			File savefile = new File(savePath);
+			FileCopyUtils.copy(mf.getBytes(), savefile);
+			String dbpath = bizPath + File.separator + nowday + File.separator + fileName;
+			if (dbpath.contains("\\")) {
+				dbpath = dbpath.replace("\\", "/");
+			}
+			result.setMessage(dbpath);
+			result.setSuccess(true);
+			map.put("message",dbpath);
+			map.put("success",true);
+			map.put("code",0);
+			Map<String,Object> map1=new HashMap<>();
+			map1.put("url","http://localhost:3000/jeecg-boot/sys/common/downloadFile/"+dbpath);
+			map.put("data",map1);
+		} catch (IOException e) {
+			map.put("success",false);
+			map.put("message",e.getMessage());
+			result.setSuccess(false);
+			result.setMessage(e.getMessage());
+			e.printStackTrace();
+		}
+		return map;
+	}
 }

+ 9 - 4
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/ActBusinessServiceImpl.java

@@ -51,7 +51,12 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
                 StringBuilder filedsVB = new StringBuilder("'"+tableId+"'");
                 for (String filed : fileds) {
                     filedsB.append(","+filed);
-                    filedsVB.append(",'"+request.getParameter(filed)+"'");
+                    if(!request.getParameter(filed).equals("")){
+                        filedsVB.append(",'"+request.getParameter(filed)+"'");
+                    }else{
+                        filedsVB.append(",'"+request.getParameter(filed+"[]")+"'");
+                    }
+
                 }
             this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)",tableName,filedsB.toString(),filedsVB.toString()));
 
@@ -72,8 +77,8 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
 
 
                     for(String filed : fileds2) {
-                        filedIdB.append("," + filed);
-                        filedIdVB.append(",'" + jobj.getString(filed) + "'");
+                            filedIdB.append(",`" + filed+"`");
+                            filedIdVB.append(",'" + jobj.getString(filed) + "'");
                     }
 
                     //排序
@@ -114,7 +119,7 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
 
 
                     for (String filed : fileds2) {
-                        filedIdB.append(","+filed);
+                        filedIdB.append(",`"+filed+"`");
                         filedIdVB.append(",'"+jobj.getString(filed)+"'");
                     }
 

+ 0 - 1
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/TbTableInfoController.java

@@ -53,7 +53,6 @@ public class TbTableInfoController {
             return Result.ok("修改成功");
         } else {
             //新增
-
             tbTableInfoService.save(tbTableInfo);
             return Result.ok("新增成功");
         }

+ 2 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -88,6 +88,8 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
 		filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
 		filterChainDefinitionMap.put("/sys/common/uploadFile/**", "anon");//文件预览不受限制
+		filterChainDefinitionMap.put("/sys/common/uploadFile2/**", "anon");//文件预览不受限制
+		filterChainDefinitionMap.put("/sys/common/upload/**", "anon");//文件预览不受限制
 		filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
 		filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
 		filterChainDefinitionMap.put("/", "anon");