Browse Source

'河湖图片'

master
daixiantong 4 years ago
parent
commit
f06840e07a
5 changed files with 51 additions and 4 deletions
  1. +1
    -1
      src/main/java/com/taauav/admin/controller/UploadController.java
  2. +16
    -3
      src/main/java/com/taauav/admin/entity/TauvDriver.java
  3. +2
    -0
      src/main/java/com/taauav/admin/service/ITauvDriverService.java
  4. +28
    -0
      src/main/java/com/taauav/admin/service/impl/TauvDriverServiceImpl.java
  5. +4
    -0
      src/main/java/com/taauav/admin/vo/TauvDriverListVo.java

+ 1
- 1
src/main/java/com/taauav/admin/controller/UploadController.java View File

private Map<String, String> getUploadFile(MultipartFile file) { private Map<String, String> getUploadFile(MultipartFile file) {
Map<String, String> dt = new HashMap<String, String>(); Map<String, String> dt = new HashMap<String, String>();
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
String extension = fileName.substring(fileName.lastIndexOf(".") + 1);
String extension = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
String newFileName = UUID.randomUUID().toString().replace("-", "").substring(0, 10) + "." + extension; String newFileName = UUID.randomUUID().toString().replace("-", "").substring(0, 10) + "." + extension;
String uploadPath = mkfilePath(); String uploadPath = mkfilePath();
String fileUrl = uploadPath + newFileName; String fileUrl = uploadPath + newFileName;

+ 16
- 3
src/main/java/com/taauav/admin/entity/TauvDriver.java View File

package com.taauav.admin.entity; package com.taauav.admin.entity;


import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.taauav.common.domain.Entity; import com.taauav.common.domain.Entity;
import lombok.Data; import lombok.Data;
*/ */
private BigInteger driverArea; private BigInteger driverArea;


/**
* 附件名称
*/
private String imgName;

/**
* 附件路径
*/
private String imgPath;

/** /**
* 附件名称 * 附件名称
*/ */
*/ */
@TableField(exist = false) @TableField(exist = false)
private String fileUrl; private String fileUrl;

/**
* 河湖图片格式化地址
*/
@TableField(exist = false)
private String imgUrl;
} }

+ 2
- 0
src/main/java/com/taauav/admin/service/ITauvDriverService.java View File

/** /**
* 获取所有河道数据 * 获取所有河道数据
* *
* @param map
* @return * @return
*/ */
Response getDriverList(Map<String, Object> map); Response getDriverList(Map<String, Object> map);
* 导入河道Json数据 * 导入河道Json数据
* *
* @return * @return
* @throws IOException
*/ */
Response importData() throws IOException; Response importData() throws IOException;
} }

+ 28
- 0
src/main/java/com/taauav/admin/service/impl/TauvDriverServiceImpl.java View File

private RedisUtils redisUtils; private RedisUtils redisUtils;
@Value("${file.uploadFolder}") @Value("${file.uploadFolder}")
private String uploadFolder; private String uploadFolder;
@Value("${server.UPLOAD_URL}")
private String uploadUrl;


/** /**
* 获取河道列表 * 获取河道列表
driverListVo.setDriverManagerName(lsAdmin.getRealname()); driverListVo.setDriverManagerName(lsAdmin.getRealname());
} }
} }
// 图片路径
if (!StringUtils.isEmpty(item.getImgPath())) {
if (item.getImgPath().contains("http")) {
driverListVo.setImgUrl(item.getImgPath());
} else {
driverListVo.setImgUrl(uploadUrl + item.getImgPath());
}
}
driverListVoList.add(driverListVo); driverListVoList.add(driverListVo);
}); });
} }
if (StringUtils.isEmpty(info)) { if (StringUtils.isEmpty(info)) {
return response.failure("数据不存在"); return response.failure("数据不存在");
} }
// 图片路径处理
if (!StringUtils.isEmpty(driver.getImgUrl())) {
String imgPath = driver.getImgUrl().replace(uploadUrl, "");
driver.setImgPath(imgPath);
}
boolean result = editData(driver); boolean result = editData(driver);
if (!result) { if (!result) {
return response.failure("编辑失败"); return response.failure("编辑失败");
if (!StringUtils.isEmpty(info)) { if (!StringUtils.isEmpty(info)) {
return response.failure("河道名称已经存在"); return response.failure("河道名称已经存在");
} }
// 图片路径处理
if (!StringUtils.isEmpty(driver.getImgUrl())) {
String imgPath = driver.getImgUrl().replace(uploadUrl, "");
driver.setImgPath(imgPath);
}
boolean result = this.addData(driver); boolean result = this.addData(driver);
if (!result) { if (!result) {
return response.failure("添加失败"); return response.failure("添加失败");
adminInfo = iSysAdminService.findById(info.getCreateUser()); adminInfo = iSysAdminService.findById(info.getCreateUser());
} }
map.put("format_create_user", StringUtils.isEmpty(adminInfo) ? "" : adminInfo.getRealname()); map.put("format_create_user", StringUtils.isEmpty(adminInfo) ? "" : adminInfo.getRealname());
// 图片附件处理
if (!StringUtils.isEmpty(info.getImgPath())) {
if (info.getImgPath().contains("http")) {
map.put("imgUrl", info.getImgPath());
} else {
map.put("imgUrl", uploadUrl + info.getImgPath());
}
}
return map; return map;
} }



+ 4
- 0
src/main/java/com/taauav/admin/vo/TauvDriverListVo.java View File

* 河湖附件格式化地址 * 河湖附件格式化地址
*/ */
private String fileUrl; private String fileUrl;

private String imgName;

private String imgUrl;
} }

Loading…
Cancel
Save