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

@@ -79,7 +79,7 @@ public class UploadController {
private Map<String, String> getUploadFile(MultipartFile file) {
Map<String, String> dt = new HashMap<String, String>();
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 uploadPath = mkfilePath();
String fileUrl = uploadPath + newFileName;

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

@@ -1,13 +1,10 @@
package com.taauav.admin.entity;

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

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.taauav.common.domain.Entity;
import lombok.Data;
@@ -85,6 +82,16 @@ public class TauvDriver extends Entity {
*/
private BigInteger driverArea;

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

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

/**
* 附件名称
*/
@@ -165,4 +172,10 @@ public class TauvDriver extends Entity {
*/
@TableField(exist = false)
private String fileUrl;

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

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

@@ -88,6 +88,7 @@ public interface ITauvDriverService extends IBaseService<TauvDriver> {
/**
* 获取所有河道数据
*
* @param map
* @return
*/
Response getDriverList(Map<String, Object> map);
@@ -112,6 +113,7 @@ public interface ITauvDriverService extends IBaseService<TauvDriver> {
* 导入河道Json数据
*
* @return
* @throws IOException
*/
Response importData() throws IOException;
}

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

@@ -74,6 +74,8 @@ public class TauvDriverServiceImpl extends BaseServiceImpl<TauvDriverMapper, Tau
private RedisUtils redisUtils;
@Value("${file.uploadFolder}")
private String uploadFolder;
@Value("${server.UPLOAD_URL}")
private String uploadUrl;

/**
* 获取河道列表
@@ -125,6 +127,14 @@ public class TauvDriverServiceImpl extends BaseServiceImpl<TauvDriverMapper, Tau
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);
});
}
@@ -154,6 +164,11 @@ public class TauvDriverServiceImpl extends BaseServiceImpl<TauvDriverMapper, Tau
if (StringUtils.isEmpty(info)) {
return response.failure("数据不存在");
}
// 图片路径处理
if (!StringUtils.isEmpty(driver.getImgUrl())) {
String imgPath = driver.getImgUrl().replace(uploadUrl, "");
driver.setImgPath(imgPath);
}
boolean result = editData(driver);
if (!result) {
return response.failure("编辑失败");
@@ -174,6 +189,11 @@ public class TauvDriverServiceImpl extends BaseServiceImpl<TauvDriverMapper, Tau
if (!StringUtils.isEmpty(info)) {
return response.failure("河道名称已经存在");
}
// 图片路径处理
if (!StringUtils.isEmpty(driver.getImgUrl())) {
String imgPath = driver.getImgUrl().replace(uploadUrl, "");
driver.setImgPath(imgPath);
}
boolean result = this.addData(driver);
if (!result) {
return response.failure("添加失败");
@@ -252,6 +272,14 @@ public class TauvDriverServiceImpl extends BaseServiceImpl<TauvDriverMapper, Tau
adminInfo = iSysAdminService.findById(info.getCreateUser());
}
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;
}


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

@@ -102,4 +102,8 @@ public class TauvDriverListVo {
* 河湖附件格式化地址
*/
private String fileUrl;

private String imgName;

private String imgUrl;
}

Loading…
Cancel
Save