健康报告删除

This commit is contained in:
limqhz
2021-03-08 17:30:58 +08:00
parent 8cad890c1b
commit 4247ae6e12
8 changed files with 146 additions and 37 deletions

View File

@@ -2,6 +2,7 @@ package com.sv.service.common;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.CannedAccessControlList;
import com.sv.service.utils.UUIDGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -50,9 +51,11 @@ public class OSSClientUtil {
private String accessKeySecret;
//文件存储目录
@Value("${sv.file.store.image}")
private String imageDir = "image/";
private String imageDir;
@Value("${sv.file.store.video}")
private String videoDir = "video/";
private String videoDir;
@Value("${sv.file.store.health}")
private String healthDir;
@Value("${oss.url}")
private String url;
@@ -103,6 +106,47 @@ public class OSSClientUtil {
return backUrl;
}
/**
* 上传健康报告文档
* @param multipartFile
* @return
* @throws IOException
*/
public String uploadHealth(MultipartFile multipartFile) throws IOException {
String originalFilename = multipartFile.getOriginalFilename();
String backUrl = "";
try {
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
String substring = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase();
String name = UUIDGenerator.randomUUID() + substring;
backUrl = healthDir + name;
// 上传文件
ossClient.putObject(bucketName, backUrl, multipartFile.getInputStream());
ossClient.setObjectAcl(bucketName, backUrl, CannedAccessControlList.PublicRead);
// 判断是否上传成功
boolean uploadResult = ossClient.doesObjectExist(bucketName, backUrl);
if (uploadResult) {
backUrl = getUploadUrl(name);
} else {
backUrl = "";
}
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
return backUrl;
}
private String getUploadUrl(String fileUrl) {
if (!StringUtils.isEmpty(fileUrl)) {
String[] split = fileUrl.split("/");
return url + this.healthDir + split[split.length - 1];
}
return null;
}
/**
* 上传视频
*
@@ -240,4 +284,5 @@ public class OSSClientUtil {
public void setUrl(String url) {
this.url = url;
}
}

View File

@@ -0,0 +1,28 @@
package com.sv.service.utils;
import java.util.StringTokenizer;
import java.util.UUID;
/**
* @title UUIDGenerator
* @description 随机生成32位UUID格式如a11686c39a154cf2a5238fb14cf3d097
* <br>
* <br>
*/
public class UUIDGenerator {
/**
* 主键生成机制
* @return
*/
public static String randomUUID(){
String result="";
UUID uuid = UUID.randomUUID();
String temp=uuid.toString();
StringTokenizer token=new StringTokenizer(temp,"-");
while(token.hasMoreTokens()){
result+=token.nextToken();
}
return result;
}
}

View File

@@ -7,8 +7,9 @@
<arg column="member_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="doc_name" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="doc_type" jdbcType="CHAR" javaType="java.lang.String" />
<arg column="file_type" jdbcType="CHAR" javaType="java.lang.String" />
<arg column="file_type" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="doc_path" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="doc_date" jdbcType="DATE" javaType="java.util.Date" />
<arg column="platform_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
<arg column="created_time" jdbcType="TIMESTAMP" javaType="java.util.Date" />
<arg column="modified_time" jdbcType="TIMESTAMP" javaType="java.util.Date" />
@@ -16,7 +17,7 @@
</constructor>
</resultMap>
<sql id="Base_Column_List" >
id, member_id, doc_name, doc_type, file_type, doc_path, platform_id, created_time,
id, member_id, doc_name, doc_type, file_type, doc_path, doc_date, platform_id, created_time,
modified_time, deleted
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
@@ -40,12 +41,12 @@
<insert id="insert" parameterType="com.sv.entity.HealthDoc" >
insert into sv_health_docs (id, member_id, doc_name,
doc_type, file_type, doc_path,
platform_id, created_time, modified_time,
deleted)
doc_date, platform_id, created_time,
modified_time, deleted)
values (#{id,jdbcType=INTEGER}, #{memberId,jdbcType=INTEGER}, #{docName,jdbcType=VARCHAR},
#{docType,jdbcType=CHAR}, #{fileType,jdbcType=CHAR}, #{docPath,jdbcType=VARCHAR},
#{platformId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{modifiedTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=TINYINT})
#{docType,jdbcType=CHAR}, #{fileType,jdbcType=VARCHAR}, #{docPath,jdbcType=VARCHAR},
#{docDate,jdbcType=DATE}, #{platformId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP},
#{modifiedTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.sv.entity.HealthDoc" >
insert into sv_health_docs
@@ -68,6 +69,9 @@
<if test="docPath != null" >
doc_path,
</if>
<if test="docDate != null" >
doc_date,
</if>
<if test="platformId != null" >
platform_id,
</if>
@@ -95,11 +99,14 @@
#{docType,jdbcType=CHAR},
</if>
<if test="fileType != null" >
#{fileType,jdbcType=CHAR},
#{fileType,jdbcType=VARCHAR},
</if>
<if test="docPath != null" >
#{docPath,jdbcType=VARCHAR},
</if>
<if test="docDate != null" >
#{docDate,jdbcType=DATE},
</if>
<if test="platformId != null" >
#{platformId,jdbcType=INTEGER},
</if>
@@ -127,11 +134,14 @@
doc_type = #{docType,jdbcType=CHAR},
</if>
<if test="fileType != null" >
file_type = #{fileType,jdbcType=CHAR},
file_type = #{fileType,jdbcType=VARCHAR},
</if>
<if test="docPath != null" >
doc_path = #{docPath,jdbcType=VARCHAR},
</if>
<if test="docDate != null" >
doc_date = #{docDate,jdbcType=DATE},
</if>
<if test="platformId != null" >
platform_id = #{platformId,jdbcType=INTEGER},
</if>
@@ -152,8 +162,9 @@
set member_id = #{memberId,jdbcType=INTEGER},
doc_name = #{docName,jdbcType=VARCHAR},
doc_type = #{docType,jdbcType=CHAR},
file_type = #{fileType,jdbcType=CHAR},
file_type = #{fileType,jdbcType=VARCHAR},
doc_path = #{docPath,jdbcType=VARCHAR},
doc_date = #{docDate,jdbcType=DATE},
platform_id = #{platformId,jdbcType=INTEGER},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},