Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
d7fe8c90
Commit
d7fe8c90
authored
Sep 24, 2024
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
附件上传限流-fxj
parent
8c78898f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
164 additions
and
4 deletions
+164
-4
SysConfigLimit.java
...fu/cloud/plus/v1/yifu/archives/entity/SysConfigLimit.java
+75
-0
SysConfigLimitMapper.java
...ud/plus/v1/yifu/archives/mapper/SysConfigLimitMapper.java
+41
-0
FileUploadServiceImpl.java
.../v1/yifu/archives/service/impl/FileUploadServiceImpl.java
+10
-4
SysConfigLimitMapper.xml
...es-biz/src/main/resources/mapper/SysConfigLimitMapper.xml
+38
-0
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/entity/SysConfigLimit.java
0 → 100644
View file @
d7fe8c90
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
entity
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotBlank
;
/**
* 系统限制配置表
*
* @author hgw
* @date 2024-09-24 17:39:57
*/
@Data
@TableName
(
"sys_config_limit"
)
@Schema
(
description
=
"系统限制配置表"
)
public
class
SysConfigLimit
{
/**
* id
*/
@TableId
(
type
=
IdType
.
ASSIGN_ID
)
@ExcelProperty
(
"id"
)
@Schema
(
description
=
"id"
)
private
String
id
;
/**
* 限制键
*/
@ExcelAttribute
(
name
=
"限制键"
,
isNotEmpty
=
true
,
errorInfo
=
"限制键不能为空"
,
maxLength
=
32
)
@NotBlank
(
message
=
"限制键不能为空"
)
@Length
(
max
=
32
,
message
=
"限制键不能超过32个字符"
)
@ExcelProperty
(
"限制键"
)
@Schema
(
description
=
"限制键"
)
private
String
configKey
;
/**
* 限制值
*/
@ExcelAttribute
(
name
=
"限制值"
,
isNotEmpty
=
true
,
errorInfo
=
"限制值不能为空"
)
@NotBlank
(
message
=
"限制值不能为空"
)
@ExcelProperty
(
"限制值"
)
@Schema
(
description
=
"限制值"
)
private
Integer
configValue
;
/**
* 备注
*/
@ExcelAttribute
(
name
=
"备注"
,
maxLength
=
255
)
@Length
(
max
=
255
,
message
=
"备注不能超过255个字符"
)
@ExcelProperty
(
"备注"
)
@Schema
(
description
=
"备注"
)
private
String
remark
;
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/mapper/SysConfigLimitMapper.java
0 → 100644
View file @
d7fe8c90
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
archives
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.SysConfigLimit
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
/**
* 系统限制配置表
*
* @author hgw
* @date 2024-09-24 17:39:57
*/
@Mapper
public
interface
SysConfigLimitMapper
extends
BaseMapper
<
SysConfigLimit
>
{
/**
* 系统限制配置表简单分页查询
*
* @param configKey 键
* @return
*/
Integer
getSysConfigLimitByKey
(
@Param
(
"configKey"
)
String
configKey
);
}
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/FileUploadServiceImpl.java
View file @
d7fe8c90
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.mapper.SysConfigLimitMapper
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService
;
import
com.yifu.cloud.plus.v1.yifu.archives.utils.QrCodeUtil
;
import
com.yifu.cloud.plus.v1.yifu.archives.utils.QrCodeUtil
;
...
@@ -42,7 +43,9 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -42,7 +43,9 @@ public class FileUploadServiceImpl implements FileUploadService {
private
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
0
);
private
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
0
);
//初始化附件上传队列上限值
//初始化附件上传队列上限值
private
int
maxLimit
=
10
;
private
int
maxLimit
=
1
;
private
final
SysConfigLimitMapper
configLimitMapper
;
@Override
@Override
public
R
<
TAttaInfo
>
uploadFileReturnAtta
(
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domainId
)
throws
IOException
{
public
R
<
TAttaInfo
>
uploadFileReturnAtta
(
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domainId
)
throws
IOException
{
...
@@ -258,7 +261,8 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -258,7 +261,8 @@ public class FileUploadServiceImpl implements FileUploadService {
}
}
public
R
getR
(
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domain
,
String
uploadType
)
{
public
R
getR
(
MultipartFile
file
,
String
filePath
,
Integer
type
,
String
domain
,
String
uploadType
)
{
if
(
atomicInteger
.
intValue
()
<
maxLimit
){
maxLimit
=
configLimitMapper
.
getSysConfigLimitByKey
(
"UPLOAD_MAX_LIMIT"
);
if
(
atomicInteger
.
incrementAndGet
()
<=
maxLimit
){
try
{
try
{
atomicInteger
.
getAndAdd
(
1
);
atomicInteger
.
getAndAdd
(
1
);
Thread
.
sleep
(
1000
);
Thread
.
sleep
(
1000
);
...
@@ -271,11 +275,13 @@ public class FileUploadServiceImpl implements FileUploadService {
...
@@ -271,11 +275,13 @@ public class FileUploadServiceImpl implements FileUploadService {
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
error
(
"附件上传异常:"
,
e
);
log
.
error
(
"附件上传异常:"
,
e
);
}
finally
{
}
finally
{
atomicInteger
.
getAndAdd
(-
1
);
atomicInteger
.
decrementAndGet
(
);
log
.
error
(
"atomicInteger-1:"
+
atomicInteger
.
intValue
());
log
.
error
(
"atomicInteger-1:"
+
atomicInteger
.
intValue
());
}
}
}
else
{
}
else
{
log
.
error
(
ResultConstants
.
FILE_UPLOADING_DATA
);
atomicInteger
.
decrementAndGet
();
log
.
error
(
"atomicInteger超出阈值-1:"
+
atomicInteger
.
intValue
());
log
.
error
(
"超出阈值:"
+
ResultConstants
.
FILE_UPLOADING_DATA
);
return
R
.
failed
(
ResultConstants
.
FILE_UPLOADING_DATA
);
return
R
.
failed
(
ResultConstants
.
FILE_UPLOADING_DATA
);
}
}
...
...
yifu-archives/yifu-archives-biz/src/main/resources/mapper/SysConfigLimitMapper.xml
0 → 100644
View file @
d7fe8c90
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.yifu.cloud.plus.v1.yifu.archives.mapper.SysConfigLimitMapper"
>
<resultMap
id=
"sysConfigLimitMap"
type=
"com.yifu.cloud.plus.v1.yifu.archives.entity.SysConfigLimit"
>
<id
property=
"id"
column=
"ID"
/>
<result
property=
"configKey"
column=
"CONFIG_KEY"
/>
<result
property=
"configValue"
column=
"CONFIG_VALUE"
/>
<result
property=
"remark"
column=
"REMARK"
/>
</resultMap>
<!-- 根据key获取value -->
<select
id=
"getSysConfigLimitByKey"
resultType=
"java.lang.Integer"
>
SELECT a.CONFIG_VALUE
FROM sys_config_limit a
where a.CONFIG_KEY = #{configKey} limit 1
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment