Merge branch 'master' of gitee.com:lab1024/smart-admin

This commit is contained in:
kkaiyun
2023-05-09 17:50:10 +08:00
21 changed files with 259 additions and 91 deletions

View File

@@ -184,10 +184,10 @@
</dependency>
<!-- sax 读取时候用到的 -->
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>xerces</groupId>-->
<!-- <artifactId>xercesImpl</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>

View File

@@ -149,7 +149,7 @@ public abstract class CodeGenerateBaseVariableService {
*/
protected String getJavaPackageName(String javaType) {
if ("BigDecimal".equals(javaType)) {
return "import java.math.BigDecimal";
return "import java.math.BigDecimal;";
} else if ("LocalDate".equals(javaType)) {
return "import java.time.LocalDate;";
} else if ("LocalDateTime".equals(javaType)) {

View File

@@ -139,9 +139,9 @@ public class FileService {
fileEntity.setFileSize(file.getSize());
fileEntity.setFileKey(uploadVO.getFileKey());
fileEntity.setFileType(uploadVO.getFileType());
fileEntity.setCreatorId(requestUser == null ? null:requestUser.getUserId());
fileEntity.setCreatorName(requestUser == null ? null:requestUser.getUserName());
fileEntity.setCreatorUserType(requestUser == null ? null:requestUser.getUserType().getValue());
fileEntity.setCreatorId(requestUser == null ? null : requestUser.getUserId());
fileEntity.setCreatorName(requestUser == null ? null : requestUser.getUserName());
fileEntity.setCreatorUserType(requestUser == null ? null : requestUser.getUserType().getValue());
fileDao.insert(fileEntity);
uploadVO.setFileId(fileEntity.getFileId());
// 添加缓存
@@ -230,6 +230,13 @@ public class FileService {
* @throws IOException
*/
public ResponseEntity<Object> downloadByFileKey(String fileKey, String userAgent) {
FileVO fileVO = fileDao.getByFileKey(fileKey);
if (fileVO == null) {
HttpHeaders heads = new HttpHeaders();
heads.add(HttpHeaders.CONTENT_TYPE, "text/html;charset=UTF-8");
return new ResponseEntity<>("文件不存在:" + fileKey, heads, HttpStatus.OK);
}
// 根据文件服务类 获取对应文件服务 查询 url
ResponseDTO<FileDownloadVO> responseDTO = fileStorageService.fileDownload(fileKey);
if (!responseDTO.getOk()) {
@@ -237,15 +244,17 @@ public class FileService {
heads.add(HttpHeaders.CONTENT_TYPE, "text/html;charset=UTF-8");
return new ResponseEntity<>(responseDTO.getMsg() + "" + fileKey, heads, HttpStatus.OK);
}
// 设置下载头
HttpHeaders heads = new HttpHeaders();
heads.add(HttpHeaders.CONTENT_TYPE, "application/octet-stream; charset=utf-8");
// 设置对应浏览器的文件名称编码
FileDownloadVO fileDownloadVO = responseDTO.getData();
FileMetadataVO metadata = fileDownloadVO.getMetadata();
String fileName = null != metadata ? metadata.getFileName() : fileKey.substring(fileKey.lastIndexOf("/"));
fileName = fileStorageService.getDownloadFileNameByUA(fileName, userAgent);
heads.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + fileName);
// 设置下载头
HttpHeaders heads = new HttpHeaders();
heads.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(metadata.getFileSize()));
heads.add(HttpHeaders.CONTENT_TYPE, "application/octet-stream; charset=utf-8");
heads.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + fileStorageService.getDownloadFileNameByUA(fileVO.getFileName(), userAgent));
// 返回给前端
ResponseEntity<Object> responseEntity = new ResponseEntity<>(fileDownloadVO.getData(), heads, HttpStatus.OK);
return responseEntity;
}

View File

@@ -5,6 +5,7 @@ import net.lab1024.sa.common.common.code.SystemErrorCode;
import net.lab1024.sa.common.common.code.UserErrorCode;
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.common.module.support.file.domain.vo.FileDownloadVO;
import net.lab1024.sa.common.module.support.file.domain.vo.FileMetadataVO;
import net.lab1024.sa.common.module.support.file.domain.vo.FileUploadVO;
import net.lab1024.sa.common.module.support.config.ConfigKeyEnum;
import net.lab1024.sa.common.module.support.config.ConfigService;
@@ -119,6 +120,13 @@ public class FileStorageLocalServiceImpl implements IFileStorageService {
byte[] buffer = FileCopyUtils.copyToByteArray(in);
FileDownloadVO fileDownloadVO = new FileDownloadVO();
fileDownloadVO.setData(buffer);
FileMetadataVO fileMetadataDTO = new FileMetadataVO();
fileMetadataDTO.setFileName(localFile.getName());
fileMetadataDTO.setFileSize(localFile.length());
fileMetadataDTO.setFileFormat(FilenameUtils.getExtension(localFile.getName()));
fileDownloadVO.setMetadata(fileMetadataDTO);
return ResponseDTO.ok(fileDownloadVO);
} catch (IOException e) {
log.error("文件下载-发生异常:", e);

View File

@@ -60,16 +60,24 @@ public class RepeatSubmitAspect {
if (timeStamp != null) {
Method method = ((MethodSignature) point.getSignature()).getMethod();
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
// 说明注解去掉了
if (annotation != null) {
return point.proceed();
}
int interval = Math.min(annotation.value(), RepeatSubmit.MAX_INTERVAL);
if (System.currentTimeMillis() < timeStamp + interval) {
// 提交频繁
return ResponseDTO.error(UserErrorCode.REPEAT_SUBMIT);
}
}
Object obj = null;
try {
obj = point.proceed();
// 先给 ticket 设置在执行中
this.repeatSubmitTicket.putTicket(ticket);
obj = point.proceed();
} catch (Throwable throwable) {
log.error("", throwable);
throw throwable;

View File

@@ -10,19 +10,14 @@
:title="form.$!{primaryKeyFieldName} ? '编辑' : '添加'"
width="$!{insertAndUpdate.width}"
:visible="visibleFlag"
@close="onClose"
@cancel="onClose"
:maskClosable="false"
:destroyOnClose="true"
>
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
#if($insertAndUpdate.countPerLine > 1)
<a-row>
#end
#foreach ($field in $formFields)
#if($insertAndUpdate.countPerLine > 1)
#set($span=24 / $!insertAndUpdate.countPerLine )
<a-col :span="$!{span}">
#end
#if($insertAndUpdate.countPerLine == 1)
<a-row>
#foreach ($field in $formFields)
#if($field.frontComponent == "Input")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<a-input style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
@@ -66,19 +61,78 @@
#if($field.frontComponent == "Upload")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<FileUpload
:defaultFileList="form.$!{field.fieldName}"
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
buttonText="上传 $!{field.label}"
listType="text"
@change="e => form.$!{field.fieldName} = e"
:defaultFileList="form.$!{field.fieldName}"
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
buttonText="上传 $!{field.label}"
listType="text"
@change="e => form.$!{field.fieldName} = e"
/>
</a-form-item>
#end
#end
#if($insertAndUpdate.countPerLine > 1)
</a-col>
<a-row>
#end
#end
</a-row>
#end
#if($insertAndUpdate.countPerLine > 1)
<a-row>
#set($span=24 / $!insertAndUpdate.countPerLine )
#foreach ($field in $formFields)
<a-col :span="$!{span}">
#if($field.frontComponent == "Input")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<a-input style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
</a-form-item>
#end
#if($field.frontComponent == "InputNumber")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<a-input-number style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
</a-form-item>
#end
#if($field.frontComponent == "Textarea")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<a-textarea style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
</a-form-item>
#end
#if($field.frontComponent == "BooleanSelect")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<BooleanSelect v-model:value="form.${field.fieldName}" style="width: 100%" />
</a-form-item>
#end
#if($field.frontComponent == "SmartEnumSelect")
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
<SmartEnumSelect width="100%" v-model:value="form.${field.fieldName}" enumName="$!{field.upperUnderscoreEnum}" placeholder="$codeGeneratorTool.removeEnumDesc($!{field.label})"/>
</a-form-item>
#end
#if($field.frontComponent == "DictSelect")
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
</a-form-item>
#end
#if($field.frontComponent == "Date")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<a-date-picker valueFormat="YYYY-MM-DD" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}"/>
</a-form-item>
#end
#if($field.frontComponent == "DateTime")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}" />
</a-form-item>
#end
#if($field.frontComponent == "Upload")
<a-form-item label="$!{field.label}" name="${field.fieldName}">
<FileUpload
:defaultFileList="form.$!{field.fieldName}"
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
buttonText="上传 $!{field.label}"
listType="text"
@change="e => form.$!{field.fieldName} = e"
/>
</a-form-item>
#end
</a-col>
#end
</a-row>
#end
</a-form>
<template #footer>

View File

@@ -3,7 +3,7 @@ spring:
datasource:
url: jdbc:p6spy:mysql://127.0.0.1:3306/smart_admin_v2?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
username: root
password: Zhuoda123456
password: Xxxx1024
initial-size: 2
min-idle: 2
max-active: 10
@@ -16,7 +16,7 @@ spring:
username: druid
password: 1024
login:
enabled: true
enabled: false
method:
pointcut: net.lab1024.sa..*Service.*
@@ -89,9 +89,9 @@ file:
local:
path: ${localPath:/home}/smart_admin_v2/upload/
cloud:
region: oss-cn-qingdao
endpoint: oss-cn-qingdao.aliyuncs.com
bucket-name: common-sit
region: oss-cn-hangzhou
endpoint: oss-cn-hangzhou.aliyuncs.com
bucket-name: 1024lab-smart-admin
access-key:
secret-key:
url:
@@ -127,8 +127,8 @@ access-control-allow-origin: '*'
# 心跳配置
heart-beat:
interval-seconds: 60
interval-seconds: 300
# 热加载配置
reload:
interval-seconds: 60
interval-seconds: 300