Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a5ff2a81
authored
Dec 18, 2020
by
ws
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
海报修改
1 parent
24f9b665
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
165 additions
and
31 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterFontController.java
linkwe-common/src/main/java/com/linkwechat/common/core/domain/BaseEntity.java
linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java
linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePoster.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePosterFont.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePosterSubassembly.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePosterFontServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePosterServiceImpl.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterController.java
View file @
a5ff2a8
...
...
@@ -9,9 +9,12 @@ import com.linkwechat.wecom.domain.WePosterSubassembly;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
com.linkwechat.wecom.service.IWePosterService
;
import
com.linkwechat.wecom.service.IWePosterSubassemblyService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
...
...
@@ -21,6 +24,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping
(
value
=
"wecom/poster/"
)
@Api
(
description
=
"海报"
)
public
class
WePosterController
extends
BaseController
{
...
...
@@ -34,6 +38,7 @@ public class WePosterController extends BaseController {
private
IWePosterFontService
wePosterFontService
;
@PostMapping
(
value
=
"insert"
)
@ApiOperation
(
"创建海报"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
insert
(
@RequestBody
WePoster
poster
){
wePosterService
.
generateSimpleImg
(
poster
);
...
...
@@ -51,6 +56,8 @@ public class WePosterController extends BaseController {
@PutMapping
(
value
=
"update"
)
@ApiOperation
(
"修改海报"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
update
(
@RequestBody
WePoster
poster
){
if
(
poster
.
getId
()
==
null
){
return
AjaxResult
.
error
(
"id为空"
);
...
...
@@ -87,6 +94,7 @@ public class WePosterController extends BaseController {
}
@GetMapping
(
value
=
"list"
)
@ApiOperation
(
"列表查询海报"
)
public
AjaxResult
list
(){
List
<
WePoster
>
fontList
=
wePosterService
.
lambdaQuery
()
.
eq
(
WePoster:
:
getDelFlag
,
1
)
...
...
@@ -96,11 +104,13 @@ public class WePosterController extends BaseController {
}
@GetMapping
(
value
=
"entity/{id}"
)
@ApiOperation
(
"查询海报详情"
)
public
AjaxResult
entity
(
@PathVariable
Long
id
){
return
AjaxResult
.
success
(
wePosterService
.
selectOne
(
id
));
}
@GetMapping
(
value
=
"page"
)
@ApiOperation
(
"分页查询海报"
)
public
AjaxResult
page
(){
startPage
();
List
<
WePoster
>
fontList
=
wePosterService
.
lambdaQuery
()
...
...
@@ -111,6 +121,8 @@ public class WePosterController extends BaseController {
}
@DeleteMapping
(
value
=
"delete/{id}"
)
@ApiOperation
(
value
=
"删除海报"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
deletePosterFont
(
@PathVariable
Long
id
){
wePosterService
.
lambdaUpdate
().
set
(
WePoster:
:
getDelFlag
,
0
).
eq
(
WePoster:
:
getId
,
id
);
wePosterSubassemblyService
.
lambdaUpdate
().
set
(
WePosterSubassembly:
:
getDelFlag
,
0
).
eq
(
WePosterSubassembly:
:
getPosterId
,
id
).
eq
(
WePosterSubassembly:
:
getFontId
,
1
);
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterFontController.java
View file @
a5ff2a8
...
...
@@ -6,6 +6,9 @@ import com.linkwechat.common.utils.SnowFlakeUtil;
import
com.linkwechat.web.controller.common.CommonController
;
import
com.linkwechat.wecom.domain.WePosterFont
;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
...
...
@@ -13,6 +16,7 @@ import java.util.List;
@RestController
@RequestMapping
(
value
=
"wecom/posterFont/"
)
@Api
(
description
=
"海报字体"
)
public
class
WePosterFontController
extends
BaseController
{
...
...
@@ -20,6 +24,8 @@ public class WePosterFontController extends BaseController {
private
IWePosterFontService
wePosterFontService
;
@PostMapping
(
value
=
"posterFont"
)
@ApiOperation
(
"创建海报字体"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
insertPosterFont
(
@RequestBody
WePosterFont
posterFont
){
posterFont
.
setId
(
SnowFlakeUtil
.
nextId
());
posterFont
.
setDelFlag
(
1
);
...
...
@@ -29,6 +35,8 @@ public class WePosterFontController extends BaseController {
@PutMapping
(
value
=
"posterFont"
)
@ApiOperation
(
"修改海报字体"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
updatePosterFont
(
@RequestBody
WePosterFont
posterFont
){
if
(
posterFont
.
getId
()
==
null
){
return
AjaxResult
.
error
(
"id为空"
);
...
...
@@ -38,6 +46,7 @@ public class WePosterFontController extends BaseController {
}
@GetMapping
(
value
=
"posterFontList"
)
@ApiOperation
(
"列表查询海报字体"
)
public
AjaxResult
selectPosterFontList
(){
List
<
WePosterFont
>
fontList
=
wePosterFontService
.
lambdaQuery
()
.
eq
(
WePosterFont:
:
getDelFlag
,
1
)
...
...
@@ -48,6 +57,7 @@ public class WePosterFontController extends BaseController {
}
@GetMapping
(
value
=
"posterFontPage"
)
@ApiOperation
(
"分页查询海报字体"
)
public
AjaxResult
selectPosterFontPage
(){
startPage
();
List
<
WePosterFont
>
fontList
=
wePosterFontService
.
lambdaQuery
()
...
...
@@ -59,6 +69,8 @@ public class WePosterFontController extends BaseController {
}
@DeleteMapping
(
value
=
"posterFont/{id}"
)
@ApiOperation
(
"删除海报字体"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
deletePosterFont
(
@PathVariable
Long
id
){
wePosterFontService
.
lambdaUpdate
().
set
(
WePosterFont:
:
getDelFlag
,
0
).
eq
(
WePosterFont:
:
getId
,
id
);
return
AjaxResult
.
success
(
"删除成功"
);
...
...
linkwe-common/src/main/java/com/linkwechat/common/core/domain/BaseEntity.java
View file @
a5ff2a8
...
...
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
io.swagger.annotations.ApiModelProperty
;
import
springfox.documentation.annotations.ApiIgnore
;
/**
...
...
@@ -23,38 +24,47 @@ public class BaseEntity implements Serializable
/** 搜索值 */
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
searchValue
;
/** 创建者 */
@ApiModelProperty
(
hidden
=
true
)
private
String
createBy
;
/** 创建时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
hidden
=
true
)
private
Date
createTime
=
new
Date
();
/** 更新者 */
@ApiModelProperty
(
hidden
=
true
)
private
String
updateBy
;
/** 更新时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
hidden
=
true
)
private
Date
updateTime
=
new
Date
();
/** 备注 */
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
remark
;
/** 开始时间 */
@JsonIgnore
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
beginTime
;
/** 结束时间 */
@JsonIgnore
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
endTime
;
/** 请求参数 */
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
Map
<
String
,
Object
>
params
;
public
String
getSearchValue
()
...
...
linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java
View file @
a5ff2a8
...
...
@@ -161,7 +161,12 @@ public class FileUploadUtils {
private
static
final
String
getPathFileName
(
String
uploadDir
,
String
fileName
)
throws
IOException
{
int
dirLastIndex
=
RuoYiConfig
.
getProfile
().
length
()
+
1
;
String
currentDir
=
StringUtils
.
substring
(
uploadDir
,
dirLastIndex
);
String
pathFileName
=
Constants
.
RESOURCE_PREFIX
+
"/"
+
currentDir
+
"/"
+
fileName
;
String
pathFileName
;
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isBlank
(
currentDir
)){
pathFileName
=
Constants
.
RESOURCE_PREFIX
+
"/"
+
fileName
;
}
else
{
pathFileName
=
Constants
.
RESOURCE_PREFIX
+
"/"
+
currentDir
+
"/"
+
fileName
;
}
return
pathFileName
;
}
...
...
linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java
View file @
a5ff2a8
...
...
@@ -5,11 +5,13 @@ import io.netty.buffer.Unpooled;
import
io.vertx.core.Vertx
;
import
io.vertx.core.buffer.Buffer
;
import
io.vertx.ext.web.client.WebClient
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.awt.*
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.*
;
import
java.nio.channels.Channels
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.ReadableByteChannel
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -25,7 +27,14 @@ public class NetFileUtils {
public
static
void
main
(
String
[]
args
)
{
FileCallable
fileCallable
=
getNetFile
(
"https://pc-index-skin.cdn.bcebos.com/hiphoto/51631423522.jpg?x-bce-process=image/crop,x_0,y_13,w_1999,h_1250"
);
getByteArrayOutputStream
(
fileCallable
,
true
);
ByteArrayOutputStream
byteArrayOutputStream
=
getByteArrayOutputStream
(
fileCallable
,
true
);
StreamMultipartFile
file
=
new
StreamMultipartFile
(
"你好啊.jpg"
,
byteArrayOutputStream
.
toByteArray
());
File
f
=
new
File
(
"D:/网页/2.jpg"
);
try
{
file
.
transferTo
(
f
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
...
...
@@ -109,5 +118,62 @@ public class NetFileUtils {
}
}
public
static
class
StreamMultipartFile
implements
MultipartFile
{
private
final
String
filename
;
private
final
byte
[]
bytes
;
public
StreamMultipartFile
(
String
filename
,
byte
[]
bytes
){
this
.
filename
=
filename
;
this
.
bytes
=
bytes
;
}
@Override
public
String
getName
()
{
return
filename
;
}
@Override
public
String
getOriginalFilename
()
{
return
filename
;
}
@Override
public
String
getContentType
()
{
return
null
;
}
@Override
public
boolean
isEmpty
()
{
return
bytes
==
null
||
bytes
.
length
==
0
;
}
@Override
public
long
getSize
()
{
return
bytes
.
length
;
}
@Override
public
byte
[]
getBytes
()
throws
IOException
{
return
this
.
bytes
;
}
@Override
public
InputStream
getInputStream
()
throws
IOException
{
return
new
ByteArrayInputStream
(
bytes
);
}
@Override
public
void
transferTo
(
File
file
)
throws
IOException
,
IllegalStateException
{
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
file
);
FileChannel
fileChannel
=
fileOutputStream
.
getChannel
();
ReadableByteChannel
channel
=
Channels
.
newChannel
(
new
ByteArrayInputStream
(
bytes
));
fileChannel
.
transferFrom
(
channel
,
0
,
bytes
.
length
);
fileChannel
.
close
();
channel
.
close
();
fileOutputStream
.
close
();
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePoster.java
View file @
a5ff2a8
...
...
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -18,42 +21,51 @@ import java.util.List;
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@TableName
(
value
=
"we_poster"
)
@ApiModel
(
value
=
"海报"
)
public
class
WePoster
extends
BaseEntity
{
@TableId
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
/**
* 海报标题
*/
@TableField
@ApiModelProperty
(
value
=
"海报标题"
)
private
String
title
;
/**
* 背景图片
*/
@TableField
@ApiModelProperty
(
value
=
"背景图片"
)
private
String
backgroundImgPath
;
/**
* 示例图片
*/
@TableField
@ApiModelProperty
(
value
=
"示例图片"
)
private
String
sampleImgPath
;
/**
* 海报类型 1 通用海报
*/
@TableField
@ApiModelProperty
(
value
=
"海报类型 1 通用海报(默认)"
)
private
Long
type
;
@TableField
@ApiModelProperty
(
value
=
"海报状态 1 启用 0 关闭"
)
private
Integer
delFlag
;
@TableField
@ApiModelProperty
(
value
=
"海报背景宽度"
)
private
Integer
width
;
@TableField
@ApiModelProperty
(
value
=
"海报背景高度"
)
private
Integer
height
;
/**
...
...
@@ -61,28 +73,6 @@ public class WePoster extends BaseEntity {
*/
@TableField
(
exist
=
false
)
private
List
<
WePosterSubassembly
>
posterSubassemblyList
;
public
static
void
main
(
String
[]
args
)
{
WePoster
wePoster
=
new
WePoster
();
wePoster
.
setDelFlag
(
1
);
wePoster
.
setTitle
(
"你好世界"
);
wePoster
.
setHeight
(
1000
);
wePoster
.
setWidth
(
1000
);
wePoster
.
setType
(
1L
);
wePoster
.
setBackgroundImgPath
(
"1"
);
wePoster
.
setPosterSubassemblyList
(
new
ArrayList
<>());
for
(
int
i
=
0
;
i
<
1
;
i
++){
WePosterSubassembly
subassembly
=
new
WePosterSubassembly
();
subassembly
.
setFontColor
(
"#544875"
);
subassembly
.
setFontId
(
1L
);
subassembly
.
setHeight
(
100
);
subassembly
.
setWidth
(
100
);
subassembly
.
setDelFlag
(
1
);
subassembly
.
setLeft
(
1
);
subassembly
.
setTop
(
1
);
subassembly
.
setFontTextAlign
(
1
);
wePoster
.
getPosterSubassemblyList
().
add
(
subassembly
);
}
System
.
out
.
println
(
JSON
.
toJSONString
(
wePoster
));
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePosterFont.java
View file @
a5ff2a8
...
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -14,34 +16,40 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@TableName
(
value
=
"we_poster_font"
)
@ApiModel
(
value
=
"海报字体"
)
public
class
WePosterFont
extends
BaseEntity
{
/**
* id
*/
@TableId
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
/**
* 字体名称
*/
@TableField
(
value
=
"font_name"
)
@ApiModelProperty
(
value
=
"字体名称"
)
private
String
fontName
;
/**
* 字体网络地址
*/
@TableField
(
value
=
"font_url"
)
@ApiModelProperty
(
value
=
"字体链接"
)
private
String
fontUrl
;
/**
* 字体排序
*/
@TableField
(
value
=
"`order`"
)
@ApiModelProperty
(
value
=
"展示排序 顺序"
)
private
Integer
order
;
/**
* 状态
*/
@TableField
(
value
=
"del_flag"
)
@ApiModelProperty
(
value
=
"1 启用 0 关闭"
)
private
Integer
delFlag
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePosterSubassembly.java
View file @
a5ff2a8
...
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -14,83 +16,99 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@TableName
(
value
=
"we_poster_subassembly"
)
@ApiModel
(
value
=
"海报组成部件"
)
public
class
WePosterSubassembly
extends
BaseEntity
{
@TableId
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
@TableField
@ApiModelProperty
(
value
=
"海报id"
)
private
Long
posterId
;
/**
* x坐标
*/
@TableField
(
value
=
"`left`"
)
@ApiModelProperty
(
value
=
"x坐标"
)
private
Integer
left
;
/**
* y坐标
*/
@TableField
@ApiModelProperty
(
value
=
"y坐标"
)
private
Integer
top
;
/**
* 宽度
*/
@TableField
@ApiModelProperty
(
value
=
"控件宽度"
)
private
Integer
width
;
/**
* 高度
*/
@TableField
@ApiModelProperty
(
value
=
"空间高度"
)
private
Integer
height
;
/**
* 类型 1 固定文本 2 固定图片 3 二维码图片
*/
@TableField
@ApiModelProperty
(
value
=
"类型 1 固定文本 2 固定图片 3 二维码图片"
)
private
Integer
type
;
@TableField
@ApiModelProperty
(
value
=
"字体id"
)
private
Long
fontId
;
/**
* 字体大小(像素大小)
*/
@TableField
@ApiModelProperty
(
value
=
"字体大小(像素大小)"
)
private
Integer
fontSize
;
/**
* 字体颜色(十六进制)
*/
@TableField
@ApiModelProperty
(
value
=
"字体颜色(十六进制)"
)
private
String
fontColor
;
/**
* 字体对齐方式 0 左对齐 1居中 2右对齐
*/
@TableField
@ApiModelProperty
(
value
=
"字体对齐方式 0 左对齐 1居中 2右对齐"
)
private
Integer
fontTextAlign
;
/**
* 图片网络地址
*/
@TableField
@ApiModelProperty
(
value
=
"图片地址(与字体id互斥)"
)
private
String
imgPath
;
@TableField
@ApiModelProperty
(
value
=
"1 启用 0 删除"
)
private
Integer
delFlag
;
/**
* 文字内容
*/
@TableField
@ApiModelProperty
(
value
=
"文本内容"
)
private
String
content
;
/**
* 字体实体
*/
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"字体信息"
)
private
WePosterFont
font
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePosterFontServiceImpl.java
View file @
a5ff2a8
...
...
@@ -47,6 +47,9 @@ public class WePosterFontServiceImpl extends ServiceImpl<WePosterFontMapper,WePo
if
(
posterFont
==
null
){
throw
new
RuntimeException
(
"字体id为:"
+
id
+
"的字体不存在"
);
}
if
(
StringUtils
.
isBlank
(
posterFont
.
getFontUrl
())){
posterFont
.
setFontUrl
(
"http://img.kometl.com/1.ttf"
);
}
Font
font
;
if
((
font
=
FONT_MAP
.
get
(
posterFont
.
getId
()))
!=
null
){
return
font
.
deriveFont
((
float
)
size
);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePosterServiceImpl.java
View file @
a5ff2a8
...
...
@@ -12,9 +12,14 @@ import com.linkwechat.wecom.mapper.WePosterMapper;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
com.linkwechat.wecom.service.IWePosterService
;
import
com.linkwechat.wecom.service.IWePosterSubassemblyService
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.FileItemFactory
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
javax.annotation.Resource
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
...
...
@@ -58,7 +63,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
WePoster
poster
=
this
.
lambdaQuery
()
.
eq
(
WePoster:
:
getId
,
id
)
.
eq
(
WePoster:
:
getDelFlag
,
1
)
.
getEntity
(
);
.
list
().
get
(
0
);
if
(
poster
==
null
)
{
return
null
;
}
...
...
@@ -110,6 +115,8 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
}
}));
BufferedImage
backgroundImg
=
bufferedImageMap
.
get
(
poster
.
getBackgroundImgPath
());
poster
.
setWidth
(
backgroundImg
.
getWidth
());
poster
.
setHeight
(
backgroundImg
.
getHeight
());
poster
.
getPosterSubassemblyList
().
forEach
(
wePosterSubassembly
->
{
if
(
wePosterSubassembly
.
getFontId
()
!=
null
)
{
Font
font
=
fontMap
.
get
(
wePosterSubassembly
.
getFontId
());
...
...
@@ -136,7 +143,10 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
try
{
ImageIO
.
write
(
backgroundImg
,
"jpg"
,
byteArrayOutputStream
);
ImageUtils
.
byteToFile
(
byteArrayOutputStream
.
toByteArray
(),
"测试"
+
System
.
currentTimeMillis
(),
"jpg"
,
"D:/网页/"
);
NetFileUtils
.
StreamMultipartFile
streamMultipartFile
=
new
NetFileUtils
.
StreamMultipartFile
(
System
.
currentTimeMillis
()+
".jpg"
,
byteArrayOutputStream
.
toByteArray
());
byteArrayOutputStream
.
close
();
String
path
=
FileUploadUtils
.
uploadFile
(
streamMultipartFile
);
poster
.
setSampleImgPath
(
path
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"图片生成错误"
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment