parent
659df35446
commit
3858e21e39
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>3.3.0</version>
|
||||||
|
|
||||||
<name>管理系统</name>
|
<name>管理系统</name>
|
||||||
<description>微服务系统</description>
|
<description>微服务系统</description>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.constant.TokenConstants;
|
import com.ruoyi.common.core.constant.TokenConstants;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
@ -8,10 +7,12 @@ import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jwt工具类
|
* Jwt工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author xiejs
|
||||||
*/
|
*/
|
||||||
public class JwtUtils
|
public class JwtUtils
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.ruoyi.file.controller;
|
||||||
|
|
||||||
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
||||||
|
import com.aliyun.oss.model.MatchMode;
|
||||||
|
import com.aliyun.oss.model.PolicyConditions;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.file.utils.OssClient;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.ruoyi.file.utils.OssClient.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oss服务控制器
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-15
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("oss")
|
||||||
|
@Api(tags = "OSS管理")
|
||||||
|
@Log4j2
|
||||||
|
public class OssController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
OssClient ossClient;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/policy")
|
||||||
|
public R policy() {
|
||||||
|
String host = HTTPS + bucketName + DOT + endpoint;
|
||||||
|
String dir = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
|
|
||||||
|
Map<String, String> respMap = null;
|
||||||
|
try {
|
||||||
|
//10分钟过期
|
||||||
|
long expireTime = 600;
|
||||||
|
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
||||||
|
Date expiration = new Date(expireEndTime);
|
||||||
|
PolicyConditions policyConds = new PolicyConditions();
|
||||||
|
policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
|
||||||
|
policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
|
||||||
|
|
||||||
|
String postPolicy = ossClient.getOssClient().generatePostPolicy(expiration, policyConds);
|
||||||
|
byte[] binaryData = postPolicy.getBytes(StandardCharsets.UTF_8);
|
||||||
|
String encodedPolicy = BinaryUtil.toBase64String(binaryData);
|
||||||
|
String postSignature = ossClient.getOssClient().calculatePostSignature(postPolicy);
|
||||||
|
|
||||||
|
respMap = new LinkedHashMap<>();
|
||||||
|
respMap.put("accessid", keyId);
|
||||||
|
respMap.put("policy", encodedPolicy);
|
||||||
|
respMap.put("signature", postSignature);
|
||||||
|
respMap.put("dir", dir);
|
||||||
|
respMap.put("host", host);
|
||||||
|
respMap.put("expire", String.valueOf(expireEndTime / 1000));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.ok(respMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,9 @@ package com.ruoyi.file.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
|
||||||
import com.ruoyi.common.core.text.UUID;
|
import com.ruoyi.common.core.text.UUID;
|
||||||
import com.ruoyi.file.config.AliyunOssProperties;
|
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
|
import com.ruoyi.file.utils.OssClient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -16,6 +15,8 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static com.ruoyi.file.utils.OssClient.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云oss文件上传实现
|
* 阿里云oss文件上传实现
|
||||||
*
|
*
|
||||||
|
|
@ -26,22 +27,17 @@ import java.util.Date;
|
||||||
@Primary
|
@Primary
|
||||||
public class AliyunOssFileServiceImpl implements ISysFileService {
|
public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
|
|
||||||
public static final String HTTPS = "https://";
|
|
||||||
|
|
||||||
public static final String DOT = ".";
|
|
||||||
|
|
||||||
public static final String SLASH = "/";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AliyunOssProperties aliyunOssProperties;
|
private OssClient ossClient;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(MultipartFile file) throws Exception {
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
Assert.notNull(file, "file is null");
|
Assert.notNull(file, "file is null");
|
||||||
try {
|
try {
|
||||||
String endpoint = aliyunOssProperties.getEndpoint();
|
String endpoint = OssClient.endpoint;
|
||||||
String bucketName = aliyunOssProperties.getBucketName();
|
String bucketName = OssClient.bucketName;
|
||||||
OSS ossClient = this.getOssClient();
|
OSS oss = ossClient.getOssClient();
|
||||||
//获取流
|
//获取流
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
//获取文件后缀
|
//获取文件后缀
|
||||||
|
|
@ -49,9 +45,9 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
//获取文件名称
|
//获取文件名称
|
||||||
String fileName = this.getDataTime() + DOT + extension;
|
String fileName = this.getDataTime() + DOT + extension;
|
||||||
//执行文件上传 bucket名称 文件名称 文件流
|
//执行文件上传 bucket名称 文件名称 文件流
|
||||||
ossClient.putObject(bucketName, fileName, is);
|
oss.putObject(bucketName, fileName, is);
|
||||||
//关闭ossClient
|
//关闭ossClient
|
||||||
ossClient.shutdown();
|
oss.shutdown();
|
||||||
//拼接文件地址
|
//拼接文件地址
|
||||||
return HTTPS + bucketName + DOT + endpoint + SLASH + fileName;
|
return HTTPS + bucketName + DOT + endpoint + SLASH + fileName;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -62,8 +58,8 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFile(String url) {
|
public void removeFile(String url) {
|
||||||
String endpoint = aliyunOssProperties.getEndpoint();
|
String endpoint = OssClient.endpoint;
|
||||||
String bucketName = aliyunOssProperties.getBucketName();
|
String bucketName = OssClient.bucketName;
|
||||||
String host = HTTPS + bucketName + DOT + endpoint + SLASH;
|
String host = HTTPS + bucketName + DOT + endpoint + SLASH;
|
||||||
|
|
||||||
//如果路径中不包含host
|
//如果路径中不包含host
|
||||||
|
|
@ -73,14 +69,13 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
|
|
||||||
String objectName = url.substring(host.length());
|
String objectName = url.substring(host.length());
|
||||||
|
|
||||||
|
OSS oss = ossClient.getOssClient();
|
||||||
OSS ossClient = this.getOssClient();
|
|
||||||
|
|
||||||
//执行删除
|
//执行删除
|
||||||
ossClient.deleteObject(bucketName, objectName);
|
oss.deleteObject(bucketName, objectName);
|
||||||
|
|
||||||
//关闭ossClient
|
//关闭ossClient
|
||||||
ossClient.shutdown();
|
oss.shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,16 +89,4 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
return today + SLASH + UUID.randomUUID();
|
return today + SLASH + UUID.randomUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取oss实例
|
|
||||||
*
|
|
||||||
* @return OSS
|
|
||||||
*/
|
|
||||||
private OSS getOssClient() {
|
|
||||||
String endpoint = aliyunOssProperties.getEndpoint();
|
|
||||||
String keyId = aliyunOssProperties.getKeyId();
|
|
||||||
String keySecret = aliyunOssProperties.getKeySecret();
|
|
||||||
return new OSSClientBuilder().build(endpoint,
|
|
||||||
keyId, keySecret);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.ruoyi.file.utils;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.ruoyi.file.config.AliyunOssProperties;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ossClient
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-15
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class OssClient implements BeanPostProcessor {
|
||||||
|
|
||||||
|
public static final String HTTPS = "https://";
|
||||||
|
|
||||||
|
public static final String DOT = ".";
|
||||||
|
|
||||||
|
public static final String SLASH = "/";
|
||||||
|
|
||||||
|
public static String endpoint;
|
||||||
|
public static String keyId;
|
||||||
|
public static String keySecret;
|
||||||
|
public static String bucketName;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AliyunOssProperties aliyunOssProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
|
OssClient.endpoint = aliyunOssProperties.getEndpoint();
|
||||||
|
OssClient.keyId = aliyunOssProperties.getKeyId();
|
||||||
|
OssClient.keySecret = aliyunOssProperties.getKeySecret();
|
||||||
|
OssClient.bucketName = aliyunOssProperties.getBucketName();
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取oss实例
|
||||||
|
*
|
||||||
|
* @return OSS
|
||||||
|
*/
|
||||||
|
public OSS getOssClient() {
|
||||||
|
String endpoint = aliyunOssProperties.getEndpoint();
|
||||||
|
String keyId = aliyunOssProperties.getKeyId();
|
||||||
|
String keySecret = aliyunOssProperties.getKeySecret();
|
||||||
|
return new OSSClientBuilder().build(endpoint,
|
||||||
|
keyId, keySecret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
//上传图片
|
//上传图片
|
||||||
export function uploadImg(data){
|
export function uploadImg(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/file/upload',
|
url: '/file/upload',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|
@ -12,10 +12,18 @@ export function uploadImg(data){
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除图片
|
//删除图片
|
||||||
export function removeImg(url){
|
export function removeImg(url) {
|
||||||
return request({
|
return request({
|
||||||
url: '/file/remove',
|
url: '/file/remove',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
params: url
|
params: url
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取oss上传秘钥
|
||||||
|
export function policy() {
|
||||||
|
return request({
|
||||||
|
url: '/file/oss/policy',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-upload
|
||||||
|
action="http://xjs-cloud.oss-cn-hangzhou.aliyuncs.com"
|
||||||
|
:data="dataObj"
|
||||||
|
list-type="picture-card"
|
||||||
|
:file-list="fileList"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:on-preview="handlePreview"
|
||||||
|
:limit="maxCount"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
>
|
||||||
|
<i class="el-icon-plus"></i>
|
||||||
|
</el-upload>
|
||||||
|
<el-dialog :visible.sync="dialogVisible">
|
||||||
|
<img width="100%" :src="dialogImageUrl" alt />
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { policy } from "./policy";
|
||||||
|
import { getUUID } from '@/utils'
|
||||||
|
export default {
|
||||||
|
name: "multiUpload",
|
||||||
|
props: {
|
||||||
|
//图片属性数组
|
||||||
|
value: Array,
|
||||||
|
//最大上传图片数量
|
||||||
|
maxCount: {
|
||||||
|
type: Number,
|
||||||
|
default: 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataObj: {
|
||||||
|
policy: "",
|
||||||
|
signature: "",
|
||||||
|
key: "",
|
||||||
|
ossaccessKeyId: "",
|
||||||
|
dir: "",
|
||||||
|
host: "",
|
||||||
|
uuid: ""
|
||||||
|
},
|
||||||
|
dialogVisible: false,
|
||||||
|
dialogImageUrl: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
fileList() {
|
||||||
|
let fileList = [];
|
||||||
|
for (let i = 0; i < this.value.length; i++) {
|
||||||
|
fileList.push({ url: this.value[i] });
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
methods: {
|
||||||
|
emitInput(fileList) {
|
||||||
|
let value = [];
|
||||||
|
for (let i = 0; i < fileList.length; i++) {
|
||||||
|
value.push(fileList[i].url);
|
||||||
|
}
|
||||||
|
this.$emit("input", value);
|
||||||
|
},
|
||||||
|
handleRemove(file, fileList) {
|
||||||
|
this.emitInput(fileList);
|
||||||
|
},
|
||||||
|
handlePreview(file) {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.dialogImageUrl = file.url;
|
||||||
|
},
|
||||||
|
beforeUpload(file) {
|
||||||
|
let _self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
policy()
|
||||||
|
.then(response => {
|
||||||
|
console.log("这是什么${filename}");
|
||||||
|
_self.dataObj.policy = response.data.policy;
|
||||||
|
_self.dataObj.signature = response.data.signature;
|
||||||
|
_self.dataObj.ossaccessKeyId = response.data.accessid;
|
||||||
|
_self.dataObj.key = response.data.dir + "/"+getUUID()+"_${filename}";
|
||||||
|
_self.dataObj.dir = response.data.dir;
|
||||||
|
_self.dataObj.host = response.data.host;
|
||||||
|
resolve(true);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log("出错了...",err)
|
||||||
|
reject(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleUploadSuccess(res, file) {
|
||||||
|
this.fileList.push({
|
||||||
|
name: file.name,
|
||||||
|
// url: this.dataObj.host + "/" + this.dataObj.dir + "/" + file.name; 替换${filename}为真正的文件名
|
||||||
|
url: this.dataObj.host + "/" + this.dataObj.key.replace("${filename}",file.name)
|
||||||
|
});
|
||||||
|
this.emitInput(this.fileList);
|
||||||
|
},
|
||||||
|
handleExceed(files, fileList) {
|
||||||
|
this.$message({
|
||||||
|
message: "最多只能上传" + this.maxCount + "张图片",
|
||||||
|
type: "warning",
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-upload class="el-upload-list__item"
|
||||||
|
action="https://xjs-cloud.oss-cn-hangzhou.aliyuncs.com"
|
||||||
|
:data="dataObj"
|
||||||
|
:multiple="false"
|
||||||
|
:show-file-list="showFileList"
|
||||||
|
accept="image/*"
|
||||||
|
:file-list="fileList"
|
||||||
|
:limit=2
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:before-upload="picture_rulBeforeUpload"
|
||||||
|
:before-remove="removeImg"
|
||||||
|
list-type="picture-card"
|
||||||
|
:on-preview="handlePreview">
|
||||||
|
<el-button size="small" type="text">+</el-button>
|
||||||
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过10MB</div>
|
||||||
|
</el-upload>
|
||||||
|
<el-dialog :visible.sync="dialogVisible">
|
||||||
|
<img width="100%" :src="fileList[0].url" alt="">
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {policy, removeImg, uploadImg} from "@/api/common";
|
||||||
|
import {getUUID} from '@/utils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'SingleUpload',
|
||||||
|
props: {
|
||||||
|
value: String
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
imageUrl() {
|
||||||
|
return this.value;
|
||||||
|
},
|
||||||
|
imageName() {
|
||||||
|
if (this.value != null && this.value !== '') {
|
||||||
|
return this.value.substr(this.value.lastIndexOf("/") + 1);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fileList() {
|
||||||
|
return [{
|
||||||
|
name: this.imageName,
|
||||||
|
url: this.imageUrl
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
showFileList: {
|
||||||
|
get: function () {
|
||||||
|
return this.value !== null && this.value !== '' && this.value !== undefined;
|
||||||
|
},
|
||||||
|
set: function (newValue) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataObj: {
|
||||||
|
policy: '',
|
||||||
|
signature: '',
|
||||||
|
key: '',
|
||||||
|
ossaccessKeyId: '',
|
||||||
|
dir: '',
|
||||||
|
host: '',
|
||||||
|
},
|
||||||
|
dialogVisible: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.init()
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
emitInput(val) {
|
||||||
|
this.$emit('input', val)
|
||||||
|
},
|
||||||
|
handleRemove(file, fileList) {
|
||||||
|
this.emitInput('');
|
||||||
|
},
|
||||||
|
handlePreview(file) {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
init() {
|
||||||
|
policy().then(response => {
|
||||||
|
this.dataObj.policy = response.data.policy;
|
||||||
|
this.dataObj.signature = response.data.signature;
|
||||||
|
this.dataObj.ossaccessKeyId = response.data.accessid;
|
||||||
|
this.dataObj.key = response.data.dir + '/' + getUUID() + '_${filename}'
|
||||||
|
this.dataObj.dir = response.data.dir;
|
||||||
|
this.dataObj.host = response.data.host;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
handleUploadSuccess(res, file) {
|
||||||
|
this.showFileList = true;
|
||||||
|
this.fileList.pop();
|
||||||
|
this.fileList.push({
|
||||||
|
name: file.name,
|
||||||
|
url: this.dataObj.host + '/' + this.dataObj.key.replace("${filename}", file.name)
|
||||||
|
});
|
||||||
|
this.emitInput(this.fileList[0].url);
|
||||||
|
},
|
||||||
|
|
||||||
|
picture_rulBeforeUpload(file) {
|
||||||
|
let isRightSize = file.size / 1024 / 1024 < 10
|
||||||
|
if (!isRightSize) {
|
||||||
|
this.$message.error('文件大小超过 10MB')
|
||||||
|
}
|
||||||
|
let isAccept = new RegExp('image/*').test(file.type)
|
||||||
|
if (!isAccept) {
|
||||||
|
this.$message.error('应该选择image/*类型的文件')
|
||||||
|
}
|
||||||
|
|
||||||
|
return isRightSize && isAccept;
|
||||||
|
},
|
||||||
|
|
||||||
|
//删除图片
|
||||||
|
removeImg() {
|
||||||
|
if (this.fileList[0].url) {
|
||||||
|
let pictureUrl = {"url": this.fileList[0].url};
|
||||||
|
removeImg(pictureUrl).then(res => {
|
||||||
|
})
|
||||||
|
this.emitInput('');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.el-upload-list__item {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -388,3 +388,12 @@ export function isNumberStr(str) {
|
||||||
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
|
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取uuid
|
||||||
|
*/
|
||||||
|
export function getUUID () {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
||||||
|
return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog width="550px"
|
||||||
:title="!dataForm.id ? '新增' : '修改'"
|
:title="!dataForm.id ? '新增' : '修改'"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
|
|
@ -9,16 +9,16 @@
|
||||||
:rules="dataRule"
|
:rules="dataRule"
|
||||||
ref="dataForm"
|
ref="dataForm"
|
||||||
@keyup.enter.native="dataFormSubmit()"
|
@keyup.enter.native="dataFormSubmit()"
|
||||||
label-width="140px"
|
label-width="90px"
|
||||||
>
|
>
|
||||||
<el-form-item label="品牌名" prop="name">
|
<el-form-item label="品牌名" prop="name">
|
||||||
<el-input v-model="dataForm.name" placeholder="品牌名"></el-input>
|
<el-input v-model="dataForm.name" placeholder="品牌名" style="width: 380px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="品牌logo地址" prop="logo">
|
<el-form-item label="品牌logo" prop="logo">
|
||||||
<single-upload v-model="dataForm.logo"></single-upload>
|
<single-upload v-model="dataForm.logo"></single-upload>
|
||||||
</el-form-item>-->
|
</el-form-item>
|
||||||
<el-form-item label="介绍" prop="descript">
|
<el-form-item label="介绍" prop="descript">
|
||||||
<el-input v-model="dataForm.descript" placeholder="介绍"></el-input>
|
<el-input type="textarea" :rows="5" v-model="dataForm.descript" placeholder="介绍" style="width: 380px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="显示状态" prop="showStatus">
|
<el-form-item label="显示状态" prop="showStatus">
|
||||||
<el-switch
|
<el-switch
|
||||||
|
|
@ -29,8 +29,8 @@
|
||||||
:inactive-value="0"
|
:inactive-value="0"
|
||||||
></el-switch>
|
></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="检索首字母" prop="firstLetter">
|
<el-form-item label="检索首字母" prop="firstLetter" >
|
||||||
<el-input v-model="dataForm.firstLetter" placeholder="检索首字母"></el-input>
|
<el-input v-model="dataForm.firstLetter" placeholder="检索首字母" style="width: 200px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
<el-input-number v-model.number="dataForm.sort" :min="1" :max="9999" label="描述文字"></el-input-number>
|
<el-input-number v-model.number="dataForm.sort" :min="1" :max="9999" label="描述文字"></el-input-number>
|
||||||
|
|
@ -44,11 +44,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import SingleUpload from "@/components/upload/singleUpload";
|
import SingleUpload from "@/components/OssUpload/singleUpload";
|
||||||
import {addBrand, editBrand, getBrand} from "@/api/mall/product/brand";
|
import {addBrand, editBrand, getBrand} from "@/api/mall/product/brand";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// components: { SingleUpload },
|
components: { SingleUpload },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
@ -62,12 +62,16 @@ export default {
|
||||||
sort: 0
|
sort: 0
|
||||||
},
|
},
|
||||||
dataRule: {
|
dataRule: {
|
||||||
name: [{ required: true, message: "品牌名不能为空", trigger: "blur" }],
|
name: [
|
||||||
/*logo: [
|
{ required: true, message: "品牌名不能为空", trigger: "blur" },
|
||||||
|
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
logo: [
|
||||||
{ required: true, message: "品牌logo地址不能为空", trigger: "blur" }
|
{ required: true, message: "品牌logo地址不能为空", trigger: "blur" }
|
||||||
],*/
|
],
|
||||||
descript: [
|
descript: [
|
||||||
{ required: true, message: "介绍不能为空", trigger: "blur" }
|
{ required: true, message: "介绍不能为空", trigger: "blur" },
|
||||||
|
{ min: 1, max: 500, message: '长度在 1 到 500 个字符', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
showStatus: [
|
showStatus: [
|
||||||
{
|
{
|
||||||
|
|
@ -114,8 +118,10 @@ export default {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs["dataForm"].resetFields();
|
this.$refs["dataForm"].resetFields();
|
||||||
if (this.dataForm.brandId) {
|
if (this.dataForm.brandId) {
|
||||||
|
this.$modal.loading("请稍候...");
|
||||||
getBrand(this.dataForm.brandId).then(res =>{
|
getBrand(this.dataForm.brandId).then(res =>{
|
||||||
this.dataForm = res.data
|
this.dataForm = res.data
|
||||||
|
this.$modal.closeLoading()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -126,6 +132,7 @@ export default {
|
||||||
this.$refs["dataForm"].validate(valid => {
|
this.$refs["dataForm"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$modal.loading("请稍候...");
|
this.$modal.loading("请稍候...");
|
||||||
|
|
||||||
if (!this.dataForm.brandId) {
|
if (!this.dataForm.brandId) {
|
||||||
addBrand(this.dataForm).then(res =>{
|
addBrand(this.dataForm).then(res =>{
|
||||||
this.$modal.notifySuccess("添加成功");
|
this.$modal.notifySuccess("添加成功");
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||||
<el-table-column prop="name" header-align="center" align="center" label="品牌名"></el-table-column>
|
<el-table-column prop="name" header-align="center" align="center" label="品牌名"></el-table-column>
|
||||||
<el-table-column prop="logo" header-align="center" align="center" label="品牌logo地址">
|
<el-table-column prop="logo" header-align="center" align="center" label="品牌logo">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<img :src="scope.row.logo" style="width: 100px; height: 80px" alt=""/>
|
<img :src="scope.row.logo" style="width: 100px; height: 80px" alt=""/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>xjs-project-mall</artifactId>
|
|
||||||
<groupId>com.xjs</groupId>
|
|
||||||
<version>3.3.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<name>第三方服务</name>
|
|
||||||
|
|
||||||
<artifactId>mall-third-party</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!--阿里云存储-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package com.xjs.mall.thirdparty;
|
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
|
||||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
|
||||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
|
||||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import io.seata.spring.boot.autoconfigure.SeataAutoConfiguration;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商城Product启动器
|
|
||||||
* @author xiejs
|
|
||||||
* @since 2022-03-15
|
|
||||||
*/
|
|
||||||
@SpringBootApplication(exclude ={DataSourceAutoConfiguration.class,
|
|
||||||
SeataAutoConfiguration.class,
|
|
||||||
MybatisPlusAutoConfiguration.class,
|
|
||||||
DynamicDataSourceAutoConfiguration.class} )
|
|
||||||
@EnableCustomConfig
|
|
||||||
@EnableCustomSwagger2
|
|
||||||
@EnableRyFeignClients
|
|
||||||
public class MallThirdPartyApp {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(MallThirdPartyApp.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9986
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: xjs-mall-third-party
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: 127.0.0.1:8848
|
|
||||||
config:
|
|
||||||
# 配置中心地址
|
|
||||||
server-addr: 127.0.0.1:8848
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
#配置组
|
|
||||||
group: xjs
|
|
||||||
#命名空间
|
|
||||||
namespace: xjs-666
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
||||||
<!-- 日志存放路径 -->
|
|
||||||
<property name="log.path" value="logs/xjs-mall/third-party"/>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/info.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/error.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
|
||||||
<logger name="com.xjs" level="info" />
|
|
||||||
<!--打印feign DEBUG日志-->
|
|
||||||
<logger name="com.xjs.common.client" level="debug"/>
|
|
||||||
<!-- Spring日志级别控制 -->
|
|
||||||
<logger name="org.springframework" level="warn" />
|
|
||||||
|
|
||||||
<!-- 打开 Bean Searcher 的 SQL 日志 -->
|
|
||||||
<logger name="com.ejlchina.searcher.implement.DefaultSqlExecutor" level="DEBUG" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info" />
|
|
||||||
<appender-ref ref="file_error" />
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
|
|
||||||
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
|
|
||||||
-->
|
|
||||||
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
|
|
||||||
|
|
||||||
<id>mall-third-party</id>
|
|
||||||
|
|
||||||
<classpath>
|
|
||||||
<dir name="D:/Dev/IdeaPerject/GitHub/Cloud/xjs-business/xjs-project-mall/mall-third-party/target/classes">
|
|
||||||
</dir>
|
|
||||||
</classpath>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
<module>mall-member</module>
|
<module>mall-member</module>
|
||||||
<module>mall-coupon</module>
|
<module>mall-coupon</module>
|
||||||
<module>renren-generator</module>
|
<module>renren-generator</module>
|
||||||
<module>mall-third-party</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue