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 048a3409
authored
Dec 18, 2020
by
ws
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
海报修改
1 parent
783121ad
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
164 additions
and
30 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 @
048a340
...
@@ -9,9 +9,12 @@ import com.linkwechat.wecom.domain.WePosterSubassembly;
...
@@ -9,9 +9,12 @@ import com.linkwechat.wecom.domain.WePosterSubassembly;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
com.linkwechat.wecom.service.IWePosterService
;
import
com.linkwechat.wecom.service.IWePosterService
;
import
com.linkwechat.wecom.service.IWePosterSubassemblyService
;
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.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -21,6 +24,7 @@ import java.util.stream.Collectors;
...
@@ -21,6 +24,7 @@ import java.util.stream.Collectors;
@RestController
@RestController
@RequestMapping
(
value
=
"wecom/poster/"
)
@RequestMapping
(
value
=
"wecom/poster/"
)
@Api
(
description
=
"海报"
)
public
class
WePosterController
extends
BaseController
{
public
class
WePosterController
extends
BaseController
{
...
@@ -34,6 +38,7 @@ public class WePosterController extends BaseController {
...
@@ -34,6 +38,7 @@ public class WePosterController extends BaseController {
private
IWePosterFontService
wePosterFontService
;
private
IWePosterFontService
wePosterFontService
;
@PostMapping
(
value
=
"insert"
)
@PostMapping
(
value
=
"insert"
)
@ApiOperation
(
"创建海报"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
insert
(
@RequestBody
WePoster
poster
){
public
AjaxResult
insert
(
@RequestBody
WePoster
poster
){
wePosterService
.
generateSimpleImg
(
poster
);
wePosterService
.
generateSimpleImg
(
poster
);
...
@@ -51,6 +56,8 @@ public class WePosterController extends BaseController {
...
@@ -51,6 +56,8 @@ public class WePosterController extends BaseController {
@PutMapping
(
value
=
"update"
)
@PutMapping
(
value
=
"update"
)
@ApiOperation
(
"修改海报"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
update
(
@RequestBody
WePoster
poster
){
public
AjaxResult
update
(
@RequestBody
WePoster
poster
){
if
(
poster
.
getId
()
==
null
){
if
(
poster
.
getId
()
==
null
){
return
AjaxResult
.
error
(
"id为空"
);
return
AjaxResult
.
error
(
"id为空"
);
...
@@ -87,6 +94,7 @@ public class WePosterController extends BaseController {
...
@@ -87,6 +94,7 @@ public class WePosterController extends BaseController {
}
}
@GetMapping
(
value
=
"list"
)
@GetMapping
(
value
=
"list"
)
@ApiOperation
(
"列表查询海报"
)
public
AjaxResult
list
(){
public
AjaxResult
list
(){
List
<
WePoster
>
fontList
=
wePosterService
.
lambdaQuery
()
List
<
WePoster
>
fontList
=
wePosterService
.
lambdaQuery
()
.
eq
(
WePoster:
:
getDelFlag
,
1
)
.
eq
(
WePoster:
:
getDelFlag
,
1
)
...
@@ -96,11 +104,13 @@ public class WePosterController extends BaseController {
...
@@ -96,11 +104,13 @@ public class WePosterController extends BaseController {
}
}
@GetMapping
(
value
=
"entity/{id}"
)
@GetMapping
(
value
=
"entity/{id}"
)
@ApiOperation
(
"查询海报详情"
)
public
AjaxResult
entity
(
@PathVariable
Long
id
){
public
AjaxResult
entity
(
@PathVariable
Long
id
){
return
AjaxResult
.
success
(
wePosterService
.
selectOne
(
id
));
return
AjaxResult
.
success
(
wePosterService
.
selectOne
(
id
));
}
}
@GetMapping
(
value
=
"page"
)
@GetMapping
(
value
=
"page"
)
@ApiOperation
(
"分页查询海报"
)
public
AjaxResult
page
(){
public
AjaxResult
page
(){
startPage
();
startPage
();
List
<
WePoster
>
fontList
=
wePosterService
.
lambdaQuery
()
List
<
WePoster
>
fontList
=
wePosterService
.
lambdaQuery
()
...
@@ -111,6 +121,8 @@ public class WePosterController extends BaseController {
...
@@ -111,6 +121,8 @@ public class WePosterController extends BaseController {
}
}
@DeleteMapping
(
value
=
"delete/{id}"
)
@DeleteMapping
(
value
=
"delete/{id}"
)
@ApiOperation
(
value
=
"删除海报"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
deletePosterFont
(
@PathVariable
Long
id
){
public
AjaxResult
deletePosterFont
(
@PathVariable
Long
id
){
wePosterService
.
lambdaUpdate
().
set
(
WePoster:
:
getDelFlag
,
0
).
eq
(
WePoster:
:
getId
,
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
);
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 @
048a340
...
@@ -6,6 +6,9 @@ import com.linkwechat.common.utils.SnowFlakeUtil;
...
@@ -6,6 +6,9 @@ import com.linkwechat.common.utils.SnowFlakeUtil;
import
com.linkwechat.web.controller.common.CommonController
;
import
com.linkwechat.web.controller.common.CommonController
;
import
com.linkwechat.wecom.domain.WePosterFont
;
import
com.linkwechat.wecom.domain.WePosterFont
;
import
com.linkwechat.wecom.service.IWePosterFontService
;
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
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -13,6 +16,7 @@ import java.util.List;
...
@@ -13,6 +16,7 @@ import java.util.List;
@RestController
@RestController
@RequestMapping
(
value
=
"wecom/posterFont/"
)
@RequestMapping
(
value
=
"wecom/posterFont/"
)
@Api
(
description
=
"海报字体"
)
public
class
WePosterFontController
extends
BaseController
{
public
class
WePosterFontController
extends
BaseController
{
...
@@ -20,6 +24,8 @@ public class WePosterFontController extends BaseController {
...
@@ -20,6 +24,8 @@ public class WePosterFontController extends BaseController {
private
IWePosterFontService
wePosterFontService
;
private
IWePosterFontService
wePosterFontService
;
@PostMapping
(
value
=
"posterFont"
)
@PostMapping
(
value
=
"posterFont"
)
@ApiOperation
(
"创建海报字体"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
insertPosterFont
(
@RequestBody
WePosterFont
posterFont
){
public
AjaxResult
insertPosterFont
(
@RequestBody
WePosterFont
posterFont
){
posterFont
.
setId
(
SnowFlakeUtil
.
nextId
());
posterFont
.
setId
(
SnowFlakeUtil
.
nextId
());
posterFont
.
setDelFlag
(
1
);
posterFont
.
setDelFlag
(
1
);
...
@@ -29,6 +35,8 @@ public class WePosterFontController extends BaseController {
...
@@ -29,6 +35,8 @@ public class WePosterFontController extends BaseController {
@PutMapping
(
value
=
"posterFont"
)
@PutMapping
(
value
=
"posterFont"
)
@ApiOperation
(
"修改海报字体"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
updatePosterFont
(
@RequestBody
WePosterFont
posterFont
){
public
AjaxResult
updatePosterFont
(
@RequestBody
WePosterFont
posterFont
){
if
(
posterFont
.
getId
()
==
null
){
if
(
posterFont
.
getId
()
==
null
){
return
AjaxResult
.
error
(
"id为空"
);
return
AjaxResult
.
error
(
"id为空"
);
...
@@ -38,6 +46,7 @@ public class WePosterFontController extends BaseController {
...
@@ -38,6 +46,7 @@ public class WePosterFontController extends BaseController {
}
}
@GetMapping
(
value
=
"posterFontList"
)
@GetMapping
(
value
=
"posterFontList"
)
@ApiOperation
(
"列表查询海报字体"
)
public
AjaxResult
selectPosterFontList
(){
public
AjaxResult
selectPosterFontList
(){
List
<
WePosterFont
>
fontList
=
wePosterFontService
.
lambdaQuery
()
List
<
WePosterFont
>
fontList
=
wePosterFontService
.
lambdaQuery
()
.
eq
(
WePosterFont:
:
getDelFlag
,
1
)
.
eq
(
WePosterFont:
:
getDelFlag
,
1
)
...
@@ -48,6 +57,7 @@ public class WePosterFontController extends BaseController {
...
@@ -48,6 +57,7 @@ public class WePosterFontController extends BaseController {
}
}
@GetMapping
(
value
=
"posterFontPage"
)
@GetMapping
(
value
=
"posterFontPage"
)
@ApiOperation
(
"分页查询海报字体"
)
public
AjaxResult
selectPosterFontPage
(){
public
AjaxResult
selectPosterFontPage
(){
startPage
();
startPage
();
List
<
WePosterFont
>
fontList
=
wePosterFontService
.
lambdaQuery
()
List
<
WePosterFont
>
fontList
=
wePosterFontService
.
lambdaQuery
()
...
@@ -59,6 +69,8 @@ public class WePosterFontController extends BaseController {
...
@@ -59,6 +69,8 @@ public class WePosterFontController extends BaseController {
}
}
@DeleteMapping
(
value
=
"posterFont/{id}"
)
@DeleteMapping
(
value
=
"posterFont/{id}"
)
@ApiOperation
(
"删除海报字体"
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
AjaxResult
deletePosterFont
(
@PathVariable
Long
id
){
public
AjaxResult
deletePosterFont
(
@PathVariable
Long
id
){
wePosterFontService
.
lambdaUpdate
().
set
(
WePosterFont:
:
getDelFlag
,
0
).
eq
(
WePosterFont:
:
getId
,
id
);
wePosterFontService
.
lambdaUpdate
().
set
(
WePosterFont:
:
getDelFlag
,
0
).
eq
(
WePosterFont:
:
getId
,
id
);
return
AjaxResult
.
success
(
"删除成功"
);
return
AjaxResult
.
success
(
"删除成功"
);
...
...
linkwe-common/src/main/java/com/linkwechat/common/core/domain/BaseEntity.java
View file @
048a340
...
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
...
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
io.swagger.annotations.ApiModelProperty
;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
/**
/**
...
@@ -23,38 +24,47 @@ public class BaseEntity implements Serializable
...
@@ -23,38 +24,47 @@ public class BaseEntity implements Serializable
/** 搜索值 */
/** 搜索值 */
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
searchValue
;
private
String
searchValue
;
/** 创建者 */
/** 创建者 */
@ApiModelProperty
(
hidden
=
true
)
private
String
createBy
;
private
String
createBy
;
/** 创建时间 */
/** 创建时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
hidden
=
true
)
private
Date
createTime
=
new
Date
();
private
Date
createTime
=
new
Date
();
/** 更新者 */
/** 更新者 */
@ApiModelProperty
(
hidden
=
true
)
private
String
updateBy
;
private
String
updateBy
;
/** 更新时间 */
/** 更新时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
hidden
=
true
)
private
Date
updateTime
=
new
Date
();
private
Date
updateTime
=
new
Date
();
/** 备注 */
/** 备注 */
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
remark
;
private
String
remark
;
/** 开始时间 */
/** 开始时间 */
@JsonIgnore
@JsonIgnore
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
beginTime
;
private
String
beginTime
;
/** 结束时间 */
/** 结束时间 */
@JsonIgnore
@JsonIgnore
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
String
endTime
;
private
String
endTime
;
/** 请求参数 */
/** 请求参数 */
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
hidden
=
true
)
private
Map
<
String
,
Object
>
params
;
private
Map
<
String
,
Object
>
params
;
public
String
getSearchValue
()
public
String
getSearchValue
()
...
...
linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java
View file @
048a340
...
@@ -161,7 +161,12 @@ public class FileUploadUtils {
...
@@ -161,7 +161,12 @@ public class FileUploadUtils {
private
static
final
String
getPathFileName
(
String
uploadDir
,
String
fileName
)
throws
IOException
{
private
static
final
String
getPathFileName
(
String
uploadDir
,
String
fileName
)
throws
IOException
{
int
dirLastIndex
=
RuoYiConfig
.
getProfile
().
length
()
+
1
;
int
dirLastIndex
=
RuoYiConfig
.
getProfile
().
length
()
+
1
;
String
currentDir
=
StringUtils
.
substring
(
uploadDir
,
dirLastIndex
);
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
;
return
pathFileName
;
}
}
...
...
linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java
View file @
048a340
...
@@ -5,11 +5,13 @@ import io.netty.buffer.Unpooled;
...
@@ -5,11 +5,13 @@ import io.netty.buffer.Unpooled;
import
io.vertx.core.Vertx
;
import
io.vertx.core.Vertx
;
import
io.vertx.core.buffer.Buffer
;
import
io.vertx.core.buffer.Buffer
;
import
io.vertx.ext.web.client.WebClient
;
import
io.vertx.ext.web.client.WebClient
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.awt.*
;
import
java.awt.*
;
import
java.io.ByteArrayInputStream
;
import
java.io.*
;
import
java.io.ByteArrayOutputStream
;
import
java.nio.channels.Channels
;
import
java.io.IOException
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.ReadableByteChannel
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -25,7 +27,14 @@ public class NetFileUtils {
...
@@ -25,7 +27,14 @@ public class NetFileUtils {
public
static
void
main
(
String
[]
args
)
{
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"
);
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 {
...
@@ -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 @
048a340
...
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
...
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
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.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -18,42 +21,51 @@ import java.util.List;
...
@@ -18,42 +21,51 @@ import java.util.List;
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Data
@TableName
(
value
=
"we_poster"
)
@TableName
(
value
=
"we_poster"
)
@ApiModel
(
value
=
"海报"
)
public
class
WePoster
extends
BaseEntity
{
public
class
WePoster
extends
BaseEntity
{
@TableId
@TableId
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
private
Long
id
;
/**
/**
* 海报标题
* 海报标题
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"海报标题"
)
private
String
title
;
private
String
title
;
/**
/**
* 背景图片
* 背景图片
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"背景图片"
)
private
String
backgroundImgPath
;
private
String
backgroundImgPath
;
/**
/**
* 示例图片
* 示例图片
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"示例图片"
)
private
String
sampleImgPath
;
private
String
sampleImgPath
;
/**
/**
* 海报类型 1 通用海报
* 海报类型 1 通用海报
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"海报类型 1 通用海报(默认)"
)
private
Long
type
;
private
Long
type
;
@TableField
@TableField
@ApiModelProperty
(
value
=
"海报状态 1 启用 0 关闭"
)
private
Integer
delFlag
;
private
Integer
delFlag
;
@TableField
@TableField
@ApiModelProperty
(
value
=
"海报背景宽度"
)
private
Integer
width
;
private
Integer
width
;
@TableField
@TableField
@ApiModelProperty
(
value
=
"海报背景高度"
)
private
Integer
height
;
private
Integer
height
;
/**
/**
...
@@ -62,27 +74,5 @@ public class WePoster extends BaseEntity {
...
@@ -62,27 +74,5 @@ public class WePoster extends BaseEntity {
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
List
<
WePosterSubassembly
>
posterSubassemblyList
;
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 @
048a340
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -14,34 +16,40 @@ import lombok.EqualsAndHashCode;
...
@@ -14,34 +16,40 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Data
@TableName
(
value
=
"we_poster_font"
)
@TableName
(
value
=
"we_poster_font"
)
@ApiModel
(
value
=
"海报字体"
)
public
class
WePosterFont
extends
BaseEntity
{
public
class
WePosterFont
extends
BaseEntity
{
/**
/**
* id
* id
*/
*/
@TableId
@TableId
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
private
Long
id
;
/**
/**
* 字体名称
* 字体名称
*/
*/
@TableField
(
value
=
"font_name"
)
@TableField
(
value
=
"font_name"
)
@ApiModelProperty
(
value
=
"字体名称"
)
private
String
fontName
;
private
String
fontName
;
/**
/**
* 字体网络地址
* 字体网络地址
*/
*/
@TableField
(
value
=
"font_url"
)
@TableField
(
value
=
"font_url"
)
@ApiModelProperty
(
value
=
"字体链接"
)
private
String
fontUrl
;
private
String
fontUrl
;
/**
/**
* 字体排序
* 字体排序
*/
*/
@TableField
(
value
=
"`order`"
)
@TableField
(
value
=
"`order`"
)
@ApiModelProperty
(
value
=
"展示排序 顺序"
)
private
Integer
order
;
private
Integer
order
;
/**
/**
* 状态
* 状态
*/
*/
@TableField
(
value
=
"del_flag"
)
@TableField
(
value
=
"del_flag"
)
@ApiModelProperty
(
value
=
"1 启用 0 关闭"
)
private
Integer
delFlag
;
private
Integer
delFlag
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WePosterSubassembly.java
View file @
048a340
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -14,83 +16,99 @@ import lombok.EqualsAndHashCode;
...
@@ -14,83 +16,99 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Data
@TableName
(
value
=
"we_poster_subassembly"
)
@TableName
(
value
=
"we_poster_subassembly"
)
@ApiModel
(
value
=
"海报组成部件"
)
public
class
WePosterSubassembly
extends
BaseEntity
{
public
class
WePosterSubassembly
extends
BaseEntity
{
@TableId
@TableId
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
private
Long
id
;
@TableField
@TableField
@ApiModelProperty
(
value
=
"海报id"
)
private
Long
posterId
;
private
Long
posterId
;
/**
/**
* x坐标
* x坐标
*/
*/
@TableField
(
value
=
"`left`"
)
@TableField
(
value
=
"`left`"
)
@ApiModelProperty
(
value
=
"x坐标"
)
private
Integer
left
;
private
Integer
left
;
/**
/**
* y坐标
* y坐标
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"y坐标"
)
private
Integer
top
;
private
Integer
top
;
/**
/**
* 宽度
* 宽度
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"控件宽度"
)
private
Integer
width
;
private
Integer
width
;
/**
/**
* 高度
* 高度
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"空间高度"
)
private
Integer
height
;
private
Integer
height
;
/**
/**
* 类型 1 固定文本 2 固定图片 3 二维码图片
* 类型 1 固定文本 2 固定图片 3 二维码图片
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"类型 1 固定文本 2 固定图片 3 二维码图片"
)
private
Integer
type
;
private
Integer
type
;
@TableField
@TableField
@ApiModelProperty
(
value
=
"字体id"
)
private
Long
fontId
;
private
Long
fontId
;
/**
/**
* 字体大小(像素大小)
* 字体大小(像素大小)
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"字体大小(像素大小)"
)
private
Integer
fontSize
;
private
Integer
fontSize
;
/**
/**
* 字体颜色(十六进制)
* 字体颜色(十六进制)
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"字体颜色(十六进制)"
)
private
String
fontColor
;
private
String
fontColor
;
/**
/**
* 字体对齐方式 0 左对齐 1居中 2右对齐
* 字体对齐方式 0 左对齐 1居中 2右对齐
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"字体对齐方式 0 左对齐 1居中 2右对齐"
)
private
Integer
fontTextAlign
;
private
Integer
fontTextAlign
;
/**
/**
* 图片网络地址
* 图片网络地址
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"图片地址(与字体id互斥)"
)
private
String
imgPath
;
private
String
imgPath
;
@TableField
@TableField
@ApiModelProperty
(
value
=
"1 启用 0 删除"
)
private
Integer
delFlag
;
private
Integer
delFlag
;
/**
/**
* 文字内容
* 文字内容
*/
*/
@TableField
@TableField
@ApiModelProperty
(
value
=
"文本内容"
)
private
String
content
;
private
String
content
;
/**
/**
* 字体实体
* 字体实体
*/
*/
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"字体信息"
)
private
WePosterFont
font
;
private
WePosterFont
font
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePosterFontServiceImpl.java
View file @
048a340
...
@@ -47,6 +47,9 @@ public class WePosterFontServiceImpl extends ServiceImpl<WePosterFontMapper,WePo
...
@@ -47,6 +47,9 @@ public class WePosterFontServiceImpl extends ServiceImpl<WePosterFontMapper,WePo
if
(
posterFont
==
null
){
if
(
posterFont
==
null
){
throw
new
RuntimeException
(
"字体id为:"
+
id
+
"的字体不存在"
);
throw
new
RuntimeException
(
"字体id为:"
+
id
+
"的字体不存在"
);
}
}
if
(
StringUtils
.
isBlank
(
posterFont
.
getFontUrl
())){
posterFont
.
setFontUrl
(
"http://img.kometl.com/1.ttf"
);
}
Font
font
;
Font
font
;
if
((
font
=
FONT_MAP
.
get
(
posterFont
.
getId
()))
!=
null
){
if
((
font
=
FONT_MAP
.
get
(
posterFont
.
getId
()))
!=
null
){
return
font
.
deriveFont
((
float
)
size
);
return
font
.
deriveFont
((
float
)
size
);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WePosterServiceImpl.java
View file @
048a340
...
@@ -12,9 +12,14 @@ import com.linkwechat.wecom.mapper.WePosterMapper;
...
@@ -12,9 +12,14 @@ import com.linkwechat.wecom.mapper.WePosterMapper;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
com.linkwechat.wecom.service.IWePosterFontService
;
import
com.linkwechat.wecom.service.IWePosterService
;
import
com.linkwechat.wecom.service.IWePosterService
;
import
com.linkwechat.wecom.service.IWePosterSubassemblyService
;
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.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.*
;
...
@@ -58,7 +63,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
...
@@ -58,7 +63,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
WePoster
poster
=
this
.
lambdaQuery
()
WePoster
poster
=
this
.
lambdaQuery
()
.
eq
(
WePoster:
:
getId
,
id
)
.
eq
(
WePoster:
:
getId
,
id
)
.
eq
(
WePoster:
:
getDelFlag
,
1
)
.
eq
(
WePoster:
:
getDelFlag
,
1
)
.
getEntity
(
);
.
list
().
get
(
0
);
if
(
poster
==
null
)
{
if
(
poster
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -110,6 +115,8 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
...
@@ -110,6 +115,8 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
}
}
}));
}));
BufferedImage
backgroundImg
=
bufferedImageMap
.
get
(
poster
.
getBackgroundImgPath
());
BufferedImage
backgroundImg
=
bufferedImageMap
.
get
(
poster
.
getBackgroundImgPath
());
poster
.
setWidth
(
backgroundImg
.
getWidth
());
poster
.
setHeight
(
backgroundImg
.
getHeight
());
poster
.
getPosterSubassemblyList
().
forEach
(
wePosterSubassembly
->
{
poster
.
getPosterSubassemblyList
().
forEach
(
wePosterSubassembly
->
{
if
(
wePosterSubassembly
.
getFontId
()
!=
null
)
{
if
(
wePosterSubassembly
.
getFontId
()
!=
null
)
{
Font
font
=
fontMap
.
get
(
wePosterSubassembly
.
getFontId
());
Font
font
=
fontMap
.
get
(
wePosterSubassembly
.
getFontId
());
...
@@ -136,7 +143,10 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
...
@@ -136,7 +143,10 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
try
{
try
{
ImageIO
.
write
(
backgroundImg
,
"jpg"
,
byteArrayOutputStream
);
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
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
RuntimeException
(
"图片生成错误"
);
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