修复oss模式,删除文件获取不到文件大小
This commit is contained in:
parent
cfc3945863
commit
c1385b5074
@ -1,27 +0,0 @@
|
||||
package com.qiwenshare.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TableQueryBean {
|
||||
//key, pageIndex, pageSize, sortField, sortOrder
|
||||
|
||||
private int page;
|
||||
private int limit;
|
||||
private int beginCount;
|
||||
|
||||
/**
|
||||
* 搜索关键词
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
private String field;
|
||||
/**
|
||||
* 排序规则
|
||||
*/
|
||||
private String order;
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.qiwenshare.common.operation;
|
||||
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class EncryptOperation {
|
||||
|
||||
public static String encodeByMd5(String string) throws UnsupportedEncodingException {
|
||||
return DigestUtils.md5DigestAsHex(string.getBytes("utf-8"));
|
||||
}
|
||||
|
||||
}
|
@ -345,15 +345,6 @@ public class FileOperation {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// unrar(new File("C:\\Users\\MACHAOP\\Desktop\\Oracle资料.rar"), "C:\\Users\\MACHAOP\\Desktop\\123");
|
||||
unzip(new File("C:\\Users\\MACHAOP\\Desktop\\123.zip"), "C:\\Users\\MACHAOP\\Desktop\\123");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static long deleteFileFromDisk(String fileurl) {
|
||||
String fileUrl = PathUtil.getStaticPath() + fileurl;
|
||||
String extendName = FileUtil.getFileType(fileUrl);
|
||||
|
@ -52,89 +52,4 @@ public class AliyunOSSDelete {
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
//
|
||||
//
|
||||
// // 生成OSSClient,您可以指定一些参数,详见“SDK手册 > Java-SDK > 初始化”,
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/init.html?spm=5176.docoss/sdk/java-sdk/get-start
|
||||
// OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// // 判断Bucket是否存在。详细请参看“SDK手册 > Java-SDK > 管理Bucket”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/manage_bucket.html?spm=5176.docoss/sdk/java-sdk/init
|
||||
// if (ossClient.doesBucketExist(bucketName)) {
|
||||
// System.out.println("您已经创建Bucket:" + bucketName + "。");
|
||||
// } else {
|
||||
// System.out.println("您的Bucket不存在,创建Bucket:" + bucketName + "。");
|
||||
// // 创建Bucket。详细请参看“SDK手册 > Java-SDK > 管理Bucket”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/manage_bucket.html?spm=5176.docoss/sdk/java-sdk/init
|
||||
// ossClient.createBucket(bucketName);
|
||||
// }
|
||||
//
|
||||
// // 查看Bucket信息。详细请参看“SDK手册 > Java-SDK > 管理Bucket”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/manage_bucket.html?spm=5176.docoss/sdk/java-sdk/init
|
||||
// BucketInfo info = ossClient.getBucketInfo(bucketName);
|
||||
// System.out.println("Bucket " + bucketName + "的信息如下:");
|
||||
// System.out.println("\t数据中心:" + info.getBucket().getLocation());
|
||||
// System.out.println("\t创建时间:" + info.getBucket().getCreationDate());
|
||||
// System.out.println("\t用户标志:" + info.getBucket().getOwner());
|
||||
//
|
||||
// // 把字符串存入OSS,Object的名称为firstKey。详细请参看“SDK手册 > Java-SDK > 上传文件”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/upload_object.html?spm=5176.docoss/user_guide/upload_object
|
||||
// InputStream is = new ByteArrayInputStream("Hello OSS".getBytes());
|
||||
// ossClient.putObject(bucketName, firstKey, is);
|
||||
// System.out.println("Object:" + firstKey + "存入OSS成功。");
|
||||
//
|
||||
// // 下载文件。详细请参看“SDK手册 > Java-SDK > 下载文件”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/download_object.html?spm=5176.docoss/sdk/java-sdk/manage_object
|
||||
// OSSObject ossObject = ossClient.getObject(bucketName, firstKey);
|
||||
// InputStream inputStream = ossObject.getObjectContent();
|
||||
// StringBuilder objectContent = new StringBuilder();
|
||||
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
// while (true) {
|
||||
// String line = reader.readLine();
|
||||
// if (line == null)
|
||||
// break;
|
||||
// objectContent.append(line);
|
||||
// }
|
||||
// inputStream.close();
|
||||
// System.out.println("Object:" + firstKey + "的内容是:" + objectContent);
|
||||
//
|
||||
// // 文件存储入OSS,Object的名称为fileKey。详细请参看“SDK手册 > Java-SDK > 上传文件”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/upload_object.html?spm=5176.docoss/user_guide/upload_object
|
||||
// String fileKey = "README.md";
|
||||
// ossClient.putObject(bucketName, fileKey, new File("README.md"));
|
||||
// System.out.println("Object:" + fileKey + "存入OSS成功。");
|
||||
//
|
||||
// // 查看Bucket中的Object。详细请参看“SDK手册 > Java-SDK > 管理文件”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/manage_object.html?spm=5176.docoss/sdk/java-sdk/manage_bucket
|
||||
// ObjectListing objectListing = ossClient.listObjects(bucketName);
|
||||
// List<OSSObjectSummary> objectSummary = objectListing.getObjectSummaries();
|
||||
// System.out.println("您有以下Object:");
|
||||
// for (OSSObjectSummary object : objectSummary) {
|
||||
// System.out.println("\t" + object.getKey());
|
||||
// }
|
||||
//
|
||||
// // 删除Object。详细请参看“SDK手册 > Java-SDK > 管理文件”。
|
||||
// // 链接地址是:https://help.aliyun.com/document_detail/oss/sdk/java-sdk/manage_object.html?spm=5176.docoss/sdk/java-sdk/manage_bucket
|
||||
// ossClient.deleteObject(bucketName, firstKey);
|
||||
// System.out.println("删除Object:" + firstKey + "成功。");
|
||||
// ossClient.deleteObject(bucketName, fileKey);
|
||||
// System.out.println("删除Object:" + fileKey + "成功。");
|
||||
//
|
||||
// } catch (OSSException oe) {
|
||||
// oe.printStackTrace();
|
||||
// } catch (ClientException ce) {
|
||||
// ce.printStackTrace();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// ossClient.shutdown();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
|
||||
<configuration>
|
||||
<properties>
|
||||
<property name="driver" value="com.mysql.jdbc.Driver"/>
|
||||
<property name="url" value="jdbc:mysql://localhost:3306/scp?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8"/>
|
||||
<property name="username" value="root"/>
|
||||
<property name="password" value="ma123456"/>
|
||||
</properties>
|
||||
<environments default="dev">
|
||||
<environment id="dev">
|
||||
<transactionManager type="JDBC"></transactionManager>
|
||||
<dataSource type="POOLED">
|
||||
<property name="driver" value="${driver}"/>
|
||||
<property name="url" value="${url}"/>
|
||||
<property name="username" value="${username}"/>
|
||||
<property name="password" value="${password}"/>
|
||||
</dataSource>
|
||||
</environment>
|
||||
<environment id="product">
|
||||
<transactionManager type="JDBC"></transactionManager>
|
||||
<dataSource type="JNDI">
|
||||
<property name="initial_context" value="java:comp/env"/>
|
||||
<property name="date_source" value="jdbc/mac"/>
|
||||
</dataSource>
|
||||
</environment>
|
||||
</environments>
|
||||
<mappers>
|
||||
<mapper resource="mybatis/mapper/ChatMapper.xml"/>
|
||||
</mappers>
|
||||
</configuration>
|
@ -2,8 +2,6 @@ package com.qiwenshare.file.api;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qiwenshare.common.cbb.RestResult;
|
||||
import com.qiwenshare.common.domain.TableQueryBean;
|
||||
import com.qiwenshare.file.domain.FileBean;
|
||||
import com.qiwenshare.file.domain.UserBean;
|
||||
|
||||
import java.util.List;
|
||||
@ -104,10 +102,5 @@ public interface IUserService extends IService<UserBean> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户数量
|
||||
* @param tableQueryBean 查询条件
|
||||
* @return 用户数量
|
||||
*/
|
||||
int selectUserCountByCondition(TableQueryBean tableQueryBean);
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.qiwenshare.file.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qiwenshare.common.domain.TableQueryBean;
|
||||
|
||||
import com.qiwenshare.file.domain.UserBean;
|
||||
|
||||
@ -57,9 +56,6 @@ public interface UserMapper extends BaseMapper<UserBean> {
|
||||
|
||||
List<UserBean> selectAllUserList();
|
||||
|
||||
List<UserBean> selectUserListByCondition(TableQueryBean tableQueryBean);
|
||||
|
||||
|
||||
int selectUserCountByCondition(TableQueryBean tableQueryBean);
|
||||
|
||||
}
|
||||
|
@ -131,6 +131,9 @@ public class FileService extends ServiceImpl<FileMapper, FileBean> implements IF
|
||||
}else{
|
||||
fileMapper.deleteFileById(fileBean);
|
||||
deleteSize = FileOperation.getFileSize(fileUrl);
|
||||
if (deleteSize == 0) {
|
||||
deleteSize = fileBean.getFileSize();
|
||||
}
|
||||
//删除服务器文件
|
||||
if (fileBean.getFileUrl() != null && fileBean.getFileUrl().indexOf("upload") != -1){
|
||||
if (fileBean.getIsOSS() == 1) {
|
||||
|
@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qiwenshare.common.cbb.DateUtil;
|
||||
import com.qiwenshare.common.cbb.RestResult;
|
||||
import com.qiwenshare.common.domain.TableQueryBean;
|
||||
import com.qiwenshare.common.util.JjwtUtil;
|
||||
import com.qiwenshare.common.util.PasswordUtil;
|
||||
import com.qiwenshare.file.api.IUserService;
|
||||
@ -306,10 +305,6 @@ public class UserService extends ServiceImpl<UserMapper, UserBean> implements IU
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int selectUserCountByCondition(TableQueryBean tableQueryBean) {
|
||||
return userMapper.selectUserCountByCondition(tableQueryBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserInfo(UserBean userBean) {
|
||||
|
@ -79,26 +79,6 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectUserListByCondition" resultMap="userBeanResultMapId"
|
||||
parameterType="com.qiwenshare.common.domain.TableQueryBean">
|
||||
SELECT * FROM user
|
||||
<if test="key != null">
|
||||
where username LIKE '%${key}%'
|
||||
</if>
|
||||
<if test="field != null and order != null">
|
||||
order by ${field} ${order}
|
||||
</if>
|
||||
limit #{beginCount}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectUserCountByCondition" resultType="int" parameterType="com.qiwenshare.common.domain.TableQueryBean">
|
||||
SELECT count(*) FROM user
|
||||
<if test="key != null">
|
||||
where username LIKE '%${key}%'
|
||||
</if>
|
||||
limit #{beginCount}, #{limit}
|
||||
</select>
|
||||
|
||||
<delete id="deleteUserInfo" parameterType="com.qiwenshare.file.domain.UserBean">
|
||||
delete from user where userId = #{userId}
|
||||
</delete>
|
||||
@ -145,16 +125,4 @@
|
||||
|
||||
|
||||
|
||||
<select id="selectPermissionListByCondition" resultType="com.qiwenshare.file.domain.Permission"
|
||||
parameterType="com.qiwenshare.common.domain.TableQueryBean">
|
||||
SELECT * FROM permission
|
||||
<if test="key != null">
|
||||
where permission LIKE '%${key}%'
|
||||
</if>
|
||||
<if test="field != null and order != null">
|
||||
order by ${field} ${order}
|
||||
</if>
|
||||
limit #{beginCount}, #{limit}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user