Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
0a0245a8
Commit
0a0245a8
authored
Nov 15, 2023
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送朋友圈图片优化
parent
ee3d4f0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
MaterialServiceImpl.java
...oban/manage/service/service/impl/MaterialServiceImpl.java
+19
-10
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/MaterialServiceImpl.java
View file @
0a0245a8
...
...
@@ -3,9 +3,12 @@ package com.gic.haoban.manage.service.service.impl;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.slf4j.Logger
;
...
...
@@ -220,17 +223,23 @@ public class MaterialServiceImpl implements MaterialService {
if
(
url
.
contains
(
"?"
))
{
logger
.
info
(
"url有参数={}"
,
url
);
url
=
url
.
split
(
"\\?"
)[
0
]
;
url
+=
"?imageView2/2/w/1440/h/1080"
;
}
else
{
}
String
key
=
"haoban:material:"
+
url
;
String
cache
=
(
String
)
RedisUtil
.
getCache
(
key
);
Map
<
String
,
Object
>
map
=
null
;
if
(
StringUtils
.
isBlank
(
cache
))
{
String
imageInfoUrl
=
url
+
"?imageInfo"
;
Map
<
String
,
Object
>
map
=
HttpClient
.
getHttpByGet
(
imageInfoUrl
);
String
width
=
(
String
)
map
.
get
(
"width"
);
String
height
=
(
String
)
map
.
get
(
"height"
);
String
size
=
(
String
)
map
.
get
(
"size"
);
//图片宽高超过限制 或 大小大于1m 处理图片
if
(
Integer
.
parseInt
(
size
)
/
1000
>
1000
||
Integer
.
parseInt
(
width
)
>
1440
||
Integer
.
parseInt
(
height
)
>
1080
)
{
url
+=
"?imageView2/2/w/1440/h/1080"
;
}
map
=
HttpClient
.
getHttpByGet
(
imageInfoUrl
);
RedisUtil
.
setCache
(
key
,
TimeUnit
.
DAYS
,
1L
);
}
else
{
map
=
JSONObject
.
parseObject
(
cache
,
Map
.
class
);
}
String
width
=
(
String
)
map
.
get
(
"width"
);
String
height
=
(
String
)
map
.
get
(
"height"
);
String
size
=
(
String
)
map
.
get
(
"size"
);
//图片宽高超过限制 或 大小大于1m 处理图片
if
(
Integer
.
parseInt
(
size
)
/
1000
>
1000
||
Integer
.
parseInt
(
width
)
>
1440
||
Integer
.
parseInt
(
height
)
>
1080
)
{
url
+=
"?imageView2/2/w/1440/h/1080"
;
}
logger
.
info
(
"url={}"
,
url
);
}
...
...
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