Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
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
licc
shop-Mall
Commits
079a1636
Commit
079a1636
authored
Mar 08, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
ff5319fb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
17 deletions
+76
-17
ImageUtil.java
...on/src/main/java/cn/wisenergy/common/utils/ImageUtil.java
+28
-0
pom.xml
wisenergy-web-admin/pom.xml
+14
-0
LoginController.java
...n/wisenergy/web/admin/controller/app/LoginController.java
+24
-7
FileUploadConfig.java
...c/main/java/cn/wisenergy/web/config/FileUploadConfig.java
+10
-10
background.jpg
...rgy-web-admin/src/main/resources/templates/background.jpg
+0
-0
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/ImageUtil.java
View file @
079a1636
...
...
@@ -13,6 +13,34 @@ import java.io.IOException;
public
class
ImageUtil
{
/**
* JAVA添加文字水印
*
* @param srcImage 目标图片
* @param waterImage 水印图片
* @return
*/
public
static
byte
[]
watermarkImageSimple
(
BufferedImage
srcImage
,
BufferedImage
waterImage
)
{
Graphics2D
graphics
=
srcImage
.
createGraphics
();
graphics
.
drawImage
(
waterImage
,
srcImage
.
getWidth
()
-
100
,
0
,
waterImage
.
getWidth
(),
waterImage
.
getHeight
(),
null
);
graphics
.
dispose
();
ImageWriter
writer
=
ImageIO
.
getImageWritersByFormatName
(
"jpg"
).
next
();
ImageWriteParam
imgWriteParams
=
new
javax
.
imageio
.
plugins
.
jpeg
.
JPEGImageWriteParam
(
null
);
imgWriteParams
.
setCompressionMode
(
ImageWriteParam
.
MODE_DISABLED
);
imgWriteParams
.
setCompressionQuality
(
1.0f
);
imgWriteParams
.
setProgressiveMode
(
ImageWriteParam
.
MODE_DISABLED
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
IIOImage
iIamge
=
new
IIOImage
(
waterImage
,
null
,
null
);
try
{
writer
.
setOutput
(
ImageIO
.
createImageOutputStream
(
baos
));
writer
.
write
(
null
,
iIamge
,
imgWriteParams
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
baos
.
toByteArray
();
}
/**
* JAVA添加文字水印
*
...
...
wisenergy-web-admin/pom.xml
View file @
079a1636
...
...
@@ -33,6 +33,20 @@
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
4.6.17
</version>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
javase
</artifactId>
<version>
3.4.1
</version>
</dependency>
<dependency>
<groupId>
commons-fileupload
</groupId>
<artifactId>
commons-fileupload
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/LoginController.java
View file @
079a1636
package
cn
.
wisenergy
.
web
.
admin
.
controller
.
app
;
import
cn.
wisenergy.common.enums.ResultEnum
;
import
cn.
hutool.extra.qrcode.QrCodeUtil
;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.model.app.UsersDto
;
import
cn.wisenergy.service.app.UserService
;
import
cn.wisenergy.web.sms.BaseException
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -14,11 +13,17 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletRequest
;
import
java.awt.image.BufferedImage
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -118,12 +123,24 @@ public class LoginController {
return
(
Map
)
ResultUtils
.
returnDataSuccess
(
userDtoJson
);
}
@ApiOperation
(
value
=
"二维码邀请注册"
,
notes
=
"二维码邀请注册"
,
httpMethod
=
"POST"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户手机号"
,
required
=
true
,
dataType
=
"String"
)
})
@PostMapping
(
"/registerByQrCode"
)
public
byte
[]
registerByQrCode
(
@RequestParam
String
userId
,
HttpServletRequest
request
)
throws
IOException
{
User
user
=
this
.
usersService
.
getById
(
userId
);
if
(
user
!=
null
)
{
String
regFullUrl
=
request
.
getScheme
()
+
"://"
+
request
.
getServerName
()
+
":"
+
request
.
getServerPort
()
+
"/regist?beInvitedCode="
+
user
.
getInviteCode
();
final
InputStream
is
=
new
ClassPathResource
(
"templates/background.jpg"
).
getInputStream
();
BufferedImage
srcImage
=
ImageIO
.
read
(
is
);
BufferedImage
waterImage
=
QrCodeUtil
.
generate
(
regFullUrl
,
100
,
100
);
return
ImageUtil
.
watermarkImageSimple
(
srcImage
,
waterImage
);
}
return
null
;
}
//用户注册
@ApiOperation
(
value
=
"用户注册"
,
notes
=
"用户注册"
,
httpMethod
=
"POST"
,
produces
=
"application/json; charset=UTF-8"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户手机号"
,
required
=
true
,
dataType
=
"String"
),
...
...
wisenergy-
common/src/main/java/cn/wisenergy/common/config/file
/FileUploadConfig.java
→
wisenergy-
web-admin/src/main/java/cn/wisenergy/web/config
/FileUploadConfig.java
View file @
079a1636
package
cn
.
wisenergy
.
common
.
config
.
file
;
package
cn
.
wisenergy
.
web
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -17,13 +17,13 @@ public class FileUploadConfig {
* 重新定义文件上传对象【springBoot request转化成MultipartHttpServletRequest】
* @return
*/
//
@Bean(name = "multipartResolver")
//
public MultipartResolver multipartResolver() {
//
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
//
resolver.setDefaultEncoding("UTF-8");
//
resolver.setResolveLazily(true);
//
resolver.setMaxInMemorySize(40960);
//
resolver.setMaxUploadSize(512 * 1024 * 1024);
//
return resolver;
//
}
@Bean
(
name
=
"multipartResolver"
)
public
MultipartResolver
multipartResolver
()
{
CommonsMultipartResolver
resolver
=
new
CommonsMultipartResolver
();
resolver
.
setDefaultEncoding
(
"UTF-8"
);
resolver
.
setResolveLazily
(
true
);
resolver
.
setMaxInMemorySize
(
40960
);
resolver
.
setMaxUploadSize
(
512
*
1024
*
1024
);
return
resolver
;
}
}
wisenergy-web-admin/src/main/resources/templates/background.jpg
0 → 100644
View file @
079a1636
128 KB
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