Commit 5307c4df authored by m1991's avatar m1991

资讯模块数据——图片展示功能修复

parent 0ad106d2
......@@ -57,12 +57,7 @@ public class zxUserDto {
@TableField(exist = false)
@ApiModelProperty(name = "zx_field", value = "资讯文字输入字段")
private String zxField;
/**
* 用户发布地址
*/
@TableField(exist = false)
@ApiModelProperty(name = "zx_address", value = "用户发布地址")
private String zxAddress;
/**
* 资讯数据创建时间
*/
......
......@@ -5,7 +5,6 @@ import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
......@@ -34,7 +33,7 @@ public interface UploadService {
* @param file
* @return
*/
List imageUpload( MultipartFile[] file, String zxField,String inviteCode);
Map imageUpload(MultipartFile[] file, String zxField, String inviteCode);
......
......@@ -9,7 +9,6 @@ import cn.wisenergy.model.app.User;
import cn.wisenergy.model.app.shopZx;
import cn.wisenergy.model.app.userLikes;
import cn.wisenergy.model.app.zxUserDto;
import com.alibaba.fastjson.JSON;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.stereotype.Service;
......@@ -158,7 +157,7 @@ public class UploadServiceImpl implements UploadService {
* @return
*/
@Override
public List imageUpload(MultipartFile[] files, String zxField, String inviteCode) {
public Map imageUpload(MultipartFile[] files, String zxField, String inviteCode) {
//获取上传图片数量,打印在控制台
System.out.println("上传图片数量" + files.length);
String zxUrl = new String();
......@@ -170,7 +169,7 @@ public class UploadServiceImpl implements UploadService {
Long time = new Date().getTime();
String localPath = "/upload/";
Map<String, Object> result = new HashMap<String, Object>();//一个文件上传的结果
String result_msg = "";//上传结果信息
String msg = "";//上传结果信息
//遍历图片数据
for (MultipartFile file : files) {
if (file.isEmpty()) {
......@@ -193,26 +192,27 @@ public class UploadServiceImpl implements UploadService {
//文件存放的相对路径(一般存放在数据库用于img标签的src)
String relativePath ="用于判断是否图片上传成功,返回值有:"+fileName;
result.put("relativePath", relativePath);//前端根据是否存在该字段来判断上传是否成功
result_msg = "图片上传成功";
msg = "图片上传成功";
result.put("zxUrl", zxUrl);
} else {
result_msg = "图片上传失败";
msg = "图片上传失败";
}
} else {
result_msg = "图片格式不正确";
msg = "图片格式不正确";
}
}
result.put("result_msg", result_msg);
root.add(result);
String root_json = JSON.toJSONString(root);
System.out.println(root_json);
result.put("returnCode", 0);
// result.put("msg", result_msg);
//root.add(result);
// String root_json = JSON.toJSONString(root);
// System.out.println(root_json);
result.put("code", 0);
result.put("msg",msg);
/**
* 生成当前时间戳
*/
Long zxDate= Long.valueOf(System.currentTimeMillis());
shopZxMapper.zxadd(zxUrl,zxField,inviteCode, zxDate);
return root;
return result;
}
/**
......
......@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
......@@ -90,7 +89,7 @@ public class UploadController {
@ApiImplicitParam(name = "inviteCode", value = "用户本人邀请码(发布人)", required = true, dataType = "String")})
@RequestMapping(method = RequestMethod.POST, value = "/multipleImageUpload", headers = "content-type=multipart/form-data")
public List multipleImageUpload(@RequestParam(required=false,value = "files") MultipartFile[] files, String zxField,String inviteCode) {
public Map multipleImageUpload(@RequestParam(required=false,value = "files") MultipartFile[] files, String zxField, String inviteCode) {
return uploadService.imageUpload(files, zxField,inviteCode);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment