Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
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
徐少华
midjourney-proxy
Commits
738fdc3e
Commit
738fdc3e
authored
Dec 12, 2018
by
田超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add qrcodeTypeEnum
parent
48db857d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
15 deletions
+103
-15
QrcodeTypeEnum.java
...src/main/java/com/pcloud/common/enums/QrcodeTypeEnum.java
+78
-0
QrcodeUtils.java
...on/src/main/java/com/pcloud/common/utils/QrcodeUtils.java
+25
-15
No files found.
pcloud-common/src/main/java/com/pcloud/common/enums/QrcodeTypeEnum.java
0 → 100644
View file @
738fdc3e
package
com
.
pcloud
.
common
.
enums
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author lily
* @date 2018/12/6 11:36
*/
public
enum
QrcodeTypeEnum
{
MAGIC
(
"AUDIO"
,
0
,
"听画书"
,
"MAGIC"
,
"APP"
,
true
),
REWARD
(
"CLOCK"
,
1
,
"打卡书"
,
"REWARD"
,
"APP"
,
true
),
PREVIEW_APP
(
"VIDEO"
,
2
,
"预习课"
,
"PREVIEW"
,
"APP"
,
true
),
PREVIEW_PRODUCT
(
"VIDEO_SCHEDULE"
,
3
,
"预习课"
,
"PREVIEW"
,
"PRODUCT"
,
true
),
ZSCORE
(
"ZSCORE"
,
4
,
"查分书"
,
"ZSCORE"
,
"APP"
,
true
);
/**
* 类型
*/
private
String
type
;
private
Integer
value
;
private
String
description
;
private
String
scene
;
private
String
typeCode
;
private
Boolean
isNeedCover
;
public
static
final
Map
<
String
,
QrcodeTypeEnum
>
QRCODE_TYPE_MAP
=
new
HashMap
<>();
QrcodeTypeEnum
(
String
type
,
Integer
value
,
String
description
,
String
scene
,
String
typeCode
,
Boolean
isNeedCover
)
{
this
.
type
=
type
;
this
.
value
=
value
;
this
.
description
=
description
;
this
.
scene
=
scene
;
this
.
typeCode
=
typeCode
;
this
.
isNeedCover
=
isNeedCover
;
}
static
{
Arrays
.
asList
(
values
()).
forEach
((
m
)
->
{
QRCODE_TYPE_MAP
.
put
(
m
.
type
,
m
);
});
}
public
String
getType
()
{
return
type
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getDescription
()
{
return
description
;
}
public
String
getScene
()
{
return
scene
;
}
public
String
getTypeCode
()
{
return
typeCode
;
}
public
Boolean
getNeedCover
()
{
return
isNeedCover
;
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/QrcodeUtils.java
View file @
738fdc3e
...
...
@@ -21,6 +21,7 @@ import java.util.Map;
import
javax.imageio.ImageIO
;
import
javax.swing.ImageIcon
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -223,21 +224,30 @@ public class QrcodeUtils {
* @throws Exception
*/
public
static
String
createWithMargin
(
String
url
,
Integer
marginNum
)
throws
BizException
{
LOGGER
.
info
(
"【二维码】创建二维码,<START>.[url]="
+
url
);
Map
<
EncodeHintType
,
Object
>
hints
=
new
HashMap
<
EncodeHintType
,
Object
>();
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
level
);
hints
.
put
(
EncodeHintType
.
MARGIN
,
marginNum
);
// 设置白边
try
{
// 生成矩阵
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
url
,
BarcodeFormat
.
QR_CODE
,
ImageConstant
.
QRCODE_WITH
,
ImageConstant
.
QRCODE_HEIGHT
,
hints
);
BufferedImage
bufferedImage
=
toBufferedImage
(
bitMatrix
,
onColor
);
bufferedImage
.
flush
();
return
uploadImage
(
bufferedImage
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【二维码】创建二维码失败,<ERROR>:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_UPLOAD_FAILURE
,
"创建二维码失败"
);
String
key
=
"createWithMargin:"
+
url
+
"_"
+
marginNum
;
if
(
JedisClusterUtils
.
exists
(
key
)){
String
s
=
JedisClusterUtils
.
get
(
key
);
return
s
;
}
else
{
LOGGER
.
info
(
"【二维码】创建二维码,<START>.[url]="
+
url
);
Map
<
EncodeHintType
,
Object
>
hints
=
new
HashMap
<
EncodeHintType
,
Object
>();
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
level
);
hints
.
put
(
EncodeHintType
.
MARGIN
,
marginNum
);
// 设置白边
try
{
// 生成矩阵
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
url
,
BarcodeFormat
.
QR_CODE
,
ImageConstant
.
QRCODE_WITH
,
ImageConstant
.
QRCODE_HEIGHT
,
hints
);
BufferedImage
bufferedImage
=
toBufferedImage
(
bitMatrix
,
onColor
);
bufferedImage
.
flush
();
String
s
=
uploadImage
(
bufferedImage
);
JedisClusterUtils
.
set
(
key
,
s
,
24
*
3600
);
return
s
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【二维码】创建二维码失败,<ERROR>:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_UPLOAD_FAILURE
,
"创建二维码失败"
);
}
}
}
...
...
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