店员管理/店员等级/账户管理

This commit is contained in:
starrySky
2024-03-31 13:52:29 +08:00
parent ccaa00990f
commit c7f81acbe5
125 changed files with 2670 additions and 1033 deletions

View File

@@ -12,17 +12,14 @@ import org.springframework.context.annotation.PropertySource;
@PropertySource(value = {"classpath:oss.properties"})
public class OssProperties implements InitializingBean {
public String endpoint;
public String accessKeyId;
public String accessKeySecret;
public String bucketName;
public static String ENDPOINT = "";
public static String KEY_ID = "";
public static String KEY_SECRET = "";
public static String BUCKET_NAME = "";
public String endpoint;
public String accessKeyId;
public String accessKeySecret;
public String bucketName;
@Override
public void afterPropertiesSet() throws Exception {

View File

@@ -30,29 +30,29 @@ public class OssFileServiceImpl implements IOssFileService {
OSS ossClient = new OSSClientBuilder().build(OssProperties.ENDPOINT, OssProperties.KEY_ID, OssProperties.KEY_SECRET);
log.info("OSSClient实例创建成功");
try {
//判断oss实例是否存在如果不存在则创建如果存在则获取
// 判断oss实例是否存在如果不存在则创建如果存在则获取
if (!ossClient.doesBucketExist(OssProperties.BUCKET_NAME)) {
//创建bucket
// 创建bucket
ossClient.createBucket(OssProperties.BUCKET_NAME);
log.info("bucket存储空间【{}】创建成功", OssProperties.BUCKET_NAME);
//设置oss实例的访问权限公共读
// 设置oss实例的访问权限公共读
ossClient.setBucketAcl(OssProperties.BUCKET_NAME, CannedAccessControlList.PublicRead);
log.info("【{}】存储空间访问权限设置为公共读成功", OssProperties.BUCKET_NAME);
}
//构建日期路径avatar/2019/02/26/文件名
// 构建日期路径avatar/2019/02/26/文件名
String folder = new DateTime().toString("yyyy/MM/dd");
//文件名uuid.扩展名
// 文件名uuid.扩展名
filename = IdUtil.fastSimpleUUID() + FileTypeUtil.getType(inputStream);
//文件根路径
// 文件根路径
String key = module + "/" + folder + "/" + filename;
// 创建PutObjectRequest对象。
PutObjectRequest putObjectRequest = new PutObjectRequest(OssProperties.BUCKET_NAME, key, inputStream);
// 创建PutObject请求。
ossClient.putObject(putObjectRequest);
log.info("oss文件上传成功");
//阿里云文件绝对路径
// 阿里云文件绝对路径
String endpoint = OssProperties.ENDPOINT.substring(OssProperties.ENDPOINT.lastIndexOf("//") + 2);
//返回文件的访问路径
// 返回文件的访问路径
return "https://" + OssProperties.BUCKET_NAME + "." + endpoint + "/" + key;
} catch (OSSException oe) {
log.error("OSSException 文件上传失败:", oe);
@@ -74,7 +74,7 @@ public class OssFileServiceImpl implements IOssFileService {
log.info("OSSClient实例创建成功");
try {
String endpoint = OssProperties.ENDPOINT.substring(OssProperties.ENDPOINT.lastIndexOf("//") + 2);
//文件名(服务器上的文件路径)
// 文件名(服务器上的文件路径)
String host = "https://" + OssProperties.BUCKET_NAME + "." + endpoint + "/";
String objectName = url.substring(host.length());
// 删除文件或目录。如果要删除目录,目录必须为空。